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 
112 #undef UNARYFUNC_MACRO
113 #undef UNARYFUNC_MACRO_SFS
114 
115 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC
116 #define BINARYFUNC_MACRO_SFS(OP,FADOP) \
117 namespace Stokhos { \
118  template <typename O, typename T, int N, typename D> \
119  class StaticFixedStorage; \
120 } \
121 namespace Sacado { \
122  namespace MP { \
123  template <typename S> class Vector; \
124  template <typename O, typename T, int N, typename D> \
125  KOKKOS_INLINE_FUNCTION \
126  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
127  OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
128  const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
129  \
130  template <typename O, typename T, int N, typename D> \
131  KOKKOS_INLINE_FUNCTION \
132  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
133  OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&, \
134  const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&); \
135  \
136  template <typename O, typename T, int N, typename D> \
137  KOKKOS_INLINE_FUNCTION \
138  Vector< Stokhos::StaticFixedStorage<O,T,N,D> > \
139  OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >&, \
140  const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type&); \
141  } \
142 }
143 #else
144 #define BINARYFUNC_MACRO_SFS(OP,FADOP) /* */
145 #endif
146 
147 #define BINARYFUNC_MACRO(OP,FADOP) \
148 BINARYFUNC_MACRO_SFS(OP,FADOP) \
149 namespace Sacado { \
150  \
151  namespace MP { \
152  template <typename T1, typename T2> class FADOP; \
153  template <typename T> class Expr; \
154  \
155  template <typename T1, typename T2> \
156  KOKKOS_INLINE_FUNCTION \
157  FADOP< T1, T2 > \
158  OP (const Expr<T1>&, \
159  const Expr<T2>&); \
160  \
161  template <typename T> \
162  KOKKOS_INLINE_FUNCTION \
163  FADOP< typename T::value_type, T > \
164  OP (const typename T::value_type&, \
165  const Expr<T>&); \
166  \
167  template <typename T> \
168  KOKKOS_INLINE_FUNCTION \
169  FADOP< T, typename T::value_type > \
170  OP (const Expr<T>&, \
171  const typename T::value_type&); \
172  } \
173 } \
174  \
175 namespace std { \
176  using Sacado::MP::OP; \
177 }
178 
183 
184 #undef BINARYFUNC_MACRO
185 #undef BINARYFUNC_MACRO_SFS
186 
187 #endif
188 
189 #ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
190 
191 #define UNARYFUNC_MACRO(OP,FADOP) \
192 namespace Sacado { \
193  \
194  namespace UQ { \
195  template <typename S> class PCE; \
196  template <typename S> \
197  KOKKOS_INLINE_FUNCTION \
198  PCE<S> OP (const PCE<S>&); \
199  } \
200 } \
201  \
202 namespace std { \
203  using Sacado::UQ::OP; \
204 }
205 
207 UNARYFUNC_MACRO(log, LogOp)
225 
226 #undef UNARYFUNC_MACRO
227 
228 #define BINARYFUNC_MACRO(OP) \
229 namespace Sacado { \
230  \
231  namespace UQ { \
232  template <typename S> class PCE; \
233  template <typename S> \
234  KOKKOS_INLINE_FUNCTION \
235  PCE<S> OP (const PCE<S>&, const PCE<S>&); \
236  template <typename S> \
237  KOKKOS_INLINE_FUNCTION \
238  PCE<S> OP (const typename PCE<S>::value_type&, const PCE<S>&); \
239  template <typename S> \
240  KOKKOS_INLINE_FUNCTION \
241  PCE<S> OP (const PCE<S>&, const typename PCE<S>::value_type&); \
242  } \
243 } \
244  \
245 namespace std { \
246  using Sacado::UQ::OP; \
247 }
248 
251 
252 #undef BINARYFUNC_MACRO
253 
254 #define BINARYFUNC_MACRO(OP) \
255 namespace Sacado { \
256  \
257  namespace UQ { \
258  template <typename S> class PCE; \
259  template <typename S> \
260  KOKKOS_INLINE_FUNCTION \
261  PCE<S> OP (const typename S::value_type&, const PCE<S>&); \
262  template <typename S> \
263  KOKKOS_INLINE_FUNCTION \
264  PCE<S> OP (const PCE<S>&, const typename S::value_type&); \
265  } \
266 } \
267  \
268 namespace std { \
269  using Sacado::UQ::OP; \
270 }
271 
274 
275 #undef BINARYFUNC_MACRO
276 
277 #endif
278 
279 #endif // STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
expr expr ASinhOp
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
expr expr TanhOp
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
expr expr ATanhOp
atanh(expr.val())
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
expr expr ASinOp
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
expr expr TanOp
#define UNARYFUNC_MACRO(OP, FADOP)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
atan2(expr1.val(), expr2.val())
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
asinh(expr.val())
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
expr expr CoshOp
#define BINARYFUNC_MACRO(OP, FADOP)
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
expr expr CosOp
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
expr2 j expr1 expr1 expr2 expr2 j expr1 c c c c PowerOp
expr expr SinhOp
acosh(expr.val())
expr expr SinOp
expr expr expr expr ExpOp
expr expr SqrtOp
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
expr expr AbsOp
expr expr ACoshOp
expr expr ATanOp
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
expr expr ACosOp