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

#include <tapeHelper.hpp>

Inheritance diagram for codi::TapeHelperPrimal< T_Type >:

Public Types

using Base = TapeHelperBase< Type, TapeHelperPrimal< Type > >
 Base class abbreviation.
 
using Real = typename Type::Real
 See TapeHelperBase.
 
using Type = T_Type
 See TapeHelperBase.
 
- Public Types inherited from codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >
using Gradient = typename Type::Gradient
 See LhsExpressionInterface.
 
using HessianType = Hessian< PassiveReal >
 Type of the Hessian.
 
using Identifier = typename Type::Identifier
 See LhsExpressionInterface.
 
using Impl = TapeHelperPrimal< T_Type >
 See TapeHelperBase.
 
using JacobianType = Jacobian< PassiveReal >
 Type of the Jacobian.
 
using PassiveReal = typename RealTraits::PassiveReal< Real >
 Passive base of the CoDiPack type.
 
using Real = typename Type::Real
 See LhsExpressionInterface.
 
using Type = T_Type
 See TapeHelperBase.
 

Public Member Functions

template<typename Jac = DummyJacobian>
void evalHessian (typename Base::HessianType &hes, Jac &jac=StaticDummy< DummyJacobian >::dummy)
 Evaluates the full Hessian of the recorded tape.
 
virtual void evalPrimal (Real const *x, Real *y=nullptr)
 Perform a primal re-evaluation of the tape.
 
- Public Member Functions inherited from codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >
GradientcreateGradientVectorInput ()
 Create a gradient vector that can hold the tangent/adjoint of the input variables.
 
GradientcreateGradientVectorOutput ()
 Create a gradient vector that can hold the tangent/adjoint of the output variables.
 
HessianTypecreateHessian ()
 Create a Hessian that can hold the Hessian of the recorded tape.
 
JacobianTypecreateJacobian ()
 Create a Jacobian that can hold the Jacobian of the recorded tape.
 
RealcreatePrimalVectorInput ()
 Create a primal vector that can hold the primal seeding of the input variables.
 
RealcreatePrimalVectorOutput ()
 Create a primal vector that can hold the primal result of the output variables.
 
void deleteGradientVector (Gradient *vec)
 Delete a gradient vector that was created with createGradientVectorInput or createGradientVectorOutput.
 
void deleteHessian (HessianType &hes)
 Delete the Hessian that was created with createHessian function.
 
void deleteJacobian (JacobianType &jac)
 Delete the Jacobian that was created with createJacobian function.
 
void deletePrimalVector (Real *vec)
 Delete a primal vector that was created with createPrimalVectorInput or createPrimalVectorOutput.
 
void evalForward (Gradient const *x_d, Gradient *y_d)
 Perform a forward (tangent) evaluation of the recorded tape.
 
void evalForwardAt (Real const *x, Gradient const *x_d, Gradient *y_d, Real *y=nullptr)
 Re-evaluate the tape with new input variables and compute the AD forward mode.
 
void evalHessian (HessianType &hes, Jac &jac=StaticDummy< DummyJacobian >::dummy)
 Evaluates the full Hessian of the recorded tape.
 
void evalHessianAt (Real const *x, HessianType &hes, Real *y=nullptr, Jac &jac=StaticDummy< DummyJacobian >::dummy)
 Re-evaluate the tape with new input variables and compute the full Hessian at the new inputs.
 
void evalJacobian (JacobianType &jac)
 Evaluates the full Jacobian of the recorded tape.
 
void evalJacobianAt (Real const *x, JacobianType &jac, Real *y=nullptr)
 Re-evaluate the tape with new input variables and compute the full Jacobian at the new inputs.
 
void evalJacobianGen (Jac &jac)
 Evaluates the full Jacobian of the recorded tape with a custom Jacobian type chosen by the user.
 
virtual void evalPrimal (Real const *x, Real *y=nullptr)=0
 Perform a primal re-evaluation of the tape.
 
void evalReverse (Gradient const *y_b, Gradient *x_b)
 Perform a reverse (adjoint) evaluation of the recorded tape.
 
void evalReverseAt (Real const *x, Gradient const *y_b, Gradient *x_b, Real *y=nullptr)
 Re-evaluate the tape with new input variables and compute the AD forward mode.
 
size_t getInputSize ()
 
size_t getOutputSize ()
 
void registerInput (Type &value)
 Add an input variable to the tape.
 
void registerOutput (Type &value)
 Add an output variable to the tape.
 
void startRecording ()
 Start the recording process. Deletes the old tape.
 
void stopRecording ()
 Stop the recording process.
 
 TapeHelperBase ()
 Constructor.
 
virtual ~TapeHelperBase ()
 Destructor.
 

Additional Inherited Members

- Protected Types inherited from codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >
using Tape = typename Type::Tape
 Underlying tape type.
 
- Protected Member Functions inherited from codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >
Implcast ()
 Cast to the implementing class.
 
void changeStateToForwardEvaluation ()
 Change state.
 
void changeStateToReverseEvaluation ()
 Change state and clear the adjoints.
 
- Protected Attributes inherited from codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >
std::vector< IdentifierinputValues
 Input value identifiers.
 
std::vector< IdentifieroutputValues
 Input value identifiers.
 
Tape & tape
 Reference to the global tape.
 
bool wasForwardEvaluated
 State of the last evaluation.
 

Detailed Description

template<typename T_Type>
struct codi::TapeHelperPrimal< T_Type >

TapeHelper implementation for the Jacobian taping strategy.

See TapeHelperBase for details.

Template Parameters
T_TypeThe CoDiPack type on which the evaluations take place.

Member Function Documentation

◆ evalHessian()

template<typename T_Type >
template<typename Jac = DummyJacobian>
void codi::TapeHelperPrimal< T_Type >::evalHessian ( typename Base::HessianType hes,
Jac &  jac = StaticDummy<DummyJacobian>::dummy 
)
inline

Evaluates the full Hessian of the recorded tape.

The algorithm will select the best choice for the evaluation, either a forward mode or reverse mode evaluation. It will also use the vector mode if the underlying tape was configured with such a mode.

Parameters
[out]hesThe storage for the Hessian which is evaluated. Must have the correct size and should be created with createHessian.
[out]jacIf also the Jacobian should be computed alongside the Hessian, a storage for the Jacobian can be provided. Must have the correct size and should be created with createJacobian.
Template Parameters
JacHas to implement JacobianInterface.

◆ evalPrimal()

template<typename T_Type >
virtual void codi::TapeHelperPrimal< T_Type >::evalPrimal ( Real const *  x,
Real y = nullptr 
)
inlinevirtual

Perform a primal re-evaluation of the tape.

The re-evaluation will change the internally stored primal variables of the tape.

Parameters
[in]xThe new seeding vector for the primal input variables. The sequence of variables is the same as for the register input call. The vector should be created with createPrimalVectorInput.
[out]yThe result of the primal evaluation. The sequence of variables is the same as for the register output call. If the pointer is a null pointer then the result is not stored. The vector should be created with createPrimalVectorOutput.

Implements codi::TapeHelperBase< T_Type, TapeHelperPrimal< T_Type > >.


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