RVL::Functional< Scalar > Class Template Reference

Interface for scalar-valued vector functions. More...

#include <functional.hh>

Inheritance diagram for RVL::Functional< Scalar >:

RVL::Writeable RVL::EuclideanForm< Scalar > RVL::FcnlOpComp< Scalar > RVL::FunctionalProductDomain< Scalar > RVL::LeastSquaresFcnlGN< Scalar > RVL::LinCombFunctional< Scalar > RVL::NullFunctional< Scalar > RVL::QuadraticForm< Scalar > RVL::RestrictFcnl< Scalar > RVL::ShiftedQuadraticForm< Scalar > RVL::StdFOFunctional< Scalar, DataType > RVL::StdLeastSquaresFcnlGN< Scalar > List of all members.

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
 $val = F(x)$
virtual void applyGradient (const Vector< Scalar > &x, Vector< Scalar > &g) const =0
 $g = grad F(x)$
virtual void applyHessian (const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy) const =0
 $dy = Hess F(x) dx$
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 >

Detailed Description

template<class Scalar>
class RVL::Functional< Scalar >

Interface for scalar-valued vector functions.

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.


Constructor & Destructor Documentation

template<class Scalar>
RVL::Functional< Scalar >::Functional (  ) 

Definition at line 188 of file functional.hh.

template<class Scalar>
RVL::Functional< Scalar >::Functional ( const Functional< Scalar > &   ) 

Definition at line 190 of file functional.hh.

template<class Scalar>
virtual RVL::Functional< Scalar >::~Functional (  )  [virtual]

Definition at line 192 of file functional.hh.


Member Function Documentation

template<class Scalar>
virtual void RVL::Functional< Scalar >::apply ( const Vector< Scalar > &  x,
Scalar &  val 
) const [protected, pure virtual]

$val = F(x)$

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

template<class Scalar>
virtual void RVL::Functional< Scalar >::applyGradient ( const Vector< Scalar > &  x,
Vector< Scalar > &  g 
) const [protected, pure virtual]

$g = grad F(x)$

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

template<class Scalar>
virtual void RVL::Functional< Scalar >::applyHessian ( const Vector< Scalar > &  x,
const Vector< Scalar > &  dx,
Vector< Scalar > &  dy 
) const [protected, pure virtual]

$dy = Hess F(x) dx$

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

template<class Scalar>
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().

template<class Scalar>
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().

template<class Scalar>
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().

template<class Scalar>
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.

template<class Scalar>
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().

template<class Scalar>
void RVL::Functional< Scalar >::export_clone ( Functional< Scalar > const &  fref,
Functional< Scalar > **  f 
) const [protected]

Definition at line 169 of file functional.hh.

References RVL::Functional< Scalar >::clone().

template<class Scalar>
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().

template<class Scalar>
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().


Friends And Related Function Documentation

template<class Scalar>
friend class FunctionalEvaluation< Scalar > [friend]

Reimplemented in RVL::FunctionalProductDomain< Scalar >.

Definition at line 101 of file functional.hh.

template<class Scalar>
friend class FcnlOpComp< Scalar > [friend]

Definition at line 102 of file functional.hh.

template<class Scalar>
friend class LinCombFunctional< Scalar > [friend]

Definition at line 103 of file functional.hh.


The documentation for this class was generated from the following file:
Generated on 5 Jan 2017 for RVL by  doxygen 1.4.7