roboptim::DerivableParametrizedFunction< F > Class Template Referenceabstract

Parametrized function with parameter derivative available. More...

#include <roboptim/core/derivable-parametrized-function.hh>

+ Inheritance diagram for roboptim::DerivableParametrizedFunction< F >:

Public Types

typedef F::value_type value_type
 Import value type. More...
 
typedef F::size_type size_type
 Import size type. More...
 
typedef F::vector_t vector_t
 Import vector type. More...
 
typedef F::matrix_t matrix_t
 Import matrix type. More...
 
typedef F result_t
 Import result type. More...
 
typedef F::argument_t argument_t
 Import argument type. More...
 
typedef F::vector_t gradient_t
 Import gradient type. More...
 
typedef F::matrix_t jacobian_t
 Import jacobian type. More...
 
typedef F::jacobianSize_t jacobianSize_t
 Import jacobian size type (pair of values). More...
 
- Public Types inherited from roboptim::ParametrizedFunction< F >
typedef F::value_type value_type
 Import value type. More...
 
typedef F::size_type size_type
 Import size type. More...
 
typedef F::vector_t vector_t
 Import vector type. More...
 
typedef F::matrix_t matrix_t
 Import matrix type. More...
 
typedef F result_t
 Import result type. More...
 
typedef F::argument_t argument_t
 Import argument type. More...
 

Public Member Functions

size_type gradientSize () const throw ()
 Return the gradient size. More...
 
jacobianSize_t jacobianSize () const throw ()
 Return the jacobian size as a pair. More...
 
bool isValidGradient (const gradient_t &gradient) const throw ()
 Check if the gradient is valid (check size). More...
 
bool isValidJacobian (const jacobian_t &jacobian) const throw ()
 Check if the jacobian is valid (check sizes). More...
 
jacobian_t jacobian (const argument_t &argument, size_type order=0) const throw ()
 Computes the jacobian. More...
 
void jacobian (jacobian_t &jacobian, const argument_t &argument, size_type order=0) const throw ()
 Computes the jacobian. More...
 
gradient_t gradient (const argument_t &argument, size_type functionId=0, size_type order=0) const throw ()
 Computes the gradient. More...
 
void gradient (gradient_t &gradient, const argument_t &argument, size_type functionId=0, size_type order=0) const throw ()
 Computes the gradient. More...
 
virtual std::ostream & print (std::ostream &o) const throw ()
 Display the function on the specified output stream. More...
 
- Public Member Functions inherited from roboptim::ParametrizedFunction< F >
result_t operator() (const argument_t &argument) const throw ()
 Evaluate the function at a specified point. More...
 
size_type inputSize () const throw ()
 Return the input size (i.e. argument's vector size). More...
 
size_type functionInputSize () const throw ()
 Return the function's input size (i.e. argument's vector size). More...
 
size_type functionOutputSize () const throw ()
 Return the function's output size (i.e. result's vector size). More...
 

Protected Member Functions

 DerivableParametrizedFunction (size_type inputSize, size_type functionInputSize, size_type functionOutputSize) throw ()
 Concrete class constructor should call this constructor. More...
 
virtual void impl_jacobian (jacobian_t &jacobian, const argument_t &arg) const throw ()
 Jacobian evaluation. More...
 
virtual void impl_gradient (gradient_t &gradient, const argument_t &argument, size_type functionId=0, size_type order=0) const =0 throw ()
 Gradient evaluation. More...
 
- Protected Member Functions inherited from roboptim::ParametrizedFunction< F >
 ParametrizedFunction (size_type inputSize, size_type functionInputSize, size_type functionOutputSize) throw ()
 Concrete class constructor should call this constructor. More...
 
virtual result_t impl_compute (const argument_t &argument) const =0 throw ()
 Function evaluation. More...
 

Detailed Description

template<typename F>
class roboptim::DerivableParametrizedFunction< F >

Parametrized function with parameter derivative available.

Depending on inner function type, this class allows computation of parameter derivative or combined parameter/function derivative.

Template Parameters
Finner function type.

Member Typedef Documentation

template<typename F >
typedef F::argument_t roboptim::DerivableParametrizedFunction< F >::argument_t

Import argument type.

template<typename F >
typedef F::vector_t roboptim::DerivableParametrizedFunction< F >::gradient_t

Import gradient type.

template<typename F >
typedef F::matrix_t roboptim::DerivableParametrizedFunction< F >::jacobian_t

Import jacobian type.

template<typename F >
typedef F::jacobianSize_t roboptim::DerivableParametrizedFunction< F >::jacobianSize_t

Import jacobian size type (pair of values).

template<typename F >
typedef F::matrix_t roboptim::DerivableParametrizedFunction< F >::matrix_t

Import matrix type.

template<typename F >
typedef F roboptim::DerivableParametrizedFunction< F >::result_t

Import result type.

template<typename F >
typedef F::size_type roboptim::DerivableParametrizedFunction< F >::size_type

Import size type.

template<typename F >
typedef F::value_type roboptim::DerivableParametrizedFunction< F >::value_type

Import value type.

template<typename F >
typedef F::vector_t roboptim::DerivableParametrizedFunction< F >::vector_t

Import vector type.

Constructor & Destructor Documentation

template<typename F >
roboptim::DerivableParametrizedFunction< F >::DerivableParametrizedFunction ( size_type  inputSize,
size_type  functionInputSize,
size_type  functionOutputSize 
)
throw (
)
inlineprotected

Concrete class constructor should call this constructor.

Parameters
inputSizeparameter size
functionInputSizeinner function argument size
functionOutputSizeinner function result size

Member Function Documentation

template<typename F >
gradient_t roboptim::DerivableParametrizedFunction< F >::gradient ( const argument_t argument,
size_type  functionId = 0,
size_type  order = 0 
) const
throw (
)
inline

Computes the gradient.

Parameters
argumentinner function argument value
functionIdfunction id in split representation
orderderivation order
Returns
gradient vector

References roboptim::DerivableParametrizedFunction< F >::gradientSize().

Referenced by roboptim::DerivableParametrizedFunction< F >::impl_jacobian(), and roboptim::DerivableParametrizedFunction< F >::isValidGradient().

template<typename F >
void roboptim::DerivableParametrizedFunction< F >::gradient ( gradient_t gradient,
const argument_t argument,
size_type  functionId = 0,
size_type  order = 0 
) const
throw (
)
inline

Computes the gradient.

Program will abort if the gradient size is wrong before or after the gradient computation.

Parameters
gradientgradient will be stored in this argument
argumentinner function point argument value
functionIdfunction id in split representation
orderderivation order
Returns
gradient vector

References roboptim::DerivableParametrizedFunction< F >::impl_gradient(), roboptim::ParametrizedFunction< F >::inputSize(), and roboptim::DerivableParametrizedFunction< F >::isValidGradient().

template<typename F >
size_type roboptim::DerivableParametrizedFunction< F >::gradientSize ( ) const
throw (
)
inline
template<typename F >
virtual void roboptim::DerivableParametrizedFunction< F >::impl_gradient ( gradient_t gradient,
const argument_t argument,
size_type  functionId = 0,
size_type  order = 0 
) const
throw (
)
protectedpure 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
argumentinner function point argument value
functionIdevaluated function id in the split representation
orderderivation order

Referenced by roboptim::DerivableParametrizedFunction< F >::gradient().

template<typename F >
virtual void roboptim::DerivableParametrizedFunction< F >::impl_jacobian ( jacobian_t jacobian,
const argument_t arg 
) const
throw (
)
inlineprotectedvirtual

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

References roboptim::ParametrizedFunction< F >::functionOutputSize(), roboptim::DerivableParametrizedFunction< F >::gradient(), roboptim::ParametrizedFunction< F >::inputSize(), and roboptim::DerivableParametrizedFunction< F >::jacobian().

Referenced by roboptim::DerivableParametrizedFunction< F >::jacobian().

template<typename F >
bool roboptim::DerivableParametrizedFunction< F >::isValidGradient ( const gradient_t gradient) const
throw (
)
inline

Check if the gradient is valid (check size).

Parameters
gradientchecked gradient
Returns
true if valid, false if not

References roboptim::DerivableParametrizedFunction< F >::gradient(), and roboptim::DerivableParametrizedFunction< F >::gradientSize().

Referenced by roboptim::DerivableParametrizedFunction< F >::gradient().

template<typename F >
bool roboptim::DerivableParametrizedFunction< F >::isValidJacobian ( const jacobian_t jacobian) const
throw (
)
inline

Check if the jacobian is valid (check sizes).

Parameters
jacobianchecked jacobian
Returns
true if valid, false if not

References roboptim::DerivableParametrizedFunction< F >::jacobian(), and roboptim::DerivableParametrizedFunction< F >::jacobianSize().

Referenced by roboptim::DerivableParametrizedFunction< F >::jacobian().

template<typename F >
jacobian_t roboptim::DerivableParametrizedFunction< F >::jacobian ( const argument_t argument,
size_type  order = 0 
) const
throw (
)
inline

Computes the jacobian.

Parameters
argumentpoint at which the jacobian will be computed
orderderivation order
Returns
jacobian matrix

References roboptim::DerivableParametrizedFunction< F >::jacobianSize().

Referenced by roboptim::DerivableParametrizedFunction< F >::impl_jacobian(), and roboptim::DerivableParametrizedFunction< F >::isValidJacobian().

template<typename F >
void roboptim::DerivableParametrizedFunction< F >::jacobian ( jacobian_t jacobian,
const argument_t argument,
size_type  order = 0 
) const
throw (
)
inline

Computes the jacobian.

Program will abort if the jacobian size is wrong before or after the jacobian computation.

Parameters
jacobianjacobian will be stored in this argument
orderderivation order
argumentinner function point argument value

References roboptim::DerivableParametrizedFunction< F >::impl_jacobian(), roboptim::ParametrizedFunction< F >::inputSize(), and roboptim::DerivableParametrizedFunction< F >::isValidJacobian().

template<typename F >
jacobianSize_t roboptim::DerivableParametrizedFunction< F >::jacobianSize ( ) const
throw (
)
inline
template<typename F >
virtual std::ostream& roboptim::DerivableParametrizedFunction< F >::print ( std::ostream &  o) const
throw (
)
inlinevirtual

Display the function on the specified output stream.

Parameters
ooutput stream used for display
Returns
output stream

Reimplemented from roboptim::ParametrizedFunction< F >.