Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
sacado_product_types.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2015 - 2018 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_differentiation_ad_sacado_product_types_h
17#define dealii_differentiation_ad_sacado_product_types_h
18
19#include <deal.II/base/config.h>
20
22
23#ifdef DEAL_II_TRILINOS_WITH_SACADO
24
25# include <Sacado.hpp>
26// It appears that some versions of Trilinos do not directly or indirectly
27// include all the headers for all forward and reverse Sacado AD types.
28// So we directly include these both here as a precaution.
29// Standard forward AD classes (templated)
30# include <Sacado_Fad_DFad.hpp>
31// Reverse AD classes (templated)
32# include <Sacado_trad.hpp>
33
35
36
37/* -------------- Sacado::Fad::DFad
38 * (Differentiation::AD::NumberTypes::[sacado_fad/sacado_fad_fad])
39 * -------------- */
40
41
42namespace internal
43{
44 template <typename T>
45 struct ProductTypeImpl<Sacado::Fad::DFad<T>, float>
46 {
47 using type = Sacado::Fad::DFad<T>;
48 };
49
50 template <typename T>
51 struct ProductTypeImpl<float, Sacado::Fad::DFad<T>>
52 {
53 using type = Sacado::Fad::DFad<T>;
54 };
55
56 template <typename T>
57 struct ProductTypeImpl<Sacado::Fad::DFad<T>, double>
58 {
59 using type = Sacado::Fad::DFad<T>;
60 };
61
62 template <typename T>
63 struct ProductTypeImpl<double, Sacado::Fad::DFad<T>>
64 {
65 using type = Sacado::Fad::DFad<T>;
66 };
67
68 template <typename T>
69 struct ProductTypeImpl<Sacado::Fad::DFad<T>, int>
70 {
71 using type = Sacado::Fad::DFad<T>;
72 };
73
74 template <typename T>
75 struct ProductTypeImpl<int, Sacado::Fad::DFad<T>>
76 {
77 using type = Sacado::Fad::DFad<T>;
78 };
79
80 template <typename T, typename U>
81 struct ProductTypeImpl<Sacado::Fad::DFad<T>, Sacado::Fad::DFad<U>>
82 {
83 using type = Sacado::Fad::DFad<typename ProductType<T, U>::type>;
84 };
85
86
87 // Sacado::Fad::Dfad expression templates
88 // We demote the result of the expression template operations
89 // to a Sacado::Fad::Dfad itself. This is the only way to retain
90 // consistency between the number type going into a complex chain of
91 // (potentially branching) operations and that coming out of them.
92
93 template <typename T, typename U>
94 struct ProductTypeImpl<Sacado::Fad::Expr<T>, U>
95 {
96 using type =
98 };
99
100 template <typename T, typename U>
101 struct ProductTypeImpl<T, Sacado::Fad::Expr<U>>
102 {
103 using type =
105 };
106
107 template <typename T, typename U>
108 struct ProductTypeImpl<Sacado::Fad::Expr<T>, Sacado::Fad::Expr<U>>
109 {
110 using type =
112 typename Sacado::Fad::Expr<U>::value_type>::type;
113 };
114
115} // namespace internal
116
117
118template <typename T>
119struct EnableIfScalar<Sacado::Fad::DFad<T>>
120{
121 using type = Sacado::Fad::DFad<T>;
122};
123
124template <typename T>
125struct EnableIfScalar<Sacado::Fad::Expr<T>>
126{
127 using type = typename Sacado::Fad::Expr<T>::value_type;
128};
129
130
131/* -------------- Sacado::Rad::ADvar
132 * (Differentiation::AD::NumberTypes::[sacado_rad/sacado_rad_fad])
133 * -------------- */
134
135
136namespace internal
137{
138 template <typename T>
139 struct ProductTypeImpl<Sacado::Rad::ADvar<T>, float>
140 {
141 using type = Sacado::Rad::ADvar<T>;
142 };
143
144 template <typename T>
145 struct ProductTypeImpl<float, Sacado::Rad::ADvar<T>>
146 {
147 using type = Sacado::Rad::ADvar<T>;
148 };
149
150 template <typename T>
151 struct ProductTypeImpl<Sacado::Rad::ADvar<T>, double>
152 {
153 using type = Sacado::Rad::ADvar<T>;
154 };
155
156 template <typename T>
157 struct ProductTypeImpl<double, Sacado::Rad::ADvar<T>>
158 {
159 using type = Sacado::Rad::ADvar<T>;
160 };
161
162 template <typename T>
163 struct ProductTypeImpl<Sacado::Rad::ADvar<T>, int>
164 {
165 using type = Sacado::Rad::ADvar<T>;
166 };
167
168 template <typename T>
169 struct ProductTypeImpl<int, Sacado::Rad::ADvar<T>>
170 {
171 using type = Sacado::Rad::ADvar<T>;
172 };
173
174 template <typename T, typename U>
175 struct ProductTypeImpl<Sacado::Rad::ADvar<T>, Sacado::Rad::ADvar<U>>
176 {
177 using type = Sacado::Rad::ADvar<typename ProductType<T, U>::type>;
178 };
179
180 /* --- Sacado::Rad::ADvar: Temporary type --- */
181
182 template <typename T>
183 struct ProductTypeImpl<Sacado::Rad::ADvari<T>, float>
184 {
185 using type = Sacado::Rad::ADvari<T>;
186 };
187
188 template <typename T>
189 struct ProductTypeImpl<float, Sacado::Rad::ADvari<T>>
190 {
191 using type = Sacado::Rad::ADvari<T>;
192 };
193
194 template <typename T>
195 struct ProductTypeImpl<Sacado::Rad::ADvari<T>, double>
196 {
197 using type = Sacado::Rad::ADvari<T>;
198 };
199
200 template <typename T>
201 struct ProductTypeImpl<double, Sacado::Rad::ADvari<T>>
202 {
203 using type = Sacado::Rad::ADvari<T>;
204 };
205
206 template <typename T>
207 struct ProductTypeImpl<Sacado::Rad::ADvari<T>, int>
208 {
209 using type = Sacado::Rad::ADvari<T>;
210 };
211
212 template <typename T>
213 struct ProductTypeImpl<int, Sacado::Rad::ADvari<T>>
214 {
215 using type = Sacado::Rad::ADvari<T>;
216 };
217
218 template <typename T, typename U>
219 struct ProductTypeImpl<Sacado::Rad::ADvari<T>, Sacado::Rad::ADvari<U>>
220 {
221 using type = Sacado::Rad::ADvari<typename ProductType<T, U>::type>;
222 };
223
224 /* --- Sacado::Rad::ADvar: Main and temporary type --- */
225
226 template <typename T, typename U>
227 struct ProductTypeImpl<Sacado::Rad::ADvar<T>, Sacado::Rad::ADvari<U>>
228 {
229 using type = Sacado::Rad::ADvar<typename ProductType<T, U>::type>;
230 };
231
232 template <typename T, typename U>
233 struct ProductTypeImpl<Sacado::Rad::ADvari<T>, Sacado::Rad::ADvar<U>>
234 {
235 using type = Sacado::Rad::ADvar<typename ProductType<T, U>::type>;
236 };
237
238} // namespace internal
239
240
241template <typename T>
242struct EnableIfScalar<Sacado::Rad::ADvar<T>>
243{
244 using type = Sacado::Rad::ADvar<T>;
245};
246
247
248template <typename T>
249struct EnableIfScalar<Sacado::Rad::ADvari<T>>
250{
251 using type = Sacado::Rad::ADvari<T>;
252};
253
254
256
257#endif // DEAL_II_TRILINOS_WITH_SACADO
258
259#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
typename Sacado::Fad::Expr< T >::value_type type
Sacado::Fad::DFad< typename ProductType< T, U >::type > type
typename ProductType< typename Sacado::Fad::Expr< T >::value_type, typename Sacado::Fad::Expr< U >::value_type >::type type
typename ProductType< typename Sacado::Fad::Expr< T >::value_type, U >::type type
typename ProductType< T, typename Sacado::Fad::Expr< U >::value_type >::type type
decltype(std::declval< T >() *std::declval< U >()) type