CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::ForwardEvaluationTapeInterface< T_Position > Struct Template Reference

Forward AD evaluation of a recorded tape. More...

#include <forwardEvaluationTapeInterface.hpp>

Inheritance diagram for codi::ForwardEvaluationTapeInterface< T_Position >:

Public Types

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
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.
 

Detailed Description

template<typename T_Position>
struct codi::ForwardEvaluationTapeInterface< T_Position >

Forward AD evaluation of a recorded tape.

See Tape Interface Design for a general overview of the tape interface design in CoDiPack.

Here is an example for a forward tape evaluation (documentation/examples/forwardEvaluationTapeInterface.cpp):

using Tape = typename Real::Tape;
Tape& tape = Real::getTape();
// Recording
Real x = 10.0;
tape.setActive();
tape.registerInput(x);
Real y = 42.0 * x * x;
tape.registerOutput(y);
tape.setPassive();
// Forward evaluation
x.setGradient(1.0);
tape.evaluateForward();
std::cout << "Gradient of dy/dx: " << y.getGradient() << std::endl;
RealReverseGen< double > RealReverse
Definition: codi.hpp:120
Represents a concrete lvalue in the CoDiPack expression tree.
Definition: activeType.hpp:52
static Tape & getTape()
Get a reference to the tape which manages this expression.
Definition: activeType.hpp:99
T_Tape Tape
See ActiveType.
Definition: activeType.hpp:55
void setGradient(Gradient const &g)
Set the gradient of this lvalue in the tape.
Definition: lhsExpressionInterface.hpp:120
Gradient getGradient() const
Get the gradient of this lvalue from the tape.
Definition: lhsExpressionInterface.hpp:115
Template Parameters
T_PositionGlobal tape position type, usually chosen as Tape::Position.

Member Function Documentation

◆ evaluateForward() [1/2]

template<typename T_Position >
void codi::ForwardEvaluationTapeInterface< T_Position >::evaluateForward ( AdjointsManagement  adjointsManagement = AdjointsManagement::Automatic)

Perform a forward evaluation of the full tape.

Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.

◆ evaluateForward() [2/2]

template<typename T_Position >
void codi::ForwardEvaluationTapeInterface< T_Position >::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.

Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.


The documentation for this struct was generated from the following file: