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