Simbody 3.7
Loading...
Searching...
No Matches
SimTK::Function_< T >::Step Class Reference

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...

#include <Function.h>

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

Public Member Functions

 Step (const T &y0, const T &y1, Real x0, Real x1)
 Create a Function_::Step object that smoothly interpolates its output through a given range as its input moves through its range.
 
void setParameters (const T &y0, const T &y1, Real x0, Real x1)
 Change the four parameters that define the step function; see constructor for documentation.
 
calcValue (const Vector &xin) const override
 Calculate the value of this function at a particular point.
 
calcDerivative (const Array_< int > &derivComponents, const Vector &xin) const override
 Calculate a partial derivative of this function at a particular point.
 
int getArgumentSize () const override
 Get the number of components expected in the input vector.
 
int getMaxDerivativeOrder () const override
 Get the maximum derivative order this Function_ object can calculate.
 
Stepclone () const override
 Create a new heap-allocated copy of this concrete Function.
 
calcDerivative (const std::vector< int > &derivComponents, const Vector &x) const
 This provides compatibility with std::vector without requiring any copying.
 
- Public Member Functions inherited from SimTK::Function_< T >
virtual ~Function_ ()
 
calcDerivative (const std::vector< int > &derivComponents, const Vector &x) const
 This provides compatibility with std::vector without requiring any copying.
 

Detailed Description

template<class T>
class SimTK::Function_< T >::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.

This is an S-shaped function with first and second derivatives y'(x0)=y'(x1)=0 and y''(x0)=y''(x1)==0. The third derivative y''' exists and is continuous but we cannot guarantee anything about it at the end points.

Constructor & Destructor Documentation

◆ Step()

template<class T >
SimTK::Function_< T >::Step::Step ( const T &  y0,
const T &  y1,
Real  x0,
Real  x1 
)
inline

Create a Function_::Step object that smoothly interpolates its output through a given range as its input moves through its range.

Parameters
y0Output value when (x-x0)*sign(x1-x0) <= 0.
y1Output value when (x-x1)*sign(x1-x0) >= 0.
x0Start of switching interval.
x1End of switching interval (must not equal x0).
Template Parameters
TThe template type is the type of y0 and y1. This must be a type that supports subtraction and scalar multiplication by a Real so that we can compute an expression like y=y0 + f*(y1-y0) for some Real scalar f.

Note that the numerical values of x0 and x1 can be in either order x0 < x1 or x0 > x1, but they cannot be equal.

Member Function Documentation

◆ setParameters()

template<class T >
void SimTK::Function_< T >::Step::setParameters ( const T &  y0,
const T &  y1,
Real  x0,
Real  x1 
)
inline

Change the four parameters that define the step function; see constructor for documentation.

◆ calcValue()

template<class T >
T SimTK::Function_< T >::Step::calcValue ( const Vector x) const
inlineoverridevirtual

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().

Implements SimTK::Function_< T >.

◆ calcDerivative() [1/2]

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

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
derivComponents
The 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().
x
The 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.

Implements SimTK::Function_< T >.

◆ getArgumentSize()

template<class T >
int SimTK::Function_< T >::Step::getArgumentSize ( ) const
inlineoverridevirtual

Get the number of components expected in the input vector.

Implements SimTK::Function_< T >.

◆ getMaxDerivativeOrder()

template<class T >
int SimTK::Function_< T >::Step::getMaxDerivativeOrder ( ) const
inlineoverridevirtual

Get the maximum derivative order this Function_ object can calculate.

Implements SimTK::Function_< T >.

◆ clone()

template<class T >
Step * SimTK::Function_< T >::Step::clone ( ) const
inlineoverridevirtual

Create a new heap-allocated copy of this concrete Function.

For backwards compatibility this is not pure virtual; it has a default implementation that throws an exception if called. However, it should always be implemented.

Reimplemented from SimTK::Function_< T >.

◆ calcDerivative() [2/2]

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

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


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