RVL::Operator< Scalar > Class Template Reference

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

#include <op.hh>

Inheritance diagram for RVL::Operator< Scalar >:

RVL::Writeable RVL::ANLOperator< Scalar > RVL::BlockOperator< Scalar > RVL::DiagOp< Scalar > RVL::IdentityOp< Scalar > RVL::InjectOp< Scalar > RVL::LinCombOperator< Scalar > RVL::LinearOp< Scalar > RVL::LNLOperator< Scalar > RVL::OpComp< Scalar > RVL::OperatorProductDomain< Scalar > RVL::OperatorWithInvertibleDeriv< Scalar > RVL::OpFO< Scalar > RVL::ResidualOperator< Scalar > RVL::RestrictOp< Scalar > RVL::ShiftOperator< Scalar > List of all members.

Public Member Functions

 Operator ()
 Operator (const Operator< Scalar > &)
virtual ~Operator ()
virtual const Space< Scalar > & getDomain () const =0
 access to domain, range
virtual const Space< Scalar > & getRange () const =0
virtual ScalarFieldTraits<
Scalar >::AbsType 
getMaxStep (const Vector< Scalar > &, const Vector< Scalar > &) const
 can be overridden to express distance to boundary of domain for operators whose domains are not the whole space.

Static Public Member Functions

static std::shared_ptr< Operator<
Scalar > > 
clonePtr (Operator< Scalar > const &op)
 safe dynamic copy construction

Protected Member Functions

virtual void apply (const Vector< Scalar > &x, Vector< Scalar > &y) const =0
 $y = F(x)$
virtual void applyDeriv (const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy) const =0
 $dy = DF(x)dx$
virtual void applyAdjDeriv (const Vector< Scalar > &x, const Vector< Scalar > &dy, Vector< Scalar > &dx) const =0
 $dx = DF(x)^*dy$
virtual void applyDeriv2 (const Vector< Scalar > &, const Vector< Scalar > &, const Vector< Scalar > &, Vector< Scalar > &) const
virtual void applyAdjDeriv2 (const Vector< Scalar > &, const Vector< Scalar > &, const Vector< Scalar > &, Vector< Scalar > &) const
 $dx_1 = D^2F(x)^*(dx_0,dy)$, defined so that $\langle D^2F(x)^*(dx_0,dy),dx_1\rangle_X = \langle dy, D^2F(x)(dx_0,dx_1) $.
void * operator new (size_t size)
 operator new - not available to general public, but available to children who will use it to define clone
virtual Operator< Scalar > * clone () const =0
 virtual copy contructor, also accessible only through OperatorEvaluation.
DerivEvaluation< Scalar > * createDerivEvaluation (OperatorEvaluation< Scalar > &opeval) const
 Virtual derivative constructor.
Deriv2Evaluation< Scalar > * createDeriv2Evaluation (OperatorEvaluation< Scalar > &opeval) const
 Virtual 2nd derivative constructor.

Static Protected Member Functions

static void export_apply (Operator< Scalar > const &f, const Vector< Scalar > &x, Vector< Scalar > &y)
 The export-apply methods make the protected apply methods of any Operator subclass instance available to other Operator subclass instances.
static void export_applyDeriv (Operator< Scalar > const &f, const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy)
static void export_applyAdjDeriv (Operator< Scalar > const &f, const Vector< Scalar > &x, const Vector< Scalar > &dy, Vector< Scalar > &dx)
static void export_applyDeriv2 (Operator< Scalar > const &f, const Vector< Scalar > &x, const Vector< Scalar > &dx0, const Vector< Scalar > &dx1, Vector< Scalar > &dy)
static void export_applyAdjDeriv2 (Operator< Scalar > const &f, const Vector< Scalar > &x, const Vector< Scalar > &dx0, const Vector< Scalar > &dy, Vector< Scalar > &dx1)
static Operator< Scalar > * export_clone (Operator< Scalar > const &op)
 export version of clone

Friends

class OperatorEvaluation< Scalar >
class FcnlOpComp< Scalar >

Detailed Description

template<class Scalar>
class RVL::Operator< Scalar >

Interface for vector-valued vector functions.

Current version provides only first derivatives - higher derivatives may be added later.

This interface has virtually no public members, other than those which idenify its domain and range. 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 Operator::clone method (virtual copy constructor) is also protected, and is used by the Evaluation constructor to create a completely independent copy.

As is the case with other core RVL classes, Operators are intended to be allocated on the stack. Therefore Operator::new is overridden as a protected method, to be used by concrete child classes to define Operator::clone.

Concrete subclasses of Operator should be written in "use-once" style: any and all internal data should be written once and treated as read-only thereafter. The only functions which might change an Operator instance's internal state are protected, and accessible only through OperatorEvaluation value access methods (such as OperatorEvaluation::getValue). All internal data generated by an instance is therefore tied to a particular evaluation point, and automatically remains consistent for the lifetime of the object. No consistency checks are required.

Since OperatorEvaluation objects clone Operator instances, 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 derivative computation is supplied as part of RVL, in the form of a standalone function (DerivTest). It is HIGHLY RECOMMENDED that every concrete Operator implementation be subjected to this test, and that the computed derivative returned by OperatorEvaluation::getDeriv be subjected to the adjoint test (standalone function AdjointTest).

Finally, this version of Operator 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 vector. The class is not a suitable abstraction for real vector-valued functions of complex vector variables, for instance.

Definition at line 112 of file op.hh.


Constructor & Destructor Documentation

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

Definition at line 255 of file op.hh.

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

Definition at line 256 of file op.hh.

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

Definition at line 257 of file op.hh.


Member Function Documentation

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

$y = F(x)$

Implemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::BlockLinearOp< Scalar >, RVL::BlockLinearOpBlock< Scalar >, RVL::ColumnLinearOp< Scalar >, RVL::InjectOp< Scalar >, RVL::CompLinearOp< Scalar >, RVL::LinearOpFO< Scalar >, RVL::AdjLinearOp< Scalar >, RVL::NormalLinearOp< Scalar >, RVL::ScaleOpFwd< Scalar >, RVL::ScaleOpInv< Scalar >, RVL::LinCombLinearOp< Scalar >, RVL::LinearBilinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::RestrictOp< Scalar >, RVL::LinOpValOp< Scalar >, RVL::LinearRestrictOp< Scalar >, RVL::DerivEvaluation< Scalar >, RVL::PartialDerivEvaluation< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::LinearOp< Scalar >::applyDeriv(), RVL::LinearOp< Scalar >::applyOp(), and RVL::Operator< Scalar >::export_apply().

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

$dy = DF(x)dx$

Implemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::InjectOp< Scalar >, RVL::LinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::Operator< Scalar >::export_applyDeriv().

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

$dx = DF(x)^*dy$

Implemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::InjectOp< Scalar >, RVL::LinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::Operator< Scalar >::export_applyAdjDeriv().

template<class Scalar>
virtual void RVL::Operator< Scalar >::applyDeriv2 ( const Vector< Scalar > &  ,
const Vector< Scalar > &  ,
const Vector< Scalar > &  ,
Vector< Scalar > &   
) const [protected, virtual]

Reimplemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::LinearOp< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, and RVL::OpComp< Scalar >.

Definition at line 141 of file op.hh.

Referenced by RVL::Operator< Scalar >::export_applyDeriv2().

template<class Scalar>
virtual void RVL::Operator< Scalar >::applyAdjDeriv2 ( const Vector< Scalar > &  ,
const Vector< Scalar > &  ,
const Vector< Scalar > &  ,
Vector< Scalar > &   
) const [protected, virtual]

$dx_1 = D^2F(x)^*(dx_0,dy)$, defined so that $\langle D^2F(x)^*(dx_0,dy),dx_1\rangle_X = \langle dy, D^2F(x)(dx_0,dx_1) $.

Note that this form should be symmetric, so the other possible definition of adjoint yields the same result.

implemented to throw exception - override in subclasses that need 2nd deriv.

Reimplemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::LinearOp< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, and RVL::OpComp< Scalar >.

Definition at line 157 of file op.hh.

Referenced by RVL::Operator< Scalar >::export_applyAdjDeriv2().

template<class Scalar>
static void RVL::Operator< Scalar >::export_apply ( Operator< Scalar > const &  f,
const Vector< Scalar > &  x,
Vector< Scalar > &  y 
) [static, protected]

The export-apply methods make the protected apply methods of any Operator subclass instance available to other Operator subclass instances.

Definition at line 170 of file op.hh.

References RVL::Operator< Scalar >::apply().

Referenced by RVL::OpComp< Scalar >::apply(), RVL::LinCombOperator< Scalar >::apply(), RVL::RestrictOp< Scalar >::apply(), RVL::ResidualOperator< Scalar >::apply(), RVL::CompLOVOp< Scalar >::apply0(), RVL::CompLOVOp< Scalar >::applyAdj0(), RVL::CompLOVOp< Scalar >::applyAdjPartialDeriv0(), RVL::CompLOVOp< Scalar >::applyAdjPartialDeriv20(), RVL::TensorLinearOp< Scalar >::applyComponent(), RVL::TensorOp< Scalar >::applyComponent(), RVL::CompLOVOp< Scalar >::applyPartialDeriv0(), and RVL::CompLOVOp< Scalar >::applyPartialDeriv20().

template<class Scalar>
static void RVL::Operator< Scalar >::export_applyDeriv ( Operator< Scalar > const &  f,
const Vector< Scalar > &  x,
const Vector< Scalar > &  dx,
Vector< Scalar > &  dy 
) [static, protected]

Definition at line 176 of file op.hh.

References RVL::Operator< Scalar >::applyDeriv().

Referenced by RVL::TangentMap< Scalar >::apply0(), RVL::CompLOVOp< Scalar >::applyAdjPartialDeriv0(), RVL::CompLOVOp< Scalar >::applyAdjPartialDeriv20(), RVL::TensorOp< Scalar >::applyComponentDeriv(), RVL::LinCombOperator< Scalar >::applyDeriv(), RVL::ResidualOperator< Scalar >::applyDeriv(), RVL::CompLOVOp< Scalar >::applyPartialDeriv0(), and RVL::CompLOVOp< Scalar >::applyPartialDeriv20().

template<class Scalar>
static void RVL::Operator< Scalar >::export_applyAdjDeriv ( Operator< Scalar > const &  f,
const Vector< Scalar > &  x,
const Vector< Scalar > &  dy,
Vector< Scalar > &  dx 
) [static, protected]

Definition at line 183 of file op.hh.

References RVL::Operator< Scalar >::applyAdjDeriv().

Referenced by RVL::TangentMap< Scalar >::applyAdj0(), RVL::LinCombOperator< Scalar >::applyAdjDeriv(), RVL::ResidualOperator< Scalar >::applyAdjDeriv(), and RVL::TensorOp< Scalar >::applyComponentAdjDeriv().

template<class Scalar>
static void RVL::Operator< Scalar >::export_applyDeriv2 ( Operator< Scalar > const &  f,
const Vector< Scalar > &  x,
const Vector< Scalar > &  dx0,
const Vector< Scalar > &  dx1,
Vector< Scalar > &  dy 
) [static, protected]

Definition at line 190 of file op.hh.

References RVL::Operator< Scalar >::applyDeriv2().

Referenced by RVL::TensorOp< Scalar >::applyComponentDeriv2(), and RVL::TangentMap< Scalar >::applyPartialDeriv0().

template<class Scalar>
static void RVL::Operator< Scalar >::export_applyAdjDeriv2 ( Operator< Scalar > const &  f,
const Vector< Scalar > &  x,
const Vector< Scalar > &  dx0,
const Vector< Scalar > &  dy,
Vector< Scalar > &  dx1 
) [static, protected]

Definition at line 198 of file op.hh.

References RVL::Operator< Scalar >::applyAdjDeriv2().

Referenced by RVL::TangentMap< Scalar >::applyAdjPartialDeriv0(), and RVL::TensorOp< Scalar >::applyComponentAdjDeriv2().

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

operator new - not available to general public, but available to children who will use it to define clone

Version 1.0: user control, for those who believe it's not just for children.

Reimplemented in RVL::LinearOp< Scalar >.

Definition at line 214 of file op.hh.

template<class Scalar>
virtual Operator<Scalar>* RVL::Operator< Scalar >::clone (  )  const [protected, pure virtual]

virtual copy contructor, also accessible only through OperatorEvaluation.

Usually implemented with operator new and copy constructor of concrete child class.

Implemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::BlockLinearOp< Scalar >, RVL::BlockLinearOpBlock< Scalar >, RVL::ColumnLinearOp< Scalar >, RVL::InjectOp< Scalar >, RVL::HessianEvaluation< Scalar >, RVL::CompLinearOp< Scalar >, RVL::LinearOpFO< Scalar >, RVL::AdjLinearOp< Scalar >, RVL::NormalLinearOp< Scalar >, RVL::ScaleOpFwd< Scalar >, RVL::ScaleOpInv< Scalar >, RVL::LinCombLinearOp< Scalar >, RVL::LinearBilinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, RVL::LinearRestrictOp< Scalar >, RVL::DerivEvaluation< Scalar >, RVL::InvertibleDerivEvaluation< Scalar >, RVL::PartialDerivEvaluation< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::Operator< Scalar >::export_clone().

template<class Scalar>
static Operator<Scalar>* RVL::Operator< Scalar >::export_clone ( Operator< Scalar > const &  op  )  [static, protected]

export version of clone

Definition at line 228 of file op.hh.

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

Referenced by RVL::DiagOp< Scalar >::set().

template<class Scalar>
DerivEvaluation<Scalar>* RVL::Operator< Scalar >::createDerivEvaluation ( OperatorEvaluation< Scalar > &  opeval  )  const [protected]

Virtual derivative constructor.

Permits subclasses to implement the derivative linear op with additional functionality using a subclass of DerivEvaluation instead of the simplest form.

Reimplemented in RVL::OperatorWithInvertibleDeriv< Scalar >.

Definition at line 237 of file op.hh.

template<class Scalar>
Deriv2Evaluation<Scalar>* RVL::Operator< Scalar >::createDeriv2Evaluation ( OperatorEvaluation< Scalar > &  opeval  )  const [protected]

Virtual 2nd derivative constructor.

Permits subclasses to implement the 2nd derivative bilinear op with additional functionality using a subclass of Deriv2Evaluation instead of the simplest form.

Definition at line 247 of file op.hh.

template<class Scalar>
virtual const Space<Scalar>& RVL::Operator< Scalar >::getDomain (  )  const [pure virtual]

access to domain, range

Implemented in RVL::TensorOp< Scalar >, RVL::DiagOp< Scalar >, RVL::BlockLinearOp< Scalar >, RVL::BlockLinearOpBlock< Scalar >, RVL::TensorLinearOp< Scalar >, RVL::InjectOp< Scalar >, RVL::HessianEvaluation< Scalar >, RVL::CompLinearOp< Scalar >, RVL::LinearOpFO< Scalar >, RVL::AdjLinearOp< Scalar >, RVL::NormalLinearOp< Scalar >, RVL::ScaleOpFwd< Scalar >, RVL::ScaleOpInv< Scalar >, RVL::LinCombLinearOp< Scalar >, RVL::LinearBilinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::OperatorProductDomain< Scalar >, RVL::RestrictOp< Scalar >, RVL::LinearRestrictOp< Scalar >, RVL::DerivEvaluation< Scalar >, RVL::InvertibleDerivEvaluation< Scalar >, RVL::PartialDerivEvaluation< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::AdjointTest(), RVL::LinearOp< Scalar >::applyAdjOp(), RVL::LinearOpWithInverse< Scalar >::applyInvAdjOp(), RVL::LinearOpWithInverse< Scalar >::applyInvOp(), RVL::LinearOp< Scalar >::applyOp(), RVL::DerivTest(), RVL::DiagOp< Scalar >::set(), RVL::OpComp< Scalar >::setNext(), and RVL::CompLinearOp< Scalar >::setNext().

template<class Scalar>
virtual const Space<Scalar>& RVL::Operator< Scalar >::getRange (  )  const [pure virtual]

Implemented in RVL::BlockOperator< Scalar >, RVL::DiagOp< Scalar >, RVL::BlockLinearOp< Scalar >, RVL::BlockLinearOpBlock< Scalar >, RVL::ColumnLinearOp< Scalar >, RVL::InjectOp< Scalar >, RVL::HessianEvaluation< Scalar >, RVL::CompLinearOp< Scalar >, RVL::LinearOpFO< Scalar >, RVL::AdjLinearOp< Scalar >, RVL::NormalLinearOp< Scalar >, RVL::ScaleOpFwd< Scalar >, RVL::ScaleOpInv< Scalar >, RVL::LinCombLinearOp< Scalar >, RVL::LinearBilinearOp< Scalar >, RVL::ShiftOperator< Scalar >, RVL::ResidualOperator< Scalar >, RVL::RestrictOp< Scalar >, RVL::ConstLinOpValOp< Scalar >, RVL::TangentMap< Scalar >, RVL::LinearRestrictOp< Scalar >, RVL::CompLOVOp< Scalar >, RVL::LinCompLOVOp< Scalar >, RVL::DerivEvaluation< Scalar >, RVL::InvertibleDerivEvaluation< Scalar >, RVL::PartialDerivEvaluation< Scalar >, RVL::LNLOperator< Scalar >, RVL::ANLOperator< Scalar >, RVL::OpFO< Scalar >, RVL::LinCombOperator< Scalar >, RVL::OpComp< Scalar >, and RVL::IdentityOp< Scalar >.

Referenced by RVL::AdjointTest(), RVL::LinearOp< Scalar >::applyAdjOp(), RVL::LinearOpWithInverse< Scalar >::applyInvAdjOp(), RVL::LinearOpWithInverse< Scalar >::applyInvOp(), RVL::LinearOp< Scalar >::applyOp(), RVL::DerivTest(), and RVL::DiagOp< Scalar >::set().

template<class Scalar>
static std::shared_ptr<Operator<Scalar> > RVL::Operator< Scalar >::clonePtr ( Operator< Scalar > const &  op  )  [static]

safe dynamic copy construction

Definition at line 264 of file op.hh.

Referenced by RVL::CompLOVOp< Scalar >::CompLOVOp(), and RVL::LinCompLOVOp< Scalar >::LinCompLOVOp().

template<class Scalar>
virtual ScalarFieldTraits<Scalar>::AbsType RVL::Operator< Scalar >::getMaxStep ( const Vector< Scalar > &  ,
const Vector< Scalar > &   
) const [virtual]

can be overridden to express distance to boundary of domain for operators whose domains are not the whole space.

First arg: position, second arg: direction

Reimplemented in RVL::ResidualOperator< Scalar >, and RVL::RestrictOp< Scalar >.

Definition at line 274 of file op.hh.

Referenced by RVL::DerivTest().


Friends And Related Function Documentation

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

Reimplemented in RVL::BlockOperator< Scalar >, RVL::ColumnLinearOp< Scalar >, RVL::OperatorProductDomain< Scalar >, and RVL::DerivEvaluation< Scalar >.

Definition at line 114 of file op.hh.

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

Definition at line 115 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