RVL::OperatorEvaluation< Scalar > Class Template Reference

OperatorEvaluation pairs a reference to a Vector with an independent, dynamically-allocated instance of an Operator. More...

#include <op.hh>

Inheritance diagram for RVL::OperatorEvaluation< Scalar >:

RVL::Writeable RVL::OperatorProductDomainEvaluation< Scalar > List of all members.

Public Member Functions

 OperatorEvaluation (const Operator< Scalar > &_f, const Vector< Scalar > &x)
 OperatorEvaluation (const OperatorEvaluation< Scalar > &ev)
virtual ~OperatorEvaluation ()
Space< Scalar > const & getDomain () const
 access to domain, implemented by delegation to Operator reference data member
Space< Scalar > const & getRange () const
 access to range, implemented by delegation to Operator reference data member
Vector< Scalar > & getPoint ()
 reference to evaluation point - can be assigned to
Vector< Scalar > const & getPoint () const
Operator< Scalar > const & getOp () const
 reference to evaluated operator copy - cannot be assigned.
Vector< Scalar > const & getValue () const
 const reference to value (internal datum).
LinearOp< Scalar > const & getDeriv () const
 const reference to derivative (internal datum)
SymmetricBilinearOp< Scalar
> const & 
getDeriv2 () const
 const reference to 2nd derivative (internal datum)
ostream & write (ostream &str) const

Protected Member Functions

void applyDeriv (const Vector< Scalar > &yin, Vector< Scalar > &yout) const
 contracted version of Operator::applyDeriv: access through DerivEvaluation
void applyAdjDeriv (const Vector< Scalar > &yin, Vector< Scalar > &yout) const
 contracted version of Operator::applyAdjDeriv: access through DerivEvaluation
void applyDeriv2 (const Vector< Scalar > &x0, const Vector< Scalar > &x1, Vector< Scalar > &y) const
 contracted version of Operator::applyDeriv2: access through Deriv2Evaluation
void applyAdjDeriv2 (const Vector< Scalar > &x0, const Vector< Scalar > &y, Vector< Scalar > &x1) const
 contracted version of Operator::applyAdjDeriv: access through DerivEvaluation
const ProductSpace< Scalar > & getProductDomain () const
 The next three functions throw exceptions if the referenced operator is not an OpProdDom.
void applyPartialDeriv (int i, const Vector< Scalar > &yin, Vector< Scalar > &yout) const
void applyAdjPartialDeriv (int i, const Vector< Scalar > &yin, Vector< Scalar > &yout) const
void * operator new (size_t size)
 operator new - not available to general public, but available to children and friends

Friends

class OpComp< Scalar >
class FcnlOpComp< Scalar >
class DerivEvaluation< Scalar >
class Deriv2Evaluation< Scalar >
class PartialDerivEvaluation< Scalar >

Detailed Description

template<class Scalar>
class RVL::OperatorEvaluation< Scalar >

OperatorEvaluation pairs a reference to a Vector with an independent, dynamically-allocated instance of an Operator.

Use of this class is extremely simple: to create the evaluation of an Operator f at a Vector x, use the main constructor:

OperatorEvaluation<Scalar> fx(f,x);

The semantics of the fx are those of f(x) for variable x. That is, fx and x are dynamically linked, and the results stored in fx change when the internal state of x changes. The mechanism by which this occurs is explained below. Thus after execution of, say,

x.linComb(a,y)

(which overwrites x with x+ay), fx refers to the evaluation of f at the updated value of x, not at the value held by x when fx was created. This dynamic linkage allows a very natural assignment syntax for algorithm expression: create an evaluation (fx, say) and use it whereever f(x) would occur.

The main role of OperatorEvaluation is to return for external use the values of the Operator and its derivatives. These values are returned by const reference to internal data owned by the OperatorEvaluation. The value of the Operator instance, evaluated at the Vector evaluation point, is the (const) return value of OperatorEvaluation::getValue. The derivative reference is returned by OperatorEvaluation::getDeriv (as a LinearOp instance).

Thus submit the the value of f at x to another function g by

g(fx.getValue());

(provided that the argument of g is a const Vector reference!).

Apply the derivative of f at x to the Vector p using LinearOp::applyOp, storing the result in Vector q:

fx.getDeriv().applyOp(p,q)

The Evaluation object implements its methods by (possibly) altering the state of the Operator instance which it owns, the way in which this is done being regulated by the referenced Vector (evaluation point). The role of the Vector reference is exactly parallel to the role of the Space reference held by Vector, which regulates the way in which Vector changes the internal state of its DataContainer member

There is a key difference: while Space is an immutable object (a factory), offering no public methods which alter its state, Vector is mutable. Therefore, in order to reduce the likelihood of the Evaluation object attaining an incoherent internal state, Vector is provided with a version index and a version increment method. The only methods altering the internal state of a Vector are fully implemented RVL class methods, such as the access methods of Evaluation types (for example OperatorEvaluation::getValue), the nonconst Vector::eval methods taking FunctionObject arguments, etc. All of these manage the version number. Thus the OperatorEvaluation instance can reliably know that its evaluation point Vector has (or has not) been altered by comparing its internal copy of the version index with that returned by Vector::getVersion. A discrepancy between these two copies of the version index causes the Operator * data member to be deleted and re-cloned, in effect forcing an update of all results and intermediate data.

Definition at line 1608 of file op.hh.


Constructor & Destructor Documentation

template<class Scalar>
RVL::OperatorEvaluation< Scalar >::OperatorEvaluation ( const Operator< Scalar > &  _f,
const Vector< Scalar > &  x 
)

Definition at line 1844 of file op.hh.

References RVL::Vector< Scalar >::getSpace().

template<class Scalar>
RVL::OperatorEvaluation< Scalar >::OperatorEvaluation ( const OperatorEvaluation< Scalar > &  ev  ) 

Definition at line 1875 of file op.hh.

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

Definition at line 1881 of file op.hh.


Member Function Documentation

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyDeriv ( const Vector< Scalar > &  yin,
Vector< Scalar > &  yout 
) const [protected]

contracted version of Operator::applyDeriv: access through DerivEvaluation

Definition at line 1647 of file op.hh.

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyAdjDeriv ( const Vector< Scalar > &  yin,
Vector< Scalar > &  yout 
) const [protected]

contracted version of Operator::applyAdjDeriv: access through DerivEvaluation

Definition at line 1662 of file op.hh.

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyDeriv2 ( const Vector< Scalar > &  x0,
const Vector< Scalar > &  x1,
Vector< Scalar > &  y 
) const [protected]

contracted version of Operator::applyDeriv2: access through Deriv2Evaluation

Definition at line 1677 of file op.hh.

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyAdjDeriv2 ( const Vector< Scalar > &  x0,
const Vector< Scalar > &  y,
Vector< Scalar > &  x1 
) const [protected]

contracted version of Operator::applyAdjDeriv: access through DerivEvaluation

Definition at line 1693 of file op.hh.

template<class Scalar>
const ProductSpace<Scalar>& RVL::OperatorEvaluation< Scalar >::getProductDomain (  )  const [protected]

The next three functions throw exceptions if the referenced operator is not an OpProdDom.

They are accessed only by PartialDerivEval, via OpProdDomEval, which provides compile time type-safety in addition to the run-time type checking built into these methods.

Definition at line 1713 of file op.hh.

References RVL::OperatorProductDomain< Scalar >::getProductDomain().

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyPartialDeriv ( int  i,
const Vector< Scalar > &  yin,
Vector< Scalar > &  yout 
) const [protected]

Definition at line 1734 of file op.hh.

References RVL::OperatorProductDomain< Scalar >::applyPartialDeriv().

template<class Scalar>
void RVL::OperatorEvaluation< Scalar >::applyAdjPartialDeriv ( int  i,
const Vector< Scalar > &  yin,
Vector< Scalar > &  yout 
) const [protected]

Definition at line 1759 of file op.hh.

References RVL::OperatorProductDomain< Scalar >::applyAdjPartialDeriv().

template<class Scalar>
void* RVL::OperatorEvaluation< Scalar >::operator new ( size_t  size  )  [protected]

operator new - not available to general public, but available to children and friends

Version 1.0: user control

Definition at line 1835 of file op.hh.

template<class Scalar>
Space<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDomain (  )  const

access to domain, implemented by delegation to Operator reference data member

Definition at line 1896 of file op.hh.

template<class Scalar>
Space<Scalar> const& RVL::OperatorEvaluation< Scalar >::getRange (  )  const

access to range, implemented by delegation to Operator reference data member

Definition at line 1901 of file op.hh.

Referenced by RVL::FcnlOpComp< Scalar >::applyHessian().

template<class Scalar>
Vector<Scalar>& RVL::OperatorEvaluation< Scalar >::getPoint (  ) 

reference to evaluation point - can be assigned to

Definition at line 1904 of file op.hh.

template<class Scalar>
Vector<Scalar> const& RVL::OperatorEvaluation< Scalar >::getPoint (  )  const

Definition at line 1905 of file op.hh.

template<class Scalar>
Operator<Scalar> const& RVL::OperatorEvaluation< Scalar >::getOp (  )  const

reference to evaluated operator copy - cannot be assigned.

Supplied to enable access to special attributes of child operator classes, in the instance currently in use by the Evaluation object. Will require dynamic casting to acquire correct interface to access these additional attributes, which must themselves be const.

Definition at line 1915 of file op.hh.

template<class Scalar>
Vector<Scalar> const& RVL::OperatorEvaluation< Scalar >::getValue (  )  const

const reference to value (internal datum).

Definition at line 1919 of file op.hh.

Referenced by RVL::OpComp< Scalar >::applyDeriv(), and RVL::DerivTest().

template<class Scalar>
LinearOp<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDeriv (  )  const

const reference to derivative (internal datum)

Definition at line 1935 of file op.hh.

template<class Scalar>
SymmetricBilinearOp<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDeriv2 (  )  const

const reference to 2nd derivative (internal datum)

Definition at line 1937 of file op.hh.

template<class Scalar>
ostream& RVL::OperatorEvaluation< Scalar >::write ( ostream &  str  )  const [virtual]

Implements RVL::Writeable.

Reimplemented in RVL::OperatorProductDomainEvaluation< Scalar >.

Definition at line 1939 of file op.hh.


Friends And Related Function Documentation

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

Definition at line 1610 of file op.hh.

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

Definition at line 1611 of file op.hh.

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

Definition at line 1612 of file op.hh.

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

Definition at line 1613 of file op.hh.

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

Reimplemented in RVL::OperatorProductDomainEvaluation< Scalar >.

Definition at line 1614 of file op.hh.


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