Reference documentation for deal.II version GIT relicensing-837-gaf73e64026 2024-06-15 22:40:02+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
28
29
30/* ------ ADOL-C taped (Differentiation::AD::NumberTypes::adolc_taped) ----- */
31
32
33namespace internal
34{
35 template <>
36 struct ProductTypeImpl<adouble, adouble>
37 {
38 using type = adouble;
39 };
40
41 // Typedefs for "adub"s are all that's necessary to ensure that no temporary
42 // ADOL-C types "adub" are created when a scalar product is performed. If this
43 // is not done, then intermediate tensors are filled with unconstructable
44 // types.
45 template <>
46 struct ProductTypeImpl<adub, adouble>
47 {
48 using type = adouble;
49 };
50
51 template <>
52 struct ProductTypeImpl<adouble, adub>
53 {
54 using type = adouble;
55 };
56
57 /* --- Double --- */
58
59 template <>
60 struct ProductTypeImpl<double, adouble>
61 {
62 using type = adouble;
63 };
64
65 template <>
66 struct ProductTypeImpl<adouble, double>
67 {
68 using type = adouble;
69 };
70
71 template <>
72 struct ProductTypeImpl<double, adub>
73 {
74 using type = adouble;
75 };
76
77 template <>
78 struct ProductTypeImpl<adub, double>
79 {
80 using type = adouble;
81 };
82
83 /* --- Float --- */
84
85 template <>
86 struct ProductTypeImpl<float, adouble>
87 {
88 using type = adouble;
89 };
90
91 template <>
92 struct ProductTypeImpl<adouble, float>
93 {
94 using type = adouble;
95 };
96
97 template <>
98 struct ProductTypeImpl<float, adub>
99 {
100 using type = adouble;
101 };
102
103 template <>
104 struct ProductTypeImpl<adub, float>
105 {
106 using type = adouble;
107 };
108
109 /* --- Complex double --- */
110
111 template <>
112 struct ProductTypeImpl<std::complex<double>, std::complex<adouble>>
113 {
114 using type = std::complex<adouble>;
115 };
116
117 template <>
118 struct ProductTypeImpl<std::complex<adouble>, std::complex<double>>
119 {
120 using type = std::complex<adouble>;
121 };
122
123 template <>
124 struct ProductTypeImpl<std::complex<adouble>, std::complex<adouble>>
125 {
126 using type = std::complex<adouble>;
127 };
128
129 template <>
130 struct ProductTypeImpl<std::complex<adub>, std::complex<adouble>>
131 {
132 using type = std::complex<adouble>;
133 };
134
135 template <>
136 struct ProductTypeImpl<std::complex<adouble>, std::complex<adub>>
137 {
138 using type = std::complex<adouble>;
139 };
140
141 /* --- Complex float --- */
142
143 template <>
144 struct ProductTypeImpl<std::complex<float>, std::complex<adouble>>
145 {
146 using type = std::complex<adouble>;
147 };
148
149 template <>
150 struct ProductTypeImpl<std::complex<adouble>, std::complex<float>>
151 {
152 using type = std::complex<adouble>;
153 };
154
155} // namespace internal
156
157template <>
158struct EnableIfScalar<adouble>
159{
160 using type = adouble;
161};
162
163template <>
164struct EnableIfScalar<std::complex<adouble>>
165{
166 using type = std::complex<adouble>;
167};
168
169
170template <>
171struct EnableIfScalar<adub>
172{
173 using type = adouble;
174};
175
176
177template <>
178struct EnableIfScalar<std::complex<adub>>
179{
180 using type = std::complex<adouble>;
181};
182
183
184/* -- ADOL-C tapeless (Differentiation::AD::NumberTypes::adolc_tapeless) -- */
185
186
187namespace internal
188{
189 /* --- Double --- */
190
191 template <>
192 struct ProductTypeImpl<double, adtl::adouble>
193 {
194 using type = adtl::adouble;
195 };
196
197 template <>
198 struct ProductTypeImpl<adtl::adouble, double>
199 {
200 using type = adtl::adouble;
201 };
202
203 template <>
204 struct ProductTypeImpl<adtl::adouble, adtl::adouble>
205 {
206 using type = adtl::adouble;
207 };
208
209 /* --- Float --- */
210
211 template <>
212 struct ProductTypeImpl<float, adtl::adouble>
213 {
214 using type = adtl::adouble;
215 };
216
217 template <>
218 struct ProductTypeImpl<adtl::adouble, float>
219 {
220 using type = adtl::adouble;
221 };
222
223 /* --- Complex double --- */
224
225 template <>
226 struct ProductTypeImpl<std::complex<double>, std::complex<adtl::adouble>>
227 {
228 using type = std::complex<adtl::adouble>;
229 };
230
231 template <>
232 struct ProductTypeImpl<std::complex<adtl::adouble>, std::complex<double>>
233 {
234 using type = std::complex<adtl::adouble>;
235 };
236
237 template <>
238 struct ProductTypeImpl<std::complex<adtl::adouble>,
239 std::complex<adtl::adouble>>
240 {
241 using type = std::complex<adtl::adouble>;
242 };
243
244 /* --- Complex float --- */
245
246 template <>
247 struct ProductTypeImpl<std::complex<float>, std::complex<adtl::adouble>>
248 {
249 using type = std::complex<adtl::adouble>;
250 };
251
252 template <>
253 struct ProductTypeImpl<std::complex<adtl::adouble>, std::complex<float>>
254 {
255 using type = std::complex<adtl::adouble>;
256 };
257
258} // namespace internal
259
260
261template <>
262struct EnableIfScalar<adtl::adouble>
263{
264 using type = adtl::adouble;
265};
266
267
268template <>
269struct EnableIfScalar<std::complex<adtl::adouble>>
270{
271 using type = std::complex<adtl::adouble>;
272};
273
274
276
277#endif // DEAL_II_WITH_ADOLC
278
279#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
Definition numbers.h:53
STL namespace.