roboptim::Polynomial< T > Class Template Reference

Polynomial function. More...

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

Inheritance diagram for roboptim::Polynomial< T >:
Collaboration diagram for roboptim::Polynomial< T >:

Public Member Functions

 ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ (GenericTwiceDifferentiableFunction< T >)
 
 Polynomial (const_vector_ref coefficients)
 Build a polynomial function. More...
 
virtual ~Polynomial ()
 
virtual std::ostream & print (std::ostream &o) const
 Display the function on the specified output stream. More...
 
- Public Member Functions inherited from roboptim::GenericTwiceDifferentiableFunction< T >
 ROBOPTIM_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ (GenericDifferentiableFunction< T >)
 
 ROBOPTIM_GENERATE_TRAITS_REFS_ (hessian)
 Hessian type. More...
 
hessianSize_t hessianSize () const
 Return the size of a hessian. More...
 
bool isValidHessian (const_hessian_ref hessian) const
 Check if the hessian is valid (check sizes). More...
 
hessian_t hessian (const_argument_ref argument, size_type functionId=0) const
 Compute the hessian at a given point. More...
 
void hessian (hessian_ref hessian, const_argument_ref argument, size_type functionId=0) const
 Compute the hessian at a given point. More...
 

Protected Member Functions

void impl_compute (result_ref result, const_argument_ref x) const
 
void impl_gradient (gradient_ref gradient, const_argument_ref x, size_type) const
 
void impl_jacobian (jacobian_ref jacobian, const_argument_ref x) const
 
void impl_hessian (hessian_ref hessian, const_argument_ref x, size_type) const
 Hessian evaluation. More...
 
value_type applyPolynomial (const_vector_ref coeffs, const_argument_ref x) const
 Implement Horner's method. More...
 
- Protected Member Functions inherited from roboptim::GenericTwiceDifferentiableFunction< T >
 GenericTwiceDifferentiableFunction (size_type inputSize, size_type outputSize=1, std::string name=std::string())
 Concrete class constructor should call this constructor. More...
 
void setZero (hessian_ref symmetric) const
 Set a symmetric matrix to zero. More...
 

Additional Inherited Members

- Public Types inherited from roboptim::GenericTwiceDifferentiableFunction< T >
typedef std::pair< size_type, size_type > hessianSize_t
 Hessian size type represented as a pair of values. More...
 

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

◆ Polynomial()

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

◆ ~Polynomial()

template<typename T >
virtual roboptim::Polynomial< T >::~Polynomial ( )
inlinevirtual

Member Function Documentation

◆ applyPolynomial()

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.

◆ impl_compute()

template<typename T >
void roboptim::Polynomial< T >::impl_compute ( result_ref  result,
const_argument_ref  x 
) const
protected

◆ impl_gradient()

template<typename T >
void roboptim::Polynomial< T >::impl_gradient ( gradient_ref  gradient,
const_argument_ref  x,
size_type   
) const
protected

◆ impl_hessian()

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

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

◆ impl_jacobian()

template<typename T >
void roboptim::Polynomial< T >::impl_jacobian ( jacobian_ref  jacobian,
const_argument_ref  x 
) const
protected

◆ print()

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

◆ ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_()

template<typename T >
roboptim::Polynomial< T >::ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ ( GenericTwiceDifferentiableFunction< T >  )