Perform a primal reevaluation of the tape. More...
#include <primalEvaluationTapeInterface.hpp>
Public Types | |
using | Identifier = T_Identifier |
See PrimalEvaluationTapeInterface. | |
using | Position = T_Position |
See PrimalEvaluationTapeInterface. | |
using | Real = T_Real |
See PrimalEvaluationTapeInterface. | |
Public Types inherited from codi::PositionalEvaluationTapeInterface< T_Position > | |
using | Position = T_Position |
See PositionalEvaluationTapeInterface. | |
Interface definition | |
static bool constexpr | HasPrimalValues = false |
True if the tape has primal values. | |
static bool constexpr | RequiresPrimalRestore |
True if the primal state changes during a reverse or forward evaluation. | |
void | evaluatePrimal (Position const &start, Position const &end) |
Perform a partly (forward) reevaluation of the primals in the tape. It has to hold start <= end. | |
void | evaluatePrimal () |
Perform a full (forward) reevaluation of the primals in the tape. | |
void | setPrimal (Identifier const &identifier, Real const &gradient) |
Set primal value. | |
Real const & | getPrimal (Identifier const &identifier) const |
Get primal value. | |
Real & | primal (Identifier const &identifier) |
Writable reference to primal value. | |
Real const & | primal (Identifier const &identifier) const |
Read only reference to primal value. | |
void | revertPrimals (Position const &pos) |
Revert the primals to the state indicated by pos. | |
Additional Inherited Members | |
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. | |
Perform a primal reevaluation of the tape.
See Tape Interface Design for a general overview of the tape interface design in CoDiPack.
Whether the tape manages primal values is indicated by the static constant HasPrimalValues
.
In a primal value tape, the correctness of the primal values is very important. The tapes should be programmed such that the primal values stored in the tape are always up to date with the state of the program. Only through user interaction this sync in states can be broken, but then the user should know what he is doing.
The primal evaluation is used to reevaluate the primal values stored in the tape for different values of the registered inputs. Note that this reevaluation follows the control flow that was observed during recording. The control flow statements themselves, e.g. if constructs or loops, are not treated by CoDiPack. The user cannot expect a reevaluation to choose different branches in if constructs or different numbers of loop iterations with respect to the code that was recorded.
Here is an example for a primal reevaluation (documentation/examples/primalEvaluationTapeInterface.cpp):
T_Real | The computation type of a tape, usually chosen as ActiveType::Real. |
T_Identifier | The adjoint/tangent identification of a tape, usually chosen as ActiveType::Identifier. |
T_Position | Global tape position, usually chosen as Tape::Position. |
|
staticconstexpr |
True if the primal state changes during a reverse or forward evaluation.