MBSim

Project Page
Classes | Public Member Functions | Protected Member Functions | Protected Attributes
MBSim::PPolynom Class Reference

class for piecewise-polynomials and cubic spline interpolation More...

#include <ppolynom.h>

Inheritance diagram for MBSim::PPolynom:
MBSim::DifferentiableFunction1< fmatvec::Vec > MBSim::Function1< Ret, Arg >

List of all members.

Classes

class  FirstDerivative
 piecewise polynomial interpolation - first derivative More...
class  SecondDerivative
 piecewise polynomial interpolation - second derivative More...
class  ZerothDerivative
 piecewise polynomial interpolation - zeroth derivative More...

Public Member Functions

 PPolynom ()
 constructor
virtual ~PPolynom ()
 destructor
void setXF (const fmatvec::Vec &x, const fmatvec::Mat &f, std::string InterpolationMethod)
 set interpolation
std::vector< fmatvec::Mat > getCoefs ()
fmatvec::Vec getBreaks ()
void setPP (const std::vector< fmatvec::Mat > &coefs_u, const fmatvec::Vec &breaks_u)
 set piecewise polynomial
virtual void initializeUsingXML (TiXmlElement *element)
 initialize function with XML code
- Public Member Functions inherited from MBSim::DifferentiableFunction1< fmatvec::Vec >
 DifferentiableFunction1 ()
 constructor
virtual ~DifferentiableFunction1 ()
 destructor
virtual fmatvec::Vec operator() (const double &x, const void *=NULL)
const Function1< fmatvec::Vec,
double > & 
getDerivative (int degree) const
Function1< fmatvec::Vec, double > & getDerivative (int degree)
void addDerivative (Function1< fmatvec::Vec, double > *diff)
void setDerivative (Function1< fmatvec::Vec, double > *diff, size_t degree)
void setOrderOfDerivative (int i)
- Public Member Functions inherited from MBSim::Function1< Ret, Arg >
virtual ~Function1 ()
 destructor
virtual Ret operator() (const Arg &x, const void *=NULL)=0

Protected Member Functions

void calculateSplinePeriodic (const fmatvec::Vec &x, const fmatvec::Mat &f)
 calculation of periodic spline by interpolation
void calculateSplineNatural (const fmatvec::Vec &x, const fmatvec::Mat &f)
 calculation of natural spline by interpolation
void calculatePLinear (const fmatvec::Vec &x, const fmatvec::Mat &f)

Protected Attributes

std::vector< fmatvec::Mat > coefs
 vector of polynomial coefficents
fmatvec::Vec breaks
 vector of breaks (interval boundaries)
int nPoly
 number of defined piecewise polynomials
int order
 order of polynomial (3 for cubic polynomials)
int index
 for internal use in ppeval functions
- Protected Attributes inherited from MBSim::DifferentiableFunction1< fmatvec::Vec >
std::vector< Function1
< fmatvec::Vec, double > * > 
derivatives
 vector of derivatives

Detailed Description

class for piecewise-polynomials and cubic spline interpolation

Author:
Robert Huber
Date:
2006-08-31 initial commit
2006-09-05 verified with matlab /octave (Robert Huber)
2008-05-21 C++ beauty treatment, PLinear (Thorsten Schindler)
2009-08-11 kernel_dev (Thorsten Schindler)
Todo:
add deletes TODO

Spline / PP-Form info Piecewise polynomial: c0* xloc^n + c1* xloc^(n-1) + c2* xloc^(n-2) + ... + cn with [c0 c1 c2 ... cn] ith row vector of coefs-matrix breaks(i) << x << breaks(i+1) defines i and xloc = x-breaks(i)

Ex. cubic spline with breaks= [0; 0.3; 0.5] coefs= [d1 c1 b1 a1; d2 c2 b2 a2] -> S(x) = a1 + b1*xloc + c1*xloc^2 + d1*xloc^3 for x[0;0.3] and x_loc = x -> S(x) = a2 + b2*xloc + c2*xloc^2 + d2*xloc^3 for x[0.3;0.5] and xloc = x - 0.3;

Cubic spline (xi,fi) i=1..N is being interpolated by N-1 piecewise polynomials Si of degree 3 yielding a global C^2 curve for uniqueness TWO additional boundary conditions are necessary (periodic / natural)

Piecewise linear polynomial (xi,fi) i=1..N is being interpolated by N-1 piecewise polynomials Si of degree 1 yielding a globally weak differentiable curve in the context of this class the second derivative is defined to be zero everywhere (which is mathematically wrong)


Member Function Documentation

void MBSim::PPolynom::calculateSplineNatural ( const fmatvec::Vec &  x,
const fmatvec::Mat &  f 
)
protected

calculation of natural spline by interpolation

Parameters:
interpolatedarguments
interpolatedfunction values
void MBSim::PPolynom::calculateSplinePeriodic ( const fmatvec::Vec &  x,
const fmatvec::Mat &  f 
)
protected

calculation of periodic spline by interpolation

Parameters:
interpolatedarguments
interpolatedfunction values
fmatvec::Vec MBSim::PPolynom::getBreaks ( )
inline
Returns:
interval boundaries
std::vector< fmatvec::Mat > MBSim::PPolynom::getCoefs ( )
inline
Returns:
polynomial coefficients
virtual void MBSim::PPolynom::initializeUsingXML ( TiXmlElement *  element)
virtual

initialize function with XML code

Parameters:
XMLelement

Reimplemented from MBSim::DifferentiableFunction1< fmatvec::Vec >.

void MBSim::PPolynom::setPP ( const std::vector< fmatvec::Mat > &  coefs_u,
const fmatvec::Vec &  breaks_u 
)
inline

set piecewise polynomial

Parameters:
polynomialcoefficients
intervalboundaries
void MBSim::PPolynom::setXF ( const fmatvec::Vec &  x,
const fmatvec::Mat &  f,
std::string  InterpolationMethod 
)

set interpolation

Parameters:
xvector of ordered x values
fcorresponding f(x) values (rowwise)
InterpolationMethod'csplinePer' -> cubic Spline with periodic end conditions (two-times continuously differentiable) S(x1) = S(xN) -> f(0)=f(end) S'(x1) = S'(xN) S''(x1) = S''(xN) 'csplineNat' -> cubic Spline with natural end conditions (two-times continuously differentiable) S''(x1) = S''(xN) = 0 'plinear' -> piecewise linear function (weak differentiable)

The documentation for this class was generated from the following file: