Simbody
Classes | Public Member Functions

SimTK::Function_< T > Class Template Reference

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

#include <Function.h>

Inheritance diagram for SimTK::Function_< T >:

List of all members.

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

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_ ( ) [inline, virtual]

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::Function_< T >::Constant, SimTK::Function_< T >::Linear, SimTK::Function_< T >::Polynomial, SimTK::Function_< T >::Step, and SimTK::Spline_< T >.

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::Function_< T >::Constant, SimTK::Function_< T >::Linear, SimTK::Function_< T >::Polynomial, SimTK::Function_< T >::Step, and SimTK::Spline_< T >.

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.

Reimplemented in SimTK::Function_< T >::Constant, SimTK::Function_< T >::Linear, SimTK::Function_< T >::Polynomial, SimTK::Function_< T >::Step, and SimTK::Spline_< T >.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines