Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdGCVSpline Class Reference

A class for representing a smooth function with a generalized cross-validation spline. More...

#include <rdGCVSpline.h>

Inheritance diagram for rdGCVSpline:

rdFunction rdObject List of all members.

Public Member Functions

 rdGCVSpline ()
 Default constructor.

 rdGCVSpline (int aDegree, int aN, const double *aTimes, const double *aValues, const char *aName=NULL, double aErrorVariance=0.0)
 Construct a spline of a specified degree given arrays of paired data points (x,f(x)).

 rdGCVSpline (IDOM_Element *aElement)
 Construct a function from an XML Element.

 rdGCVSpline (const rdGCVSpline &aSpline)
 Copy constructor.

virtual ~rdGCVSpline ()
 Destructor.

virtual rdFunctioncopy () const
 Copy this object.

virtual rdFunctioncopy (IDOM_Element *aElement) const
 Copy this object and modify the copy so that it is consistent with a specified XML element node.

rdGCVSpline & operator= (const rdGCVSpline &aSpline)
 Assignment operator.

void setDegree (int aDegree)
 Set the degree of this spline.

int getDegree ()
 Get the degree of this spline.

int getOrder ()
 Get the order of this spline.

int getHalfOrder ()
 Get the half order of this spline.

int getN ()
 Get the number of data points (or number of coefficients) used to construct the spline.

double getMinX ()
 Get the minimum value of the independent variable.

double getMaxX ()
 Get the maximum value of the independent variable.

const double * getX ()
 Get the array of independent variables used to construct the spline.

int getNW ()
const double * getWorkArray ()
const double * getCoefficients ()
 Get the array of coefficients for the spline.

virtual void updateBoundingBox ()
 Update the bounding box for this function.

virtual double evaluate (int aDerivOrder, double aX=0.0, double aY=0.0, double aZ=0.0)
 Evaluate this function or a derivative of this function given a set of independent variables.

virtual void updateObject (bool aDeep=true)
 Update this object based on its XML node.

virtual void updateNode (bool aDeep=true)
 Update the XML node representing this object.

virtual void generateNode (IDOM_Element *aParent)
 Generate an XML node representing this object.

void updateData ()
 Update the member data of this object based on its XML node.


Static Public Attributes

const char PROP_HALF_ORDER [] = "half_order"
const char PROP_ERROR_VARIANCE [] = "error_variance"
const char PROP_X [] = "x"
const char PROP_COEFF [] = "coefficents"
const char PROP_WEIGHTS [] = "weights"
const char PROP_WK [] = "wk"

Protected Attributes

int _halfOrder
 Half order of the spline (degree+1)/2.

int _n
 Number of data points.

double * _x
 Array of values for the independent variables (i.e., the spline knot sequence).

double * _weights
 Array of weight values, one for each data point.

double * _coefficients
 Spline coefficients.

double _errorVariance
 Error variance for the data and spline fit.

int _knotIndex
 Knot index used to fascilitate finding the appropriate knot during an evaluation.

int _nw
 Size of the work array for contructing the spline.

double * _wk
 Work array for construction of the spline.

double * _workEval
 Work array for evaluating the spline.


Private Member Functions

void setNull ()
 Set all member variables to their NULL or default values.

void setEqual (const rdGCVSpline &aSpline)
 Set all member variables equal to the members of another object.


Detailed Description

A class for representing a smooth function with a generalized cross-validation spline.

Linear, cubic, qunitic, and heptic splines are supported:

m (half-order) order degree description 1 2 1 linear 2 4 3 cubic 3 6 5 quintic 4 8 7 heptic

This class wraps the gcvspl.c source code written by D. Twisk in 1994, which is based on the GCVSPL code written in Fortran by Woltring in 1985_07_04. This class was initially based on a spline class authored by Darryl Thelen and Victor Ng; it has been rewritten to fit into the Realistic Dynamics, Inc. software framework.

See the following source for details on how the GCV spline is fit: Woltring, H.J. (1986). A Fortran package for generalized, cross-validatory spline smoothing and differentiation. Advances in Engineering Software, Vol. 8, No. 2, 104-113.

This class inherits from rdFunction and so can be used as input to any class requiring an rdFuction as input.

Author:
Frank C. Anderson


Constructor & Destructor Documentation

rdGCVSpline::rdGCVSpline int  aDegree,
int  aN,
const double *  aTimes,
const double *  aValues,
const char *  aName = NULL,
double  aErrorVariance = 0.0
 

Construct a spline of a specified degree given arrays of paired data points (x,f(x)).

A name for the spline may be specified.

Parameters:
aDegree Degree of the spline. Only the following degrees are supported: 1 = linear, 3 = cubic, 5 = qunitic, and 7 = heptic.
aN Number of data points.
aX Array of independent values- should be aN long.
aF Array of function values- should be aN long.
aName Optional name of the spline.
aErrorVariance Estimate of the variance of the error in the data to be fit. If negative, the variance will be estimated. If 0.0, the fit will try to fit the data points exactly- no smoothing. If positive, the fit will be smoothed according to the specified variance. The larger the error variance, the more the smoothing. The smoothing parameter, p, in Woltring (1986) is computed based on the error variance.

rdGCVSpline::rdGCVSpline IDOM_Element *  aElement  ) 
 

Construct a function from an XML Element.

Parameters:
aElement XML element.

rdGCVSpline::rdGCVSpline const rdGCVSpline &  aSpline  ) 
 

Copy constructor.

All data members of the specified spline are copied.

Parameters:
aSpline rdGCVSpline object to be copied.


Member Function Documentation

rdFunction * rdGCVSpline::copy IDOM_Element *  aElement  )  const [virtual]
 

Copy this object and modify the copy so that it is consistent with a specified XML element node.

The copy is constructed by first using rdGCVSpline::rdGCVSpline(IDOM_Element*) in order to establish the XML node. Then, the assignment operator is used to set all data members of the copy to the values of this object. Finally, the data members of the copy are updated using rdGCVSpline::updateObject().

Parameters:
aElement XML element.
Returns:
Pointer to a copy of this object modified by the specified XML element.

Implements rdFunction.

rdFunction * rdGCVSpline::copy  )  const [virtual]
 

Copy this object.

Returns:
Pointer to a copy of this object.

Implements rdFunction.

double rdGCVSpline::evaluate int  aDerivOrder,
double  aX = 0.0,
double  aY = 0.0,
double  aZ = 0.0
[virtual]
 

Evaluate this function or a derivative of this function given a set of independent variables.

Only splines of one dimension are supported by this class, so values of independent variables y and z are ignored.

Parameters:
aDerivOrder Derivative order. If aDerivOrder == 0, the function is evaluated. Otherwise, if aDerivOrder > 0, the aDerivOrder'th derivative of the function is evaluated. For example, if aDerivOrder == 1, the first derivative of the function is returned. Negative values of aDerivOrder (integrals of the function) are not supported.
aX Value of the x independent variable at which to evaluate this function or its derivatives.
aY Value of the y independent variable at which to evaluate this function or its derivatives (ignored).
aZ Value of the z independent variable at which to evaluate this function or its derivatives (ignored).
Returns:
Value of the function or one of its derivatives.

Implements rdFunction.

void rdGCVSpline::generateNode IDOM_Element *  aParent  )  [virtual]
 

Generate an XML node representing this object.

Parameters:
aParent Intended parent of the node to be generated. If aParent is NULL, the intent is for this object to serve as the root element of a new document.
See also:
rdObject::generateNode()

Reimplemented from rdFunction.

const double * rdGCVSpline::getCoefficients  ) 
 

Get the array of coefficients for the spline.

For the number of coefficients use getNX().

Returns:
Pointer to the coefficients.
See also:
getCoefficients();

int rdGCVSpline::getDegree  ) 
 

Get the degree of this spline.

Returns:
Degree of spline: 1 = linear, 3 = cubic, 5 = qunitic, 7 = heptic.

int rdGCVSpline::getHalfOrder  ) 
 

Get the half order of this spline.

Returns:
Half order of spline: 1 = linear, 2 = cubic, 3 = qunitic, 4 = heptic.

double rdGCVSpline::getMaxX  ) 
 

Get the maximum value of the independent variable.

Returns:
Maximum value of the independent variable.

double rdGCVSpline::getMinX  ) 
 

Get the minimum value of the independent variable.

Returns:
Minimum value of the independent variable.

int rdGCVSpline::getN  ) 
 

Get the number of data points (or number of coefficients) used to construct the spline.

Returns:
Number of data points (or number of coefficients).

int rdGCVSpline::getOrder  ) 
 

Get the order of this spline.

Returns:
Order of spline: 2 = linear, 4 = cubic, 6 = qunitic, 8 = heptic.

const double * rdGCVSpline::getX  ) 
 

Get the array of independent variables used to construct the spline.

For the number of independent variable data points use getN().

Returns:
Pointer to the independent variable data points.
See also:
getN();

rdGCVSpline & rdGCVSpline::operator= const rdGCVSpline &  aSpline  ) 
 

Assignment operator.

Note that data members of the base class are also assigned.

Returns:
Reference to this object.

void rdGCVSpline::setDegree int  aDegree  ) 
 

Set the degree of this spline.

Parameters:
aDegree Degree of spline. Legal values: 1 = linear, 3 = cubic, 5 = qunitic, 7 = heptic.

void rdGCVSpline::setEqual const rdGCVSpline &  aSpline  )  [private]
 

Set all member variables equal to the members of another object.

Note that this method is private. It is only meant for copying the data members defined in this class. It does not, for example, make any changes to data members of base classes.

void rdGCVSpline::updateBoundingBox  )  [virtual]
 

Update the bounding box for this function.

For an rdGCVSpline, there is only one indepdendent variable x, so the minimum and maximum values of indepdent variables y and z is 0.0.

When this method is called, the minimum and maximum x of the bounding box is simply set to the minimum and maximum values of the x data points that were used to construct the spline, that is, min x = x[0] and max x = x[getN()-1].

See also:
rdFunction

Implements rdFunction.

void rdGCVSpline::updateData  ) 
 

Update the member data of this object based on its XML node.

Member objects (children) are not updated.

Reimplemented from rdFunction.

void rdGCVSpline::updateNode bool  aDeep = true  )  [virtual]
 

Update the XML node representing this object.

Parameters:
aDeep If true, update the XML node of this object AND the XML nodes of all class members that are rdObjects (child nodes); if false, update only the XML node of this object without updating the XML nodes of its children.

Reimplemented from rdFunction.

void rdGCVSpline::updateObject bool  aDeep = true  )  [virtual]
 

Update this object based on its XML node.

Parameters:
aDeep If true, update this object and all its child objects (that is, member variables that are rdObject's); if false, update only the member variables that are not rdObject's.

Reimplemented from rdFunction.


Member Data Documentation

double rdGCVSpline::_errorVariance [protected]
 

Error variance for the data and spline fit.

The smoothing factor p is computed based on the error variance.

double* rdGCVSpline::_x [protected]
 

Array of values for the independent variables (i.e., the spline knot sequence).

This array must be monotonically increasing.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:10 2003 for Simulation Software by doxygen1.3