Simbody  3.5
SimTK::Function_< T > Class Template Referenceabstract

This abstract class represents a mathematical function that calculates a value of arbitrary type based on M real arguments. More...

+ Inheritance diagram for SimTK::Function_< T >:

Classes

class  Constant
 This is a Function_ subclass which simply returns a fixed value, independent of its arguments. More...
 
class  Linear
 This is a Function_ subclass whose output value is a linear function of its arguments: f(x, y, ...) = ax+by+...+c. More...
 
class  Polynomial
 This is a Function_ subclass whose output value is a polynomial of its argument: f(x) = ax^n+bx^(n-1)+...+c. More...
 
class  Sinusoid
 This is a Function_ subclass whose output value is a sinusoid of its argument: f(x) = a*sin(w*x + p) where a is amplitude, w is frequency in radians per unit of x, p is phase in radians. More...
 
class  Step
 This is a Function_ subclass whose output value y=f(x) is smoothly stepped from y=y0 to y1 as its input argument goes from x=x0 to x1. More...
 

Public Member Functions

virtual ~Function_ ()
 
virtual T calcValue (const Vector &x) const =0
 Calculate the value of this function at a particular point. More...
 
virtual T calcDerivative (const Array_< int > &derivComponents, const Vector &x) const =0
 Calculate a partial derivative of this function at a particular point. More...
 
calcDerivative (const std::vector< int > &derivComponents, const Vector &x) const
 This provides compatibility with std::vector without requiring any copying. More...
 
virtual int getArgumentSize () const =0
 Get the number of components expected in the input vector. More...
 
virtual int getMaxDerivativeOrder () const =0
 Get the maximum derivative order this Function_ object can calculate. More...
 

Detailed Description

template<class T>
class SimTK::Function_< T >

This abstract class represents a mathematical function that calculates a value of arbitrary type based on M real arguments.

The output type is set as a template argument, while the number of input components may be determined at runtime. The name "Function" (with no trailing _) may be used as a synonym for Function_<Real>.

Subclasses define particular mathematical functions. Predefined subclasses are provided for several common function types: Function_<T>::Constant, Function_<T>::Linear, Function_<T>::Polynomial, and Function_<T>::Step. You can define your own subclasses for other function types. The Spline_ class also provides a convenient way to create various types of Functions.

Constructor & Destructor Documentation

template<class T>
virtual SimTK::Function_< T >::~Function_ ( )
inlinevirtual

Member Function Documentation

template<class T>
virtual T SimTK::Function_< T >::calcValue ( const Vector x) const
pure virtual

Calculate the value of this function at a particular point.

Parameters
xthe Vector of input arguments. Its size must equal the value returned by getArgumentSize().

Implemented in SimTK::BicubicFunction, SimTK::Function_< T >::Step, SimTK::Function_< T >::Sinusoid, SimTK::Function_< T >::Polynomial, SimTK::Function_< T >::Linear, SimTK::Spline_< T >, and SimTK::Function_< T >::Constant.

template<class T>
virtual T SimTK::Function_< T >::calcDerivative ( const Array_< int > &  derivComponents,
const Vector x 
) const
pure virtual

Calculate a partial derivative of this function at a particular point.

Which derivative to take is specified by listing the input components with which to take it. For example, if derivComponents=={0}, that indicates a first derivative with respective to component 0. If derivComponents=={0, 0, 0}, that indicates a third derivative with respective to component 0. If derivComponents=={4, 7}, that indicates a partial second derivative with respect to components 4 and 7.

Parameters
derivComponentsThe input components with respect to which the derivative should be taken. Its size must be less than or equal to the value returned by getMaxDerivativeOrder().
xThe Vector of input arguments. Its size must equal the value returned by getArgumentSize().
Returns
The value of the selected derivative, which is of type T.

Implemented in SimTK::BicubicFunction, SimTK::Function_< T >::Step, SimTK::Function_< T >::Sinusoid, SimTK::Function_< T >::Polynomial, SimTK::Function_< T >::Linear, SimTK::Spline_< T >, and SimTK::Function_< T >::Constant.

template<class T>
T SimTK::Function_< T >::calcDerivative ( const std::vector< int > &  derivComponents,
const Vector x 
) const
inline

This provides compatibility with std::vector without requiring any copying.

template<class T>
virtual int SimTK::Function_< T >::getArgumentSize ( ) const
pure virtual
template<class T>
virtual int SimTK::Function_< T >::getMaxDerivativeOrder ( ) const
pure virtual

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