CChebyshevApprox2D Class Reference

#include <chebyshev.h>

Collaboration diagram for CChebyshevApprox2D:
[legend]

List of all members.

Public Member Functions

 CChebyshevApprox2D (void)
 Plain vanilla constructor for a 2D approximation.
 CChebyshevApprox2D (double upperlimit_x, double lowerlimit_x, double upperlimit_y, double lowerlimit_y, int ncoeff_x, int ncoeff_y, double(*func)(double, double, void *), void *pars)
 CChebyshevApprox2D (double upperlimit_x, double lowerlimit_x, double upperlimit_y, double lowerlimit_y, int ncoeff_x, int ncoeff_y, const Array1D< double > &x_controlpts, const Array1D< double > &y_controlpts, const Array2D< double > &ftnvals)
 ~CChebyshevApprox2D (void)
 Plain vanilla destructor for a 2D approximation.
CChebyshevApprox2D Copy (const CChebyshevApprox2D &A)
CChebyshevApprox2D operator= (const CChebyshevApprox2D &A)
int Ncoeffs_x (void) const
double Upperlimit_x (void) const
double Lowerlimit_x (void) const
int Ncoeffs_y (void) const
double Upperlimit_y (void) const
double Lowerlimit_y (void) const
double Coeff (int i, int j) const
Array2D< double > CoeffMatrix (void) const
void SetParameters (double upperlimit_x, double lowerlimit_x, double upperlimit_y, double lowerlimit_y, int ncoeff_x, int ncoeff_y)
 Initializes some parameters of 2D approximation.
void Setup (double upperlimit_x, double lowerlimit_x, double upperlimit_y, double lowerlimit_y, int ncoeff_x, int ncoeff_y, double(*func)(double, double, void *), void *pars)
 Routine to setup the 2d Chebyshev approximation.
void SetupFit (double upperlimit_x, double lowerlimit_x, double upperlimit_y, double lowerlimit_y, int ncoeff_x, int ncoeff_y, const Array1D< double > &x_controlpts, const Array1D< double > &y_controlpts, const Array2D< double > &ftnvals)
double ColocPoint_x (int i) const
 Routine to return the x Colocations points of the 2d Chebyshev approximation.
double ColocPoint_y (int i) const
 Routine to return the y Colocations points of the 2d Chebyshev approximation.
double Val (double x, double y, int m_x, int m_y) const
 Routine to return the approximated value of the Chebyshev approximation using the first m_x coefficients in the x direction and the first m_y coefficients in the y direction.
double Val (double x, double y) const
double operator() (double x, double y, int m_x, int m_y) const
double operator() (double x, double y) const

Protected Attributes

int nc_x
int nc_y
double uplim_x
double lolim_x
double uplim_y
double lolim_y
Array2D< double > c

Friends

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


Detailed Description

Definition at line 84 of file chebyshev.h.


Constructor & Destructor Documentation

CChebyshevApprox2D::CChebyshevApprox2D ( void   ) 

Plain vanilla constructor for a 2D approximation.

Definition at line 502 of file chebyshev.cc.

CChebyshevApprox2D::CChebyshevApprox2D ( double  upperlimit_x,
double  lowerlimit_x,
double  upperlimit_y,
double  lowerlimit_y,
int  ncoeff_x,
int  ncoeff_y,
double(*)(double, double, void *)  func,
void *  pars 
) [inline]

Definition at line 94 of file chebyshev.h.

CChebyshevApprox2D::CChebyshevApprox2D ( double  upperlimit_x,
double  lowerlimit_x,
double  upperlimit_y,
double  lowerlimit_y,
int  ncoeff_x,
int  ncoeff_y,
const Array1D< double > &  x_controlpts,
const Array1D< double > &  y_controlpts,
const Array2D< double > &  ftnvals 
) [inline]

Definition at line 104 of file chebyshev.h.

CChebyshevApprox2D::~CChebyshevApprox2D ( void   )  [inline]

Plain vanilla destructor for a 2D approximation.

Definition at line 118 of file chebyshev.h.


Member Function Documentation

double CChebyshevApprox2D::Coeff ( int  i,
int  j 
) const [inline]

Definition at line 130 of file chebyshev.h.

Array2D<double> CChebyshevApprox2D::CoeffMatrix ( void   )  const [inline]

Definition at line 131 of file chebyshev.h.

double CChebyshevApprox2D::ColocPoint_x ( int  i  )  const

Routine to return the x Colocations points of the 2d 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{\tt nc\_x}\right)}, k=0,1,...,\mbox{\tt nc\_x} \]

Definition at line 574 of file chebyshev.cc.

double CChebyshevApprox2D::ColocPoint_y ( int  i  )  const

Routine to return the y Colocations points of the 2d Chebyshev approximation.

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

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

Definition at line 590 of file chebyshev.cc.

CChebyshevApprox2D CChebyshevApprox2D::Copy ( const CChebyshevApprox2D A  ) 

Definition at line 525 of file chebyshev.cc.

double CChebyshevApprox2D::Lowerlimit_x ( void   )  const [inline]

Definition at line 126 of file chebyshev.h.

double CChebyshevApprox2D::Lowerlimit_y ( void   )  const [inline]

Definition at line 129 of file chebyshev.h.

int CChebyshevApprox2D::Ncoeffs_x ( void   )  const [inline]

Definition at line 124 of file chebyshev.h.

int CChebyshevApprox2D::Ncoeffs_y ( void   )  const [inline]

Definition at line 127 of file chebyshev.h.

double CChebyshevApprox2D::operator() ( double  x,
double  y 
) const [inline]

Definition at line 158 of file chebyshev.h.

double CChebyshevApprox2D::operator() ( double  x,
double  y,
int  m_x,
int  m_y 
) const [inline]

Definition at line 156 of file chebyshev.h.

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

Definition at line 121 of file chebyshev.h.

void CChebyshevApprox2D::SetParameters ( double  upperlimit_x,
double  lowerlimit_x,
double  upperlimit_y,
double  lowerlimit_y,
int  ncoeff_x,
int  ncoeff_y 
)

Initializes some parameters of 2D approximation.

Parameters:
upperlimit_x upper limit of the interval in the x direction
lowerlimit_x lower limit of the interval in the x direction
upperlimit_y upper limit of the interval in the y direction
lowerlimit_y lower limit of the interval in the y direction
ncoeff_x number of coefficients to use in the x direction
ncoeff_y number of coefficients to use in the y direction

Definition at line 549 of file chebyshev.cc.

void CChebyshevApprox2D::Setup ( double  upperlimit_x,
double  lowerlimit_x,
double  upperlimit_y,
double  lowerlimit_y,
int  ncoeff_x,
int  ncoeff_y,
double(*)(double, double, void *)  func,
void *  pars 
)

Routine to setup the 2d Chebyshev approximation.

Parameters:
upperlimit_x upper limit of approximation in x direction
lowerlimit_x lower limit of approximation in x direction
upperlimit_y upper limit of approximation in y direction
lowerlimit_y lower limit of approximation in y direction
ncoeff_x number of coefficients in x direction
ncoeff_y number of coefficients in y direction
*func pointer to function to be approximated
This routine sets up the 2d Chebyshev approximation by computing the coefficient matrix c using the 2d generalization of the scheme used in the 1d approximation:

\[ c_{ij}=\frac{4}{\mbox{nc\_x}*\mbox{nx\_y}}\sum_{k=0}^{\mbox{nc\_x}} \sum_{l=0}^{\mbox{nc\_y}} f\left(\cos{\left(\frac{\pi(k+\frac{1}{2})}{\mbox{\tt nc\_x}}\right)}, \cos{\left(\frac{\pi(l+\frac{1}{2})}{\mbox{\tt nc\_y}}\right)} \right) \cos{\left(\frac{\pi i(k+\frac{1}{2})}{\mbox{\tt nc\_x}}\right)} \cos{\left(\frac{\pi j(l+\frac{1}{2})}{\mbox{\tt nc\_y}}\right)} \]

Definition at line 618 of file chebyshev.cc.

void CChebyshevApprox2D::SetupFit ( double  upperlimit_x,
double  lowerlimit_x,
double  upperlimit_y,
double  lowerlimit_y,
int  ncoeff_x,
int  ncoeff_y,
const Array1D< double > &  x_controlpts,
const Array1D< double > &  y_controlpts,
const Array2D< double > &  ftnvals 
)

Definition at line 698 of file chebyshev.cc.

double CChebyshevApprox2D::Upperlimit_x ( void   )  const [inline]

Definition at line 125 of file chebyshev.h.

double CChebyshevApprox2D::Upperlimit_y ( void   )  const [inline]

Definition at line 128 of file chebyshev.h.

double CChebyshevApprox2D::Val ( double  x,
double  y 
) const [inline]

Definition at line 154 of file chebyshev.h.

double CChebyshevApprox2D::Val ( double  x,
double  y,
int  m_x,
int  m_y 
) const

Routine to return the approximated value of the Chebyshev approximation using the first m_x coefficients in the x direction and the first m_y coefficients in the y direction.

Parameters:
x x coordinate you want the approximation evaluated at
y y coordinate you want the approximation evaluated at
m_x number of coefficients to keep in the x direction
m_y number of coefficients to keep in the y direction
This function returns the approximated value of the Chebyshev using a generalization of the procedure advocated in Numerical Recipes pp. 191-193. Basically, we write the approximation of func(x,y) in the x direction as

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

where $ T(\tilde{x}) $ is the Chebyshev polynomial, $ c_k(y)$ is the coefficient of the expansion as a function of $ y $ and $ \tilde{x}$ is the value of $ x$ rescaled by the upper and lower limits of the approximation:

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

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.

How do we compute $ c_k(y)$? Well, basically the same way... we make a Chebyshev approximation of it:

\[ c_k(y)=\left[\sum_{l=0}^{m_y-1} c_{kl} T_l(\tilde{y}) \right]-\frac{1}{2}c_{k0} \]

Here the terms mean the same thing as above, but noting that the coefficient matrix $ c_{kl}=$ c [k][l], which we compute above in CChebyshevApprox2D::Setup.

Definition at line 843 of file chebyshev.cc.


Friends And Related Function Documentation

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

Definition at line 885 of file chebyshev.cc.

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

Definition at line 896 of file chebyshev.cc.


Member Data Documentation

Array2D<double> CChebyshevApprox2D::c [protected]

Definition at line 166 of file chebyshev.h.

double CChebyshevApprox2D::lolim_x [protected]

Definition at line 164 of file chebyshev.h.

double CChebyshevApprox2D::lolim_y [protected]

Definition at line 165 of file chebyshev.h.

int CChebyshevApprox2D::nc_x [protected]

Definition at line 159 of file chebyshev.h.

int CChebyshevApprox2D::nc_y [protected]

Definition at line 159 of file chebyshev.h.

double CChebyshevApprox2D::uplim_x [protected]

Definition at line 164 of file chebyshev.h.

double CChebyshevApprox2D::uplim_y [protected]

Definition at line 165 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