#include <op.hh>
Inheritance diagram for RVL::OpComp< Scalar >:
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. |
To construct an Operator representation of the composition (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 .
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.
RVL::OpComp< Scalar >::OpComp | ( | ) |
RVL::OpComp< Scalar >::OpComp | ( | OpComp< Scalar > const & | oc | ) |
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().
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().
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().
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().
RVL::OpComp< Scalar >::~OpComp | ( | ) |
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().
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().
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 >.
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().
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().
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 >.
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().
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().
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().
ostream& RVL::OpComp< Scalar >::write | ( | ostream & | str | ) | const [virtual] |