Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Fad_Exp_MathFunctions.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_FAD_EXP_MATHFUNCTIONS_HPP
11 #define SACADO_FAD_EXP_MATHFUNCTIONS_HPP
12 
13 #include "Sacado_cmath.hpp"
14 #include "Sacado_SFINAE_Macros.hpp"
15 
16 // Note: Sacado::Fad::Ops are forward-declared here, instead of in macros
17 // below.
19 
20 #define UNARYFUNC_MACRO(OP,FADOP) \
21 namespace Sacado { \
22  \
23  namespace Fad { \
24  namespace Exp { \
25  template <typename T> class Expr; \
26  template <typename T> \
27  SACADO_INLINE_FUNCTION \
28  FADOP< typename Expr<T>::derived_type, \
29  typename T::expr_spec_type > \
30  OP (const Expr<T>&); \
31  } \
32  } \
33  \
34 } \
35  \
36 namespace std { \
37  using Sacado::Fad::Exp::OP; \
38 }
39 
60 
61 #undef UNARYFUNC_MACRO
62 
63 #define BINARYFUNC_MACRO(OP,FADOP) \
64 namespace Sacado { \
65  \
66  namespace Fad { \
67  namespace Exp { \
68  template <typename T> class Expr; \
69  template <typename T> struct IsFadExpr; \
70  template <typename T> struct ExprLevel; \
71  template <typename T1, typename T2> \
72  SACADO_INLINE_FUNCTION \
73  SACADO_FAD_EXP_OP_ENABLE_EXPR_EXPR(FADOP) \
74  OP (const T1&, const T2&); \
75  \
76  template <typename T> \
77  SACADO_INLINE_FUNCTION \
78  FADOP< typename T::value_type, typename Expr<T>::derived_type, \
79  true, false, typename T::expr_spec_type > \
80  OP (const typename T::value_type&, const Expr<T>&); \
81  \
82  template <typename T> \
83  SACADO_INLINE_FUNCTION \
84  FADOP< typename Expr<T>::derived_type, typename T::value_type, \
85  false, true, typename T::expr_spec_type > \
86  OP (const Expr<T>&, const typename T::value_type&); \
87  \
88  template <typename T> \
89  SACADO_INLINE_FUNCTION \
90  SACADO_FAD_EXP_OP_ENABLE_SCALAR_EXPR(FADOP) \
91  OP (const typename T::scalar_type&, const Expr<T>&); \
92  \
93  template <typename T> \
94  SACADO_INLINE_FUNCTION \
95  SACADO_FAD_EXP_OP_ENABLE_EXPR_SCALAR(FADOP) \
96  OP (const Expr<T>&, const typename T::scalar_type&); \
97  } \
98  } \
99  \
100 } \
101  \
102 namespace std { \
103  using Sacado::Fad::Exp::OP; \
104 }
105 
110 
111 #undef BINARYFUNC_MACRO
112 
113 #if defined(HAVE_SACADO_KOKKOS)
114 
115 namespace Sacado {
116  namespace Fad {
117  namespace Exp {
118  template <typename S> class GeneralFad;
119  template <typename ValT, unsigned sl, unsigned ss, typename U>
120  class ViewFadPtr;
121 
122  template <typename S>
124  void atomic_add(GeneralFad<S>* dst, const GeneralFad<S>& x);
125  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
127  void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst, const Expr<T>& x);
128 
129  template <typename S>
130  SACADO_INLINE_FUNCTION GeneralFad<S>
131  atomic_max_fetch(GeneralFad<S>* dest, const GeneralFad<S>& val);
132  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
134  atomic_max_fetch(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
135  template <typename S>
136  SACADO_INLINE_FUNCTION GeneralFad<S>
137  atomic_min_fetch(GeneralFad<S>* dest, const GeneralFad<S>& val);
138  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
140  atomic_min_fetch(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
141  template <typename S>
142  SACADO_INLINE_FUNCTION GeneralFad<S>
143  atomic_add_fetch(GeneralFad<S>* dst, const GeneralFad<S>& x);
144  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
146  atomic_add_fetch(ViewFadPtr<ValT,sl,ss,U> dst, const Expr<T>& x);
147  template <typename S>
148  SACADO_INLINE_FUNCTION GeneralFad<S>
149  atomic_sub_fetch(GeneralFad<S>* dest, const GeneralFad<S>& val);
150  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
152  atomic_sub_fetch(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
153  template <typename S>
154  SACADO_INLINE_FUNCTION GeneralFad<S>
155  atomic_mul_fetch(GeneralFad<S>* dest, const GeneralFad<S>& val);
156  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
158  atomic_mul_fetch(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
159  template <typename S>
160  SACADO_INLINE_FUNCTION GeneralFad<S>
161  atomic_div_fetch(GeneralFad<S>* dest, const GeneralFad<S>& val);
162  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
164  atomic_div_fetch(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
165 
166  template <typename S>
167  SACADO_INLINE_FUNCTION GeneralFad<S>
168  atomic_fetch_max(GeneralFad<S>* dest, const GeneralFad<S>& val);
169  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
171  atomic_fetch_max(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
172  template <typename S>
173  SACADO_INLINE_FUNCTION GeneralFad<S>
174  atomic_fetch_min(GeneralFad<S>* dest, const GeneralFad<S>& val);
175  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
177  atomic_fetch_min(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
178  template <typename S>
179  SACADO_INLINE_FUNCTION GeneralFad<S>
180  atomic_fetch_add(GeneralFad<S>* dst, const GeneralFad<S>& x);
181  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
183  atomic_fetch_add(ViewFadPtr<ValT,sl,ss,U> dst, const Expr<T>& x);
184  template <typename S>
185  SACADO_INLINE_FUNCTION GeneralFad<S>
186  atomic_fetch_sub(GeneralFad<S>* dest, const GeneralFad<S>& val);
187  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
189  atomic_fetch_sub(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
190  template <typename S>
191  SACADO_INLINE_FUNCTION GeneralFad<S>
192  atomic_fetch_mul(GeneralFad<S>* dest, const GeneralFad<S>& val);
193  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
195  atomic_fetch_mul(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
196  template <typename S>
197  SACADO_INLINE_FUNCTION GeneralFad<S>
198  atomic_fetch_div(GeneralFad<S>* dest, const GeneralFad<S>& val);
199  template <typename ValT, unsigned sl, unsigned ss, typename U, typename T>
201  atomic_fetch_div(ViewFadPtr<ValT,sl,ss,U> dest, const Expr<T>& val);
202  }
203  }
204 }
205 
206 namespace Kokkos {
207  using Sacado::Fad::Exp::atomic_add;
208  using Sacado::Fad::Exp::atomic_max_fetch;
209  using Sacado::Fad::Exp::atomic_min_fetch;
210  using Sacado::Fad::Exp::atomic_add_fetch;
211  using Sacado::Fad::Exp::atomic_sub_fetch;
212  using Sacado::Fad::Exp::atomic_mul_fetch;
213  using Sacado::Fad::Exp::atomic_div_fetch;
214  using Sacado::Fad::Exp::atomic_fetch_max;
215  using Sacado::Fad::Exp::atomic_fetch_min;
216  using Sacado::Fad::Exp::atomic_fetch_add;
217  using Sacado::Fad::Exp::atomic_fetch_sub;
218  using Sacado::Fad::Exp::atomic_fetch_mul;
219  using Sacado::Fad::Exp::atomic_fetch_div;
220 }
221 
222 #endif
223 
224 #endif // SACADO_FAD_EXP_MATHFUNCTIONS_HPP
cbrt(expr.val())
expr expr SinOp
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
asinh(expr.val())
asin(expr.val())
cosh(expr.val())
abs(expr.val())
atanh(expr.val())
expr expr CoshOp
expr expr ATanhOp
expr expr TanhOp
expr expr SqrtOp
expr expr ASinhOp
atan(expr.val())
#define BINARYFUNC_MACRO(OP, FADOP)
expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 expr1 expr1 c *expr2 expr1 c *expr2 expr1 c *expr2 expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 Atan2Op
expr val()
tanh(expr.val())
expr expr CosOp
#define UNARYFUNC_MACRO(OP, FADOP)
expr expr ATanOp
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
expr expr ACosOp
sqrt(expr.val())
sinh(expr.val())
tan(expr.val())
atan2(expr1.val(), expr2.val())
sin(expr.val())
SACADO_INLINE_FUNCTION T safe_sqrt(const T &x)
log(expr.val())
expr expr ACoshOp
expr expr Log10Op
expr expr SinhOp
acosh(expr.val())
acos(expr.val())
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
expr expr ASinOp
SACADO_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
#define SACADO_INLINE_FUNCTION
exp(expr.val())
expr expr expr ExpOp
fabs(expr.val())
expr expr AbsOp
expr expr TanOp
log10(expr.val())
cos(expr.val())
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 PowerOp