Debian Codegraph @

packages/stokhos/src/sacado/kokkos/Stokhos_Sacado_Kokkos_MathFunctions.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
11 #define STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
12
13 #include <cmath>
14
15 #include "Stokhos_ConfigDefs.h"
16
17 #include "Kokkos_Macros.hpp"
18
19 #ifdef HAVE_STOKHOS_ENSEMBLE_SCALAR_TYPE
20
21 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
22 #define UNARYFUNC_MACRO_SFS(OP,FADOP) \
23 namespace Stokhos { \
24 template <typename O, typename T, int N, typename D> \
25 class StaticFixedStorage; \
26 } \
27 namespace Sacado { \
28 namespace MP { \
29 template <typename S> class Vector; \
30 template <typename O, typename T, int N, typename D> \
31 KOKKOS_INLINE_FUNCTION \
32 Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
33 OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
34 } \
35 }
36 #else
37 #define UNARYFUNC_MACRO_SFS(OP,FADOP) /* */
38 #endif
39
40 #define UNARYFUNC_MACRO(OP,FADOP) \
41 UNARYFUNC_MACRO_SFS(OP,FADOP) \
42 namespace Sacado { \
43 \
44 namespace MP { \
45 template <typename T> class FADOP; \
46 template <typename T> class Expr; \
47 \
48 template <typename T> \
49 KOKKOS_INLINE_FUNCTION \
50 FADOP< T > \
51 OP (const Expr<T>&); \
52 } \
53 \
54 } \
55 \
56 namespace std { \
57 using Sacado::MP::OP; \
58 }
59
60 UNARYFUNC_MACRO(exp, ExpOp)
61 UNARYFUNC_MACRO(log, LogOp)
62 UNARYFUNC_MACRO(log10, Log10Op)
63 UNARYFUNC_MACRO(sqrt, SqrtOp)
64 UNARYFUNC_MACRO(cbrt, CbrtOp)
65 UNARYFUNC_MACRO(cos, CosOp)
66 UNARYFUNC_MACRO(sin, SinOp)
67 UNARYFUNC_MACRO(tan, TanOp)
68 UNARYFUNC_MACRO(acos, ACosOp)
69 UNARYFUNC_MACRO(asin, ASinOp)
70 UNARYFUNC_MACRO(atan, ATanOp)
71 UNARYFUNC_MACRO(cosh, CoshOp)
72 UNARYFUNC_MACRO(sinh, SinhOp)
73 UNARYFUNC_MACRO(tanh, TanhOp)
74 UNARYFUNC_MACRO(acosh, ACoshOp)
75 UNARYFUNC_MACRO(asinh, ASinhOp)
76 UNARYFUNC_MACRO(atanh, ATanhOp)
77 UNARYFUNC_MACRO(abs, AbsOp)
78 UNARYFUNC_MACRO(fabs, FAbsOp)
79 UNARYFUNC_MACRO(ceil, CeilOp)
80
81 #undef UNARYFUNC_MACRO
82 #undef UNARYFUNC_MACRO_SFS
83
84 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
85 #define BINARYFUNC_MACRO_SFS(OP,FADOP) \
86 namespace Stokhos { \
87 template <typename O, typename T, int N, typename D> \
88 class StaticFixedStorage; \
89 } \
90 namespace Sacado { \
91 namespace MP { \
92 template <typename S> class Vector; \
93 template <typename O, typename T, int N, typename D> \
94 KOKKOS_INLINE_FUNCTION \
95 Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
96 OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
97 const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
98 \
99 template <typename O, typename T, int N, typename D> \
100 KOKKOS_INLINE_FUNCTION \
101 Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
102 OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&, \
103 const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
104 \
105 template <typename O, typename T, int N, typename D> \
106 KOKKOS_INLINE_FUNCTION \
107 Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
108 OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
109 const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&); \
110 } \
111 }
112 #else
113 #define BINARYFUNC_MACRO_SFS(OP,FADOP) /* */
114 #endif
115
116 #define BINARYFUNC_MACRO(OP,FADOP) \
117 BINARYFUNC_MACRO_SFS(OP,FADOP) \
118 namespace Sacado { \
119 \
120 namespace MP { \
121 template <typename T1, typename T2> class FADOP; \
122 template <typename T> class Expr; \
123 \
124 template <typename T1, typename T2> \
125 KOKKOS_INLINE_FUNCTION \
126 FADOP< T1, T2 > \
127 OP (const Expr<T1>&, \
128 const Expr<T2>&); \
129 \
130 template <typename T> \
131 KOKKOS_INLINE_FUNCTION \
132 FADOP< typename T::value_type, T > \
133 OP (const typename T::value_type&, \
134 const Expr<T>&); \
135 \
136 template <typename T> \
137 KOKKOS_INLINE_FUNCTION \
138 FADOP< T, typename T::value_type > \
139 OP (const Expr<T>&, \
140 const typename T::value_type&); \
141 } \
142 } \
143 \
144 namespace std { \
145 using Sacado::MP::OP; \
146 }
147
148 BINARYFUNC_MACRO(atan2, Atan2Op)
149 BINARYFUNC_MACRO(pow, PowerOp)
150 BINARYFUNC_MACRO(max, MaxOp)
151 BINARYFUNC_MACRO(min, MinOp)
152 BINARYFUNC_MACRO(fmax, FMaxOp)
153 BINARYFUNC_MACRO(fmin, FMinOp)
154
155 #undef BINARYFUNC_MACRO
156 #undef BINARYFUNC_MACRO_SFS
157
158 #endif
159
160 #ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
161
162 #define UNARYFUNC_MACRO(OP,FADOP) \
163 namespace Sacado { \
164 \
165 namespace UQ { \
166 template <typename S> class PCE; \
167 template <typename S> \
168 KOKKOS_INLINE_FUNCTION \
169 PCE<S> OP (const PCE<S>&); \
170 } \
171 } \
172 \
173 namespace std { \
174 using Sacado::UQ::OP; \
175 }
176
177 UNARYFUNC_MACRO(exp, ExpOp)
178 UNARYFUNC_MACRO(log, LogOp)
179 UNARYFUNC_MACRO(log10, Log10Op)
180 UNARYFUNC_MACRO(sqrt, SqrtOp)
181 UNARYFUNC_MACRO(cbrt, CbrtOp)
182 UNARYFUNC_MACRO(cos, CosOp)
183 UNARYFUNC_MACRO(sin, SinOp)
184 UNARYFUNC_MACRO(tan, TanOp)
185 UNARYFUNC_MACRO(acos, ACosOp)
186 UNARYFUNC_MACRO(asin, ASinOp)
187 UNARYFUNC_MACRO(atan, ATanOp)
188 UNARYFUNC_MACRO(cosh, CoshOp)
189 UNARYFUNC_MACRO(sinh, SinhOp)
190 UNARYFUNC_MACRO(tanh, TanhOp)
191 UNARYFUNC_MACRO(acosh, ACoshOp)
192 UNARYFUNC_MACRO(asinh, ASinhOp)
193 UNARYFUNC_MACRO(atanh, ATanhOp)
194 UNARYFUNC_MACRO(abs, AbsOp)
195 UNARYFUNC_MACRO(fabs, FAbsOp)
196 UNARYFUNC_MACRO(ceil, CeilOp)
197
198 #undef UNARYFUNC_MACRO
199
200 #define BINARYFUNC_MACRO(OP) \
201 namespace Sacado { \
202 \
203 namespace UQ { \
204 template <typename S> class PCE; \
205 template <typename S> \
206 KOKKOS_INLINE_FUNCTION \
207 PCE<S> OP (const PCE<S>&, const PCE<S>&); \
208 template <typename S> \
209 KOKKOS_INLINE_FUNCTION \
210 PCE<S> OP (const typename PCE<S>::value_type&, const PCE<S>&); \
211 template <typename S> \
212 KOKKOS_INLINE_FUNCTION \
213 PCE<S> OP (const PCE<S>&, const typename PCE<S>::value_type&); \
214 } \
215 } \
216 \
217 namespace std { \
218 using Sacado::UQ::OP; \
219 }
220
221 BINARYFUNC_MACRO(atan2)
222 BINARYFUNC_MACRO(pow)
223
224 #undef BINARYFUNC_MACRO
225
226 #define BINARYFUNC_MACRO(OP) \
227 namespace Sacado { \
228 \
229 namespace UQ { \
230 template <typename S> class PCE; \
231 template <typename S> \
232 KOKKOS_INLINE_FUNCTION \
233 PCE<S> OP (const typename S::value_type&, const PCE<S>&); \
234 template <typename S> \
235 KOKKOS_INLINE_FUNCTION \
236 PCE<S> OP (const PCE<S>&, const typename S::value_type&); \
237 } \
238 } \
239 \
240 namespace std { \
241 using Sacado::UQ::OP; \
242 }
243
244 BINARYFUNC_MACRO(max)
245 BINARYFUNC_MACRO(min)
246
247 #undef BINARYFUNC_MACRO
248
249 #endif
250
251 #endif // STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP