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;
203 template<
typename T_Type,
typename =
void>
207 "Instantiation of unspecialized RealTraits::TapeRegistration.");
232 template<
typename T_Type,
typename =
void>
246 "Instantiation of unspecialized AggregatedTypeTraits.");
255 template<
size_t element>
259 "Instantiation of unspecialized AggregatedTypeTraits.");
266 template<
size_t element>
270 "Instantiation of unspecialized AggregatedTypeTraits.");
276 template<
size_t element>
280 "Instantiation of unspecialized AggregatedTypeTraits.");
288 template<
size_t element>
292 "Instantiation of unspecialized AggregatedTypeTraits.");
300 "Instantiation of unspecialized AggregatedTypeTraits.");
307 template<
typename T_Type,
typename T_InnerType,
typename T_Real,
int T_Elements>
311 sizeof(T_Type) == T_Elements *
sizeof(T_InnerType),
312 "ArrayAggregatedTypeTraitsBase is designed for aggregated types that resemble arrays of their inner type."
313 " The sizes in the given instantiation do not match this use case.");
328 wArray[i.value] = v[i.value];
335 template<
size_t element>
342 return ComputationTraits::transpose(w_bArray[element]);
346 template<
size_t element>
350 return wArray[element];
354 template<
size_t element>
358 return wArray[element];
362 template<
size_t element>
373 w_bArray[element] = v_b;
380 template<
typename Type>
386 template<
typename Type>
392 template<
typename Type>
398 template<
typename Type>
404 template<
typename Type>
410 template<
typename Type>
421 template<
typename Type>
427 template<
typename Expr>
430 typename Expr::Impl, Expr::isStatic>,
434 template<
typename Type>
438 template<
typename Expr>
442 template<
typename Type>
446 template<
typename Type>
449#ifndef DOXYGEN_DISABLE
457 template<
typename T_Type>
458 struct DataExtraction<T_Type, typename std::enable_if<std::is_floating_point<T_Type>::value>::type> {
463 using Identifier = int;
502 template<
typename T_Type>
508 using TypeTraits = AggregatedTypeTraits<Type>;
509 using InnerType =
typename TypeTraits::InnerType;
510 static int constexpr Elements = TypeTraits::Elements;
512 using InnerDataExtraction = DataExtraction<InnerType>;
514 using Real =
typename TypeTraits::Real;
515 using Identifier = std::array<
CODI_DD(
typename InnerType::Identifier,
int), Elements>;
516 using TapeData = std::array<
CODI_DD(
typename InnerType::TapeData,
int), Elements>;
518 using RealTypeTraits = AggregatedTypeTraits<Real>;
525 RealTypeTraits::template arrayAccess<i.value>(
real) =
526 InnerDataExtraction::getValue(TypeTraits::template arrayAccess<i.value>(v));
537 res[i.value] = InnerDataExtraction::getIdentifier(TypeTraits::template arrayAccess<i.value>(v));
548 res[i.value] = InnerDataExtraction::getTapeData(TypeTraits::template arrayAccess<i.value>(v));
557 InnerDataExtraction::setValue(TypeTraits::template arrayAccess<i.value>(v),
558 RealTypeTraits::template arrayAccess<i.value>(value));
565 InnerDataExtraction::setIdentifier(TypeTraits::template arrayAccess<i.value>(v), identifier[i.value]);
572 InnerDataExtraction::setTapeData(TypeTraits::template arrayAccess<i.value>(v), data[i.value]);
578 template<
typename T_Type>
584 using TypeTraits = AggregatedTypeTraits<Type>;
585 using InnerType =
typename TypeTraits::InnerType;
586 static int constexpr Elements = TypeTraits::Elements;
588 using Real =
typename TypeTraits::Real;
590 using RealTypeTraits = RealTraits::AggregatedTypeTraits<Real>;
591 using InnerTraits = TapeRegistration<InnerType>;
596 InnerTraits::registerInput(TypeTraits::template arrayAccess<i.value>(v));
603 InnerTraits::registerOutput(TypeTraits::template arrayAccess<i.value>(v));
612 RealTypeTraits::template arrayAccess<i.value>(res) =
613 InnerTraits::registerExternalFunctionOutput(TypeTraits::template arrayAccess<i.value>(v));
619 template<
typename T_Type>
620 struct AggregatedTypeTraits<T_Type, typename std::enable_if<std::is_floating_point<T_Type>::value>::type>
623 template<
typename T_Type>
624 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:97
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:101
#define CODI_STATIC_ASSERT(cond, message)
Static assert definition for CoDiPack. Not evaluated in IDE mode.
Definition macros.hpp:130
Traits for values that can be used as real values, e.g. double, float, codi::RealReverse etc....
Definition stdComplex.hpp:242
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:422
typename std::enable_if< IsPassiveReal< Type >::value >::type EnableIfPassiveReal
Enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:447
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:411
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:387
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:428
inlinetypename DataExtraction< Type >::Real getValue(Type const &v)
Extract an aggregate of primal values from an aggregate of active types.
Definition realTraits.hpp:381
bool constexpr isPassiveReal
Value entry of IsPassiveReal.
Definition realTraits.hpp:439
inlinevoid setValue(Type &v, typename DataExtraction< Type >::Real const &value)
Set the primal values of an aggregate of active types.
Definition realTraits.hpp:393
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:405
typename std::enable_if<!IsPassiveReal< Type >::value >::type EnableIfNotPassiveReal
Negated enable if wrapper for IsPassiveReal.
Definition realTraits.hpp:443
inlinevoid registerInput(Type &v)
Register all active types of an aggregated type as tape inputs.
Definition realTraits.hpp:399
std::is_same< Type, PassiveReal< Type > > IsPassiveReal
If the real type is not handled by CoDiPack.
Definition realTraits.hpp:435
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
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:55
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:179
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:233
int InnerType
Definition realTraits.hpp:236
static int constexpr Elements
Definition realTraits.hpp:239
int Real
Definition realTraits.hpp:237
Real Type
Definition realTraits.hpp:235
inlinestatic InnerType & arrayAccess(Type &v)
Definition realTraits.hpp:277
static Type arrayConstructor(InnerType const *v)
Definition realTraits.hpp:243
static InnerType adjointOfConstructor(Type const &w, Type const &w_b)
Definition realTraits.hpp:256
static InnerType arrayAccess(Type const &w)
Definition realTraits.hpp:267
static Type adjointOfArrayAccess(Type const &w, InnerType const &v_b)
Definition realTraits.hpp:289
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition realTraits.hpp:298
Base implementation of AggregatedTypeTraits for aggregated types that can be defined as an array.
Definition realTraits.hpp:308
inlinestatic Type adjointOfArrayAccess(Type const &w, InnerType const &v_b)
Definition realTraits.hpp:363
T_Real Real
See AggregatedTypeTraits.
Definition realTraits.hpp:317
inlinestatic Type arrayConstructor(InnerType const *v)
Definition realTraits.hpp:322
static int constexpr Elements
See AggregatedTypeTraits.
Definition realTraits.hpp:319
T_InnerType InnerType
See AggregatedTypeTraits.
Definition realTraits.hpp:316
inlinestatic InnerType & arrayAccess(Type &w)
Definition realTraits.hpp:347
inlinestatic InnerType const & arrayAccess(Type const &w)
Definition realTraits.hpp:355
T_Type Type
See AggregatedTypeTraits.
Definition realTraits.hpp:315
inlinestatic InnerType adjointOfConstructor(Type const &w, Type const &w_b)
Definition realTraits.hpp:336
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:204
T_Type Type
See TapeRegistration.
Definition realTraits.hpp:209
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:211
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