RVL::OpComp< Scalar > Class Template Reference

OpComp is a concrete class implementing composition of any number of Operator and/or LinearOp instancess. More...

#include <op.hh>

Inheritance diagram for RVL::OpComp< Scalar >:

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

Public Member Functions

 OpComp ()
 OpComp (OpComp< Scalar > const &oc)
void setNext (Operator< Scalar > const &opref)
 Run-time initialization - standard use case.
 OpComp (Operator< Scalar > const &op1ref, Operator< Scalar > const &op2ref)
 composition of two operators
 OpComp (Operator< Scalar > const &op1ref, Operator< Scalar > const &op2ref, Operator< Scalar > const &op3ref)
 composition of three operators
 OpComp (Operator< Scalar > const &op1ref, Operator< Scalar > const &op2ref, Operator< Scalar > const &op3ref, Operator< Scalar > const &op4ref)
 composition of four operators
 OpComp (Operator< Scalar > const &op1ref, Operator< Scalar > const &op2ref, Operator< Scalar > const &op3ref, Operator< Scalar > const &op4ref, Operator< Scalar > const &op5ref)
 composition of five operators
 ~OpComp ()
const Space< Scalar > & getDomain () const
 access to domain and range
const Space< Scalar > & getRange () const
ostream & write (ostream &str) const

Protected Member Functions

void apply (const Vector< Scalar > &x, Vector< Scalar > &val) const
 composition
void applyDeriv (const Vector< Scalar > &x, const Vector< Scalar > &dx, Vector< Scalar > &dy) const
 implements the chain rule to apply the derivative
void applyAdjDeriv (const Vector< Scalar > &x, const Vector< Scalar > &dy, Vector< Scalar > &dx) const
 the chain rule, backwards - in effect, the adjoint state method - however, all data is stored, no attempt at checkpointing!
void applyDeriv2 (const Vector< Scalar > &x, const Vector< Scalar > &dx0, const Vector< Scalar > &dx1, Vector< Scalar > &dy) const
 implements the chain rule to apply the second order derivative
void applyAdjDeriv2 (const Vector< Scalar > &x, const Vector< Scalar > &dx0, const Vector< Scalar > &dy, Vector< Scalar > &dx1) const
Operator< Scalar > * clone () const
 virtual copy constructor: make a complete new copy including internal workspace.

Detailed Description

template<class Scalar>
class RVL::OpComp< Scalar >

OpComp is a concrete class implementing composition of any number of Operator and/or LinearOp instancess.

To construct an Operator representation of the composition $x \mapsto M(x)=L2(L1(x))$ (template types left out for brevity):

OpComp M(L1,L2);

Note the order: the Operator (or LinearOp) to be evaluated first is the first constructor argument, the operator to be evaluated second is the second argument.

Compositions of more than two operators can be built up by recursion, using the two-operator composition constructor above. Alternatively, convenience constructors are supplied for up to five-fold composition: for example,

OpComp M(L1,L2,L3,L4,L5)

produces $x \mapsto M(x)=L5(L4(L3(L2(L1(x)))))$.

Note that the OpComp constructor is stack-based, that is, the composition must be instantiated within the scope of its factors. As with other fundamental RVL classes, this restriction exists to make dangling reference busts impossible. This restriction is necessary, absent enforced employment of smart pointers, since operator subtypes may store references to instances of other, stack-allocated data types.

The derivative and adjoint derivative methods are constructed for maximal efficiency in the case that some of the composition factors are LinearOps. If all operators from some factor on to the end of a composition are linear, then the value of the partial composition of the preceding factors need not be computed, only the value of its derivative, as the value plays no role in the evaluation of the remaining factors, which act only on the tangent part, being linear. In particular, workspace does not need to be allocated to hold this value. For large-scale computation, the efficiency obtained by distinguishing the linear and nonlinear cases can be considerable.

Note on structure: OpComp is a handle class, which owns dynamically allocated instances of its Op data members (via clone). This design is efficient if Operator instances are kept lightweight.

Definition at line 3002 of file op.hh.


Constructor & Destructor Documentation

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

Definition at line 3308 of file op.hh.

template<class Scalar>
RVL::OpComp< Scalar >::OpComp ( OpComp< Scalar > const &  oc  ) 

Definition at line 3310 of file op.hh.

References RVL::OpComp< Scalar >::opvec.

template<class Scalar>
RVL::OpComp< Scalar >::OpComp ( Operator< Scalar > const &  op1ref,
Operator< Scalar > const &  op2ref 
)

composition of two operators

Definition at line 3350 of file op.hh.

References RVL::OpComp< Scalar >::setNext().

template<class Scalar>
RVL::OpComp< Scalar >::OpComp ( Operator< Scalar > const &  op1ref,
Operator< Scalar > const &  op2ref,
Operator< Scalar > const &  op3ref 
)

composition of three operators

Definition at line 3364 of file op.hh.

References RVL::OpComp< Scalar >::setNext().

template<class Scalar>
RVL::OpComp< Scalar >::OpComp ( Operator< Scalar > const &  op1ref,
Operator< Scalar > const &  op2ref,
Operator< Scalar > const &  op3ref,
Operator< Scalar > const &  op4ref 
)

composition of four operators

Definition at line 3380 of file op.hh.

References RVL::OpComp< Scalar >::setNext().

template<class Scalar>
RVL::OpComp< Scalar >::OpComp ( Operator< Scalar > const &  op1ref,
Operator< Scalar > const &  op2ref,
Operator< Scalar > const &  op3ref,
Operator< Scalar > const &  op4ref,
Operator< Scalar > const &  op5ref 
)

composition of five operators

Definition at line 3398 of file op.hh.

References RVL::OpComp< Scalar >::setNext().

template<class Scalar>
RVL::OpComp< Scalar >::~OpComp (  ) 

Definition at line 3417 of file op.hh.


Member Function Documentation

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

composition

Implements RVL::Operator< Scalar >.

Definition at line 3013 of file op.hh.

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

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

implements the chain rule to apply the derivative

Implements RVL::Operator< Scalar >.

Definition at line 3045 of file op.hh.

References RVL::OperatorEvaluation< Scalar >::getValue().

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

the chain rule, backwards - in effect, the adjoint state method - however, all data is stored, no attempt at checkpointing!

Implements RVL::Operator< Scalar >.

Definition at line 3119 of file op.hh.

template<class Scalar>
void RVL::OpComp< Scalar >::applyDeriv2 ( const Vector< Scalar > &  x,
const Vector< Scalar > &  dx0,
const Vector< Scalar > &  dx1,
Vector< Scalar > &  dy 
) const [protected, virtual]

implements the chain rule to apply the second order derivative

Reimplemented from RVL::Operator< Scalar >.

Definition at line 3199 of file op.hh.

References RVL::OpComp< Scalar >::getDomain(), RVL::OpComp< Scalar >::getRange(), and RVL::Vector< Scalar >::linComb().

template<class Scalar>
void RVL::OpComp< Scalar >::applyAdjDeriv2 ( const Vector< Scalar > &  x,
const Vector< Scalar > &  dx0,
const Vector< Scalar > &  dy,
Vector< Scalar > &  dx1 
) const [protected, virtual]

Reimplemented from RVL::Operator< Scalar >.

Definition at line 3251 of file op.hh.

References RVL::OpComp< Scalar >::getDomain(), and RVL::Vector< Scalar >::linComb().

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

virtual copy constructor: make a complete new copy including internal workspace.

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

Implements RVL::Operator< Scalar >.

Definition at line 3304 of file op.hh.

template<class Scalar>
void RVL::OpComp< Scalar >::setNext ( Operator< Scalar > const &  opref  ) 

Run-time initialization - standard use case.

Definition at line 3319 of file op.hh.

References RVL::Operator< Scalar >::getDomain(), and RVL::Writeable::write().

Referenced by RVL::OpComp< Scalar >::OpComp().

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

access to domain and range

Implements RVL::Operator< Scalar >.

Definition at line 3422 of file op.hh.

Referenced by RVL::OpComp< Scalar >::applyAdjDeriv2(), and RVL::OpComp< Scalar >::applyDeriv2().

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

Implements RVL::Operator< Scalar >.

Definition at line 3440 of file op.hh.

Referenced by RVL::OpComp< Scalar >::applyDeriv2().

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

Implements RVL::Writeable.

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