Public Types | Public Member Functions | Protected Attributes | List of all members
o2scl::cheb_approx Class Reference

Chebyshev approximation (GSL) More...

#include <cheb_approx.h>

Public Types

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

Public Member Functions

 cheb_approx (const cheb_approx &gc)
 Copy constructor.
 
cheb_approxoperator= (const cheb_approx &gc)
 Copy constructor.
 
Initialization methods
template<class func_t >
void init (func_t &func, size_t ord, double a1, double b1)
 Initialize a Chebyshev approximation of the function func over the interval from a1 to b1. More...
 
template<class vec_t >
void init (double a1, double b1, size_t ord, vec_t &v)
 Create an approximation from a vector of coefficients.
 
template<class vec_t >
void init_func_values (double a1, double b1, size_t ord, vec_t &fval)
 Create an approximation from a vector of function values.
 
Evaulation methods
double eval (double x) const
 Evaluate the approximation.
 
double operator() (double x) const
 Evaluate the approximation.
 
double eval_n (size_t n, double x) const
 Evaluate the approximation to a specified order.
 
void eval_err (double x, double &result, double &abserr)
 Evaluate the approximation and give the uncertainty.
 
void eval_n_err (size_t n, double x, double &result, double &abserr)
 Evaluate the approximation to a specified order and give the uncertainty.
 
Maniupulating coefficients and endpoints
double get_coefficient (size_t ix) const
 Get a coefficient. More...
 
void set_coefficient (size_t ix, double co)
 Set a coefficient. More...
 
void get_endpoints (double &la, double &lb)
 Return the endpoints of the approximation.
 
template<class vec_t >
void get_coefficients (size_t n, vec_t &v) const
 Get the coefficients.
 
template<class vec_t >
void set_coefficients (size_t n, const vec_t &v)
 Set the coefficients.
 
Derivatives and integrals
void deriv (cheb_approx &gc) const
 Make gc an approximation to the derivative.
 
void integ (cheb_approx &gc) const
 Make gc an approximation to the integral.
 

Protected Attributes

ubvector c
 Coefficients.
 
size_t order
 Order of the approximation.
 
double a
 Lower end of the interval.
 
double 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.
 

Detailed Description

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 .

Idea for Future:
Move non-template functions to .cpp file.

Definition at line 52 of file cheb_approx.h.

Member Function Documentation

◆ get_coefficient()

double o2scl::cheb_approx::get_coefficient ( size_t  ix) const
inline

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

Definition at line 347 of file cheb_approx.h.

◆ init()

template<class func_t >
void o2scl::cheb_approx::init ( func_t &  func,
size_t  ord,
double  a1,
double  b1 
)
inline

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

Definition at line 120 of file cheb_approx.h.

◆ set_coefficient()

void o2scl::cheb_approx::set_coefficient ( size_t  ix,
double  co 
)
inline

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

Definition at line 361 of file cheb_approx.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).