42#include "../misc/compileTimeLoop.hpp"
44#include "computationTraits.hpp"
45#include "expressionTraits.hpp"
50 template<
typename T_Real,
typename T_InnerActiveType,
typename T_Impl,
bool T_isStatic>
65 template<
typename T_Type,
typename =
void>
87 template<
typename T_Type,
typename =
void>
105 template<
typename T_Type,
typename =
void>
118 template<
typename Type>
122 template<
typename Type>
126 template<
typename Type>
132 template<
typename Type>
138 template<
typename Type>
144 template<
typename Type>
163 template<
typename T_Type,
typename =
void>
167 "Instantiation of unspecialized RealTraits::DataExtraction.");
171 using Real =
typename Type::Real;
196 template<
typename T_Type,
typename =
void>
200 "Instantiation of unspecialized RealTraits::TapeRegistration.");
225 template<
typename T_Type,
typename =
void>
239 "Instantiation of unspecialized AggregatedTypeTraits.");
248 template<
size_t element>
252 "Instantiation of unspecialized AggregatedTypeTraits.");
259 template<
size_t element>
263 "Instantiation of unspecialized AggregatedTypeTraits.");
269 template<
size_t element>
273 "Instantiation of unspecialized AggregatedTypeTraits.");
281 template<
size_t element>
285 "Instantiation of unspecialized AggregatedTypeTraits.");
293 "Instantiation of unspecialized AggregatedTypeTraits.");
300 template<
typename T_Type,
typename T_InnerType,
typename T_Real,
int T_Elements>
304 sizeof(T_Type) == T_Elements *
sizeof(T_InnerType),
305 "ArrayAggregatedTypeTraitsBase is designed for aggregated types that resemble arrays of their inner type."
306 " The sizes in the given instantiation do not match this use case.");
321 wArray[i.value] = v[i.value];
328 template<
size_t element>
335 return ComputationTraits::transpose(w_bArray[element]);
339 template<
size_t element>
343 return wArray[element];
347 template<
size_t element>
351 return wArray[element];
355 template<
size_t element>
366 w_bArray[element] = v_b;
373 template<
typename Type>
379 template<
typename Type>
385 template<
typename Type>
391 template<
typename Type>
397 template<
typename Type>
403 template<
typename Type>
414 template<
typename Type>
420 template<
typename Expr>
423 typename Expr::Impl, Expr::isStatic>,
427 template<
typename Type>
431 template<
typename Expr>
435 template<
typename Type>
439 template<
typename Type>
442#ifndef DOXYGEN_DISABLE
450 template<
typename T_Type>
451 struct DataExtraction<T_Type, typename std::enable_if<std::is_floating_point<T_Type>::value>::type> {
456 using Identifier = int;
482 template<
typename T_Type>
488 using TypeTraits = AggregatedTypeTraits<Type>;
489 using InnerType =
typename TypeTraits::InnerType;
490 static int constexpr Elements = TypeTraits::Elements;
492 using InnerDataExtraction = DataExtraction<InnerType>;
494 using Real =
typename TypeTraits::Real;
495 using Identifier = std::array<
CODI_DD(
typename InnerType::Identifier,
int), Elements>;
497 using RealTypeTraits = AggregatedTypeTraits<Real>;
504 RealTypeTraits::template arrayAccess<i.value>(
real) =
505 InnerDataExtraction::getValue(TypeTraits::template arrayAccess<i.value>(v));
516 res[i.value] = InnerDataExtraction::getIdentifier(TypeTraits::template arrayAccess<i.value>(v));
525 InnerDataExtraction::setValue(TypeTraits::template arrayAccess<i.value>(v),
526 RealTypeTraits::template arrayAccess<i.value>(value));
533 InnerDataExtraction::setIdentifier(TypeTraits::template arrayAccess<i.value>(v), identifier[i.value]);
539 template<
typename T_Type>
545 using TypeTraits = AggregatedTypeTraits<Type>;
546 using InnerType =
typename TypeTraits::InnerType;
547 static int constexpr Elements = TypeTraits::Elements;
549 using Real =
typename TypeTraits::Real;
551 using RealTypeTraits = RealTraits::AggregatedTypeTraits<Real>;
552 using InnerTraits = TapeRegistration<InnerType>;
557 InnerTraits::registerInput(TypeTraits::template arrayAccess<i.value>(v));
564 InnerTraits::registerOutput(TypeTraits::template arrayAccess<i.value>(v));
573 RealTypeTraits::template arrayAccess<i.value>(res) =
574 InnerTraits::registerExternalFunctionOutput(TypeTraits::template arrayAccess<i.value>(v));
580 template<
typename T_Type>
581 struct AggregatedTypeTraits<T_Type, typename std::enable_if<std::is_floating_point<T_Type>::value>::type>
584 template<
typename T_Type>
585 struct AggregatedTypeTraits<T_Type, typename std::enable_if<std::is_integral<T_Type>::value>::type>
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:100
#define CODI_STATIC_ASSERT(cond, message)
Static assert definition for CoDiPack. Not evaluated in IDE mode.
Definition macros.hpp:129
Traits for values that can be used as real values, e.g. double, float, codi::RealReverse etc....
Definition stdComplex.hpp:204
inlinebool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:139
typename std::enable_if<(AggregatedTypeTraits< Type >::Elements !=0) &(!ExpressionTraits::IsLhsExpression< Type >::value)>::type EnableIfAggregatedTypeTraitsIsSpecialized
Enable if helper when a type has been specialized for the AggregatedTypeTraits.
Definition realTraits.hpp:415
typename std::enable_if< IsPassiveReal< Type >::value >::type EnableIfPassiveReal
Enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:440
typename TraitsImplementation< Type >::Real Real
Inner type of the real value.
Definition realTraits.hpp:119
inlinetypename DataExtraction< Type >::Real registerExternalFunctionOutput(Type &v)
Register all active types of an aggregated type as external function outputs.
Definition realTraits.hpp:404
inlinebool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:145
inlinePassiveReal< Type > getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:133
inlinetypename DataExtraction< Type >::Identifier getIdentifier(Type const &v)
Extract an aggregate of identifiers from an aggregate of active types.
Definition realTraits.hpp:380
inlinesize_t constexpr MaxDerivativeOrder()
CoDiPack derivative order of the type.
Definition realTraits.hpp:127
typename enable_if_base_of< AggregatedActiveTypeBase< typename Expr::Real, typename Expr::InnerActiveType, typename Expr::Impl, Expr::isStatic >, Expr >::type EnableIfAggregatedActiveType
Enable if helper for AggregatedActiveType.
Definition realTraits.hpp:421
inlinetypename DataExtraction< Type >::Real getValue(Type const &v)
Extract an aggregate of primal values from an aggregate of active types.
Definition realTraits.hpp:374
bool constexpr isPassiveReal
Value entry of IsPassiveReal.
Definition realTraits.hpp:432
inlinevoid setValue(Type &v, typename DataExtraction< Type >::Real const &value)
Set the primal values of an aggregate of active types.
Definition realTraits.hpp:386
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
inlinevoid registerOutput(Type &v)
Register all active types of an aggregated type as tape outputs.
Definition realTraits.hpp:398
typename std::enable_if<!IsPassiveReal< Type >::value >::type EnableIfNotPassiveReal
Negated enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:436
inlinevoid registerInput(Type &v)
Register all active types of an aggregated type as tape inputs.
Definition realTraits.hpp:392
std::is_same< Type, PassiveReal< Type > > IsPassiveReal
If the real type is not handled by CoDiPack.
Definition realTraits.hpp:428
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
std::enable_if< std::is_base_of< Base, Impl >::value, R > enable_if_base_of
Enable if abbreviation for std::is_base_of.
Definition enableIfHelpers.hpp:47
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
inlinebool isfinite(ExpressionInterface< Real, Arg > const &arg)
Function overload for isfinite.
Definition unaryOperators.hpp:787
Defines an aggregated type via an array and implements the ExpressionInterface.
Definition aggregatedActiveType.hpp:59
If the expression inherits from LhsExpressionInterface. Is either std::false_type or std::true_type.
Definition expressionTraits.hpp:164
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:226
int InnerType
Definition realTraits.hpp:229
static int constexpr Elements
Definition realTraits.hpp:232
int Real
Definition realTraits.hpp:230
Real Type
Definition realTraits.hpp:228
inlinestatic InnerType & arrayAccess(Type &v)
Definition realTraits.hpp:270
static Type arrayConstructor(InnerType const *v)
Definition realTraits.hpp:236
static InnerType adjointOfConstructor(Type const &w, Type const &w_b)
Definition realTraits.hpp:249
static InnerType arrayAccess(Type const &w)
Definition realTraits.hpp:260
static Type adjointOfArrayAccess(Type const &w, InnerType const &v_b)
Definition realTraits.hpp:282
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition realTraits.hpp:291
Base implementation of AggregatedTypeTraits for aggregated types that can be defined as an array.
Definition realTraits.hpp:301
inlinestatic Type adjointOfArrayAccess(Type const &w, InnerType const &v_b)
Definition realTraits.hpp:356
T_Real Real
See AggregatedTypeTraits.
Definition realTraits.hpp:310
inlinestatic Type arrayConstructor(InnerType const *v)
Definition realTraits.hpp:315
static int constexpr Elements
See AggregatedTypeTraits.
Definition realTraits.hpp:312
T_InnerType InnerType
See AggregatedTypeTraits.
Definition realTraits.hpp:309
inlinestatic InnerType & arrayAccess(Type &w)
Definition realTraits.hpp:340
inlinestatic InnerType const & arrayAccess(Type const &w)
Definition realTraits.hpp:348
T_Type Type
See AggregatedTypeTraits.
Definition realTraits.hpp:308
inlinestatic InnerType adjointOfConstructor(Type const &w, Type const &w_b)
Definition realTraits.hpp:329
Function for checking if all values of the type are finite.
Definition realTraits.hpp:88
T_Type Type
See IsTotalFinite.
Definition realTraits.hpp:91
static inlinebool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition realTraits.hpp:94
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:106
T_Type Type
See IsTotalZero.
Definition realTraits.hpp:109
static inlinebool isTotalZero(Type const &v)
Checks if the values are completely zero.
Definition realTraits.hpp:112
Tape registration methods for aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:197
T_Type Type
See TapeRegistration.
Definition realTraits.hpp:202
inlinestatic void registerInput(Type &v)
Register all active types of an aggregated type as tape inputs.
inlinestatic void registerOutput(Type &v)
Register all active types of an aggregated type as tape outputs.
typename DataExtraction< Type >::Real Real
See DataExtraction::Real.
Definition realTraits.hpp:204
inlinestatic Real registerExternalFunctionOutput(Type &v)
Register all active types of an aggregated type as external function outputs.
Common traits for all types used as real values.
Definition realTraits.hpp:66
static int constexpr MaxDerivativeOrder
CoDiPack derivative order of the type.
Definition realTraits.hpp:74
T_Type Type
See TraitsImplementation.
Definition realTraits.hpp:69
static inlinePassiveReal getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:77
Type PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:72
Type Real
Inner type of the real value.
Definition realTraits.hpp:71