42#include "expressionTraits.hpp"
48 namespace RealTraits {
59 template<
typename T_Type,
typename =
void>
81 template<
typename T_Type,
typename =
void>
99 template<
typename T_Type,
typename =
void>
112 template<
typename Type>
116 template<
typename Type>
120 template<
typename Type>
126 template<
typename Type>
132 template<
typename Type>
138 template<
typename Type>
157 template<
typename T_Type,
typename =
void>
161 "Instantiation of unspecialized RealTraits::DataExtraction.");
165 using Real =
typename Type::Real;
167 typename Type::Identifier;
188 template<
typename T_Type,
typename =
void>
192 "Instantiation of unspecialized RealTraits::TapeRegistration.");
209 template<
typename Type>
215 template<
typename Type>
221 template<
typename Type>
227 template<
typename Type>
233 template<
typename Type>
239 template<
typename Type>
244#ifndef DOXYGEN_DISABLE
247 template<
typename T_Type>
248 struct DataExtraction<T_Type, typename std::enable_if<std::is_floating_point<T_Type>::value>::type> {
253 using Identifier = int;
274 template<
typename T_InnerType>
275 struct DataExtraction<std::complex<T_InnerType>> {
278 using InnerType =
CODI_DD(T_InnerType, ActiveTypeProxy);
279 using Type = std::complex<T_InnerType>;
281 using InnerExtraction = DataExtraction<InnerType>;
283 using Real = std::complex<typename InnerExtraction::Real>;
284 using Identifier = std::complex<typename InnerExtraction::Identifier>;
288 InnerType
const* vArray =
reinterpret_cast<InnerType const*
>(&v);
290 return Real(InnerExtraction::getValue(vArray[0]), InnerExtraction::getValue(vArray[1]));
295 InnerType
const* vArray =
reinterpret_cast<InnerType const*
>(&v);
297 return Identifier(InnerExtraction::getIdentifier(vArray[0]), InnerExtraction::getIdentifier(vArray[1]));
302 InnerType* vArray =
reinterpret_cast<InnerType*
>(&v);
304 InnerExtraction::setValue(vArray[0], std::real(value));
305 InnerExtraction::setValue(vArray[1], std::imag(value));
310 template<
typename T_InnerType>
311 struct TapeRegistration<std::complex<T_InnerType>> {
315 using Type = std::complex<T_InnerType>;
317 using InnerRegistration = TapeRegistration<InnerType>;
323 InnerType* vArray =
reinterpret_cast<InnerType*
>(&v);
325 InnerRegistration::registerInput(vArray[0]);
326 InnerRegistration::registerInput(vArray[1]);
331 InnerType* vArray =
reinterpret_cast<InnerType*
>(&v);
333 InnerRegistration::registerOutput(vArray[0]);
334 InnerRegistration::registerOutput(vArray[1]);
339 InnerType* vArray =
reinterpret_cast<InnerType*
>(&v);
341 return Real(InnerRegistration::registerExternalFunctionOutput(vArray[0]),
342 InnerRegistration::registerExternalFunctionOutput(vArray[1]));
353 template<
typename Type>
358 template<
typename Expr>
363 template<
typename Type>
367 template<
typename Type>
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:98
#define CODI_STATIC_ASSERT(cond, message)
Static assert in CoDiPack.
Definition macros.hpp:123
typename std::enable_if< IsPassiveReal< Type >::value >::type EnableIfPassiveReal
Enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:368
typename TraitsImplementation< Type >::Real Real
Inner type of the real value.
Definition realTraits.hpp:113
PassiveReal< Type > const & getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:127
DataExtraction< Type >::Identifier registerExternalFunctionOutput(Type &v)
Register all active types of a aggregated type as external function outputs.
Definition realTraits.hpp:240
DataExtraction< Type >::Identifier getIdentifier(Type const &v)
Extract the identifiers from a type of aggregated active types.
Definition realTraits.hpp:216
size_t constexpr MaxDerivativeOrder()
CoDiPack derivative order of the type.
Definition realTraits.hpp:121
void setValue(Type &v, typename DataExtraction< Type >::Real const &value)
Set the primal values of a type of aggregated active types.
Definition realTraits.hpp:222
void registerInput(Type &v)
Register all active types of a aggregated type as tape input.
Definition realTraits.hpp:228
void registerOutput(Type &v)
Register all active types of a aggregated type as tape output.
Definition realTraits.hpp:234
bool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:133
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
typename std::enable_if<!IsPassiveReal< Type >::value >::type EnableIfNotPassiveReal
Negated enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:364
DataExtraction< Type >::Real getValue(Type const &v)
Extract the primal values from a type of aggregated active types.
Definition realTraits.hpp:210
bool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:139
std::is_same< Type, PassiveReal< Type > > IsPassiveReal
If the real type is not handled by CoDiPack.
Definition realTraits.hpp:354
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
bool isfinite(ExpressionInterface< Real, Arg > const &arg)
Function overload for isfinite.
Definition unaryOperators.hpp:539
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Function for checking if all values of the type are finite.
Definition realTraits.hpp:82
T_Type Type
See IsTotalFinite.
Definition realTraits.hpp:85
static bool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition realTraits.hpp:88
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:100
T_Type Type
See IsTotalZero.
Definition realTraits.hpp:103
static bool isTotalZero(Type const &v)
Checks if the values are completely zero.
Definition realTraits.hpp:106
Tape registration methods for aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:189
static Real registerExternalFunctionOutput(Type &v)
Register all active types of a aggregated type as external function outputs.
T_Type Type
See TapeRegistration.
Definition realTraits.hpp:194
static void registerOutput(Type &v)
Register all active types of a aggregated type as tape output.
static void registerInput(Type &v)
Register all active types of a aggregated type as tape input.
typename DataExtraction< Type >::Real Real
See DataExtraction::Real.
Definition realTraits.hpp:196
Common traits for all types used as real values.
Definition realTraits.hpp:60
static PassiveReal const & getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:71
static int constexpr MaxDerivativeOrder
CoDiPack derivative order of the type.
Definition realTraits.hpp:68
T_Type Type
See TraitsImplementation.
Definition realTraits.hpp:63
Type PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:66
Type Real
Inner type of the real value.
Definition realTraits.hpp:65