30 #ifndef SACADO_MATHFUNCTIONS_HPP
31 #define SACADO_MATHFUNCTIONS_HPP
44 #define UNARYFUNC_MACRO(OP,FADOP) \
48 template <typename T> \
49 KOKKOS_INLINE_FUNCTION \
50 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
52 template <typename T> class SimpleFad; \
53 template <typename T> \
54 SimpleFad<T> OP (const SimpleFad<T>&); \
58 template <typename T> class FADOP; \
59 template <typename T> class Expr; \
60 template <typename T> \
61 KOKKOS_INLINE_FUNCTION \
62 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
65 namespace CacheFad { \
66 template <typename T> class FADOP; \
67 template <typename T> class Expr; \
68 template <typename T> \
69 KOKKOS_INLINE_FUNCTION \
70 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
73 namespace ELRCacheFad { \
74 template <typename T> class FADOP; \
75 template <typename T> class Expr; \
76 template <typename T> \
77 KOKKOS_INLINE_FUNCTION \
78 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
82 template <typename T> class FADOP; \
83 template <typename T> class Expr; \
84 template <typename T> \
85 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
89 template <typename T> class Taylor; \
90 template <typename T> Taylor<T> OP (const Base< Taylor<T> >&); \
93 namespace FlopCounterPack { \
94 template <typename T> class ScalarFlopCounter; \
95 template <typename T> \
96 ScalarFlopCounter<T> OP (const Base< ScalarFlopCounter<T> >&); \
100 template <typename T> class ADvari; \
101 template <typename T> class IndepADvar; \
102 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&); \
103 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&); \
108 using Sacado::Fad::OP; \
109 using Sacado::ELRFad::OP; \
110 using Sacado::CacheFad::OP; \
111 using Sacado::ELRCacheFad::OP; \
112 using Sacado::LFad::OP; \
113 using Sacado::Tay::OP; \
114 using Sacado::FlopCounterPack::OP; \
115 using Sacado::Rad::OP; \
136 #ifdef HAVE_SACADO_CXX11
140 #undef UNARYFUNC_MACRO
144 template <
typename T>
146 Expr< SafeSqrtOp< Expr<T> > >
safe_sqrt (
const Expr<T>&);
151 template <
typename T>
158 template <
typename T>
163 namespace ELRCacheFad {
165 template <
typename T>
171 #define BINARYFUNC_MACRO(OP,FADOP) \
175 template <typename T> class ConstExpr; \
176 template <typename T> struct IsFadExpr; \
177 template <typename T> struct ExprLevel; \
178 template <typename T1, typename T2> \
179 KOKKOS_INLINE_FUNCTION \
180 typename mpl::enable_if_c< \
181 ExprLevel< Expr<T1> >::value == ExprLevel< Expr<T2> >::value, \
182 Expr< FADOP< Expr<T1>, Expr<T2> > > \
185 OP (const Expr<T1>&, const Expr<T2>&); \
187 template <typename T> \
188 KOKKOS_INLINE_FUNCTION \
189 Expr< FADOP< Expr<T>, Expr<T> > > \
190 OP (const Expr<T>&, const Expr<T>&); \
192 template <typename T> \
193 KOKKOS_INLINE_FUNCTION \
194 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
195 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
197 template <typename T> \
198 KOKKOS_INLINE_FUNCTION \
199 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
200 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
202 template <typename T> \
203 KOKKOS_INLINE_FUNCTION \
204 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
205 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
207 template <typename T> \
208 KOKKOS_INLINE_FUNCTION \
209 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
210 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
212 template <typename T> class SimpleFad; \
213 template <typename T> \
215 OP (const SimpleFad<T>&, const SimpleFad<T>&); \
217 template <typename T> \
219 OP (const SimpleFad<T>&, \
220 const typename SimpleFad<T>::value_type&); \
222 template <typename T> \
224 OP (const typename SimpleFad<T>::value_type&, \
225 const SimpleFad<T>&); \
229 template <typename T1, typename T2> class FADOP; \
230 template <typename T> class Expr; \
231 template <typename T> class ConstExpr; \
232 template <typename T> struct IsFadExpr; \
233 template <typename T> struct ExprLevel; \
234 template <typename T1, typename T2> \
235 KOKKOS_INLINE_FUNCTION \
236 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
237 OP (const T1&, const T2&); \
239 template <typename T> \
240 KOKKOS_INLINE_FUNCTION \
241 Expr< FADOP< Expr<T>, Expr<T> > > \
242 OP (const Expr<T>&, const Expr<T>&); \
244 template <typename T> \
245 KOKKOS_INLINE_FUNCTION \
246 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
247 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
249 template <typename T> \
250 KOKKOS_INLINE_FUNCTION \
251 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
252 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
254 template <typename T> \
255 KOKKOS_INLINE_FUNCTION \
256 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
257 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
259 template <typename T> \
260 KOKKOS_INLINE_FUNCTION \
261 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
262 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
265 namespace CacheFad { \
266 template <typename T1, typename T2> class FADOP; \
267 template <typename T> class Expr; \
268 template <typename T> class ConstExpr; \
269 template <typename T> struct IsFadExpr; \
270 template <typename T> struct ExprLevel; \
271 template <typename T1, typename T2> \
272 KOKKOS_INLINE_FUNCTION \
273 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
274 OP (const T1&, const T2&); \
276 template <typename T> \
277 KOKKOS_INLINE_FUNCTION \
278 Expr< FADOP< Expr<T>, Expr<T> > > \
279 OP (const Expr<T>&, const Expr<T>&); \
281 template <typename T> \
282 KOKKOS_INLINE_FUNCTION \
283 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
284 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
286 template <typename T> \
287 KOKKOS_INLINE_FUNCTION \
288 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
289 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
291 template <typename T> \
292 KOKKOS_INLINE_FUNCTION \
293 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
294 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
296 template <typename T> \
297 KOKKOS_INLINE_FUNCTION \
298 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
299 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
302 namespace ELRCacheFad { \
303 template <typename T1, typename T2> class FADOP; \
304 template <typename T> class Expr; \
305 template <typename T> class ConstExpr; \
306 template <typename T> struct IsFadExpr; \
307 template <typename T> struct ExprLevel; \
308 template <typename T1, typename T2> \
309 KOKKOS_INLINE_FUNCTION \
310 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
311 OP (const T1&, const T2&); \
313 template <typename T> \
314 KOKKOS_INLINE_FUNCTION \
315 Expr< FADOP< Expr<T>, Expr<T> > > \
316 OP (const Expr<T>&, const Expr<T>&); \
318 template <typename T> \
319 KOKKOS_INLINE_FUNCTION \
320 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
321 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
323 template <typename T> \
324 KOKKOS_INLINE_FUNCTION \
325 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
326 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
328 template <typename T> \
329 KOKKOS_INLINE_FUNCTION \
330 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
331 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
333 template <typename T> \
334 KOKKOS_INLINE_FUNCTION \
335 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
336 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
340 template <typename T1, typename T2> class FADOP; \
341 template <typename T> class Expr; \
343 template <typename T1, typename T2> \
344 Expr< FADOP< Expr<T1>, Expr<T2> > > \
345 OP (const Expr<T1>&, const Expr<T2>&); \
347 template <typename T> \
348 Expr< FADOP< Expr<T>, Expr<T> > > \
349 OP (const Expr<T>&, const Expr<T>&); \
351 template <typename T> \
352 Expr< FADOP< typename Expr<T>::value_type, Expr<T> > > \
353 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
355 template <typename T> \
356 Expr< FADOP< Expr<T>, typename Expr<T>::value_type > > \
357 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
361 template <typename T> class Taylor; \
362 template <typename T> Taylor<T> OP ( \
363 const Base< Taylor<T> >&, \
364 const Base< Taylor<T> >&); \
365 template <typename T> Taylor<T> OP ( \
366 const typename Taylor<T>::value_type&, \
367 const Base< Taylor<T> >&); \
368 template <typename T> Taylor<T> OP ( \
369 const Base< Taylor<T> >&, \
370 const typename Taylor<T>::value_type&); \
373 namespace FlopCounterPack { \
374 template <typename T> class ScalarFlopCounter; \
375 template <typename T> \
376 ScalarFlopCounter<T> OP ( \
377 const Base< ScalarFlopCounter<T> >&, \
378 const Base< ScalarFlopCounter<T> >&); \
379 template <typename T> \
380 ScalarFlopCounter<T> OP ( \
381 const typename ScalarFlopCounter<T>::value_type&, \
382 const Base< ScalarFlopCounter<T> >&); \
383 template <typename T> \
384 ScalarFlopCounter<T> OP ( \
385 const Base< ScalarFlopCounter<T> >&, \
386 const typename ScalarFlopCounter<T>::value_type&); \
387 template <typename T> \
388 ScalarFlopCounter<T> OP ( \
390 const Base< ScalarFlopCounter<T> >&); \
391 template <typename T> \
392 ScalarFlopCounter<T> OP ( \
393 const Base< ScalarFlopCounter<T> >&, \
398 template <typename T> class ADvari; \
399 template <typename T> class IndepADvar; \
400 template <typename T> class DoubleAvoid; \
401 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
402 const Base< ADvari<T> >&); \
403 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
404 const Base< ADvari<T> >&); \
405 template <typename T> ADvari<T>& OP (T, \
406 const Base< ADvari<T> >&); \
407 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype,\
408 const Base< ADvari<T> >&); \
409 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::itype,\
410 const Base< ADvari<T> >&); \
411 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::ltype,\
412 const Base< ADvari<T> >&); \
413 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
414 const Base< IndepADvar<T> >&); \
415 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
417 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
418 typename DoubleAvoid<T>::dtype);\
419 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
420 typename DoubleAvoid<T>::itype);\
421 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
422 typename DoubleAvoid<T>::ltype);\
423 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
424 const Base< IndepADvar<T> >&); \
425 template <typename T> ADvari<T>& OP (T, \
426 const Base< IndepADvar<T> >&); \
427 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype,\
428 const Base< IndepADvar<T> >&); \
429 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::itype,\
430 const Base< IndepADvar<T> >&); \
431 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::ltype,\
432 const Base< IndepADvar<T> >&); \
433 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
435 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
436 typename DoubleAvoid<T>::dtype);\
437 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
438 typename DoubleAvoid<T>::itype);\
439 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
440 typename DoubleAvoid<T>::ltype);\
446 using Sacado::Fad::OP; \
447 using Sacado::ELRFad::OP; \
448 using Sacado::CacheFad::OP; \
449 using Sacado::ELRCacheFad::OP; \
450 using Sacado::LFad::OP; \
451 using Sacado::Tay::OP; \
452 using Sacado::FlopCounterPack::OP; \
453 using Sacado::Rad::OP; \
461 #undef BINARYFUNC_MACRO
463 #if defined(HAVE_SACADO_KOKKOSCORE)
466 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
468 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
470 template <
typename T>
class DFad;
471 template <
typename T,
int N>
class SFad;
472 template <
typename T,
int N>
class SLFad;
473 template <
typename T>
475 void atomic_add(DFad<T>* dst,
const DFad<T>& x);
476 template <
typename T,
int N>
478 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
479 template <
typename T,
int N>
481 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
482 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
484 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
488 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
490 template <
typename T>
class DFad;
491 template <
typename T,
int N>
class SFad;
492 template <
typename T,
int N>
class SLFad;
493 template <
typename T>
495 void atomic_add(DFad<T>* dst,
const DFad<T>& x);
496 template <
typename T,
int N>
498 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
499 template <
typename T,
int N>
501 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
502 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
504 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
507 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
509 template <
typename T>
class DFad;
510 template <
typename T,
int N>
class SFad;
511 template <
typename T,
int N>
class SLFad;
512 template <
typename T>
514 void atomic_add(DFad<T>* dst,
const DFad<T>& x);
515 template <
typename T,
int N>
517 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
518 template <
typename T,
int N>
520 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
521 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
523 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
525 namespace ELRCacheFad {
526 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
528 template <
typename T>
class DFad;
529 template <
typename T,
int N>
class SFad;
530 template <
typename T,
int N>
class SLFad;
531 template <
typename T>
533 void atomic_add(DFad<T>* dst,
const DFad<T>& x);
534 template <
typename T,
int N>
536 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
537 template <
typename T,
int N>
539 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
540 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
542 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
547 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
548 using Sacado::Fad::atomic_add;
550 using Sacado::ELRFad::atomic_add;
551 using Sacado::CacheFad::atomic_add;
552 using Sacado::ELRCacheFad::atomic_add;
557 #ifdef SACADO_ENABLE_NEW_DESIGN
561 #endif // SACADO_MATHFUNCTIONS_HPP
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MinOp
GeneralFad< StaticStorage< T, Num > > SLFad
KOKKOS_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
KOKKOS_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)
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
#define KOKKOS_INLINE_FUNCTION
#define BINARYFUNC_MACRO(OP, FADOP)
GeneralFad< DynamicStorage< T > > DFad
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
KOKKOS_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
Wrapper for a generic expression template.
atan2(expr1.val(), expr2.val())
Wrapper for a generic expression template.
KOKKOS_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
KOKKOS_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
Wrapper for a generic expression template.
GeneralFad< StaticFixedStorage< T, Num > > SFad
#define UNARYFUNC_MACRO(OP, FADOP)
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