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

Implementation of VectorAccessInterface for adjoint vectors. More...

#include <adjointVectorAccess.hpp>

Inheritance diagram for codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >:

Public Types

using Gradient = T_Gradient
 See AdjointVectorAccess.
 
using Identifier = T_Identifier
 See AdjointVectorAccess.
 
using Real = T_Real
 See AdjointVectorAccess.
 
- Public Types inherited from codi::VectorAccessInterface< T_Real, T_Identifier >
using Identifier = CODI_DD(T_Identifier, int)
 See VectorAccessInterface.
 
using Real = CODI_DD(T_Real, double)
 See VectorAccessInterface.
 

Public Member Functions

 AdjointVectorAccess (Gradient *adjointVector)
 Constructor. See interface documentation for details about the adjoint vector.
 
Misc
size_t getVectorSize () const
 Vector size in the current tape evaluation.
 
bool isLhsZero ()
 True if the adjoint set with setLhsAdjoint is zero.
 
VectorAccessInterface< Real, Identifier > * clone () const
 
Indirect adjoint access
void setLhsAdjoint (Identifier const &index)
 
void updateAdjointWithLhs (Identifier const &index, Real const &jacobian)
 
Indirect tangent access
void setLhsTangent (Identifier const &index)
 
void updateTangentWithLhs (Identifier const &index, Real const &jacobian)
 
Direct adjoint access
void resetAdjoint (Identifier const &index, size_t dim)
 Set the adjoint component to zero.
 
void resetAdjointVec (Identifier const &index)
 Set the adjoint entry to zero.
 
Real getAdjoint (Identifier const &index, size_t dim)
 Get the adjoint component.
 
void getAdjointVec (Identifier const &index, Real *const vec)
 Get the adjoint entry.
 
Real const * getAdjointVec (Identifier const &index)
 Get the adjoint entry.
 
void updateAdjoint (Identifier const &index, size_t dim, Real const &adjoint)
 Update the adjoint component.
 
void updateAdjointVec (Identifier const &index, Real const *const vec)
 Update the adjoint entry.
 
Primal access
void setPrimal (Identifier const &index, Real const &primal)
 Set the primal value.


 
Real getPrimal (Identifier const &index)
 Get the primal value.


 
bool hasPrimals ()
 Set the primal value.


 
- Public Member Functions inherited from codi::VectorAccessInterface< T_Real, T_Identifier >
virtual ~VectorAccessInterface ()
 Destructor.
 
virtual void setLhsAdjoint (Identifier const &index)=0
 
virtual void updateAdjointWithLhs (Identifier const &index, Real const &jacobian)=0
 
virtual void setLhsTangent (Identifier const &index)=0
 
virtual void updateTangentWithLhs (Identifier const &index, Real const &jacobian)=0
 
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.
 
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.
 

Protected Attributes

GradientadjointVector
 Pointer to the gradient vector.
 

Detailed Description

template<typename T_Real, typename T_Identifier, typename T_Gradient>
struct codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >

Implementation of VectorAccessInterface for adjoint vectors.

The adjoint vector is used as is, it is assumed to have the correct size. No bounds checking is performed.

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.
T_GradientThe gradient type of a tape, usually chosen as ActiveType::Gradient.

Member Function Documentation

◆ clone()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
VectorAccessInterface< Real, Identifier > * codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::clone ( ) const
inlinevirtual

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

Implements codi::VectorAccessInterface< T_Real, T_Identifier >.

Reimplemented in codi::PrimalAdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ getAdjoint()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
Real codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::getAdjoint ( Identifier const &  index,
size_t  dim 
)
inline

Get the adjoint component.

◆ getAdjointVec() [1/2]

template<typename T_Real , typename T_Identifier , typename T_Gradient >
Real const * codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::getAdjointVec ( Identifier const &  index)
inline

Get the adjoint entry.

◆ getAdjointVec() [2/2]

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::getAdjointVec ( Identifier const &  index,
Real *const  vec 
)
inline

Get the adjoint entry.

◆ getPrimal()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
Real codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::getPrimal ( Identifier const &  index)
inline

Get the primal value.



Implementation: Not implemented, returns zero.

◆ getVectorSize()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
size_t codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::getVectorSize ( ) const
inlinevirtual

Vector size in the current tape evaluation.

Implements codi::VectorAccessInterface< T_Real, T_Identifier >.

◆ hasPrimals()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
bool codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::hasPrimals ( )
inlinevirtual

Set the primal value.



Implementation: Always returns false.

Implements codi::VectorAccessInterface< T_Real, T_Identifier >.

Reimplemented in codi::PrimalAdjointVectorAccess< T_Real, T_Identifier, T_Gradient >.

◆ isLhsZero()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
bool codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::isLhsZero ( )
inlinevirtual

True if the adjoint set with setLhsAdjoint is zero.

Implements codi::VectorAccessInterface< T_Real, T_Identifier >.

◆ resetAdjoint()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::resetAdjoint ( Identifier const &  index,
size_t  dim 
)
inline

Set the adjoint component to zero.

◆ resetAdjointVec()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::resetAdjointVec ( Identifier const &  index)
inline

Set the adjoint entry to zero.

◆ setLhsAdjoint()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::setLhsAdjoint ( Identifier const &  index)
inline

Identify the lhs variable $ w $. Create an internal copy of $ \bar w $ and set $ \bar w $ to zero.

◆ setLhsTangent()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::setLhsTangent ( Identifier const &  index)
inline

Perform $ \dot w = \text{internalMem} $. Internal memory is reset afterwards.

◆ setPrimal()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::setPrimal ( Identifier const &  index,
Real const &  primal 
)
inline

Set the primal value.



Implementation: Not implemented, empty function.

◆ updateAdjoint()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::updateAdjoint ( Identifier const &  index,
size_t  dim,
Real const &  adjoint 
)
inline

Update the adjoint component.

◆ updateAdjointVec()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::updateAdjointVec ( Identifier const &  index,
Real const *const  vec 
)
inline

Update the adjoint entry.

◆ updateAdjointWithLhs()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::updateAdjointWithLhs ( Identifier const &  index,
Real const &  jacobian 
)
inline

Perform $ \bar u_{\text{index}} \aeq
                  \text{jacobian} * \bar w $

◆ updateTangentWithLhs()

template<typename T_Real , typename T_Identifier , typename T_Gradient >
void codi::AdjointVectorAccess< T_Real, T_Identifier, T_Gradient >::updateTangentWithLhs ( Identifier const &  index,
Real const &  jacobian 
)
inline

Perform $ \text{internalMem} \aeq jacobian *
                 < \dot
                  u_{\text{index}} $.


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