Class cheb_approx_tl (o2scl)

O2scl : Class List

template<class fp_t = double>
class cheb_approx_tl

Chebyshev approximation (GSL)

Approximate a function on a finite interval using a Chebyshev series:

\[ f(x) = \sum_n c_n T_n(x) \]
where \( T_n(x)=\cos(n \arccos x) \)

See also the Chebyshev approximation example.

Initialization methods

template<class func_t>
inline void init(func_t &func, size_t ord, fp_t a1, fp_t b1)

Initialize a Chebyshev approximation of the function func over the interval from a1 to b1.

The interval must be specified so that \( a < b \) , so a and b are swapped if this is not the case.

template<class vec_t>
inline void init(fp_t a1, fp_t b1, size_t ord, vec_t &v)

Create an approximation from a vector of coefficients.

template<class vec_t>
inline void init_func_values(fp_t a1, fp_t b1, size_t ord, vec_t &fval)

Create an approximation from a vector of function values.

Evaulation methods

inline fp_t eval(fp_t x) const

Evaluate the approximation.

inline fp_t operator()(fp_t x) const

Evaluate the approximation.

inline fp_t eval_n(size_t n, fp_t x) const

Evaluate the approximation to a specified order.

inline void eval_err(fp_t x, fp_t &result, fp_t &abserr)

Evaluate the approximation and give the uncertainty.

inline void eval_n_err(size_t n, fp_t x, fp_t &result, fp_t &abserr)

Evaluate the approximation to a specified order and give the uncertainty.

Maniupulating coefficients and endpoints

inline fp_t get_coefficient(size_t ix) const

Get a coefficient.

Legal values of the argument are 0 to order (inclusive)

inline void set_coefficient(size_t ix, fp_t co)

Set a coefficient.

Legal values of the argument are 0 to order (inclusive)

inline void get_endpoints(fp_t &la, fp_t &lb)

Return the endpoints of the approximation.

template<class vec_t>
inline void get_coefficients(size_t n, vec_t &v) const

Get the coefficients.

template<class vec_t>
inline void set_coefficients(size_t n, const vec_t &v)

Set the coefficients.

Derivatives and integrals

inline void deriv(cheb_approx_tl &gc) const

Make gc an approximation to the derivative.

inline void integ(cheb_approx_tl &gc) const

Make gc an approximation to the integral.

Public Types

typedef boost::numeric::ublas::vector<fp_t> ubvector

Public Functions

inline cheb_approx_tl()
inline cheb_approx_tl(const cheb_approx_tl &gc)

Copy constructor.

inline cheb_approx_tl &operator=(const cheb_approx_tl &gc)

Copy constructor.

Protected Attributes

ubvector c

Coefficients.

size_t order

Order of the approximation.

fp_t a

Lower end of the interval.

fp_t b

Upper end of the interval.

size_t order_sp

Single precision order.

ubvector f

Function evaluated at Chebyshev points.

bool init_called

True if init has been called.

fp_t pi

The constant \( \pi \).