roboptim::NTimesDerivableFunction< 2 > Class Template Reference

Explicit specialization for the stop case of NTimesDerivable class. More...

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

Inheritance diagram for roboptim::NTimesDerivableFunction< 2 >:
roboptim::GenericTwiceDifferentiableFunction< T > roboptim::GenericDifferentiableFunction< T > roboptim::GenericFunction< T >

List of all members.

Public Member Functions

virtual size_type derivabilityOrderMax () const
 Returns the maximum derivability order (relevant for N>2 only)
virtual ~NTimesDerivableFunction ()
size_type derivativeSize () const
 Return the size of the derivative vector.
bool isValidDerivative (const_gradient_ref derivative) const
 Check if a derivative is valid (check sizes).
result_t operator() (value_type argument) const
 Evaluate the function at a specified point.
void operator() (result_ref result, value_type argument) const
 Evaluate the function at a specified point.
gradient_t derivative (value_type argument, size_type order=1) const
 Compute the derivative of the function.
void derivative (gradient_ref derivative, value_type argument, size_type order=1) const
 Compute the derivative of the function.
virtual std::ostream & print (std::ostream &o) const
 Display the function on the specified output stream.

Static Public Attributes

static const size_type derivabilityOrder = 2
 Function derivability order.

Protected Member Functions

 NTimesDerivableFunction (size_type outputSize=1, std::string name=std::string())
 Concrete class constructor should call this constructor.
void impl_compute (result_ref result, const_argument_ref argument) const
 Function evaluation.
virtual void impl_compute (result_ref result, value_type t) const =0
 Function evaluation.
void impl_gradient (gradient_ref gradient, const_argument_ref argument, size_type functionId=0) const
 Gradient evaluation.
virtual void impl_derivative (gradient_ref derivative, value_type argument, size_type order=1) const =0
 Derivative evaluation.
void impl_hessian (hessian_ref hessian, const_argument_ref argument, size_type functionId=0) const
 Hessian evaluation.

Detailed Description

template<>
class roboptim::NTimesDerivableFunction< 2 >

Explicit specialization for the stop case of NTimesDerivable class.

This specialization defines the interface of a ``n times derivable function'' and implements generic methods required by upper classes using this class specific interface.


Constructor & Destructor Documentation

virtual roboptim::NTimesDerivableFunction< 2 >::~NTimesDerivableFunction ( ) [inline, virtual]
roboptim::NTimesDerivableFunction< 2 >::NTimesDerivableFunction ( size_type  outputSize = 1,
std::string  name = std::string () 
) [inline, protected]

Concrete class constructor should call this constructor.

Parameters:
outputSizeoutput size (result size)
namefunction's name

Member Function Documentation

virtual size_type roboptim::NTimesDerivableFunction< 2 >::derivabilityOrderMax ( ) const [inline, virtual]

Returns the maximum derivability order (relevant for N>2 only)

gradient_t roboptim::NTimesDerivableFunction< 2 >::derivative ( value_type  argument,
size_type  order = 1 
) const [inline]

Compute the derivative of the function.

Derivative is computed for a certain order, at a given point.

Parameters:
argumentpoint at which the derivative will be computed
orderderivative order (if 0 then function is evaluated)
Returns:
derivative vector

References roboptim::derivative().

void roboptim::NTimesDerivableFunction< 2 >::derivative ( gradient_ref  derivative,
value_type  argument,
size_type  order = 1 
) const [inline]

Compute the derivative of the function.

Derivative is computed for a certain order, at a given point.

Parameters:
derivativederivative will be stored in this vector
argumentpoint at which the derivative will be computed
orderderivative order (if 0 then function is evaluated)

References roboptim::NTimesDerivableFunction< DerivabilityOrder >::derivabilityOrderMax().

Return the size of the derivative vector.

Returns:
derivative vector size
void roboptim::NTimesDerivableFunction< 2 >::impl_compute ( result_ref  result,
const_argument_ref  argument 
) const [inline, protected, virtual]

Function evaluation.

Implement generic function evaluation, as required by Function, using this class evaluation method (using a double instead of a vector).

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

virtual void roboptim::NTimesDerivableFunction< 2 >::impl_compute ( result_ref  result,
value_type  t 
) const [protected, pure virtual]

Function evaluation.

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

Warning:
Do not call this function directly, call #operator()(double) const instead.
Parameters:
resultresult will be stored in this vector
tpoint at which the function will be evaluated
virtual void roboptim::NTimesDerivableFunction< 2 >::impl_derivative ( gradient_ref  derivative,
value_type  argument,
size_type  order = 1 
) const [protected, pure virtual]

Derivative evaluation.

Compute the derivative, has to be implemented in concrete classes.

Warning:
Do not call this function directly, call derivative instead.
Parameters:
derivativederivative will be store in this argument
argumentpoint where the gradient will be computed
orderderivative order (if 0 evaluates the function)
void roboptim::NTimesDerivableFunction< 2 >::impl_gradient ( gradient_ref  gradient,
const_argument_ref  argument,
size_type  functionId = 0 
) const [inline, protected, virtual]

Gradient evaluation.

Implement the gradient computation, as required by DerivableFunction. 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 or derivative instead.
Parameters:
gradientgradient will be store in this argument
argumentpoint where the gradient will be computed
functionIdevaluated function id in the split representation

ROBOPTIM_DO_NOT_CHECK_ALLOCATION

Implements roboptim::GenericDifferentiableFunction< T >.

References roboptim::derivative().

void roboptim::NTimesDerivableFunction< 2 >::impl_hessian ( hessian_ref  hessian,
const_argument_ref  argument,
size_type  functionId = 0 
) const [inline, protected, virtual]

Hessian evaluation.

Implement the hessian computation, as required by the TwiceDerivableFunction class using the derivative method. 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

ROBOPTIM_DO_NOT_CHECK_ALLOCATION

Implements roboptim::GenericTwiceDifferentiableFunction< T >.

References roboptim::derivative().

bool roboptim::NTimesDerivableFunction< 2 >::isValidDerivative ( const_gradient_ref  derivative) const [inline]

Check if a derivative is valid (check sizes).

Parameters:
derivativederivative vector to be checked
Returns:
true if valid, false if not
result_t roboptim::NTimesDerivableFunction< 2 >::operator() ( value_type  argument) const [inline]

Evaluate the function at a specified point.

The program will abort if the argument does not have the expected size.

Parameters:
argumentpoint at which the function will be evaluated
Returns:
computed result
void roboptim::NTimesDerivableFunction< 2 >::operator() ( result_ref  result,
value_type  argument 
) const [inline]

Evaluate the function at a specified point.

The program will abort if the argument does not have the expected size.

Parameters:
resultresult will be stored in this vector
argumentpoint at which the function will be evaluated
Returns:
computed result
virtual std::ostream& roboptim::NTimesDerivableFunction< 2 >::print ( std::ostream &  o) const [inline, 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::NTimesDerivableFunction< DerivabilityOrder >::derivabilityOrderMax().


Member Data Documentation

Function derivability order.

One static const variable per class in inheritance structure.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines