Allows user defined vectors for the forward and adjoint evaluation, and for clearing adjoints. More...
#include <customAdjointVectorEvaluationTapeInterface.hpp>
Public Types | |
using | Position = T_Position |
See CustomAdjointVectorEvaluationTapeInterface. | |
Public Types inherited from codi::ForwardEvaluationTapeInterface< T_Position > | |
using | Position = T_Position |
See ForwardEvaluationTapeInterface. | |
Public Types inherited from codi::PositionalEvaluationTapeInterface< T_Position > | |
using | Position = T_Position |
See PositionalEvaluationTapeInterface. | |
Public Member Functions | |
Interface definition | |
template<typename AdjointVector > | |
void | evaluate (Position const &start, Position const &end, AdjointVector &&data) |
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end. | |
template<typename AdjointVector > | |
void | evaluateForward (Position const &start, Position const &end, AdjointVector &&data) |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
template<typename AdjointVector > | |
void | clearCustomAdjoints (Position const &start, Position const &end, AdjointVector &&data) |
Clear all adjoint values, that is, set them to zero. | |
template<typename InternalAdjoints > | |
InternalAdjoints | getInternalAdjoints () |
Obtain a representation of the tape's internal adjoint vector that can be used as custom adjoints. | |
Public Member Functions inherited from codi::ForwardEvaluationTapeInterface< T_Position > | |
void | evaluateForward (Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
void | evaluateForward (AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Perform a forward evaluation of the full tape. | |
Public Member Functions inherited from codi::PositionalEvaluationTapeInterface< T_Position > | |
void | evaluate (Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end. | |
void | clearAdjoints (Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Clear all adjoints that would be set in a tape evaluation from start to end. It has to hold start >= end. | |
Position | getPosition () const |
Current position of the tape. | |
Position | getZeroPosition () const |
Initial position of the tape. | |
void | resetTo (Position const &pos, bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Reset the tape to the provided position. | |
Allows user defined vectors for the forward and adjoint evaluation, and for clearing adjoints.
See Tape Interface Design for a general overview of the tape interface design in CoDiPack.
The two additional evaluate methods allow for the evaluation of the tape with a custom adjoint vector, and the additional clearing method allows clearing the custom adjoint vector according to the recorded tape.
The adjoint vector type (template parameter AdjointVector in the member functions) must be a accessible with operator[]. Suitable choices are pointers, e.g., Adjoint*, or classes with overloaded operator[] like std::vector<Adjoint>.
codi::AdjointVectorTraits::GradientImplementation must be specialized for AdjointVector. The type of the vector entries deduced from these traits (gradient type) must support the following operators:
Here is an example for an evaluation with a custom adjoint vector (documentation/examples/customAdjointVectorEvaluationTapeInterface.cpp):
T_Position | Global tape position, usually chosen as Tape::Position. |
void codi::CustomAdjointVectorEvaluationTapeInterface< T_Position >::clearCustomAdjoints | ( | Position const & | start, |
Position const & | end, | ||
AdjointVector && | data ) |
Clear all adjoint values, that is, set them to zero.
Clear custom adjoint vector according to a tape recording.
AdjointVector | See CustomAdjointVectorEvaluationTapeInterface documentation. |
void codi::CustomAdjointVectorEvaluationTapeInterface< T_Position >::evaluate | ( | Position const & | start, |
Position const & | end, | ||
AdjointVector && | data ) |
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Tape evaluation with a custom adjoint vector.
AdjointVector | See CustomAdjointVectorEvaluationTapeInterface documentation. |
void codi::CustomAdjointVectorEvaluationTapeInterface< T_Position >::evaluateForward | ( | Position const & | start, |
Position const & | end, | ||
AdjointVector && | data ) |
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Tape evaluation with a custom adjoint vector.
AdjointVector | See CustomAdjointVectorEvaluationTapeInterface documentation. |
InternalAdjoints codi::CustomAdjointVectorEvaluationTapeInterface< T_Position >::getInternalAdjoints | ( | ) |
Obtain a representation of the tape's internal adjoint vector that can be used as custom adjoints.
To avoid that functionality has to be implemented both for custom, external and internal adjoints, this method provides access to the internal adjoints so that they can be used as if they were custom adjoints.
Warning: If you use this method, proceed with care. If internal adjoints are modified due to side effect of other methods, the object returned here might become invalid, or, conversely, modifications of the returned object other than reading/writing adjoints might interfere with the tape's management of internal adjoints.
InternalAdjoints | Placeholder for the implementation-dependent return type. |