Cheb Class Template Reference

Abstract class template supports generation of interpolation data of known functions using Chebyshev polynomials. More...

#include <Cheb.h>

Inherits Base.

Inherited by Differ, Integr, and Interp.

Inheritance diagram for Cheb:

Inheritance graph
[legend]
List of all members.

Public Types

enum  CTYPE { INTERPOLATE = 0, DIFFERENTIATE, INTEGRATE, CTYPE_CNT }
 CTYPE_CNT
 DIFFERENTIATE
 INTEGRATE
 INTERPOLATE = 0

Public Member Functions

yType eval (xType x) const throw (ChebErr)
const yType * getArray (void) const
xType getBound (enum Base::BOUND iBnd) const
int getCount (void) const
xType getError (void) const
yType getParameter (int iDeg) const
enum Cheb< xType, yType
>::CTYPE 
getType (void) const
 operator const yType * (void) const

Static Public Attributes

static const int POINT_MAX = 50
static const int POINT_MIN = 1

Protected Member Functions

 Cheb (const Cheb &ch)
 Cheb (const yType *const arCn, xType x1, xType x2, int nCount, int iArr)
 Cheb (yType(*pFn)(xType), xType x1, xType x2, int nCount)
 Cheb (yType(*pFn)(xType), xType x1, xType x2, xType dEps)
virtual void putCoefs (yType *ut, const yType *up, int cnt)=0
bool trunCoefs (const yType *ut, int nCount)
bool trunCoefs (const yType *ut, xType dEps)
 ~Cheb (void)

Protected Attributes

yType * aC
enum Cheb< xType, yType
>::CTYPE 
cTyp
int nData
xType xBnd [Base::BOUND_CNT]
yType yOffset

Detailed Description

template<typename xType, typename yType>
class calc::Cheb< xType, yType >

Abstract class template supports generation of interpolation data of known functions using Chebyshev polynomials.

Object instantiation of this class should be made only through classes which inherit this class.

The declaration typename <xType> specifies the form of independent variables used in interpolation calculations. The declaration typename <yType> specifies the form of solution variables used in interpolation calculations. In general, the <yType> variables should be the equal or superset of the <xType> variables.

See the cited References to obtain more information on the mathematical theory applied here.

Author
efgeorge
Date
2006/07/18 01:45:34
Revision
1.2
Examples:

example_Cheb.txt.


Member Enumeration Documentation

enum CTYPE

Enumeration indicates the class index of the interpolated function type used.

Enumerator:
INTERPOLATE  interpolate function
DIFFERENTIATE  interpolate function derivative
INTEGRATE  interpolate function integral
CTYPE_CNT  class type index count


Constructor & Destructor Documentation

Cheb ( yType(*)(xType)  pFn,
xType  x1,
xType  x2,
xType  dEps 
) [protected]

Constructor initializes a Chebyshev polynomial interpolation object from the specified function pFn within the specified interval x1 to x2.

Parameters:
pFn a pointer to an evaluation function to be interpolated
x1 interpolation lower bound (x units)
x2 interpolation upper bound (x units)
dEps required absolute error of interpolation (|y| units)
Remarks:
  • The interpolation bounds x1 and x2 cannot be equal.
  • The specified function pFn(x) returns a value from which interpolation parameters are calculated given an independent variable value between x1 and x2.
  • The function pFn(x) accepts a single independent value (x units).
  • The function pFn(x) returns a single value at the specified point (y units).
  • pFn(x) declaration: yType fn(xType x);
  • The error parameter dEps must have a value greater than zero.

Cheb ( yType(*)(xType)  pFn,
xType  x1,
xType  x2,
int  nCount 
) [protected]

Constructor initializes a Chebyshev polynomial interpolation object from the specified function pFn within the specified interval x1 to x2.

Parameters:
pFn a pointer to an evaluation function to be interpolated
x1 interpolation lower bound (x units)
x2 interpolation upper bound (x units)
nCount coefficient count of interpolation polynomial
Remarks:
  • The interpolation bounds x1 and x2 cannot be equal.
  • The specified function pFn(x) returns a value from which interpolation parameters are calculated given an independent variable value between x1 and x2.
  • The function pFn(x) accepts a single independent value (x units).
  • The function pFn(x) returns a single value at the specified point (y units).
  • pFn(x) declaration: yType fn(xType x);
  • The coefficient count nCount must have a value greater than or equal to Cheb::POINT_MIN.

Cheb ( const yType *const   arCn,
xType  x1,
xType  x2,
int  nCount,
int  iArr 
) [protected]

Constructor initializes a Chebyshev polynomial interpolation object from the specified coefficient array arCn within the specified interval x1 to x2.

Parameters:
arCn a pointer to an array of nCount Chebyshev polynomial coefficients (y units)
x1 interpolation lower bound (x units)
x2 interpolation upper bound (x units)
nCount coefficient count of the interpolation polynomial
iArr array size increment/decrement
Remarks:
  • The interpolation bounds x1 and x2 cannot be equal.
  • The coefficient count nCount must have a value greater than or equal to Cheb::POINT_MIN.
  • The final polynomial coefficient array size is changed based on the parameter iArr:
    • decremented for derivatives (iArr=-1)
    • unchanged for interpolations (iArr=0)
    • incremented for integrals (iArr=1)

Cheb ( const Cheb< xType, yType > &  ch  )  [protected]

Copy constructor initializes a function interpolation object from the specified existing interpolation object.

Parameters:
ch a reference to a function interpolation object

~Cheb ( void   )  [protected]

Destructor frees allocated memory.


Member Function Documentation

yType eval ( xType  x  )  const throw (ChebErr)

Function evaluates the Chebyshev polynomial at point x.

Parameters:
x independent variable at which to evaluate the interpolation (x units)
Returns:
calculated interpolation value evaluated at x (variable units)
Exceptions:
ChebErr type of object thrown
Remarks:
  • The interpolation value is in absolute units of the function value (y units) combined with the independent value x (x units) depending on the function evaluation type (see Cheb::getType()).
  • The units of the returned value correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (y units) (interpolate function)
    • DIFFERENTIATE (y/x units) (interpolate function derivative)
    • INTEGRATE (x*y units) (interpolate function integral)

const yType* getArray ( void   )  const

Function returns a pointer to the Chebyshev polynomial coefficient array.

Returns:
a pointer to the coefficient array (y units)
Remarks:
  • If an object initialization error occurred, a null pointer is returned.
  • The coefficients are in absolute units of the function value (y units) combined with the independent value (x units) depending on the function evaluation type (see Cheb::getType()).
  • The units of the coefficients correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (y units) (interpolate function)
    • DIFFERENTIATE (y/x units) (interpolate function derivative)
    • INTEGRATE (x*y units) (interpolate function integral)

xType getBound ( enum Base::BOUND  iBnd  )  const

Function returns the user-specified bound of the interpolation range.

Parameters:
iBnd boundary index
Returns:
interpolation limit value (x units)

int getCount ( void   )  const

Function returns the number of coefficients used in the interpolation polynomial.

Returns:
the number of coefficients used in the interpolating polynomial
Remarks:
The coefficients of the polynomial always begin with degree zero.

xType getError ( void   )  const

Function returns an error estimate of the polynomial interpolation based on the value of the truncation coefficient in the series.

Returns:
interpolation error estimate (|y| units)
Remarks:
  • The error is in absolute units of the function value (y units) combined with the independent value x (x units) depending on the function evaluation type (see Cheb::getType()).
  • The units of the error correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (|y| units) (interpolate function)
    • DIFFERENTIATE (|y/x| units) (interpolate function derivative)
    • INTEGRATE (|x*y| units) (interpolate function integral)

yType getParameter ( int  iDeg  )  const

Function returns the coefficient value of the monomial with the specified degree.

Parameters:
iDeg coefficient index
Returns:
coefficient value (variable units)
Remarks:
  • If an object initialization error occurred, zero is returned.
  • If the degree specified iDeg is out of range, zero is returned.
  • The coefficients are in absolute units of the function value (y units) combined with the independent value (x units) depending on the function evaluation type (see Cheb::getType()).
  • The units of the coefficients correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (y units) (interpolate function)
    • DIFFERENTIATE (y/x units) (interpolate function derivative)
    • INTEGRATE (x*y units) (interpolate function integral)

enum Cheb< xType, yType >::CTYPE getType ( void   )  const

Function returns the value of an enumeration indicating the type of the interpolation evaluation.

Returns:
an enumeration indicating the interpolation type
Remarks:
The returned parameter can be one of the following Cheb::CTYPE enumerations:
  • INTERPOLATE (interpolate function)
  • DIFFERENTIATE (interpolate function derivative)
  • INTEGRATE (interpolate function integral)

operator const yType * ( void   )  const

Conversion function returns a pointer to the Chebyshev coefficient array of values of the interpolation object.

Returns:
a pointer to the coefficient data
Remarks:
  • The number of values in the array equals the number of coefficient values required to express the specified function. (see Cheb::getCount()).
  • The coefficients of the polynomial always begin with degree zero.
  • If an object initialization error occurred, a null pointer is returned.
Note:
For conversion reference of a Chebyshev polynomial object ch, the object is cast as: const yType *ch;

virtual void putCoefs ( yType *  ut,
const yType *  up,
int  cnt 
) [protected, pure virtual]

Virtual function transfers specified interpolation polynomial coefficient array up to specified array ut with transformation as required.

Parameters:
up a pointer to Chebyshev polynomial coefficients (y units)
ut a pointer to calculated Chebyshev polynomial coefficients transformed as required (variable units)
cnt polynomial coefficient count

bool trunCoefs ( const yType *  ut,
int  nCount 
) [protected]

Function shortens the array (ut) of polynomial coefficients based on the coefficient count nCount.

Parameters:
ut a pointer to an array of Chebyshev polynomial coefficients (variable units)
nCount coefficient count of interpolation polynomial
Returns:
status flag
  • false (successful execution)
  • true (memory allocation error)
Remarks:
  • The coefficient parameters (ut) are in absolute units of the function value (y units) combined with the independent value x (x units) depending on the function evaluation type (see Cheb::getType()).
  • The coefficient count nCount must have a value greater than or equal to Cheb::POINT_MIN.
  • The units of parameters (ut) correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (y units) (interpolate function)
    • DIFFERENTIATE (y/x units) (interpolate function derivative)
    • INTEGRATE (x*y units) (interpolate function integral)

bool trunCoefs ( const yType *  ut,
xType  dEps 
) [protected]

Function shortens the array (ut) of polynomial coefficients based on the error condition dEps.

Parameters:
ut a pointer to an array of Chebyshev polynomial coefficients (variable units)
dEps required absolute error of interpolation (|y| units)
Returns:
status flag
  • false (successful execution)
  • true (memory allocation error or error condition (dEps) not met)
Remarks:
  • The input parameters (ut and dEps) are in absolute units of the function value (y units) combined with the independent value x (x units) depending on the function evaluation type (see Cheb::getType()).
  • The units of parameters ut and dEps correspond to the following Cheb::CTYPE types:
    • INTERPOLATE (y units) (interpolate function)
    • DIFFERENTIATE (y/x units) (interpolate function derivative)
    • INTEGRATE (x*y units) (interpolate function integral)


Member Data Documentation

yType* aC [protected]

pointer to a Chebyshev coefficient array (variable units)

enum Cheb< xType, yType >::CTYPE cTyp [protected]

class type of function evaluation

int nData [protected]

Chebyshev coefficient array count

const int POINT_MAX = 50 [static]

default maximum calculation polynomial coefficient count

const int POINT_MIN = 1 [static]

minimum calculation polynomial coefficient count

xType xBnd[Base::BOUND_CNT] [protected]

evaluation bounds (x units)

yType yOffset [protected]

conversion offset from -1:1 Chebyshev interval (variable units)


The documentation for this class was generated from the following files:
Generated on Wed Jul 19 09:24:05 2006 for CalcLib by  doxygen 1.4.7