52 #ifndef SACADO_ELRFAD_OPS_HPP
53 #define SACADO_ELRFAD_OPS_HPP
59 #define FAD_UNARYOP_MACRO(OPNAME,OP,VALUE,ADJOINT, \
60 LINEAR,DX,FASTACCESSDX) \
64 template <typename ExprT> \
67 template <typename ExprT> \
68 class Expr< OP<ExprT> > { \
71 typedef typename ExprT::value_type value_type; \
72 typedef typename ExprT::scalar_type scalar_type; \
73 typedef typename ExprT::base_expr_type base_expr_type; \
75 static const int num_args = ExprT::num_args; \
77 static const bool is_linear = LINEAR; \
79 KOKKOS_INLINE_FUNCTION \
80 Expr(const ExprT& expr_) : expr(expr_) {} \
82 KOKKOS_INLINE_FUNCTION \
83 int size() const { return expr.size(); } \
86 KOKKOS_INLINE_FUNCTION \
87 bool isActive() const { return expr.template isActive<Arg>(); } \
89 KOKKOS_INLINE_FUNCTION \
90 bool isActive2(int j) const { return expr.isActive2(j); } \
92 KOKKOS_INLINE_FUNCTION \
93 bool updateValue() const { return expr.updateValue(); } \
95 KOKKOS_INLINE_FUNCTION \
96 void cache() const {} \
98 KOKKOS_INLINE_FUNCTION \
99 value_type val() const { \
103 KOKKOS_INLINE_FUNCTION \
104 void computePartials(const value_type& bar, \
105 value_type partials[]) const { \
106 expr.computePartials(ADJOINT, partials); \
109 KOKKOS_INLINE_FUNCTION \
110 void getTangents(int i, value_type dots[]) const { \
111 expr.getTangents(i, dots); } \
114 KOKKOS_INLINE_FUNCTION \
115 const value_type& getTangent(int i) const { \
116 return expr.template getTangent<Arg>(i); \
119 KOKKOS_INLINE_FUNCTION \
120 bool isLinear() const { \
124 KOKKOS_INLINE_FUNCTION \
125 bool hasFastAccess() const { \
126 return expr.hasFastAccess(); \
129 KOKKOS_INLINE_FUNCTION \
130 const value_type dx(int i) const { \
134 KOKKOS_INLINE_FUNCTION \
135 const value_type fastAccessDx(int i) const { \
136 return FASTACCESSDX; \
139 KOKKOS_INLINE_FUNCTION \
140 const value_type* getDx(int j) const { \
141 return expr.getDx(j); \
144 KOKKOS_INLINE_FUNCTION \
145 int numActiveArgs() const { \
146 return expr.numActiveArgs(); \
149 KOKKOS_INLINE_FUNCTION \
150 void computeActivePartials(const value_type& bar, \
151 value_type *partials) const { \
152 expr.computePartials(ADJOINT, partials); \
160 template <typename T> \
161 KOKKOS_INLINE_FUNCTION \
162 Expr< OP< Expr<T> > > \
163 OPNAME (const Expr<T>& expr) \
165 typedef OP< Expr<T> > expr_t; \
167 return Expr<expr_t>(expr); \
178 expr.fastAccessDx(i))
185 -expr.fastAccessDx(i))
192 std::exp(expr.val())*expr.fastAccessDx(i))
198 expr.dx(i)/expr.val(),
199 expr.fastAccessDx(i)/expr.val())
206 expr.fastAccessDx(i) / (
std::log(value_type(10))*expr.val()))
209 std::sqrt(expr.
val()),
210 value_type(0.5)*
bar/std::sqrt(expr.val()),
212 expr.
dx(i)/(value_type(2)* std::sqrt(expr.val())),
213 expr.
fastAccessDx(i)/(value_type(2)* std::sqrt(expr.val())))
216 std::cos(expr.val()),
217 -
bar*std::
sin(expr.val()),
219 -expr.
dx(i)* std::
sin(expr.val()),
223 std::sin(expr.val()),
224 bar*std::cos(expr.val()),
226 expr.
dx(i)* std::cos(expr.val()),
230 std::tan(expr.val()),
231 bar*(value_type(1.)+ std::tan(expr.val())*std::tan(expr.val())),
234 (value_type(1)+ std::tan(expr.val())* std::tan(expr.val())),
236 (value_type(1)+ std::tan(expr.val())* std::tan(expr.val())))
239 std::acos(expr.val()),
240 -
bar/std::sqrt(value_type(1.)-expr.val()*expr.val()),
242 -expr.
dx(i)/ std::sqrt(value_type(1)-expr.val()*expr.val()),
244 std::sqrt(value_type(1)-expr.val()*expr.val()))
247 std::asin(expr.val()),
248 bar/std::sqrt(value_type(1.)-expr.val()*expr.val()),
250 expr.
dx(i)/ std::sqrt(value_type(1)-expr.val()*expr.val()),
252 std::sqrt(value_type(1)-expr.val()*expr.val()))
255 std::atan(expr.val()),
256 bar/(value_type(1.)+expr.val()*expr.val()),
258 expr.
dx(i)/(value_type(1)+expr.val()*expr.val()),
259 expr.
fastAccessDx(i)/(value_type(1)+expr.val()*expr.val()))
262 std::cosh(expr.val()),
265 expr.
dx(i)* std::
sinh(expr.val()),
269 std::sinh(expr.val()),
270 bar*std::cosh(expr.val()),
272 expr.
dx(i)* std::cosh(expr.val()),
276 std::tanh(expr.val()),
277 bar/(std::cosh(expr.val())*std::cosh(expr.val())),
279 expr.
dx(i)/( std::cosh(expr.val())* std::cosh(expr.val())),
281 ( std::cosh(expr.val())* std::cosh(expr.val())))
284 std::acosh(expr.val()),
285 bar/std::sqrt((expr.val()-value_type(1.)) *
286 (expr.val()+value_type(1.))),
288 expr.
dx(i)/ std::sqrt((expr.val()-value_type(1)) *
289 (expr.val()+value_type(1))),
290 expr.
fastAccessDx(i)/ std::sqrt((expr.val()-value_type(1)) *
291 (expr.val()+value_type(1))))
294 std::asinh(expr.val()),
295 bar/std::sqrt(value_type(1.)+expr.val()*expr.val()),
297 expr.
dx(i)/ std::sqrt(value_type(1)+expr.val()*expr.val()),
299 expr.val()*expr.val()))
302 std::atanh(expr.val()),
303 bar/(value_type(1.)-expr.val()*expr.val()),
305 expr.
dx(i)/(value_type(1)-expr.val()*expr.val()),
307 expr.val()*expr.val()))
310 std::abs(expr.val()),
311 (expr.val() >= value_type(0.)) ?
bar : value_type(-
bar),
313 expr.val() >= 0 ? value_type(+expr.
dx(i)) :
314 value_type(-expr.
dx(i)),
319 std::fabs(expr.val()),
320 (expr.val() >= value_type(0.)) ? bar : value_type(-bar),
322 expr.val() >= 0 ? value_type(+expr.
dx(i)) :
323 value_type(-expr.
dx(i)),
326 #ifdef HAVE_SACADO_CXX11
330 bar/(value_type(3)*
std::cbrt(expr.val()*expr.val())),
332 expr.dx(i)/(value_type(3)*
std::cbrt(expr.val()*expr.val())),
333 expr.fastAccessDx(i)/(value_type(3)*
std::cbrt(expr.val()*expr.val())))
339 OPNAME,OP,VALUE,LADJOINT,RADJOINT, \
340 LINEAR,CONST_LINEAR_1, CONST_LINEAR_2, \
341 LINEAR_2,CONST_LINEAR_1_2, CONST_LINEAR_2_2, \
342 DX,FASTACCESSDX,CONST_DX_1,CONST_DX_2, \
343 CONST_FASTACCESSDX_1,CONST_FASTACCESSDX_2) \
347 template <typename ExprT1, typename ExprT2> \
350 template <typename ExprT1, typename ExprT2> \
351 class Expr< OP<ExprT1,ExprT2> > { \
355 typedef
typename ExprT1::value_type value_type_1; \
356 typedef
typename ExprT2::value_type value_type_2; \
358 value_type_2>::type value_type; \
360 typedef
typename ExprT1::scalar_type scalar_type_1; \
361 typedef
typename ExprT2::scalar_type scalar_type_2; \
363 scalar_type_2>::type scalar_type; \
365 typedef
typename ExprT1::base_expr_type base_expr_type_1; \
366 typedef
typename ExprT2::base_expr_type base_expr_type_2; \
368 base_expr_type_2>::type base_expr_type; \
370 static
const int num_args1 = ExprT1::num_args; \
371 static
const int num_args2 = ExprT2::num_args; \
372 static
const int num_args = num_args1 + num_args2; \
374 static
const bool is_linear = LINEAR_2; \
376 KOKKOS_INLINE_FUNCTION \
377 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) : \
378 expr1(expr1_), expr2(expr2_) {} \
380 KOKKOS_INLINE_FUNCTION \
382 int sz1 = expr1.size(), sz2 = expr2.size(); \
383 return sz1 > sz2 ? sz1 : sz2; \
387 KOKKOS_INLINE_FUNCTION \
388 bool isActive()
const {
\
389 if (Arg < num_args1) \
390 return expr1.template isActive<Arg>(); \
392 return expr2.template isActive<Arg-num_args1>(); \
395 KOKKOS_INLINE_FUNCTION \
396 bool isActive2(
int j)
const {
\
398 return expr1.isActive2(j); \
400 return expr2.isActive2(j); \
403 KOKKOS_INLINE_FUNCTION \
404 bool updateValue()
const { \
405 return expr1.updateValue() && expr2.updateValue(); \
409 void cache()
const {} \
411 KOKKOS_INLINE_FUNCTION \
412 value_type
val()
const { \
417 void computePartials(
const value_type& bar, \
418 value_type partials[])
const {
\
420 expr1.computePartials(LADJOINT, partials);
\
422 expr2.computePartials(RADJOINT, partials+num_args1); \
426 void getTangents(
int i, value_type dots[])
const { \
427 expr1.getTangents(i, dots); \
428 expr2.getTangents(i, dots+num_args1); \
432 KOKKOS_INLINE_FUNCTION \
433 const value_type& getTangent(
int i)
const {
\
434 if (Arg < num_args1) \
435 return expr1.template getTangent<Arg>(i); \
437 return expr2.template getTangent<Arg-num_args1>(i); \
440 KOKKOS_INLINE_FUNCTION \
441 bool isLinear()
const { \
445 KOKKOS_INLINE_FUNCTION \
446 bool hasFastAccess()
const { \
447 return expr1.hasFastAccess() && expr2.hasFastAccess(); \
450 KOKKOS_INLINE_FUNCTION \
451 const value_type
dx(
int i)
const { \
455 KOKKOS_INLINE_FUNCTION \
457 return FASTACCESSDX; \
460 KOKKOS_INLINE_FUNCTION \
461 const value_type* getDx(
int j)
const {
\
463 return expr1.getDx(j); \
465 return expr2.getDx(j-num_args1); \
468 KOKKOS_INLINE_FUNCTION \
469 int numActiveArgs()
const { \
470 return expr1.numActiveArgs() + expr2.numActiveArgs(); \
474 void computeActivePartials(
const value_type& bar, \
475 value_type *partials)
const {
\
476 if (expr1.numActiveArgs() > 0) \
477 expr1.computePartials(LADJOINT, partials);
\
478 if (expr2.numActiveArgs() > 0) \
479 expr2.computePartials(RADJOINT, partials+expr2.numActiveArgs()); \
483 typename ExprConstRef<ExprT1>::type expr1; \
484 typename ExprConstRef<ExprT2>::type expr2; \
488 template <typename ExprT1, typename T2> \
489 class Expr< OP<ExprT1, ConstExpr<T2> > > { \
493 typedef ConstExpr<T2> ExprT2; \
494 typedef
typename ExprT1::value_type value_type_1; \
495 typedef
typename ExprT2::value_type value_type_2; \
497 value_type_2>::type value_type; \
499 typedef
typename ExprT1::scalar_type scalar_type_1; \
500 typedef
typename ExprT2::scalar_type scalar_type_2; \
502 scalar_type_2>::type scalar_type; \
504 typedef
typename ExprT1::base_expr_type base_expr_type_1; \
505 typedef
typename ExprT2::base_expr_type base_expr_type_2; \
507 base_expr_type_2>::type base_expr_type; \
509 static
const int num_args = ExprT1::num_args; \
511 static
const bool is_linear = CONST_LINEAR_2_2; \
513 KOKKOS_INLINE_FUNCTION \
514 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) : \
515 expr1(expr1_), expr2(expr2_) {} \
517 KOKKOS_INLINE_FUNCTION \
519 return expr1.size(); \
523 KOKKOS_INLINE_FUNCTION \
524 bool isActive()
const { \
525 return expr1.template isActive<Arg>(); \
528 KOKKOS_INLINE_FUNCTION \
529 bool isActive2(
int j)
const {
return expr1.isActive2(j); } \
531 KOKKOS_INLINE_FUNCTION \
532 bool updateValue()
const { \
533 return expr1.updateValue(); \
537 void cache()
const {} \
539 KOKKOS_INLINE_FUNCTION \
540 value_type
val()
const { \
545 void computePartials(
const value_type& bar, \
546 value_type partials[])
const { \
547 expr1.computePartials(LADJOINT, partials); \
551 void getTangents(
int i, value_type dots[])
const { \
552 expr1.getTangents(i, dots); \
556 KOKKOS_INLINE_FUNCTION \
557 const value_type& getTangent(
int i)
const { \
558 return expr1.template getTangent<Arg>(i); \
561 KOKKOS_INLINE_FUNCTION \
562 bool isLinear()
const { \
563 return CONST_LINEAR_2; \
566 KOKKOS_INLINE_FUNCTION \
567 bool hasFastAccess()
const { \
568 return expr1.hasFastAccess(); \
571 KOKKOS_INLINE_FUNCTION \
572 const value_type
dx(
int i)
const { \
576 KOKKOS_INLINE_FUNCTION \
578 return CONST_FASTACCESSDX_2; \
581 KOKKOS_INLINE_FUNCTION \
582 const value_type* getDx(
int j)
const { \
583 return expr1.getDx(j); \
586 KOKKOS_INLINE_FUNCTION \
587 int numActiveArgs()
const { \
588 return expr1.numActiveArgs(); \
592 void computeActivePartials(
const value_type& bar, \
593 value_type *partials)
const { \
594 expr1.computePartials(LADJOINT, partials); \
599 typename ExprConstRef<ExprT1>::type expr1; \
600 typename ExprConstRef<ExprT2>::type expr2; \
604 template <typename T1, typename ExprT2> \
605 class Expr< OP<ConstExpr<T1>,ExprT2> > { \
609 typedef ConstExpr<T1> ExprT1; \
610 typedef
typename ExprT1::value_type value_type_1; \
611 typedef
typename ExprT2::value_type value_type_2; \
613 value_type_2>::type value_type; \
615 typedef
typename ExprT1::scalar_type scalar_type_1; \
616 typedef
typename ExprT2::scalar_type scalar_type_2; \
618 scalar_type_2>::type scalar_type; \
620 typedef
typename ExprT1::base_expr_type base_expr_type_1; \
621 typedef
typename ExprT2::base_expr_type base_expr_type_2; \
623 base_expr_type_2>::type base_expr_type; \
625 static
const int num_args = ExprT2::num_args; \
627 static
const bool is_linear = CONST_LINEAR_1_2; \
629 KOKKOS_INLINE_FUNCTION \
630 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) : \
631 expr1(expr1_), expr2(expr2_) {} \
633 KOKKOS_INLINE_FUNCTION \
635 return expr2.size(); \
639 KOKKOS_INLINE_FUNCTION \
640 bool isActive()
const { \
641 return expr2.template isActive<Arg>(); \
644 KOKKOS_INLINE_FUNCTION \
645 bool isActive2(
int j)
const {
return expr2.isActive2(j); } \
647 KOKKOS_INLINE_FUNCTION \
648 bool updateValue()
const { \
649 return expr2.updateValue(); \
653 void cache()
const {} \
655 KOKKOS_INLINE_FUNCTION \
656 value_type
val()
const { \
661 void computePartials(
const value_type& bar, \
662 value_type partials[])
const { \
663 expr2.computePartials(RADJOINT, partials); \
667 void getTangents(
int i, value_type dots[])
const { \
668 expr2.getTangents(i, dots); \
672 KOKKOS_INLINE_FUNCTION \
673 const value_type& getTangent(
int i)
const { \
674 return expr2.template getTangent<Arg>(i); \
677 KOKKOS_INLINE_FUNCTION \
678 bool isLinear()
const { \
679 return CONST_LINEAR_1; \
682 KOKKOS_INLINE_FUNCTION \
683 bool hasFastAccess()
const { \
684 return expr2.hasFastAccess(); \
687 KOKKOS_INLINE_FUNCTION \
688 const value_type
dx(
int i)
const { \
692 KOKKOS_INLINE_FUNCTION \
694 return CONST_FASTACCESSDX_1; \
697 KOKKOS_INLINE_FUNCTION \
698 const value_type* getDx(
int j)
const { \
699 return expr2.getDx(j); \
702 KOKKOS_INLINE_FUNCTION \
703 int numActiveArgs()
const { \
704 return expr2.numActiveArgs(); \
708 void computeActivePartials(
const value_type& bar, \
709 value_type *partials)
const { \
710 expr2.computePartials(RADJOINT, partials); \
714 typename ExprConstRef<ExprT1>::type expr1; \
715 typename ExprConstRef<ExprT2>::type expr2; \
719 template <typename T1, typename T2>
\
722 OPNAME (
const T1& expr1,
const T2& expr2) \
724 typedef OP< T1, T2 > expr_t; \
726 return Expr<expr_t>(expr1, expr2); \
729 template <typename T> \
730 KOKKOS_INLINE_FUNCTION \
731 Expr< OP< Expr<T>, Expr<T> > > \
732 OPNAME (
const Expr<T>& expr1,
const Expr<T>& expr2) \
734 typedef OP< Expr<T>, Expr<T> > expr_t; \
736 return Expr<expr_t>(expr1, expr2); \
739 template <typename T> \
740 KOKKOS_INLINE_FUNCTION \
741 Expr< OP< ConstExpr<typename Expr<T>::value_type>, \
743 OPNAME (
const typename Expr<T>::value_type&
c, \
744 const Expr<T>& expr) \
746 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
747 typedef OP< ConstT, Expr<T> > expr_t; \
749 return Expr<expr_t>(ConstT(c), expr); \
752 template <typename T> \
753 KOKKOS_INLINE_FUNCTION \
755 ConstExpr<typename Expr<T>::value_type> > > \
756 OPNAME (
const Expr<T>& expr, \
757 const typename Expr<T>::value_type& c) \
759 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
760 typedef OP< Expr<T>, ConstT > expr_t; \
762 return Expr<expr_t>(expr, ConstT(c)); \
765 template <typename T>
\
768 OPNAME (
const typename Expr<T>::scalar_type& c, \
769 const Expr<T>& expr) \
771 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
772 typedef OP< ConstT, Expr<T> > expr_t; \
774 return Expr<expr_t>(ConstT(c), expr); \
777 template <typename T>
\
780 OPNAME (
const Expr<T>& expr, \
781 const typename Expr<T>::scalar_type& c) \
783 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
784 typedef OP< Expr<T>, ConstT > expr_t; \
786 return Expr<expr_t>(expr, ConstT(c)); \
794 expr1.val() + expr2.val(),
797 expr1.isLinear() && expr2.isLinear(),
800 ExprT1::is_linear && ExprT2::is_linear,
803 expr1.dx(i) + expr2.dx(i),
804 expr1.fastAccessDx(i) + expr2.fastAccessDx(i),
807 expr2.fastAccessDx(i),
808 expr1.fastAccessDx(i))
811 expr1.val() - expr2.val(),
814 expr1.isLinear() && expr2.isLinear(),
817 ExprT1::is_linear && ExprT2::is_linear,
820 expr1.dx(i) - expr2.dx(i),
821 expr1.fastAccessDx(i) - expr2.fastAccessDx(i),
824 -expr2.fastAccessDx(i),
825 expr1.fastAccessDx(i))
828 expr1.val() * expr2.val(),
837 expr1.val()*expr2.dx(i) + expr1.dx(i)*expr2.val(),
838 expr1.val()*expr2.fastAccessDx(i) +
839 expr1.fastAccessDx(i)*expr2.val(),
840 expr1.val()*expr2.dx(i),
841 expr1.dx(i)*expr2.val(),
842 expr1.val()*expr2.fastAccessDx(i),
843 expr1.fastAccessDx(i)*expr2.val())
846 expr1.val() / expr2.val(),
848 -bar*expr1.val()/(expr2.val()*expr2.val()),
855 (expr1.dx(i)*expr2.val() - expr2.dx(i)*expr1.val()) /
856 (expr2.val()*expr2.val()),
857 (expr1.fastAccessDx(i)*expr2.val() -
858 expr2.fastAccessDx(i)*expr1.val()) /
859 (expr2.val()*expr2.val()),
860 -expr2.dx(i)*expr1.val() / (expr2.val()*expr2.val()),
861 expr1.dx(i)/expr2.val(),
862 -expr2.fastAccessDx(i)*expr1.val() / (expr2.val()*expr2.val()),
863 expr1.fastAccessDx(i)/expr2.val())
868 (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
870 (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
877 (expr2.val()*expr1.dx(i) - expr1.val()*expr2.dx(i))/ (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
878 (expr2.val()*expr1.fastAccessDx(i) - expr1.val()*expr2.fastAccessDx(i))/
879 (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
880 (-expr1.val()*expr2.dx(i)) / (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
881 (expr2.val()*expr1.dx(i))/ (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
882 (-expr1.val()*expr2.fastAccessDx(i))/ (expr1.val()*expr1.val() + expr2.val()*expr2.val()),
883 (expr2.val()*expr1.fastAccessDx(i))/ (expr1.val()*expr1.val() + expr2.val()*expr2.val()))
886 std::pow(expr1.val(), expr2.val()),
887 expr1.val() == value_type(0) ? value_type(0) : value_type(bar*std::pow(expr1.val(),expr2.val())*expr2.val()/expr1.val()),
888 expr1.val() == value_type(0) ? value_type(0) : value_type(bar*std::pow(expr1.val(),expr2.val())*std::
log(expr1.val())),
895 expr1.val() == value_type(0) ? value_type(0) : value_type((expr2.
dx(i)*std::
log(expr1.val())+expr2.val()*expr1.
dx(i)/expr1.val())*std::pow(expr1.val(),expr2.val())),
896 expr1.val() == value_type(0) ? value_type(0.0) : value_type((expr2.
fastAccessDx(i)*std::
log(expr1.val())+expr2.val()*expr1.
fastAccessDx(i)/expr1.val())*std::pow(expr1.val(),expr2.val())),
897 expr1.val() == value_type(0) ? value_type(0) : value_type(expr2.
dx(i)*std::
log(expr1.val())*std::pow(expr1.val(),expr2.val())),
898 expr1.val() == value_type(0.0) ? value_type(0.0) : value_type(expr2.val()*expr1.
dx(i)/expr1.val()*std::pow(expr1.val(),expr2.val())),
899 expr1.val() == value_type(0) ? value_type(0) : value_type(expr2.
fastAccessDx(i)*std::
log(expr1.val())*std::pow(expr1.val(),expr2.val())),
900 expr1.val() == value_type(0.0) ? value_type(0.0) : value_type(expr2.val()*expr1.
fastAccessDx(i)/expr1.val()*std::pow(expr1.val(),expr2.val())))
903 expr1.val() >= expr2.val() ? expr1.val() : expr2.val(),
904 expr1.val() >= expr2.val() ? bar : value_type(0.),
905 expr2.val() > expr1.val() ? bar : value_type(0.),
906 expr1.isLinear() && expr2.isLinear(),
909 ExprT1::is_linear && ExprT2::is_linear,
912 expr1.val() >= expr2.val() ? expr1.
dx(i) : expr2.
dx(i),
915 expr1.val() >= expr2.val() ? value_type(0) : expr2.
dx(i),
916 expr1.val() >= expr2.val() ? expr1.
dx(i) : value_type(0),
917 expr1.val() >= expr2.val() ? value_type(0) :
923 expr1.val() <= expr2.val() ? expr1.val() : expr2.val(),
924 expr1.val() <= expr2.val() ? bar : value_type(0.),
925 expr2.val() < expr1.val() ? bar : value_type(0.),
926 expr1.isLinear() && expr2.isLinear(),
929 ExprT1::is_linear && ExprT2::is_linear,
932 expr1.val() <= expr2.val() ? expr1.
dx(i) : expr2.
dx(i),
935 expr1.val() <= expr2.val() ? value_type(0) : expr2.
dx(i),
936 expr1.val() <= expr2.val() ? expr1.
dx(i) : value_type(0),
937 expr1.val() <= expr2.val() ? value_type(0) :
942 #undef FAD_BINARYOP_MACRO
946 #define FAD_RELOP_MACRO(OP) \
949 template <typename ExprT1, typename ExprT2> \
950 KOKKOS_INLINE_FUNCTION \
952 operator OP (const Expr<ExprT1>& expr1, \
953 const Expr<ExprT2>& expr2) \
955 return expr1.val() OP expr2.val(); \
958 template <typename ExprT2> \
959 KOKKOS_INLINE_FUNCTION \
961 operator OP (const typename Expr<ExprT2>::value_type& a, \
962 const Expr<ExprT2>& expr2) \
964 return a OP expr2.val(); \
967 template <typename ExprT1> \
968 KOKKOS_INLINE_FUNCTION \
970 operator OP (const Expr<ExprT1>& expr1, \
971 const typename Expr<ExprT1>::value_type& b) \
973 return expr1.val() OP b; \
989 #undef FAD_RELOP_MACRO
995 template <
typename ExprT>
1011 template <
typename ExprT>
1014 bool is_zero = (x.val() == 0.0);
1015 for (
int i=0; i<x.size(); i++)
1016 is_zero = is_zero && (x.dx(i) == 0.0);
1024 #define FAD_BOOL_MACRO(OP) \
1025 namespace Sacado { \
1026 namespace ELRFad { \
1027 template <typename ExprT1, typename ExprT2> \
1028 KOKKOS_INLINE_FUNCTION \
1030 operator OP (const Expr<ExprT1>& expr1, \
1031 const Expr<ExprT2>& expr2) \
1033 return toBool(expr1) OP toBool(expr2); \
1036 template <typename ExprT2> \
1037 KOKKOS_INLINE_FUNCTION \
1039 operator OP (const typename Expr<ExprT2>::value_type& a, \
1040 const Expr<ExprT2>& expr2) \
1042 return a OP toBool(expr2); \
1045 template <typename ExprT1> \
1046 KOKKOS_INLINE_FUNCTION \
1048 operator OP (const Expr<ExprT1>& expr1, \
1049 const typename Expr<ExprT1>::value_type& b) \
1051 return toBool(expr1) OP b; \
1059 #undef FAD_BOOL_MACRO
1067 template <
typename ExprT>
1068 std::ostream& operator << (std::ostream& os, const Expr<ExprT>& x) {
1069 os << x.val() <<
" [";
1071 for (
int i=0; i< x.size(); i++) {
1072 os <<
" " << x.dx(i);
1083 #endif // SACADO_FAD_OPS_HPP
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
expr expr expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 MultiplicationOp
#define FAD_UNARYOP_MACRO(OPNAME, OP, USING, VALUE, DX, FASTACCESSDX)
#define FAD_BOOL_MACRO(OP)
#define SACADO_FAD_OP_ENABLE_EXPR_EXPR(OP)
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MinOp
expr expr expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 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 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(OP)
#define FAD_BINARYOP_MACRO(OPNAME, OP, VALUE, LADJOINT, RADJOINT,LINEAR, CONST_LINEAR_1, CONST_LINEAR_2,LINEAR_2, CONST_LINEAR_1_2, CONST_LINEAR_2_2,DX, FASTACCESSDX, CONST_DX_1, CONST_DX_2,CONST_FASTACCESSDX_1, CONST_FASTACCESSDX_2)
KOKKOS_INLINE_FUNCTION bool operator!(const Expr< ExprT > &expr)
expr expr expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 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 DivisionOp
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)
#define KOKKOS_INLINE_FUNCTION
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 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
KOKKOS_INLINE_FUNCTION bool toBool(const Expr< ExprT > &x)
atan2(expr1.val(), expr2.val())
#define FAD_RELOP_MACRO(OP)
Wrapper for a generic expression template.
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
#define SACADO_FAD_OP_ENABLE_EXPR_SCALAR(OP)
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
expr expr expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 SubtractionOp
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