1 #ifndef __DUNE_ACFEM_TENSORS_OPERATIONS_AUTODIFF_PLACEHOLDERTRAITS_HH__
2 #define __DUNE_ACFEM_TENSORS_OPERATIONS_AUTODIFF_PLACEHOLDERTRAITS_HH__
4 #include "../indeterminate.hh"
5 #include "../placeholder.hh"
13 template<std::
size_t Id,
class Signature,
class T,
class DT>
14 class AutoDiffPlaceholder;
17 struct IsAutoDiffPlaceholder
22 struct IsAutoDiffPlaceholder<T&>
23 : IsAutoDiffPlaceholder<std::decay_t<T> >
27 struct IsAutoDiffPlaceholder<T&&>
28 : IsAutoDiffPlaceholder<std::decay_t<T> >
31 template<std::
size_t Id,
class Signature,
class T,
class DT>
32 struct IsAutoDiffPlaceholder<AutoDiffPlaceholder<Id, Signature, T, DT> >
36 template<
class T,
class SFINAE =
void>
39 static constexpr std::size_t depth_ = 0;
43 struct AutoDiffTraits<T, std::enable_if_t<!IsDecay<T>::value> >
44 : AutoDiffTraits<std::decay_t<T> >
47 template<std::
size_t Id,
class Signature,
class T,
class DT>
48 struct AutoDiffTraits<AutoDiffPlaceholder<Id, Signature, T, DT> >
50 static constexpr std::size_t id_ = Id;
51 using IdType = IndexConstant<Id>;
52 using IndeterminateSignature = Signature;
54 using DerivativeType = DT;
55 static constexpr std::size_t depth_ = AutoDiffTraits<DT>::depth_ + 1;
56 using DepthType = IndexConstant<depth_>;
60 template<std::
size_t N,
class T,
class SFINAE =
void>
61 struct AutoDiffOfDepthHelper;
64 struct AutoDiffOfDepthHelper<0, T, std::enable_if_t<!IsAutoDiffPlaceholder<T>::value> >
70 struct AutoDiffOfDepthHelper<0, T, std::enable_if_t<IsAutoDiffPlaceholder<T>::value> >
72 using Type =
typename AutoDiffTraits<T>::ValuesType;
75 template<std::
size_t N,
class T>
76 struct AutoDiffOfDepthHelper<N, T, std::enable_if_t<IsAutoDiffPlaceholder<T>::value> >
78 static_assert(N <= AutoDiffTraits<T>::depth_,
"Not so many levels of AD available...");
79 using Type = AutoDiffPlaceholder<
80 AutoDiffTraits<T>::id_,
81 typename AutoDiffTraits<T>::IndeterminateSignature,
82 typename AutoDiffTraits<T>::ValuesType,
83 typename AutoDiffOfDepthHelper<N-1,
typename AutoDiffTraits<T>::DerivativeType>::Type>;
88 template<std::
size_t N,
class T>
89 using AutoDiffOfDepth =
typename AutoDiffOfDepthHelper<N, T>::Type;
94 template<
class T,
class Ids,
class... Signature>
99 template<
class T, std::
size_t Id,
class Signature,
class SFINAE =
void>
100 struct IsSingleMatchingAutoDiffPlaceholder
102 && typename AutoDiffTraits<T>::IndeterminateSignature{} == Signature{})>
105 template<
class T, std::
size_t Id,
class Signature>
106 struct IsSingleMatchingAutoDiffPlaceholder<
107 T, Id, Signature, std::enable_if_t<!IsAutoDiffPlaceholder<T>::value> >
112 struct IsMatchingAutoDiffPlaceholder<T, Seq<> >
116 template<
class T, std::
size_t Id,
class Signature>
117 struct IsMatchingAutoDiffPlaceholder<T, Seq<Id>, Signature>
118 : IsSingleMatchingAutoDiffPlaceholder<T, Id, Signature>
122 std::size_t Id0, std::size_t Id1, std::size_t... RestId,
123 class Sig0,
class Sig1,
class... RestSig>
124 struct IsMatchingAutoDiffPlaceholder<T, Seq<Id0, Id1, RestId...>, Sig0, Sig1, RestSig...>
125 :
BoolConstant<(IsSingleMatchingAutoDiffPlaceholder<T, Id0, Sig0>::value
126 && IsMatchingAutoDiffPlaceholder<T, Seq<Id1, RestId...>, Sig1, RestSig...>::value
130 template<std::
size_t Id,
class Signature,
class T,
class DT>
131 struct HasSpecializedExpressionTraits<Tensor::AutoDiffPlaceholder<Id, Signature, T, DT> >
138 template<std::
size_t Id,
class Signature,
class T,
class DT>
142 static constexpr
bool isVolatile =
true;
147 template<std::
size_t Id,
class Signature,
class T,
class DT>
148 struct FieldTraits<ACFem::Tensor::AutoDiffPlaceholder<Id, Signature, T, DT> >
149 : FieldTraits<std::decay_t<T> >
Constant< bool, V > BoolConstant
Short-cut for integral constant of type bool.
Definition: types.hh:48
BoolConstant< false > FalseType
Alias for std::false_type.
Definition: types.hh:110
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107
Default expression traits definition is a recursion in order to ease disambiguation.
Definition: expressiontraits.hh:54
Check whehter T is a placeholder which matches the givens indeterminate ids and signature.
Definition: placeholdertraits.hh:97