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