CChebyshevApprox1D Class Reference

#include <chebyshev.h>

Inheritance diagram for CChebyshevApprox1D:
[legend]
Collaboration diagram for CChebyshevApprox1D:
[legend]

List of all members.

Public Member Functions

 CChebyshevApprox1D (void)
 Plain vanilla constructor for the 1D approximation.
 CChebyshevApprox1D (double upperlimit, double lowerlimit, int ncoeff, double(*func)(double, void *), void *pars)
 This routine is both the constructor and setup function bundled together.
 CChebyshevApprox1D (double upperlimit, double lowerlimit, int ncoeff, const Array1D< double > &controlpts, const Array1D< double > &ftnvals)
 ~CChebyshevApprox1D (void)
 Plain vanilla destructor. STL vector class deallocates the coefficients for me.
CChebyshevApprox1D Copy (const CChebyshevApprox1D &A)
CChebyshevApprox1D operator= (const CChebyshevApprox1D &A)
int Ncoeffs (void) const
 Returns the number of coefficients in the approximation.
double Upperlimit (void) const
 Returns the upper limit of the range of func to be approximated.
double Lowerlimit (void) const
 Returns the lower limit of the range of func to be approximated.
double Coeff (int i) const
 Returns the i th coeffient of the approximation.
Array1D< double > CoeffVector (void) const
 Returns the entire c coeffient vector of the approximation.
void SetParameters (double upperlimit, double lowerlimit, int ncoeff)
 Little function to set the upper & lower limits and number of coefficients.
void Setup (double upperlimit, double lowerlimit, int ncoeff, double(*func)(double, void *), void *pars)
 Routine to setup the 1d Chebyshev approximation.
void Setup (double upperlimit, double lowerlimit, int ncoeff, Array1D< double > coeffs)
void SetupFit (double upperlimit, double lowerlimit, int ncoeff, const Array1D< double > &controlpts, const Array1D< double > &ftnvals)
double ColocPoint (int i) const
 Routine to return the Colocations points of the Chebyshev approximation.
double Val (double x, int m) const
 Routine to return the approximated value of the 1d Chebyshev approximation using the first m coefficients.
double Val (double x) const
 Returns the value of the approximation at x, using all nc coefficients.
double operator() (double x, int m) const
 Returns the value of the approximation at x, the first m coefficients.
double operator() (double x) const
 Returns the value of the approximation at x, using all nc coefficients.
CChebyshevApprox1D Derivative (void) const
CChebyshevApprox1D Integral (void) const
void RunQuiet (void)
void RunLoud (void)

Protected Attributes

int nc
double uplim
double lolim
Array1D< double > c
bool quiet

Friends

ostream & operator<< (ostream &s, const CChebyshevApprox1D &A)
istream & operator>> (istream &s, CChebyshevApprox1D &A)


Detailed Description

Definition at line 17 of file chebyshev.h.


Constructor & Destructor Documentation

CChebyshevApprox1D::CChebyshevApprox1D ( void   )  [inline]

Plain vanilla constructor for the 1D approximation.

Definition at line 26 of file chebyshev.h.

CChebyshevApprox1D::CChebyshevApprox1D ( double  upperlimit,
double  lowerlimit,
int  ncoeff,
double(*)(double, void *)  func,
void *  pars 
) [inline]

This routine is both the constructor and setup function bundled together.

Parameters:
upperlimit upper limit of the range that func is approximated over
lowerlimit lower limit of the range that func is approximated over
ncoeff number of coefficients to use in the Chebyshev approximation
*func pointer to the user-defined function func which is to be approximated
This routine is basically a wrapper around CChebyshevApprox1D::Setup.

Definition at line 27 of file chebyshev.h.

CChebyshevApprox1D::CChebyshevApprox1D ( double  upperlimit,
double  lowerlimit,
int  ncoeff,
const Array1D< double > &  controlpts,
const Array1D< double > &  ftnvals 
) [inline]

Definition at line 31 of file chebyshev.h.

CChebyshevApprox1D::~CChebyshevApprox1D ( void   )  [inline]

Plain vanilla destructor. STL vector class deallocates the coefficients for me.

Definition at line 37 of file chebyshev.h.


Member Function Documentation

double CChebyshevApprox1D::Coeff ( int  i  )  const [inline]

Returns the i th coeffient of the approximation.

Parameters:
i the index of the coefficient

Definition at line 46 of file chebyshev.h.

Vector< double > CChebyshevApprox1D::CoeffVector< double > ( void   )  const [inline]

Returns the entire c coeffient vector of the approximation.

Definition at line 47 of file chebyshev.h.

double CChebyshevApprox1D::ColocPoint ( int  i  )  const

Routine to return the Colocations points of the Chebyshev approximation.

Parameters:
i index of the Colocation point you are after
The Colocation points of the Chebyshev approximation are given by

\[ x_k=\cos{\left(\pi(k+\frac{1}{2})/\mbox{nc}\right)}, k=0,1,...,\mbox{nc} \]

Definition at line 253 of file chebyshev.cc.

CChebyshevApprox1D CChebyshevApprox1D::Copy ( const CChebyshevApprox1D A  ) 

Definition at line 436 of file chebyshev.cc.

CChebyshevApprox1D CChebyshevApprox1D::Derivative ( void   )  const

Definition at line 327 of file chebyshev.cc.

CChebyshevApprox1D CChebyshevApprox1D::Integral ( void   )  const

Definition at line 347 of file chebyshev.cc.

double CChebyshevApprox1D::Lowerlimit ( void   )  const [inline]

Returns the lower limit of the range of func to be approximated.

Definition at line 45 of file chebyshev.h.

int CChebyshevApprox1D::Ncoeffs ( void   )  const [inline]

Returns the number of coefficients in the approximation.

Definition at line 43 of file chebyshev.h.

double CChebyshevApprox1D::operator() ( double  x  )  const [inline]

Returns the value of the approximation at x, using all nc coefficients.

Parameters:
x the value to evaluate the approximation at.
This routine is a wrapper around CChebyshevApprox1D::Val.

Definition at line 66 of file chebyshev.h.

double CChebyshevApprox1D::operator() ( double  x,
int  m 
) const [inline]

Returns the value of the approximation at x, the first m coefficients.

Parameters:
x the value to evaluate the approximation at.
m the number of coefficients to use in the approximation.
This routine is a wrapper around CChebyshevApprox1D::Val.

Definition at line 65 of file chebyshev.h.

CChebyshevApprox1D CChebyshevApprox1D::operator= ( const CChebyshevApprox1D A  )  [inline]

Definition at line 40 of file chebyshev.h.

void CChebyshevApprox1D::RunLoud ( void   )  [inline]

Definition at line 72 of file chebyshev.h.

void CChebyshevApprox1D::RunQuiet ( void   )  [inline]

Definition at line 71 of file chebyshev.h.

void CChebyshevApprox1D::SetParameters ( double  upperlimit,
double  lowerlimit,
int  ncoeff 
)

Little function to set the upper & lower limits and number of coefficients.

Parameters:
upperlimit upper limit of the range that func is approximated over
lowerlimit lower limit of the range that func is approximated over
ncoeff number of coefficients to use in the Chebyshev approximation

Definition at line 71 of file chebyshev.cc.

void CChebyshevApprox1D::Setup ( double  upperlimit,
double  lowerlimit,
int  ncoeff,
Array1D< double >  coeffs 
)

Definition at line 81 of file chebyshev.cc.

void CChebyshevApprox1D::Setup ( double  upperlimit,
double  lowerlimit,
int  ncoeff,
double(*)(double, void *)  func,
void *  pars 
)

Routine to setup the 1d Chebyshev approximation.

Parameters:
upperlimit upper limit of the range that func is approximated over
lowerlimit lower limit of the range that func is approximated over
ncoeff number of coefficients to use in the Chebyshev approximation
*func pointer to the user-defined function func which is to be approximated
This function computes the coefficients of the Chebyshev approximation to func using the well known procedure explained in Numerical Recipes pp. 191-193. In detail, the coefficients are computed by:

\[ c_j = \frac{2}{\mbox{nc}}\sum_{k=0}^{\mbox{nc}-1} \mbox{func}\left[\cos{\left(\frac{\pi (k+\frac{1}{2})}{\mbox{nc}}\right)}\right] \cos\left(\frac{\pi j (k+\frac{1}{2})}{\mbox{nc}}\right) \]

Definition at line 95 of file chebyshev.cc.

void CChebyshevApprox1D::SetupFit ( double  upperlimit,
double  lowerlimit,
int  ncoeff,
const Array1D< double > &  controlpts,
const Array1D< double > &  ftnvals 
)

Definition at line 169 of file chebyshev.cc.

double CChebyshevApprox1D::Upperlimit ( void   )  const [inline]

Returns the upper limit of the range of func to be approximated.

Definition at line 44 of file chebyshev.h.

double CChebyshevApprox1D::Val ( double  x  )  const [inline]

Returns the value of the approximation at x, using all nc coefficients.

Parameters:
x the value to evaluate the approximation at.
This routine is a wrapper around CChebyshevApprox1D::Val.

Definition at line 64 of file chebyshev.h.

double CChebyshevApprox1D::Val ( double  x,
int  m 
) const

Routine to return the approximated value of the 1d Chebyshev approximation using the first m coefficients.

Parameters:
x arguement of func that you which to evaluate the approximation at
m number of coefficients you wish to use in the approximation
The Chebyshev approximation to the function func is given by

\[ \mbox{func}(x)=\left[\sum_{k=0}^{m-1} c_k T_k(y) \right]-\frac{1}{2}c_0 \]

where $ T(y) $ is the Chebyshev polynomial, $ c_k=$ c [k] is the coefficient of the expansion and $ y$ is the value of $ x$ rescaled by the upper and lower limits of the approximation:

\[ y=\frac{x-\frac{1}{2}(\mbox{uplim}+\mbox{lolim})} {\frac{1}{2}(\mbox{uplim}-\mbox{lolim})} \]

The routine doesn't actually do the sum this way -- it actually uses the Clenshaw recurrance relation. See Numerical Recipes pp. 191-193 for more details.

Definition at line 293 of file chebyshev.cc.


Friends And Related Function Documentation

ostream & CChebyshevApprox1D::operator<< ( ostream &  s,
const CChebyshevApprox1D A 
) [friend]

Definition at line 450 of file chebyshev.cc.

istream & CChebyshevApprox1D::operator>> ( istream &  s,
CChebyshevApprox1D A 
) [friend]

Definition at line 459 of file chebyshev.cc.


Member Data Documentation

Array1D< double > CChebyshevApprox1D::c [protected]

Vector of coefficients of the Chebyshev polynomial approximation

Definition at line 78 of file chebyshev.h.

Lower limit of the fitting interval of the Chebyshev polynomial approximation

Definition at line 77 of file chebyshev.h.

nt CChebyshevApprox1D::nc [protected]

Number of coefficients in the Chebyshev polynomial approximation

Definition at line 76 of file chebyshev.h.

bool CChebyshevApprox1D::quiet [protected]

Definition at line 79 of file chebyshev.h.

double CChebyshevApprox1D::uplim [protected]

Upper limit of the fitting interval of the Chebyshev polynomial approximation

Definition at line 77 of file chebyshev.h.


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

Generated on Fri Feb 6 13:30:17 2009 for CorAL by  doxygen 1.5.8