Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
Stokhos_Sacado_Kokkos_MathFunctions.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
43 #define STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
44 
45 #include <cmath>
46 
47 #include "Stokhos_ConfigDefs.h"
48 
49 #include "Kokkos_Macros.hpp"
50 
51 #ifdef HAVE_STOKHOS_ENSEMBLE_SCALAR_TYPE
52 
53 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
54 #define UNARYFUNC_MACRO_SFS(OP,FADOP) \
55 namespace Stokhos { \
56  template <typename O, typename T, int N, typename D> \
57  class StaticFixedStorage; \
58 } \
59 namespace Sacado { \
60  namespace MP { \
61  template <typename S> class Vector; \
62  template <typename O, typename T, int N, typename D> \
63  KOKKOS_INLINE_FUNCTION \
64  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
65  OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
66  } \
67 }
68 #else
69 #define UNARYFUNC_MACRO_SFS(OP,FADOP) /* */
70 #endif
71 
72 #define UNARYFUNC_MACRO(OP,FADOP) \
73 UNARYFUNC_MACRO_SFS(OP,FADOP) \
74 namespace Sacado { \
75  \
76  namespace MP { \
77  template <typename T> class FADOP; \
78  template <typename T> class Expr; \
79  \
80  template <typename T> \
81  KOKKOS_INLINE_FUNCTION \
82  FADOP< T > \
83  OP (const Expr<T>&); \
84  } \
85  \
86 } \
87  \
88 namespace std { \
89  using Sacado::MP::OP; \
90 }
91 
93 UNARYFUNC_MACRO(log, LogOp)
111 UNARYFUNC_MACRO(ceil, CeilOp)
112 
113 #undef UNARYFUNC_MACRO
114 #undef UNARYFUNC_MACRO_SFS
115 
116 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
117 #define BINARYFUNC_MACRO_SFS(OP,FADOP) \
118 namespace Stokhos { \
119  template <typename O, typename T, int N, typename D> \
120  class StaticFixedStorage; \
121 } \
122 namespace Sacado { \
123  namespace MP { \
124  template <typename S> class Vector; \
125  template <typename O, typename T, int N, typename D> \
126  KOKKOS_INLINE_FUNCTION \
127  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
128  OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
129  const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
130  \
131  template <typename O, typename T, int N, typename D> \
132  KOKKOS_INLINE_FUNCTION \
133  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
134  OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&, \
135  const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
136  \
137  template <typename O, typename T, int N, typename D> \
138  KOKKOS_INLINE_FUNCTION \
139  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
140  OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
141  const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&); \
142  } \
143 }
144 #else
145 #define BINARYFUNC_MACRO_SFS(OP,FADOP) /* */
146 #endif
147 
148 #define BINARYFUNC_MACRO(OP,FADOP) \
149 BINARYFUNC_MACRO_SFS(OP,FADOP) \
150 namespace Sacado { \
151  \
152  namespace MP { \
153  template <typename T1, typename T2> class FADOP; \
154  template <typename T> class Expr; \
155  \
156  template <typename T1, typename T2> \
157  KOKKOS_INLINE_FUNCTION \
158  FADOP< T1, T2 > \
159  OP (const Expr<T1>&, \
160  const Expr<T2>&); \
161  \
162  template <typename T> \
163  KOKKOS_INLINE_FUNCTION \
164  FADOP< typename T::value_type, T > \
165  OP (const typename T::value_type&, \
166  const Expr<T>&); \
167  \
168  template <typename T> \
169  KOKKOS_INLINE_FUNCTION \
170  FADOP< T, typename T::value_type > \
171  OP (const Expr<T>&, \
172  const typename T::value_type&); \
173  } \
174 } \
175  \
176 namespace std { \
177  using Sacado::MP::OP; \
178 }
179 
181 BINARYFUNC_MACRO(pow, PowerOp)
184 
185 #undef BINARYFUNC_MACRO
186 #undef BINARYFUNC_MACRO_SFS
187 
188 #endif
189 
190 #ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
191 
192 #define UNARYFUNC_MACRO(OP,FADOP) \
193 namespace Sacado { \
194  \
195  namespace UQ { \
196  template <typename S> class PCE; \
197  template <typename S> \
198  KOKKOS_INLINE_FUNCTION \
199  PCE<S> OP (const PCE<S>&); \
200  } \
201 } \
202  \
203 namespace std { \
204  using Sacado::UQ::OP; \
205 }
206 
208 UNARYFUNC_MACRO(log, LogOp)
226 UNARYFUNC_MACRO(ceil, CeilOp)
227 
228 #undef UNARYFUNC_MACRO
229 
230 #define BINARYFUNC_MACRO(OP) \
231 namespace Sacado { \
232  \
233  namespace UQ { \
234  template <typename S> class PCE; \
235  template <typename S> \
236  KOKKOS_INLINE_FUNCTION \
237  PCE<S> OP (const PCE<S>&, const PCE<S>&); \
238  template <typename S> \
239  KOKKOS_INLINE_FUNCTION \
240  PCE<S> OP (const typename PCE<S>::value_type&, const PCE<S>&); \
241  template <typename S> \
242  KOKKOS_INLINE_FUNCTION \
243  PCE<S> OP (const PCE<S>&, const typename PCE<S>::value_type&); \
244  } \
245 } \
246  \
247 namespace std { \
248  using Sacado::UQ::OP; \
249 }
250 
253 
254 #undef BINARYFUNC_MACRO
255 
256 #define BINARYFUNC_MACRO(OP) \
257 namespace Sacado { \
258  \
259  namespace UQ { \
260  template <typename S> class PCE; \
261  template <typename S> \
262  KOKKOS_INLINE_FUNCTION \
263  PCE<S> OP (const typename S::value_type&, const PCE<S>&); \
264  template <typename S> \
265  KOKKOS_INLINE_FUNCTION \
266  PCE<S> OP (const PCE<S>&, const typename S::value_type&); \
267  } \
268 } \
269  \
270 namespace std { \
271  using Sacado::UQ::OP; \
272 }
273 
276 
277 #undef BINARYFUNC_MACRO
278 
279 #endif
280 
281 #endif // STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 j expr1 expr1 expr1 expr1 j expr1 c *expr2 expr1 c expr1 c expr1 c expr1 expr1 expr1 expr1 j *expr1 expr2 expr1 expr1 j *expr1 c expr2 expr1 c expr1 expr2 expr1 expr2 expr1 Atan2Op
asinh(expr.val())
expr expr SinOp
expr expr SinhOp
expr expr SqrtOp
expr expr ACosOp
expr expr ATanOp
expr2 j expr1 expr1 expr2 expr2 j expr1 c c c c MinOp
expr expr ACoshOp
expr expr ASinOp
expr expr TanhOp
expr expr TanOp
expr expr CoshOp
expr expr ASinhOp
acosh(expr.val())
expr expr AbsOp
atan2(expr1.val(), expr2.val())
expr expr ATanhOp
expr expr expr expr ExpOp
atanh(expr.val())
expr expr CosOp
expr2 j expr1 expr1 expr2 expr2 j expr1 c c c c MaxOp
#define UNARYFUNC_MACRO(OP, FADOP)
#define BINARYFUNC_MACRO(OP, FADOP)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > ceil(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)