#include <chebyshev.h>
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) |
Definition at line 17 of file chebyshev.h.
CChebyshevApprox1D::CChebyshevApprox1D | ( | void | ) | [inline] |
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.
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 |
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.
double CChebyshevApprox1D::Coeff | ( | int | i | ) | const [inline] |
Returns the i
th
coeffient of the approximation.
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.
i | index of the Colocation point you are after |
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] |
double CChebyshevApprox1D::operator() | ( | double | x | ) | const [inline] |
Returns the value of the approximation at x, using all nc
coefficients
.
x | the value to evaluate the approximation at. |
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
.
x | the value to evaluate the approximation at. | |
m | the number of coefficients to use in the approximation. |
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.
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.
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 |
func
using
the well known procedure explained in Numerical Recipes pp. 191-193. In detail, the coefficients are computed by:
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
.
x | the value to evaluate the approximation at. |
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.
x | arguement of func that you which to evaluate the approximation at | |
m | number of coefficients you wish to use in the approximation |
func
is
given by
where is the Chebyshev polynomial,
c
[k] is
the coefficient of the expansion and is the value of
rescaled by the upper and lower limits of the approximation:
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.
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.
Array1D< double > CChebyshevApprox1D::c [protected] |
Vector of coefficients of the Chebyshev polynomial approximation
Definition at line 78 of file chebyshev.h.
CChebyshevApprox1D::lolim [protected] |
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.