Cube Class Template Reference

Class template interpolates tabulated data with cubic splines. More...

#include <Intp.h>

Inherits Intp< xType, yType >.

Inheritance diagram for Cube:

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual yType * copyArrayY (enum Intp< xType, yType >::VTYPE vType, yType *array) const
 Cube (const xType *arX, const yType *arY, int nCount, const EndCube< xType, yType > &rDc)
 Cube (const xType *arX, const yType *arY, int nCount)
 Cube (const Intp< xType, yType > &in)
 Cube (const Cube< xType, yType > &cu)
virtual yType eval (xType x) throw (IntpErr)
virtual const yType * getArrayY (enum Intp< xType, yType >::VTYPE vType) const
virtual int getCount (enum Intp< xType, yType >::VTYPE vType) const
EndCube< xType, yType > getEndCube (void) const
bool setEndCube (EndCube< xType, yType > eCube)
virtual bool update (void)
 ~Cube (void)

Static Public Attributes

static const xType DDY_SCALE = 6
static const int DEF_POINTS = 4

Detailed Description

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

Class template interpolates tabulated data with cubic splines.

In instantiation, an object is supplied with a one-dimensional set of independent variable and corresponding dependent variable data tables with a specific domain and range. The independent data must be monotonically increasing. The dependent data must be defined at every independent data point, continuous, and single-valued. When the interpolation object is evaluated within the data table domain, an interpolation value is calculated and returned. All interpolation splines are cubic in degree having four coefficients. Adjacent splines agree at their end points in zero, first and second derivative evaluations.

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.

Author
efgeorge
Date
2006/07/19 13:21:43
Revision
1.3
Examples:

example_Intp.txt.


Constructor & Destructor Documentation

Cube ( const Cube< xType, yType > &  cu  ) 

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

Parameters:
cu a reference to a spline interpolation object

Cube ( const Intp< xType, yType > &  in  ) 

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

Parameters:
in a reference to an interpolation object
Remarks:
  • Cube interpolation objects carry an existing interpolation polynomial data point count of Cube::DEF_POINTS.
  • The cubic spline derivative identifier object is set to the default values of the natural spline (see calc::EndCube).
  • The function Cube::update() is called after data values are initialized for the cubic interpolation object.

~Cube ( void   ) 

Destructor frees allocated memory.

Cube ( const xType *  arX,
const yType *  arY,
int  nCount 
)

Constructor initializes a cubic spline interpolation object using the natural spline requirement.

Parameters:
arX a pointer to an independent value interpolation array (x units)
arY a pointer to a dependent value interpolation array (y units)
nCount data count for the specified arrays arX and arY
Remarks:
  • The data count value nCount must be greater than zero.
  • The independent interpolation array arX must contain monotonically increasing values.
  • Spline calculations use the natural spline requirement that second derivatives of first and last data points in the spline are set equal to zero.
  • With a natural spline, the first derivative of an end point assumes the slope to the adjacent data point.

Cube ( const xType *  arX,
const yType *  arY,
int  nCount,
const EndCube< xType, yType > &  rDc 
)

Constructor initializes a cubic spline interpolation object with specified derivative data for the first and last data points in the spline.

Parameters:
arX a pointer to an independent value interpolation array (x units)
arY a pointer to a dependent value interpolation array (y units)
nCount data count for the specified arrays arX and arY
rDc a reference to a derivative identifier object. (see Cube::getEndCube())
Remarks:
  • The data count value nCount must be greater than zero.
  • The independent interpolation array arX must contain monotonically increasing values.


Member Function Documentation

yType * copyArrayY ( enum Intp< xType, yType >::VTYPE  vType,
yType *  array 
) const [virtual]

Virtual function copies values contained in an identified object dependent array to the specified pointer.

Parameters:
vType variable index indentifying the type of data
array a pointer to a copy of the object's dependent data array (varying units)
Returns:
the value of the pointer array
Remarks:
  • The data count of the object's array identified by vType is returned by a corresponding function call Intp::getCount().
  • The pointer to the object's array identified by vType is returned by a corresponding function call Intp::getArrayY().
  • The user-supplied pointer array should have sufficient allocated memory.
  • If the object is not initialized, a null pointer is returned.
  • If the object does not have the variable identified by vType, a null pointer is returned.
  • The units expressed in the values of array vary depending on the the variable index vType.

Note:
Stored second derivative interpolation values are pre-divided by the value 6 to reduce evaluation calculations (see Cube::DDY_SCALE). To recover the spline second derivative at a data point, the value in the array must be multiplied by 6.

yType eval ( xType  x  )  throw (IntpErr) [virtual]

Virtual function interpolates the dependent data at the specified independent data value.

Parameters:
x an independent value interpolation point (x units)
Returns:
calculated interpolation value evaluated at value x (y units)
Exceptions:
IntpErr type of object thrown

Implements Intp.

const yType * getArrayY ( enum Intp< xType, yType >::VTYPE  vType  )  const [virtual]

Virtual function returns the pointer of the identified object dependent array.

Parameters:
vType variable index indentifying the dependent array type
Returns:
a pointer to the object's identified array (varying units)
Remarks:
  • The data count of the object's array identified by vType is returned by a corresponding function call Intp::getCount().
  • The data contained in the object's array identified by vType can be copied to user-identified memory by a corresponding function call Intp::copyArrayY().
  • If the object is not initialized, a null pointer is returned.
  • If the object does not have the variable identified by vType, a null pointer is returned.
  • The units expressed in the values of the returned array vary depending on the the variable index vType.

Note:
Stored second derivative interpolation values are pre-divided by the value 6 to reduce evaluation calculations (see Cube::DDY_SCALE). To recover the spline second derivative at a data point, the value in the array must be multiplied by 6.

int getCount ( enum Intp< xType, yType >::VTYPE  vType  )  const [virtual]

Virtual function determines the number of values contained in the object's identified array.

Parameters:
vType variable index indentifying the type of data
Returns:
the data count of the object's array
Remarks:
  • The pointer of the object's array identified by vType is returned by a corresponding function call Intp::getArrayX() or Intp::getArrayY().
  • If the object is not initialized, -1 is returned.
  • If the object does not have the variable identified by vType, -1 is returned.

EndCube<xType,yType> getEndCube ( void   )  const

Function returns values of the cubic spline interpolation object's derivative identifier object.

Returns:
a derivative identifier object (calc::EndCube)
Remarks:
  • This value can be set during the object's instantiation Cube::Cube(), or with the function call Cube::setEndCube().
  • If the natural spline requirement is specified for the interpolation object, a calc::EndCube object indicating zero second derivatives is returned.

bool setEndCube ( EndCube< xType, yType >  eCube  ) 

Function sets values of the cubic spline interpolation object's derivative identifier object.

Parameters:
eCube a derivative identifier object
Returns:
status flag
  • false (successful execution)
  • true (execution error, parameter not set)
Remarks:
  • If the natural spline requirement is required for the interpolation object, an EndCube object indicating zero second derivatives should be passed to this function.
  • The function Cube::update() is called after end derivative values are changed for the cubic interpolation object.

bool update ( void   )  [virtual]

Virtual function prepares the interpolation object for interpolation evaluations.

Returns:
status flag
  • false (successful execution)
  • true (execution error)
    • object initialization error
    • memory allocation error
    • some independent data points are equal or decreasing

Reimplemented from Intp.


Member Data Documentation

const xType DDY_SCALE = 6 [static]

cubic interpolation polynomial second derivative scale factor

const int DEF_POINTS = 4 [static]

cubic interpolation polynomial data point count

Reimplemented from Intp.


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