CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::GradientTraits Namespace Reference

Classes

struct  IsDirection
 If the expression inherits from Direction. Is either std::false_type or std::true_type. More...
 
struct  TraitsImplementation
 Common traits for all types used as gradients. More...
 

Typedefs

Detection of specific gradient types
template<typename Gradient >
using EnableIfDirection = typename std::enable_if< IsDirection< Gradient >::value >::type
 Enable if wrapper for EnableIfDirection.
 

General gradient traits

template<typename Gradient >
using Real = typename TraitsImplementation< Gradient >::Real
 The base value used in the gradient entries.
 
template<typename Gradient >
size_t constexpr dim ()
 Number of dimensions this gradient value has.
 
template<typename Gradient >
TraitsImplementation< Gradient >::Realat (Gradient &gradient, size_t dim)
 Get the entry at the given index.
 
template<typename Gradient >
TraitsImplementation< Gradient >::Real const & at (Gradient const &gradient, size_t dim)
 Get the entry at the given index.
 
template<typename Gradient >
std::array< AtomicTraits::RemoveAtomic< typename TraitsImplementation< Gradient >::Real >, TraitsImplementation< Gradient >::dimtoArray (Gradient const &gradient)
 Converts the (possibly multi-component) gradient to an array of Reals.
 

Detailed Description

Traits for everything that can be an used as a gradient (adjoint, tangent) usually the second template argument of CoDi Gen types codi::RealReverseGen. Possible types are double, codi::RealReverse, codi::Direction etc..

Typedef Documentation

◆ Real

template<typename Gradient >
using codi::GradientTraits::Real = typedef typename TraitsImplementation<Gradient>::Real

The base value used in the gradient entries.

Function Documentation

◆ at() [1/2]

template<typename Gradient >
TraitsImplementation< Gradient >::Real & codi::GradientTraits::at ( Gradient &  gradient,
size_t  dim 
)
inline

Get the entry at the given index.

◆ at() [2/2]

template<typename Gradient >
TraitsImplementation< Gradient >::Real const & codi::GradientTraits::at ( Gradient const &  gradient,
size_t  dim 
)
inline

Get the entry at the given index.

◆ dim()

template<typename Gradient >
size_t constexpr codi::GradientTraits::dim ( )
inlineconstexpr

Number of dimensions this gradient value has.

◆ toArray()

template<typename Gradient >
std::array< AtomicTraits::RemoveAtomic< typename TraitsImplementation< Gradient >::Real >, TraitsImplementation< Gradient >::dim > codi::GradientTraits::toArray ( Gradient const &  gradient)
inline

Converts the (possibly multi-component) gradient to an array of Reals.