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 #define UNARYFUNC_MACRO(OP,FADOP) \
54 namespace Sacado { \
55  \
56  namespace MP { \
57  template <typename T> class FADOP; \
58  template <typename T> class Expr; \
59  \
60  template <typename T> \
61  KOKKOS_INLINE_FUNCTION \
62  FADOP< T > \
63  OP (const Expr<T>&); \
64  } \
65  \
66 } \
67  \
68 namespace std { \
69  using Sacado::MP::OP; \
70 }
71 
73 UNARYFUNC_MACRO(log, LogOp)
75 UNARYFUNC_MACRO(sqrt, SqrtOp)
76 UNARYFUNC_MACRO(cbrt, CbrtOp)
77 UNARYFUNC_MACRO(cos, CosOp)
78 UNARYFUNC_MACRO(sin, SinOp)
79 UNARYFUNC_MACRO(tan, TanOp)
80 UNARYFUNC_MACRO(acos, ACosOp)
81 UNARYFUNC_MACRO(asin, ASinOp)
82 UNARYFUNC_MACRO(atan, ATanOp)
83 UNARYFUNC_MACRO(cosh, CoshOp)
84 UNARYFUNC_MACRO(sinh, SinhOp)
85 UNARYFUNC_MACRO(tanh, TanhOp)
86 UNARYFUNC_MACRO(acosh, ACoshOp)
87 UNARYFUNC_MACRO(asinh, ASinhOp)
88 UNARYFUNC_MACRO(atanh, ATanhOp)
89 UNARYFUNC_MACRO(abs, AbsOp)
90 UNARYFUNC_MACRO(fabs, FAbsOp)
91 
92 #undef UNARYFUNC_MACRO
93 
94 #define BINARYFUNC_MACRO(OP,FADOP) \
95 namespace Sacado { \
96  \
97  namespace MP { \
98  template <typename T1, typename T2> class FADOP; \
99  template <typename T> class Expr; \
100  \
101  template <typename T1, typename T2> \
102  KOKKOS_INLINE_FUNCTION \
103  FADOP< T1, T2 > \
104  OP (const Expr<T1>&, \
105  const Expr<T2>&); \
106  \
107  template <typename T> \
108  KOKKOS_INLINE_FUNCTION \
109  FADOP< typename T::value_type, T > \
110  OP (const typename T::value_type&, \
111  const Expr<T>&); \
112  \
113  template <typename T> \
114  KOKKOS_INLINE_FUNCTION \
115  FADOP< T, typename T::value_type > \
116  OP (const Expr<T>&, \
117  const typename T::value_type&); \
118  } \
119 } \
120  \
121 namespace std { \
122  using Sacado::MP::OP; \
123 }
124 
125 BINARYFUNC_MACRO(atan2, Atan2Op)
126 BINARYFUNC_MACRO(pow, PowerOp)
127 BINARYFUNC_MACRO(max, MaxOp)
128 BINARYFUNC_MACRO(min, MinOp)
129 
130 #undef BINARYFUNC_MACRO
131 
132 #endif
133 
134 #ifdef HAVE_STOKHOS_PCE_SCALAR_TYPE
135 
136 #define UNARYFUNC_MACRO(OP,FADOP) \
137 namespace Sacado { \
138  \
139  namespace UQ { \
140  template <typename S> class PCE; \
141  template <typename S> \
142  KOKKOS_INLINE_FUNCTION \
143  PCE<S> OP (const PCE<S>&); \
144  } \
145 } \
146  \
147 namespace std { \
148  using Sacado::UQ::OP; \
149 }
150 
152 UNARYFUNC_MACRO(log, LogOp)
154 UNARYFUNC_MACRO(sqrt, SqrtOp)
155 UNARYFUNC_MACRO(cbrt, CbrtOp)
156 UNARYFUNC_MACRO(cos, CosOp)
157 UNARYFUNC_MACRO(sin, SinOp)
158 UNARYFUNC_MACRO(tan, TanOp)
159 UNARYFUNC_MACRO(acos, ACosOp)
160 UNARYFUNC_MACRO(asin, ASinOp)
161 UNARYFUNC_MACRO(atan, ATanOp)
162 UNARYFUNC_MACRO(cosh, CoshOp)
163 UNARYFUNC_MACRO(sinh, SinhOp)
164 UNARYFUNC_MACRO(tanh, TanhOp)
165 UNARYFUNC_MACRO(acosh, ACoshOp)
166 UNARYFUNC_MACRO(asinh, ASinhOp)
167 UNARYFUNC_MACRO(atanh, ATanhOp)
168 UNARYFUNC_MACRO(abs, AbsOp)
169 UNARYFUNC_MACRO(fabs, FAbsOp)
170 
171 #undef UNARYFUNC_MACRO
172 
173 #define BINARYFUNC_MACRO(OP) \
174 namespace Sacado { \
175  \
176  namespace UQ { \
177  template <typename S> class PCE; \
178  template <typename S> \
179  KOKKOS_INLINE_FUNCTION \
180  PCE<S> OP (const PCE<S>&, const PCE<S>&); \
181  template <typename S> \
182  KOKKOS_INLINE_FUNCTION \
183  PCE<S> OP (const typename PCE<S>::value_type&, const PCE<S>&); \
184  template <typename S> \
185  KOKKOS_INLINE_FUNCTION \
186  PCE<S> OP (const PCE<S>&, const typename PCE<S>::value_type&); \
187  } \
188 } \
189  \
190 namespace std { \
191  using Sacado::UQ::OP; \
192 }
193 
194 BINARYFUNC_MACRO(atan2)
196 
197 #undef BINARYFUNC_MACRO
198 
199 #define BINARYFUNC_MACRO(OP) \
200 namespace Sacado { \
201  \
202  namespace UQ { \
203  template <typename S> class PCE; \
204  template <typename S> \
205  KOKKOS_INLINE_FUNCTION \
206  PCE<S> OP (const typename S::value_type&, const PCE<S>&); \
207  template <typename S> \
208  KOKKOS_INLINE_FUNCTION \
209  PCE<S> OP (const PCE<S>&, const typename S::value_type&); \
210  } \
211 } \
212  \
213 namespace std { \
214  using Sacado::UQ::OP; \
215 }
216 
219 
220 #undef BINARYFUNC_MACRO
221 
222 #endif
223 
224 #endif // STOKHOS_SACADO_KOKKOS_MATHFUNCTIONS_HPP
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)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
OrthogPoly< T, Storage > atanh(const OrthogPoly< T, Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
#define UNARYFUNC_MACRO(OP, FADOP)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
OrthogPoly< T, Storage > acosh(const OrthogPoly< T, Storage > &a)
expr expr expr expr ExpOp
expr expr expr expr j Log10Op
#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)
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)
OrthogPoly< T, Storage > asinh(const OrthogPoly< T, Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
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)