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

Add statements to the tape where the Jacobians are computed manually. More...

#include <statementPushHelper.hpp>

Inheritance diagram for codi::StatementPushHelper< T_Type, typename >:

Public Types

using Identifier = typename Type::Identifier
 
using Real = typename Type::Real
 See LhsExpressionInterface.
 
using Tape = typename Type::Tape
 See LhsExpressionInterface.
 
using Type = T_Type
 < See StatementPushHelper.
 
- Public Types inherited from codi::StatementPushHelperBase< T_Type, StatementPushHelper< T_Type > >
using Impl
 See StatementPushHelperBase.
 
using Real
 See LhsExpressionInterface.
 
using Type
 See StatementPushHelperBase.
 

Public Member Functions

Implementation of StatementPushHelperBase
void startPushStatement ()
 Initialize all data for the push of a statement.
 
void pushArgument (Type const &arg, Real const &jacobian)
 Add the Jacobian of an argument of the statement.
 
void endPushStatement (Type &lhs, Real const &primal)
 Finish the push of a statement. Performs lhs = primal and cleans up all data.
 
- Public Member Functions inherited from codi::StatementPushHelperBase< T_Type, StatementPushHelper< T_Type > >
void endPushStatement (Type &lhs, Real const &primal)
 Finish the push of a statement. Performs lhs = primal and cleans up all data.
 
void pushArgument (Type const &arg, Real const &jacobian)
 Add the Jacobian of an argument of the statement.
 
void startPushStatement ()
 Initialize all data for the push of a statement.
 
void pushStatement (Type &lhs, Real const &primal, ArgIter const startArg, ArgIter const endArg, JacobiIter const startJac)
 Push a complete statement where the Jacobians and arguments are provided as iterator objects.
 
void pushStatement (Type &lhs, Real const &primal, ArgVector const &arguments, JacobiVector const &jacobians, size_t const size)
 Push a complete statement where the Jacobians and arguments are provided as arrays.
 

Protected Attributes

size_t dataPos
 Current number of arguments.
 
Identifier indexData [Config::MaxArgumentSize]
 Storage for the identifiers of the arguments.
 
Real jacobianData [Config::MaxArgumentSize]
 Storage for the Jacobians of the arguments.
 

Detailed Description

template<typename T_Type, typename = void>
struct codi::StatementPushHelper< T_Type, typename >

Add statements to the tape where the Jacobians are computed manually.

This helper class can be used to optimize the storage of a statement or to handle involved functions that cannot be handled with CoDiPack.

The three basic use cases are:

y[0] = x * x;
// Regular use
sh.pushArgument(x, 2.0 * x.value());
sh.endPushStatement(y[1], x.value() * x.value());
// Iterator based push
std::vector<Real> valuesIter;
std::vector<double> jacobiansIter;
valuesIter.push_back(x);
jacobiansIter.push_back(2.0 * x.value());
sh.pushStatement(y[2], x.value() * x.value(), valuesIter.begin(), valuesIter.end(), jacobiansIter.begin());
// Array based push
Real valuesArray[] = {x};
double jacobiansArray[] = {2.0 * x.value()};
sh.pushStatement(y[3], x.value() * x.value(), valuesArray, jacobiansArray, 1);

After a statement is pushed, the helper can be used again for the next statement.

Template Parameters
T_TypeThe CoDiPack type on whose tape the statements are pushed.

Member Typedef Documentation

◆ Identifier

template<typename T_Type , typename = void>
using codi::StatementPushHelper< T_Type, typename >::Identifier = typename Type::Identifier

Member Function Documentation

◆ endPushStatement()

template<typename T_Type , typename = void>
void codi::StatementPushHelper< T_Type, typename >::endPushStatement ( Type & lhs,
Real const & primal )
inline

Finish the push of a statement. Performs lhs = primal and cleans up all data.

◆ pushArgument()

template<typename T_Type , typename = void>
void codi::StatementPushHelper< T_Type, typename >::pushArgument ( Type const & arg,
Real const & jacobian )
inline

Add the Jacobian of an argument of the statement.

◆ startPushStatement()

template<typename T_Type , typename = void>
void codi::StatementPushHelper< T_Type, typename >::startPushStatement ( )
inline

Initialize all data for the push of a statement.


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