Add derivative information for custom operations to the tape. More...
#include <manualStatementPushTapeInterface.hpp>
Public Types | |
using | Gradient = T_Gradient |
See ManualStatementPushTapeInterface. | |
using | Identifier = T_Identifier |
See ManualStatementPushTapeInterface. | |
using | Real = T_Real |
See ManualStatementPushTapeInterface. | |
Public Member Functions | |
Interface definition | |
void | pushJacobianManual (Real const &jacobian, Real const &value, Identifier const &index) |
void | storeManual (Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size) |
Add derivative information for custom operations to the tape.
See Tape Interface Design for a general overview of the tape interface design in CoDiPack.
The functions in this interface can be used to provide derivative information to CoDiPack for functions that are not known to CoDiPack but so small that an external function implementation is an overkill.
The forward and reverse AD equations are the base for this interface. The user has to provide the Jacobian for all arguments and compute the value for .
Before the call to storeManual the user has to update the value of the output, that is, in the above equations. This is usually done with output.value() = w
. Afterwards, storeManual() has to be called. The size
argument is the number of arguments from the equations above. This call ensures that output
gets a proper identifier and the dependency chain is not broken or wrong for this variable.
Afterwards the user has to call pushJacobianManual() for each argument .
The user has to ensure that the computations of the Jacobians are evaluated such that the CoDiPack tape does not accidentally record them.
Here is an example for manual statement push (documentation/examples/manualStatementPushTapeInterface.cpp):
T_Real | The computation type of a tape, usually chosen as ActiveType::Real. |
T_Gradient | The gradient type of a tape, usually chosen as ActiveType::Gradient. |
T_Identifier | The adjoint/tangent identification type of a tape, usually chosen as ActiveType::Identifier. |
void codi::ManualStatementPushTapeInterface< T_Real, T_Gradient, T_Identifier >::pushJacobianManual | ( | Real const & | jacobian, |
Real const & | value, | ||
Identifier const & | index ) |
Push a Jacobian entry to the tape. storeManual() has to be called first and is passed the number of arguments. Afterwards, this method has to be called once for each argument.
jacobian | Jacobian of the argument . |
value | Value of the argument . Usually u_i.value() . |
index | Identifier of the argument . Usually u_i.identifier() . |
void codi::ManualStatementPushTapeInterface< T_Real, T_Gradient, T_Identifier >::storeManual | ( | Real const & | lhsValue, |
Identifier & | lhsIndex, | ||
Config::ArgumentSize const & | size ) |
Initialize the storing of a hand computed statement. The primal value has to be updated already.
lhsValue | Value of the result . Usually w.value() . |
lhsIndex | Identifier of the result . Usually w.identifier() . |
size | Number of arguments of . |