roboptim::CachedFunction< T > Class Template Reference
Function filters

Store previous function computation. More...

`#include <roboptim/core/filter/cached-function.hh>`

Inheritance diagram for roboptim::CachedFunction< T >:

## Public Types

typedef DifferentiableFunction::value_type | value_type
| Import value type. More...
typedef DifferentiableFunction::size_type | size_type
| Import size type. More...
typedef DifferentiableFunction::vector_t | vector_t
| Import vector type. More...
typedef DifferentiableFunction::result_t | result_t
| Import result type. More...
typedef DifferentiableFunction::argument_t | argument_t
| Import argument type. More...
typedef DifferentiableFunction::gradient_t | gradient_t
| Import gradient type. More...
typedef TwiceDifferentiableFunction::hessian_t | hessian_t
| Import hessian type. More...
typedef DifferentiableFunction::jacobian_t | jacobian_t
| Import jacobian type. More...
typedef DifferentiableFunction::interval_t | interval_t
| Import interval type. More...
typedef std::map< Function::vector_t, Function::vector_t, detail::ltvector > | functionCache_t
typedef std::map< Function::vector_t, hessian_t, detail::ltvector > | hessianCache_t

## Public Member Functions

| CachedFunction (boost::shared_ptr< const T > fct) throw ()
| ~CachedFunction () throw ()
void | reset () throw ()

## Protected Member Functions

virtual void | impl_compute (result_t &result, const argument_t &argument) const throw ()
virtual void | impl_gradient (gradient_t &gradient, const argument_t &argument, size_type functionId=0) const throw ()
virtual void | impl_hessian (hessian_t &hessian, const argument_t &argument, size_type functionId=0) const throw ()
virtual void | impl_derivative (gradient_t &derivative, double argument, size_type order=1) const throw ()
template<>
void | impl_gradient (gradient_t &, const argument_t &, size_type) const throw()
template<>
void | impl_hessian (hessian_t &, const argument_t &, size_type) const throw()
template<>
void | impl_hessian (hessian_t &, const argument_t &, size_type) const throw()
template<>
void | impl_derivative (gradient_t &, double, size_type) const throw()
template<>
void | impl_derivative (gradient_t &, double, size_type) const throw()
template<>
void | impl_derivative (gradient_t &, double, size_type) const throw()

## Detailed Description

### template<typename T>
class roboptim::CachedFunction< T >

Store previous function computation.

When an expensive function is called several times at the same point (exactly!), the cached function prevents useless computation by caching the function result.

This filter is experimental in this release.

## Member Typedef Documentation

template<typename T >

typedef DifferentiableFunction::argument_t roboptim::CachedFunction< T >::argument_t

Import argument type.

template<typename T >

typedef std::map<Function::vector_t, Function::vector_t, detail::ltvector> roboptim::CachedFunction< T >::functionCache_t

template<typename T >

typedef DifferentiableFunction::gradient_t roboptim::CachedFunction< T >::gradient_t

Import gradient type.

template<typename T >

typedef TwiceDifferentiableFunction::hessian_t roboptim::CachedFunction< T >::hessian_t

Import hessian type.

template<typename T >

typedef std::map<Function::vector_t, hessian_t, detail::ltvector> roboptim::CachedFunction< T >::hessianCache_t

template<typename T >

typedef DifferentiableFunction::interval_t roboptim::CachedFunction< T >::interval_t

Import interval type.

template<typename T >

typedef DifferentiableFunction::jacobian_t roboptim::CachedFunction< T >::jacobian_t

Import jacobian type.

template<typename T >

typedef DifferentiableFunction::result_t roboptim::CachedFunction< T >::result_t

Import result type.

template<typename T >

typedef DifferentiableFunction::size_type roboptim::CachedFunction< T >::size_type

Import size type.

template<typename T >

typedef DifferentiableFunction::value_type roboptim::CachedFunction< T >::value_type

Import value type.

template<typename T >

typedef DifferentiableFunction::vector_t roboptim::CachedFunction< T >::vector_t

Import vector type.

## Constructor & Destructor Documentation

template<typename T >

roboptim::CachedFunction< T >::CachedFunction | ( | boost::shared_ptr< const T > | fct | ) |
throw | ( |
| ) |  |

explicit

template<typename T >

roboptim::CachedFunction< T >::~CachedFunction | ( |  | ) |
throw | ( |
| ) |  |

## Member Function Documentation

template<typename T >

void roboptim::CachedFunction< T >::impl_compute | ( | result_t & | result,
|  | const argument_t & | argument
| ) |  | const
throw | ( |
| ) |  |

protected virtual

template<typename T >

void roboptim::CachedFunction< T >::impl_derivative | ( | gradient_t & | derivative,
|  | double | argument,
|  | size_type | order = `1`
| ) |  | const
throw | ( |
| ) |  |

protected virtual

template<>

void roboptim::CachedFunction< Function >::impl_derivative | ( | gradient_t & | ,
|  | double | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<>

void roboptim::CachedFunction< DifferentiableFunction >::impl_derivative | ( | gradient_t & | ,
|  | double | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<>

void roboptim::CachedFunction< TwiceDifferentiableFunction >::impl_derivative | ( | gradient_t & | ,
|  | double | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<>

void roboptim::CachedFunction< Function >::impl_gradient | ( | gradient_t & | ,
|  | const argument_t & | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<typename T >

void roboptim::CachedFunction< T >::impl_gradient | ( | gradient_t & | gradient,
|  | const argument_t & | argument,
|  | size_type | functionId = `0`
| ) |  | const
throw | ( |
| ) |  |

protected virtual

template<typename T >

void roboptim::CachedFunction< T >::impl_hessian | ( | hessian_t & | hessian,
|  | const argument_t & | argument,
|  | size_type | functionId = `0`
| ) |  | const
throw | ( |
| ) |  |

protected virtual

template<>

void roboptim::CachedFunction< Function >::impl_hessian | ( | hessian_t & | ,
|  | const argument_t & | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<>

void roboptim::CachedFunction< DifferentiableFunction >::impl_hessian | ( | hessian_t & | ,
|  | const argument_t & | ,
|  | size_type |
| ) |  | const
throw | ( |
| ) |  |

protected

template<typename T >

void roboptim::CachedFunction< T >::reset | ( |  | ) |
throw | ( |
| ) |  |