#include <op.hh>
Inheritance diagram for RVL::OperatorEvaluation< Scalar >:
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 > |
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.
RVL::OperatorEvaluation< Scalar >::OperatorEvaluation | ( | const Operator< Scalar > & | _f, | |
const Vector< Scalar > & | x | |||
) |
RVL::OperatorEvaluation< Scalar >::OperatorEvaluation | ( | const OperatorEvaluation< Scalar > & | ev | ) |
virtual RVL::OperatorEvaluation< Scalar >::~OperatorEvaluation | ( | ) | [virtual] |
void RVL::OperatorEvaluation< Scalar >::applyDeriv | ( | const Vector< Scalar > & | yin, | |
Vector< Scalar > & | yout | |||
) | const [protected] |
contracted version of Operator::applyDeriv: access through DerivEvaluation
void RVL::OperatorEvaluation< Scalar >::applyAdjDeriv | ( | const Vector< Scalar > & | yin, | |
Vector< Scalar > & | yout | |||
) | const [protected] |
contracted version of Operator::applyAdjDeriv: access through DerivEvaluation
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
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
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().
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().
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().
void* RVL::OperatorEvaluation< Scalar >::operator new | ( | size_t | size | ) | [protected] |
Space<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDomain | ( | ) | const |
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().
Vector<Scalar>& RVL::OperatorEvaluation< Scalar >::getPoint | ( | ) |
Vector<Scalar> const& RVL::OperatorEvaluation< Scalar >::getPoint | ( | ) | const |
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.
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().
LinearOp<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDeriv | ( | ) | const |
SymmetricBilinearOp<Scalar> const& RVL::OperatorEvaluation< Scalar >::getDeriv2 | ( | ) | const |
ostream& RVL::OperatorEvaluation< Scalar >::write | ( | ostream & | str | ) | const [virtual] |
friend class OpComp< Scalar > [friend] |
friend class FcnlOpComp< Scalar > [friend] |
friend class DerivEvaluation< Scalar > [friend] |
friend class Deriv2Evaluation< Scalar > [friend] |
friend class PartialDerivEvaluation< Scalar > [friend] |
Reimplemented in RVL::OperatorProductDomainEvaluation< Scalar >.