roboptim::Polynomial< T > Class Template Reference

Polynomial function. More...

#include <roboptim/core/function/polynomial.hh>

Inheritance diagram for roboptim::Polynomial< T >:
roboptim::GenericTwiceDifferentiableFunction< T > roboptim::GenericDifferentiableFunction< T > roboptim::GenericFunction< T >

List of all members.

Public Member Functions

 ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ (GenericTwiceDifferentiableFunction< T >)
 Polynomial (const_vector_ref coefficients)
 Build a polynomial function.
virtual ~Polynomial ()
virtual std::ostream & print (std::ostream &o) const
 Display the function on the specified output stream.

Protected Member Functions

void impl_compute (result_ref result, const_argument_ref x) const
 Function evaluation.
void impl_gradient (gradient_ref gradient, const_argument_ref x, size_type) const
 Gradient evaluation.
void impl_jacobian (jacobian_ref jacobian, const_argument_ref x) const
 Jacobian evaluation.
void impl_hessian (hessian_ref hessian, const_argument_ref x, size_type) const
 Hessian evaluation.
value_type applyPolynomial (const_vector_ref coeffs, const_argument_ref x) const
 Implement Horner's method.

Detailed Description

template<typename T>
class roboptim::Polynomial< T >

Polynomial function.

Implement a polynomial function using the formula:

\[f(x) = a_0 + a_1 * x + a_2 * x^2 + a_3 * x^3 + ...\]

where polynomial coefficients $a_i$ are set when the class is instanciated

Examples:
function-polynomial.cc.

Constructor & Destructor Documentation

template<typename T >
roboptim::Polynomial< T >::Polynomial ( const_vector_ref  coefficients) [explicit]

Build a polynomial function.

Parameters:
coefficientspolynomial coefficients given in increasing degree order
Exceptions:
std::runtime_error
template<typename T>
virtual roboptim::Polynomial< T >::~Polynomial ( ) [inline, virtual]

Member Function Documentation

template<typename T >
Polynomial< T >::value_type roboptim::Polynomial< T >::applyPolynomial ( const_vector_ref  coeffs,
const_argument_ref  x 
) const [protected]

Implement Horner's method.

template<typename T >
void roboptim::Polynomial< T >::impl_compute ( result_ref  result,
const_argument_ref  argument 
) const [protected, virtual]

Function evaluation.

Evaluate the function, has to be implemented in concrete classes.

Warning:
Do not call this function directly, call operator()(result_ref, const_argument_ref) const instead.
Parameters:
resultresult will be stored in this vector
argumentpoint at which the function will be evaluated

Implements roboptim::GenericFunction< T >.

template<typename T >
void roboptim::Polynomial< T >::impl_gradient ( gradient_ref  gradient,
const_argument_ref  argument,
size_type  functionId 
) const [protected, virtual]

Gradient evaluation.

Compute the gradient, has to be implemented in concrete classes. The gradient is computed for a specific sub-function which id is passed through the functionId argument.

Warning:
Do not call this function directly, call gradient instead.
Parameters:
gradientgradient will be store in this argument
argumentpoint where the gradient will be computed
functionIdevaluated function id in the split representation

Implements roboptim::GenericDifferentiableFunction< T >.

template<typename T >
void roboptim::Polynomial< T >::impl_hessian ( hessian_ref  hessian,
const_argument_ref  argument,
size_type  functionId 
) const [protected, virtual]

Hessian evaluation.

Compute the hessian, has to be implemented in concrete classes. The hessian is computed for a specific sub-function which id is passed through the functionId argument.

Warning:
Do not call this function directly, call hessian instead.
Parameters:
hessianhessian will be stored here
argumentpoint where the hessian will be computed
functionIdevaluated function id in the split representation

Implements roboptim::GenericTwiceDifferentiableFunction< T >.

template<typename T >
void roboptim::Polynomial< T >::impl_jacobian ( jacobian_ref  jacobian,
const_argument_ref  arg 
) const [protected, virtual]

Jacobian evaluation.

Computes the jacobian, can be overridden by concrete classes. The default behavior is to compute the jacobian from the gradient.

Warning:
Do not call this function directly, call jacobian instead.
Parameters:
jacobianjacobian will be store in this argument
argpoint where the jacobian will be computed

Reimplemented from roboptim::GenericDifferentiableFunction< T >.

template<typename T >
std::ostream & roboptim::Polynomial< T >::print ( std::ostream &  o) const [virtual]

Display the function on the specified output stream.

Parameters:
ooutput stream used for display
Returns:
output stream

Reimplemented from roboptim::GenericTwiceDifferentiableFunction< T >.

References roboptim::decindent(), roboptim::iendl(), and roboptim::incindent().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines