10 #ifndef SACADO_MATHFUNCTIONS_HPP
11 #define SACADO_MATHFUNCTIONS_HPP
24 #define UNARYFUNC_MACRO(OP,FADOP) \
28 template <typename T> \
29 SACADO_INLINE_FUNCTION \
30 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
32 template <typename T> class SimpleFad; \
33 template <typename T> \
34 SimpleFad<T> OP (const SimpleFad<T>&); \
38 template <typename T> class FADOP; \
39 template <typename T> class Expr; \
40 template <typename T> \
41 SACADO_INLINE_FUNCTION \
42 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
45 namespace CacheFad { \
46 template <typename T> class FADOP; \
47 template <typename T> class Expr; \
48 template <typename T> \
49 SACADO_INLINE_FUNCTION \
50 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
53 namespace ELRCacheFad { \
54 template <typename T> class FADOP; \
55 template <typename T> class Expr; \
56 template <typename T> \
57 SACADO_INLINE_FUNCTION \
58 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
62 template <typename T> class FADOP; \
63 template <typename T> class Expr; \
64 template <typename T> \
65 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
69 template <typename T> class Taylor; \
70 template <typename T> Taylor<T> OP (const Base< Taylor<T> >&); \
73 namespace FlopCounterPack { \
74 template <typename T> class ScalarFlopCounter; \
75 template <typename T> \
76 ScalarFlopCounter<T> OP (const Base< ScalarFlopCounter<T> >&); \
80 template <typename T> class ADvari; \
81 template <typename T> class IndepADvar; \
82 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&); \
83 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&); \
88 using Sacado::Fad::OP; \
89 using Sacado::ELRFad::OP; \
90 using Sacado::CacheFad::OP; \
91 using Sacado::ELRCacheFad::OP; \
92 using Sacado::LFad::OP; \
93 using Sacado::Tay::OP; \
94 using Sacado::FlopCounterPack::OP; \
95 using Sacado::Rad::OP; \
118 #undef UNARYFUNC_MACRO
122 template <
typename T>
124 Expr< SafeSqrtOp< Expr<T> > >
safe_sqrt (
const Expr<T>&);
129 template <
typename T>
136 template <
typename T>
141 namespace ELRCacheFad {
143 template <
typename T>
149 #define BINARYFUNC_MACRO(OP,FADOP) \
153 template <typename T> class ConstExpr; \
154 template <typename T> struct IsFadExpr; \
155 template <typename T> struct ExprLevel; \
156 template <typename T1, typename T2> \
157 SACADO_INLINE_FUNCTION \
158 typename mpl::enable_if_c< \
159 ExprLevel< Expr<T1> >::value == ExprLevel< Expr<T2> >::value, \
160 Expr< FADOP< Expr<T1>, Expr<T2> > > \
163 OP (const Expr<T1>&, const Expr<T2>&); \
165 template <typename T> \
166 SACADO_INLINE_FUNCTION \
167 Expr< FADOP< Expr<T>, Expr<T> > > \
168 OP (const Expr<T>&, const Expr<T>&); \
170 template <typename T> \
171 SACADO_INLINE_FUNCTION \
172 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
173 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
175 template <typename T> \
176 SACADO_INLINE_FUNCTION \
177 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
178 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
180 template <typename T> \
181 SACADO_INLINE_FUNCTION \
182 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
183 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
185 template <typename T> \
186 SACADO_INLINE_FUNCTION \
187 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
188 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
190 template <typename T> class SimpleFad; \
191 template <typename T> \
193 OP (const SimpleFad<T>&, const SimpleFad<T>&); \
195 template <typename T> \
197 OP (const SimpleFad<T>&, \
198 const typename SimpleFad<T>::value_type&); \
200 template <typename T> \
202 OP (const typename SimpleFad<T>::value_type&, \
203 const SimpleFad<T>&); \
207 template <typename T1, typename T2> class FADOP; \
208 template <typename T> class Expr; \
209 template <typename T> class ConstExpr; \
210 template <typename T> struct IsFadExpr; \
211 template <typename T> struct ExprLevel; \
212 template <typename T1, typename T2> \
213 SACADO_INLINE_FUNCTION \
214 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
215 OP (const T1&, const T2&); \
217 template <typename T> \
218 SACADO_INLINE_FUNCTION \
219 Expr< FADOP< Expr<T>, Expr<T> > > \
220 OP (const Expr<T>&, const Expr<T>&); \
222 template <typename T> \
223 SACADO_INLINE_FUNCTION \
224 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
225 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
227 template <typename T> \
228 SACADO_INLINE_FUNCTION \
229 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
230 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
232 template <typename T> \
233 SACADO_INLINE_FUNCTION \
234 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
235 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
237 template <typename T> \
238 SACADO_INLINE_FUNCTION \
239 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
240 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
243 namespace CacheFad { \
244 template <typename T1, typename T2> class FADOP; \
245 template <typename T> class Expr; \
246 template <typename T> class ConstExpr; \
247 template <typename T> struct IsFadExpr; \
248 template <typename T> struct ExprLevel; \
249 template <typename T1, typename T2> \
250 SACADO_INLINE_FUNCTION \
251 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
252 OP (const T1&, const T2&); \
254 template <typename T> \
255 SACADO_INLINE_FUNCTION \
256 Expr< FADOP< Expr<T>, Expr<T> > > \
257 OP (const Expr<T>&, const Expr<T>&); \
259 template <typename T> \
260 SACADO_INLINE_FUNCTION \
261 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
262 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
264 template <typename T> \
265 SACADO_INLINE_FUNCTION \
266 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
267 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
269 template <typename T> \
270 SACADO_INLINE_FUNCTION \
271 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
272 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
274 template <typename T> \
275 SACADO_INLINE_FUNCTION \
276 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
277 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
280 namespace ELRCacheFad { \
281 template <typename T1, typename T2> class FADOP; \
282 template <typename T> class Expr; \
283 template <typename T> class ConstExpr; \
284 template <typename T> struct IsFadExpr; \
285 template <typename T> struct ExprLevel; \
286 template <typename T1, typename T2> \
287 SACADO_INLINE_FUNCTION \
288 SACADO_FAD_OP_ENABLE_EXPR_EXPR(FADOP) \
289 OP (const T1&, const T2&); \
291 template <typename T> \
292 SACADO_INLINE_FUNCTION \
293 Expr< FADOP< Expr<T>, Expr<T> > > \
294 OP (const Expr<T>&, const Expr<T>&); \
296 template <typename T> \
297 SACADO_INLINE_FUNCTION \
298 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
299 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
301 template <typename T> \
302 SACADO_INLINE_FUNCTION \
303 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
304 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
306 template <typename T> \
307 SACADO_INLINE_FUNCTION \
308 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(FADOP) \
309 OP (const typename Expr<T>::scalar_type&, const Expr<T>&); \
311 template <typename T> \
312 SACADO_INLINE_FUNCTION \
313 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(FADOP) \
314 OP (const Expr<T>&, const typename Expr<T>::scalar_type&); \
318 template <typename T1, typename T2> class FADOP; \
319 template <typename T> class Expr; \
321 template <typename T1, typename T2> \
322 Expr< FADOP< Expr<T1>, Expr<T2> > > \
323 OP (const Expr<T1>&, const Expr<T2>&); \
325 template <typename T> \
326 Expr< FADOP< Expr<T>, Expr<T> > > \
327 OP (const Expr<T>&, const Expr<T>&); \
329 template <typename T> \
330 Expr< FADOP< typename Expr<T>::value_type, Expr<T> > > \
331 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
333 template <typename T> \
334 Expr< FADOP< Expr<T>, typename Expr<T>::value_type > > \
335 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
339 template <typename T> class Taylor; \
340 template <typename T> Taylor<T> OP ( \
341 const Base< Taylor<T> >&, \
342 const Base< Taylor<T> >&); \
343 template <typename T> Taylor<T> OP ( \
344 const typename Taylor<T>::value_type&, \
345 const Base< Taylor<T> >&); \
346 template <typename T> Taylor<T> OP ( \
347 const Base< Taylor<T> >&, \
348 const typename Taylor<T>::value_type&); \
351 namespace FlopCounterPack { \
352 template <typename T> class ScalarFlopCounter; \
353 template <typename T> \
354 ScalarFlopCounter<T> OP ( \
355 const Base< ScalarFlopCounter<T> >&, \
356 const Base< ScalarFlopCounter<T> >&); \
357 template <typename T> \
358 ScalarFlopCounter<T> OP ( \
359 const typename ScalarFlopCounter<T>::value_type&, \
360 const Base< ScalarFlopCounter<T> >&); \
361 template <typename T> \
362 ScalarFlopCounter<T> OP ( \
363 const Base< ScalarFlopCounter<T> >&, \
364 const typename ScalarFlopCounter<T>::value_type&); \
365 template <typename T> \
366 ScalarFlopCounter<T> OP ( \
368 const Base< ScalarFlopCounter<T> >&); \
369 template <typename T> \
370 ScalarFlopCounter<T> OP ( \
371 const Base< ScalarFlopCounter<T> >&, \
376 template <typename T> class ADvari; \
377 template <typename T> class IndepADvar; \
378 template <typename T> class DoubleAvoid; \
379 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
380 const Base< ADvari<T> >&); \
381 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
382 const Base< ADvari<T> >&); \
383 template <typename T> ADvari<T>& OP (T, \
384 const Base< ADvari<T> >&); \
385 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype,\
386 const Base< ADvari<T> >&); \
387 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::itype,\
388 const Base< ADvari<T> >&); \
389 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::ltype,\
390 const Base< ADvari<T> >&); \
391 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
392 const Base< IndepADvar<T> >&); \
393 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
395 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
396 typename DoubleAvoid<T>::dtype);\
397 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
398 typename DoubleAvoid<T>::itype);\
399 template <typename T> ADvari<T>& OP (const Base< ADvari<T> >&, \
400 typename DoubleAvoid<T>::ltype);\
401 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
402 const Base< IndepADvar<T> >&); \
403 template <typename T> ADvari<T>& OP (T, \
404 const Base< IndepADvar<T> >&); \
405 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype,\
406 const Base< IndepADvar<T> >&); \
407 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::itype,\
408 const Base< IndepADvar<T> >&); \
409 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::ltype,\
410 const Base< IndepADvar<T> >&); \
411 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
413 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
414 typename DoubleAvoid<T>::dtype);\
415 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
416 typename DoubleAvoid<T>::itype);\
417 template <typename T> ADvari<T>& OP (const Base< IndepADvar<T> >&, \
418 typename DoubleAvoid<T>::ltype);\
424 using Sacado::Fad::OP; \
425 using Sacado::ELRFad::OP; \
426 using Sacado::CacheFad::OP; \
427 using Sacado::ELRCacheFad::OP; \
428 using Sacado::LFad::OP; \
429 using Sacado::Tay::OP; \
430 using Sacado::FlopCounterPack::OP; \
431 using Sacado::Rad::OP; \
439 #undef BINARYFUNC_MACRO
441 #if defined(HAVE_SACADO_KOKKOS)
444 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
446 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
448 template <
typename T>
class DFad;
449 template <
typename T,
int N>
class SFad;
450 template <
typename T,
int N>
class SLFad;
451 template <
typename T>
453 void atomic_add(DFad<T>* dst,
const DFad<T>&
x);
454 template <
typename T,
int N>
456 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
457 template <
typename T,
int N>
459 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
460 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
462 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
466 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
468 template <
typename T>
class DFad;
469 template <
typename T,
int N>
class SFad;
470 template <
typename T,
int N>
class SLFad;
471 template <
typename T>
473 void atomic_add(DFad<T>* dst,
const DFad<T>&
x);
474 template <
typename T,
int N>
476 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
477 template <
typename T,
int N>
479 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
480 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
482 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
485 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
487 template <
typename T>
class DFad;
488 template <
typename T,
int N>
class SFad;
489 template <
typename T,
int N>
class SLFad;
490 template <
typename T>
492 void atomic_add(DFad<T>* dst,
const DFad<T>&
x);
493 template <
typename T,
int N>
495 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
496 template <
typename T,
int N>
498 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
499 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
501 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
503 namespace ELRCacheFad {
504 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U>
506 template <
typename T>
class DFad;
507 template <
typename T,
int N>
class SFad;
508 template <
typename T,
int N>
class SLFad;
509 template <
typename T>
511 void atomic_add(DFad<T>* dst,
const DFad<T>&
x);
512 template <
typename T,
int N>
514 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x);
515 template <
typename T,
int N>
517 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x);
518 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
520 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x);
525 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
526 using Sacado::Fad::atomic_add;
528 using Sacado::ELRFad::atomic_add;
529 using Sacado::CacheFad::atomic_add;
530 using Sacado::ELRCacheFad::atomic_add;
535 #ifdef SACADO_ENABLE_NEW_DESIGN
539 #endif // SACADO_MATHFUNCTIONS_HPP
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
SACADO_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
SACADO_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
GeneralFad< StaticStorage< T, Num > > SLFad
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 BINARYFUNC_MACRO(OP, FADOP)
GeneralFad< DynamicStorage< T > > DFad
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
Wrapper for a generic expression template.
atan2(expr1.val(), expr2.val())
Wrapper for a generic expression template.
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
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
Wrapper for a generic expression template.
GeneralFad< StaticFixedStorage< T, Num > > SFad
#define UNARYFUNC_MACRO(OP, FADOP)
SACADO_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
SACADO_INLINE_FUNCTION Expr< SafeSqrtOp< Expr< T > > > safe_sqrt(const Expr< T > &)
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