deal.II version GIT relicensing-2574-g486eec3ad1 2025-02-07 04:40:00+00:00
\(\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
adolc_product_types.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2017 - 2018 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_differentiation_ad_adolc_product_types_h
16#define dealii_differentiation_ad_adolc_product_types_h
17
18#include <deal.II/base/config.h>
19
20#ifdef DEAL_II_WITH_ADOLC
21
23
24# include <adolc/adouble.h> // Taped double
25# include <adolc/adtl.h> // Tapeless double
26
27# include <complex>
28
29
31
32
33/* ------ ADOL-C taped (Differentiation::AD::NumberTypes::adolc_taped) ----- */
34
35
36namespace internal
37{
38 template <>
39 struct ProductTypeImpl<adouble, adouble>
40 {
41 using type = adouble;
42 };
43
44 // Typedefs for "adub"s are all that's necessary to ensure that no temporary
45 // ADOL-C types "adub" are created when a scalar product is performed. If this
46 // is not done, then intermediate tensors are filled with unconstructable
47 // types.
48 template <>
49 struct ProductTypeImpl<adub, adouble>
50 {
51 using type = adouble;
52 };
53
54 template <>
55 struct ProductTypeImpl<adouble, adub>
56 {
57 using type = adouble;
58 };
59
60 /* --- Double --- */
61
62 template <>
63 struct ProductTypeImpl<double, adouble>
64 {
65 using type = adouble;
66 };
67
68 template <>
69 struct ProductTypeImpl<adouble, double>
70 {
71 using type = adouble;
72 };
73
74 template <>
75 struct ProductTypeImpl<double, adub>
76 {
77 using type = adouble;
78 };
79
80 template <>
81 struct ProductTypeImpl<adub, double>
82 {
83 using type = adouble;
84 };
85
86 /* --- Float --- */
87
88 template <>
89 struct ProductTypeImpl<float, adouble>
90 {
91 using type = adouble;
92 };
93
94 template <>
95 struct ProductTypeImpl<adouble, float>
96 {
97 using type = adouble;
98 };
99
100 template <>
101 struct ProductTypeImpl<float, adub>
102 {
103 using type = adouble;
104 };
105
106 template <>
107 struct ProductTypeImpl<adub, float>
108 {
109 using type = adouble;
110 };
111
112 /* --- Complex double --- */
113
114 template <>
115 struct ProductTypeImpl<std::complex<double>, std::complex<adouble>>
116 {
117 using type = std::complex<adouble>;
118 };
119
120 template <>
121 struct ProductTypeImpl<std::complex<adouble>, std::complex<double>>
122 {
123 using type = std::complex<adouble>;
124 };
125
126 template <>
127 struct ProductTypeImpl<std::complex<adouble>, std::complex<adouble>>
128 {
129 using type = std::complex<adouble>;
130 };
131
132 template <>
133 struct ProductTypeImpl<std::complex<adub>, std::complex<adouble>>
134 {
135 using type = std::complex<adouble>;
136 };
137
138 template <>
139 struct ProductTypeImpl<std::complex<adouble>, std::complex<adub>>
140 {
141 using type = std::complex<adouble>;
142 };
143
144 /* --- Complex float --- */
145
146 template <>
147 struct ProductTypeImpl<std::complex<float>, std::complex<adouble>>
148 {
149 using type = std::complex<adouble>;
150 };
151
152 template <>
153 struct ProductTypeImpl<std::complex<adouble>, std::complex<float>>
154 {
155 using type = std::complex<adouble>;
156 };
157
158} // namespace internal
159
160template <>
161struct EnableIfScalar<adouble>
162{
163 using type = adouble;
164};
165
166template <>
167struct EnableIfScalar<std::complex<adouble>>
168{
169 using type = std::complex<adouble>;
170};
171
172
173template <>
174struct EnableIfScalar<adub>
175{
176 using type = adouble;
177};
178
179
180template <>
181struct EnableIfScalar<std::complex<adub>>
182{
183 using type = std::complex<adouble>;
184};
185
186
187/* -- ADOL-C tapeless (Differentiation::AD::NumberTypes::adolc_tapeless) -- */
188
189
190namespace internal
191{
192 /* --- Double --- */
193
194 template <>
195 struct ProductTypeImpl<double, adtl::adouble>
196 {
197 using type = adtl::adouble;
198 };
199
200 template <>
201 struct ProductTypeImpl<adtl::adouble, double>
202 {
203 using type = adtl::adouble;
204 };
205
206 template <>
207 struct ProductTypeImpl<adtl::adouble, adtl::adouble>
208 {
209 using type = adtl::adouble;
210 };
211
212 /* --- Float --- */
213
214 template <>
215 struct ProductTypeImpl<float, adtl::adouble>
216 {
217 using type = adtl::adouble;
218 };
219
220 template <>
221 struct ProductTypeImpl<adtl::adouble, float>
222 {
223 using type = adtl::adouble;
224 };
225
226 /* --- Complex double --- */
227
228 template <>
229 struct ProductTypeImpl<std::complex<double>, std::complex<adtl::adouble>>
230 {
231 using type = std::complex<adtl::adouble>;
232 };
233
234 template <>
235 struct ProductTypeImpl<std::complex<adtl::adouble>, std::complex<double>>
236 {
237 using type = std::complex<adtl::adouble>;
238 };
239
240 template <>
241 struct ProductTypeImpl<std::complex<adtl::adouble>,
242 std::complex<adtl::adouble>>
243 {
244 using type = std::complex<adtl::adouble>;
245 };
246
247 /* --- Complex float --- */
248
249 template <>
250 struct ProductTypeImpl<std::complex<float>, std::complex<adtl::adouble>>
251 {
252 using type = std::complex<adtl::adouble>;
253 };
254
255 template <>
256 struct ProductTypeImpl<std::complex<adtl::adouble>, std::complex<float>>
257 {
258 using type = std::complex<adtl::adouble>;
259 };
260
261} // namespace internal
262
263
264template <>
265struct EnableIfScalar<adtl::adouble>
266{
267 using type = adtl::adouble;
268};
269
270
271template <>
272struct EnableIfScalar<std::complex<adtl::adouble>>
273{
274 using type = std::complex<adtl::adouble>;
275};
276
277
279
280#endif // DEAL_II_WITH_ADOLC
281
282#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
Definition numbers.h:48
STL namespace.