#include <functional.hh>
Inheritance diagram for RVL::Functional< Scalar >:
Public Member Functions | |
Functional () | |
Functional (const Functional< Scalar > &) | |
virtual | ~Functional () |
virtual const Space< Scalar > & | getDomain () const =0 |
virtual Scalar | getMaxStep (const Vector< Scalar > &x, const Vector< Scalar > &dx) const |
getMaxStep() computes the largest value of $a$ such that $x+a*dir$ lies in the domain of definition of the functional. | |
Protected Member Functions | |
virtual void | apply (const Vector< Scalar > &x, Scalar &val) const =0 |
| |
virtual void | applyGradient (const Vector< Scalar > &x, Vector< Scalar > &g) const =0 |
| |
virtual void | applyHessian (const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy) const =0 |
| |
void | export_apply (Functional< Scalar > const &f, const Vector< Scalar > &x, Scalar &val) const |
The export-apply methods make the protected apply methods of any Functional subclass instance available to other Functional subclass instances. | |
void | export_applyGradient (Functional< Scalar > const &f, const Vector< Scalar > &x, Vector< Scalar > &g) const |
void | export_applyHessian (Functional< Scalar > const &f, const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy) const |
void * | operator new (size_t size) |
operator new - not available to general public, but available to children who will use it to define a clone method, for example | |
virtual Functional< Scalar > * | clone () const =0 |
virtual copy constructor: make a complete new copy including internal workspace. | |
void | export_clone (Functional< Scalar > const &fref, Functional< Scalar > **f) const |
Friends | |
class | FunctionalEvaluation< Scalar > |
class | FcnlOpComp< Scalar > |
class | LinCombFunctional< Scalar > |
Provides first and second derivatives (gradient and Hessian) - higher derivatives may be added later.
This interface has virtually no public members, other than those which idenify its domain. The action happens in the protected member functions. These get used by the Evaluation classes to initialize the various values (of the function itself, its derivatives, etc.) and any intermediate data on which these might depend. The clone method is also protected, and is used by the Evaluation constructor to create a completely independent copy.
So concrete instances of this type should be written in "use-once" style: any and all internal data should be written once and treated as read-only thereafter. The only access to those functions which might change its internal state (all protected) is through Evaluation, and therefore tied to a particular evaluation point.
Since Evaluation objects clone these, efficient implementations will typically allocate as much internal storage as possiblE dynamically, and only at the point of use. For example an array foo of length n used in the apply method would be initialized in the constructor as a pointer to NULL then reinitialized at the point of use: const void apply(...) { ... if (!foo) foo = new Scalar[n]; ... }
A unit test for validity of the gradient computation is supplied as part of RVL, in the form of a standalone function (GradientTest). It is HIGHLY RECOMMENDED that every concrete Functional implementation be subjected to this test.
Finally, this version of Function presumes that the values produced are of the same type as the input, that is, the template parameter Scalar describes the scalar field of both the input vector and the output value. The class is not a suitable abstraction for real valued functions of complex vector variables, for instance.
Definition at line 99 of file functional.hh.
RVL::Functional< Scalar >::Functional | ( | ) |
Definition at line 188 of file functional.hh.
RVL::Functional< Scalar >::Functional | ( | const Functional< Scalar > & | ) |
Definition at line 190 of file functional.hh.
virtual RVL::Functional< Scalar >::~Functional | ( | ) | [virtual] |
Definition at line 192 of file functional.hh.
virtual void RVL::Functional< Scalar >::apply | ( | const Vector< Scalar > & | x, | |
Scalar & | val | |||
) | const [protected, pure virtual] |
Implemented in RVL::LinCombFunctional< Scalar >, RVL::StdFOFunctional< Scalar, DataType >, RVL::NullFunctional< Scalar >, RVL::FcnlOpComp< Scalar >, RVL::RestrictFcnl< Scalar >, RVL::EuclideanForm< Scalar >, RVL::QuadraticForm< Scalar >, RVL::ShiftedQuadraticForm< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Referenced by RVL::Functional< Scalar >::export_apply().
virtual void RVL::Functional< Scalar >::applyGradient | ( | const Vector< Scalar > & | x, | |
Vector< Scalar > & | g | |||
) | const [protected, pure virtual] |
Implemented in RVL::FunctionalProductDomain< Scalar >, RVL::LinCombFunctional< Scalar >, RVL::StdFOFunctional< Scalar, DataType >, RVL::NullFunctional< Scalar >, RVL::FcnlOpComp< Scalar >, RVL::RestrictFcnl< Scalar >, RVL::EuclideanForm< Scalar >, RVL::QuadraticForm< Scalar >, RVL::ShiftedQuadraticForm< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Referenced by RVL::Functional< Scalar >::export_applyGradient().
virtual void RVL::Functional< Scalar >::applyHessian | ( | const Vector< Scalar > & | x, | |
const Vector< Scalar > & | dx, | |||
Vector< Scalar > & | dy | |||
) | const [protected, pure virtual] |
Implemented in RVL::FunctionalProductDomain< Scalar >, RVL::LinCombFunctional< Scalar >, RVL::StdFOFunctional< Scalar, DataType >, RVL::NullFunctional< Scalar >, RVL::FcnlOpComp< Scalar >, RVL::RestrictFcnl< Scalar >, RVL::EuclideanForm< Scalar >, RVL::QuadraticForm< Scalar >, RVL::ShiftedQuadraticForm< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Referenced by RVL::Functional< Scalar >::export_applyHessian().
void RVL::Functional< Scalar >::export_apply | ( | Functional< Scalar > const & | f, | |
const Vector< Scalar > & | x, | |||
Scalar & | val | |||
) | const [protected] |
The export-apply methods make the protected apply methods of any Functional subclass instance available to other Functional subclass instances.
Definition at line 129 of file functional.hh.
References RVL::Functional< Scalar >::apply().
Referenced by RVL::StdLeastSquaresFcnlGN< Scalar >::apply(), RVL::LeastSquaresFcnlGN< Scalar >::apply(), RVL::RestrictFcnl< Scalar >::apply(), and RVL::LinCombFunctional< Scalar >::apply().
void RVL::Functional< Scalar >::export_applyGradient | ( | Functional< Scalar > const & | f, | |
const Vector< Scalar > & | x, | |||
Vector< Scalar > & | g | |||
) | const [protected] |
Definition at line 135 of file functional.hh.
References RVL::Functional< Scalar >::applyGradient().
Referenced by RVL::StdLeastSquaresFcnlGN< Scalar >::applyGradient(), RVL::LeastSquaresFcnlGN< Scalar >::applyGradient(), and RVL::LinCombFunctional< Scalar >::applyGradient().
void RVL::Functional< Scalar >::export_applyHessian | ( | Functional< Scalar > const & | f, | |
const Vector< Scalar > & | x, | |||
const Vector< Scalar > & | dx, | |||
Vector< Scalar > & | dy | |||
) | const [protected] |
Definition at line 141 of file functional.hh.
References RVL::Functional< Scalar >::applyHessian().
Referenced by RVL::StdLeastSquaresFcnlGN< Scalar >::applyHessian(), RVL::LeastSquaresFcnlGN< Scalar >::applyHessian(), and RVL::LinCombFunctional< Scalar >::applyHessian().
void* RVL::Functional< Scalar >::operator new | ( | size_t | size | ) | [protected] |
operator new - not available to general public, but available to children who will use it to define a clone method, for example
Version 1.0: user control
Definition at line 155 of file functional.hh.
virtual Functional<Scalar>* RVL::Functional< Scalar >::clone | ( | ) | const [protected, pure virtual] |
virtual copy constructor: make a complete new copy including internal workspace.
Usually implemented with operator new and copy constructor of concrete child class.
Implemented in RVL::FunctionalProductDomain< Scalar >, RVL::LinCombFunctional< Scalar >, RVL::StdFOFunctional< Scalar, DataType >, RVL::NullFunctional< Scalar >, RVL::FcnlOpComp< Scalar >, RVL::RestrictFcnl< Scalar >, RVL::EuclideanForm< Scalar >, RVL::QuadraticForm< Scalar >, RVL::ShiftedQuadraticForm< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Referenced by RVL::Functional< Scalar >::export_clone(), and RVL::LinCombFunctional< Scalar >::LinCombFunctional().
void RVL::Functional< Scalar >::export_clone | ( | Functional< Scalar > const & | fref, | |
Functional< Scalar > ** | f | |||
) | const [protected] |
virtual const Space<Scalar>& RVL::Functional< Scalar >::getDomain | ( | ) | const [pure virtual] |
Implemented in RVL::FunctionalProductDomain< Scalar >, RVL::LinCombFunctional< Scalar >, RVL::StdFOFunctional< Scalar, DataType >, RVL::NullFunctional< Scalar >, RVL::FcnlOpComp< Scalar >, RVL::EuclideanForm< Scalar >, RVL::QuadraticForm< Scalar >, RVL::ShiftedQuadraticForm< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Referenced by RVL::GradientTest(), RVL::LinCombFunctional< Scalar >::LinCombFunctional(), and RVL::Scan().
virtual Scalar RVL::Functional< Scalar >::getMaxStep | ( | const Vector< Scalar > & | x, | |
const Vector< Scalar > & | dx | |||
) | const [virtual] |
getMaxStep() computes the largest value of $a$ such that $x+a*dir$ lies in the domain of definition of the functional.
By default (i.e. unless this virtual function is implemented in a derived class), the domain is assumed to be the whole space, and MaxStep return the largest floating point number. This method is used in some of the optimization algorithms and provides a partial solution to the problem that many functionals are not defined on an entire vector space, but rather only on a subset. It can be overridden in derived classes
Reimplemented in RVL::FcnlOpComp< Scalar >, RVL::RestrictFcnl< Scalar >, RVL::LeastSquaresFcnlGN< Scalar >, and RVL::StdLeastSquaresFcnlGN< Scalar >.
Definition at line 207 of file functional.hh.
Referenced by RVL::GradientTest(), and RVL::Scan().
friend class FunctionalEvaluation< Scalar > [friend] |
Reimplemented in RVL::FunctionalProductDomain< Scalar >.
Definition at line 101 of file functional.hh.
friend class FcnlOpComp< Scalar > [friend] |
Definition at line 102 of file functional.hh.
friend class LinCombFunctional< Scalar > [friend] |
Definition at line 103 of file functional.hh.