CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::VectorAccessInterface< T_Real, T_Identifier > Struct Template Referenceabstract

Unified access to the adjoint vector and primal vector in a tape evaluation. More...

#include <vectorAccessInterface.hpp>

Inheritance diagram for codi::VectorAccessInterface< T_Real, T_Identifier >:

Public Types

using Identifier = T_Identifier
 See VectorAccessInterface.
 
using Real = T_Real
 See VectorAccessInterface.
 

Public Member Functions

virtual ~VectorAccessInterface ()
 Destructor.
 
Misc
virtual size_t getVectorSize () const =0
 Vector size in the current tape evaluation.
 
virtual bool isLhsZero ()=0
 True if the adjoint set with setLhsAdjoint is zero.
 
virtual VectorAccessInterfaceclone () const =0
 
Indirect adjoint access
virtual void setLhsAdjoint (Identifier const &index)=0
 
virtual void updateAdjointWithLhs (Identifier const &index, Real const &jacobian)=0
 
Indirect tangent access
virtual void setLhsTangent (Identifier const &index)=0
 
virtual void updateTangentWithLhs (Identifier const &index, Real const &jacobian)=0
 
Direct adjoint access
virtual void resetAdjoint (Identifier const &index, size_t dim)=0
 Set the adjoint component to zero.
 
virtual void resetAdjointVec (Identifier const &index)=0
 Set the adjoint entry to zero.
 
virtual Real getAdjoint (Identifier const &index, size_t dim)=0
 Get the adjoint component.
 
virtual void getAdjointVec (Identifier const &index, Real *const vec)=0
 Get the adjoint entry.
 
virtual Real const * getAdjointVec (Identifier const &index)=0
 Get the adjoint entry.
 
virtual void updateAdjoint (Identifier const &index, size_t dim, Real const &adjoint)=0
 Update the adjoint component.
 
virtual void updateAdjointVec (Identifier const &index, Real const *const vec)=0
 Update the adjoint entry.
 
Primal access
virtual void setPrimal (Identifier const &index, Real const &primal)=0
 Set the primal value.
 
virtual Real getPrimal (Identifier const &index)=0
 Get the primal value.
 
virtual bool hasPrimals ()=0
 True if the tape/vector interface has primal values.
 

Detailed Description

template<typename T_Real, typename T_Identifier>
struct codi::VectorAccessInterface< T_Real, T_Identifier >

Unified access to the adjoint vector and primal vector in a tape evaluation.

The interface abstracts the vector access such that custom vectors modes ( Example 11 - External function user data) can be handled in a generalized way for external functions. All definitions in this interface are based on the primal evaluation type of the tape. This means that also all vector definitions need to be evaluated with this type.

In general, this interface allows to evaluate the forward and reverse AD equations. All mathematical symbols in this documentation refer to the linked equations.

All identifiers in this interface are tape identifiers and can be obtained with codi::ActiveType::getIdentifier.

The interface provides different access types for the user which can be separated into five categories (all functions listed in their typical order of use):

  • Indirect adjoint access:
  • Indirect tangent access:
  • Direct adjoint vector access: The arrays need to have the size of getVectorSize()
  • Direct adjoint component access:
    • Same as the 'direct adjoint vector access' but all functions just work on one component.
    • Same function without the 'Vec' suffix.
  • Primal access: (Optional)
    • Only available if 'hasPrimals()' is true
    • setPrimal(): Set the primal value
    • getPrimal(): Get the primal value
    • This access is required for primal values tapes, which need to update or revert primal values during the tape evaluation.
Template Parameters
T_RealThe computation type of a tape, usually chosen as ActiveType::Real.
T_IdentifierThe adjoint/tangent identification of a tape, usually chosen as ActiveType::Identifier.

Member Function Documentation

◆ clone()

template<typename T_Real , typename T_Identifier >
virtual VectorAccessInterface * codi::VectorAccessInterface< T_Real, T_Identifier >::clone ( ) const
pure virtual

Obtain a heap-allocated copy of the vector access inter- face. The user is responsible for deleting the pointer.

Implemented in codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >, codi::AdjointVectorAccess< Real, Identifier, Gradient >, and codi::PrimalAdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ getAdjoint()

template<typename T_Real , typename T_Identifier >
virtual Real codi::VectorAccessInterface< T_Real, T_Identifier >::getAdjoint ( Identifier const & index,
size_t dim )
pure virtual

Get the adjoint component.

Implemented in codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ getAdjointVec() [1/2]

template<typename T_Real , typename T_Identifier >
virtual Real const * codi::VectorAccessInterface< T_Real, T_Identifier >::getAdjointVec ( Identifier const & index)
pure virtual

◆ getAdjointVec() [2/2]

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::getAdjointVec ( Identifier const & index,
Real *const vec )
pure virtual

◆ getPrimal()

template<typename T_Real , typename T_Identifier >
virtual Real codi::VectorAccessInterface< T_Real, T_Identifier >::getPrimal ( Identifier const & index)
pure virtual

◆ getVectorSize()

template<typename T_Real , typename T_Identifier >
virtual size_t codi::VectorAccessInterface< T_Real, T_Identifier >::getVectorSize ( ) const
pure virtual

◆ hasPrimals()

template<typename T_Real , typename T_Identifier >
virtual bool codi::VectorAccessInterface< T_Real, T_Identifier >::hasPrimals ( )
pure virtual

◆ isLhsZero()

template<typename T_Real , typename T_Identifier >
virtual bool codi::VectorAccessInterface< T_Real, T_Identifier >::isLhsZero ( )
pure virtual

◆ resetAdjoint()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::resetAdjoint ( Identifier const & index,
size_t dim )
pure virtual

Set the adjoint component to zero.

Implemented in codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ resetAdjointVec()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::resetAdjointVec ( Identifier const & index)
pure virtual

Set the adjoint entry to zero.

Implemented in codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ setLhsAdjoint()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::setLhsAdjoint ( Identifier const & index)
pure virtual

◆ setLhsTangent()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::setLhsTangent ( Identifier const & index)
pure virtual

◆ setPrimal()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::setPrimal ( Identifier const & index,
Real const & primal )
pure virtual

◆ updateAdjoint()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::updateAdjoint ( Identifier const & index,
size_t dim,
Real const & adjoint )
pure virtual

Update the adjoint component.

Implemented in codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ updateAdjointVec()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::updateAdjointVec ( Identifier const & index,
Real const *const vec )
pure virtual

◆ updateAdjointWithLhs()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::updateAdjointWithLhs ( Identifier const & index,
Real const & jacobian )
pure virtual

◆ updateTangentWithLhs()

template<typename T_Real , typename T_Identifier >
virtual void codi::VectorAccessInterface< T_Real, T_Identifier >::updateTangentWithLhs ( Identifier const & index,
Real const & jacobian )
pure virtual

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