33 #ifndef SACADO_CACHEFAD_OPS_HPP
34 #define SACADO_CACHEFAD_OPS_HPP
48 template <
typename ExprT>
51 template <
typename ExprT>
60 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
63 int size()
const {
return expr.size(); }
80 return expr.isLinear();
85 return expr.hasFastAccess();
95 return expr.fastAccessDx(i);
103 template <
typename T>
116 template <
typename ExprT>
119 template <
typename ExprT>
128 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
131 int size()
const {
return expr.size(); }
148 return expr.isLinear();
153 return expr.hasFastAccess();
163 return -expr.fastAccessDx(i);
171 template <
typename T>
185 template <
typename ExprT>
188 template <
typename ExprT>
197 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
200 int size()
const {
return expr.size(); }
224 return expr.hasFastAccess();
229 return v_pos ? expr.dx(i) :
value_type(-expr.dx(i));
234 return v_pos ? expr.fastAccessDx(i) :
value_type(-expr.fastAccessDx(i));
244 template <
typename T>
258 template <
typename ExprT>
261 template <
typename ExprT>
270 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
273 int size()
const {
return expr.size(); }
297 return expr.hasFastAccess();
302 return v_pos ? expr.dx(i) :
value_type(-expr.dx(i));
307 return v_pos ? expr.fastAccessDx(i) :
value_type(-expr.fastAccessDx(i));
317 template <
typename T>
330 #define FAD_UNARYOP_MACRO(OPNAME,OP,PARTIAL,VALUE) \
332 namespace CacheFad { \
334 template <typename ExprT> \
337 template <typename ExprT> \
338 class Expr< OP<ExprT> > { \
341 typedef typename ExprT::value_type value_type; \
342 typedef typename ExprT::scalar_type scalar_type; \
343 typedef typename ExprT::base_expr_type base_expr_type; \
345 SACADO_INLINE_FUNCTION \
346 explicit Expr(const ExprT& expr_) : expr(expr_) {} \
348 SACADO_INLINE_FUNCTION \
349 int size() const { return expr.size(); } \
351 SACADO_INLINE_FUNCTION \
352 bool hasFastAccess() const { return expr.hasFastAccess(); } \
354 SACADO_INLINE_FUNCTION \
355 bool isPassive() const { return expr.isPassive();} \
357 SACADO_INLINE_FUNCTION \
358 bool updateValue() const { return expr.updateValue(); } \
360 SACADO_INLINE_FUNCTION \
361 void cache() const { \
367 SACADO_INLINE_FUNCTION \
368 value_type val() const { \
372 SACADO_INLINE_FUNCTION \
373 value_type dx(int i) const { \
374 return expr.dx(i)*a; \
377 SACADO_INLINE_FUNCTION \
378 value_type fastAccessDx(int i) const { \
379 return expr.fastAccessDx(i)*a; \
385 mutable value_type v; \
386 mutable value_type a; \
389 template <typename T> \
390 SACADO_INLINE_FUNCTION \
391 Expr< OP< Expr<T> > > \
392 OPNAME (const Expr<T>& expr) \
394 typedef OP< Expr<T> > expr_t; \
396 return Expr<expr_t>(expr); \
411 a = value_type(1)/(std::log(value_type(10))*v),
415 a = value_type(1)/(value_type(2)*std::sqrt(v)),
419 a = (v == value_type(0.0) ? value_type(0.0) : value_type(value_type(1)/(value_type(2)*std::sqrt(v)))),
431 a = value_type(1)+std::tan(v)*std::tan(v),
435 a = value_type(-1)/std::sqrt(value_type(1)-v*v),
439 a = value_type(1)/std::sqrt(value_type(1)-v*v),
443 a = value_type(1)/(value_type(1)+v*v),
455 a = value_type(1)-std::tanh(v)*std::tanh(v),
459 a = value_type(1)/std::sqrt((v-value_type(1))*(v+value_type(1))),
463 a = value_type(1)/std::sqrt(value_type(1)+v*v),
467 a = value_type(1)/(value_type(1)-v*v),
471 a = value_type(1)/(value_type(3)*std::cbrt(v*v)),
474 #undef FAD_UNARYOP_MACRO
486 template <
typename ExprT1,
typename ExprT2>
489 template <
typename ExprT1,
typename ExprT2>
490 class Expr< AdditionOp<ExprT1,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;
510 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
511 expr1(expr1_), expr2(expr2_) {}
515 int sz1 = expr1.size(), sz2 = expr2.size();
516 return sz1 > sz2 ? sz1 : sz2;
520 bool updateValue()
const {
521 return expr1.updateValue() && expr2.updateValue();
531 value_type
val()
const {
532 return expr1.val()+expr2.val();
536 bool isLinear()
const {
537 return expr1.isLinear() && expr2.isLinear();
541 bool hasFastAccess()
const {
542 return expr1.hasFastAccess() && expr2.hasFastAccess();
546 const value_type
dx(
int i)
const {
547 return expr1.dx(i) + expr2.dx(i);
552 return expr1.fastAccessDx(i) + expr2.fastAccessDx(i);
562 template <
typename ExprT1,
typename T2>
563 class Expr< AdditionOp<ExprT1, ConstExpr<T2> > > {
567 typedef ConstExpr<T2> ExprT2;
568 typedef typename ExprT1::value_type value_type_1;
569 typedef typename ExprT2::value_type value_type_2;
571 value_type_2>::type value_type;
573 typedef typename ExprT1::scalar_type scalar_type_1;
574 typedef typename ExprT2::scalar_type scalar_type_2;
576 scalar_type_2>::type scalar_type;
578 typedef typename ExprT1::base_expr_type base_expr_type_1;
579 typedef typename ExprT2::base_expr_type base_expr_type_2;
581 base_expr_type_2>::type base_expr_type;
584 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
585 expr1(expr1_), expr2(expr2_) {}
593 bool updateValue()
const {
594 return expr1.updateValue();
603 value_type
val()
const {
604 return expr1.val() + expr2.val();
608 bool isLinear()
const {
609 return expr1.isLinear();
613 bool hasFastAccess()
const {
614 return expr1.hasFastAccess();
618 const value_type
dx(
int i)
const {
624 return expr1.fastAccessDx(i);
634 template <
typename T1,
typename ExprT2>
635 class Expr< AdditionOp< ConstExpr<T1>,ExprT2> > {
639 typedef ConstExpr<T1> ExprT1;
640 typedef typename ExprT1::value_type value_type_1;
641 typedef typename ExprT2::value_type value_type_2;
643 value_type_2>::type value_type;
645 typedef typename ExprT1::scalar_type scalar_type_1;
646 typedef typename ExprT2::scalar_type scalar_type_2;
648 scalar_type_2>::type scalar_type;
650 typedef typename ExprT1::base_expr_type base_expr_type_1;
651 typedef typename ExprT2::base_expr_type base_expr_type_2;
653 base_expr_type_2>::type base_expr_type;
656 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
657 expr1(expr1_), expr2(expr2_) {}
665 bool updateValue()
const {
666 return expr2.updateValue();
675 value_type
val()
const {
676 return expr1.val() + expr2.val();
680 bool isLinear()
const {
681 return expr2.isLinear();
685 bool hasFastAccess()
const {
686 return expr2.hasFastAccess();
690 const value_type
dx(
int i)
const {
696 return expr2.fastAccessDx(i);
710 template <
typename ExprT1,
typename ExprT2>
713 template <
typename ExprT1,
typename ExprT2>
714 class Expr< SubtractionOp<ExprT1,ExprT2> > {
718 typedef typename ExprT1::value_type value_type_1;
719 typedef typename ExprT2::value_type value_type_2;
721 value_type_2>::type value_type;
723 typedef typename ExprT1::scalar_type scalar_type_1;
724 typedef typename ExprT2::scalar_type scalar_type_2;
726 scalar_type_2>::type scalar_type;
728 typedef typename ExprT1::base_expr_type base_expr_type_1;
729 typedef typename ExprT2::base_expr_type base_expr_type_2;
731 base_expr_type_2>::type base_expr_type;
734 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
735 expr1(expr1_), expr2(expr2_) {}
739 int sz1 = expr1.size(), sz2 = expr2.size();
740 return sz1 > sz2 ? sz1 : sz2;
744 bool updateValue()
const {
745 return expr1.updateValue() && expr2.updateValue();
755 value_type
val()
const {
756 return expr1.val()-expr2.val();
760 bool isLinear()
const {
761 return expr1.isLinear() && expr2.isLinear();
765 bool hasFastAccess()
const {
766 return expr1.hasFastAccess() && expr2.hasFastAccess();
770 const value_type
dx(
int i)
const {
771 return expr1.dx(i) - expr2.dx(i);
776 return expr1.fastAccessDx(i) - expr2.fastAccessDx(i);
786 template <
typename ExprT1,
typename T2>
787 class Expr< SubtractionOp<ExprT1, ConstExpr<T2> > > {
791 typedef ConstExpr<T2> ExprT2;
792 typedef typename ExprT1::value_type value_type_1;
793 typedef typename ExprT2::value_type value_type_2;
795 value_type_2>::type value_type;
797 typedef typename ExprT1::scalar_type scalar_type_1;
798 typedef typename ExprT2::scalar_type scalar_type_2;
800 scalar_type_2>::type scalar_type;
802 typedef typename ExprT1::base_expr_type base_expr_type_1;
803 typedef typename ExprT2::base_expr_type base_expr_type_2;
805 base_expr_type_2>::type base_expr_type;
808 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
809 expr1(expr1_), expr2(expr2_) {}
817 bool updateValue()
const {
818 return expr1.updateValue();
827 value_type
val()
const {
828 return expr1.val() - expr2.val();
832 bool isLinear()
const {
833 return expr1.isLinear();
837 bool hasFastAccess()
const {
838 return expr1.hasFastAccess();
842 const value_type
dx(
int i)
const {
848 return expr1.fastAccessDx(i);
858 template <
typename T1,
typename ExprT2>
859 class Expr< SubtractionOp< ConstExpr<T1>,ExprT2> > {
863 typedef ConstExpr<T1> ExprT1;
864 typedef typename ExprT1::value_type value_type_1;
865 typedef typename ExprT2::value_type value_type_2;
867 value_type_2>::type value_type;
869 typedef typename ExprT1::scalar_type scalar_type_1;
870 typedef typename ExprT2::scalar_type scalar_type_2;
872 scalar_type_2>::type scalar_type;
874 typedef typename ExprT1::base_expr_type base_expr_type_1;
875 typedef typename ExprT2::base_expr_type base_expr_type_2;
877 base_expr_type_2>::type base_expr_type;
880 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
881 expr1(expr1_), expr2(expr2_) {}
889 bool updateValue()
const {
890 return expr2.updateValue();
899 value_type
val()
const {
900 return expr1.val() - expr2.val();
904 bool isLinear()
const {
905 return expr2.isLinear();
909 bool hasFastAccess()
const {
910 return expr2.hasFastAccess();
914 const value_type
dx(
int i)
const {
920 return -expr2.fastAccessDx(i);
934 template <
typename ExprT1,
typename ExprT2>
937 template <
typename ExprT1,
typename ExprT2>
938 class Expr< MultiplicationOp<ExprT1,ExprT2> > {
942 typedef typename ExprT1::value_type value_type_1;
943 typedef typename ExprT2::value_type value_type_2;
945 value_type_2>::type value_type;
947 typedef typename ExprT1::scalar_type scalar_type_1;
948 typedef typename ExprT2::scalar_type scalar_type_2;
950 scalar_type_2>::type scalar_type;
952 typedef typename ExprT1::base_expr_type base_expr_type_1;
953 typedef typename ExprT2::base_expr_type base_expr_type_2;
955 base_expr_type_2>::type base_expr_type;
958 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
959 expr1(expr1_), expr2(expr2_) {}
963 int sz1 = expr1.size(), sz2 = expr2.size();
964 return sz1 > sz2 ? sz1 : sz2;
968 bool updateValue()
const {
969 return expr1.updateValue() && expr2.updateValue();
981 value_type
val()
const {
986 bool isLinear()
const {
991 bool hasFastAccess()
const {
992 return expr1.hasFastAccess() && expr2.hasFastAccess();
996 const value_type
dx(
int i)
const {
997 if (expr1.size() > 0 && expr2.size() > 0)
998 return v1*expr2.dx(i) + expr1.dx(i)*v2;
999 else if (expr1.size() > 0)
1000 return expr1.dx(i)*v2;
1002 return v1*expr2.dx(i);
1007 return v1*expr2.fastAccessDx(i) + expr1.fastAccessDx(i)*v2;
1012 const ExprT1& expr1;
1013 const ExprT2& expr2;
1014 mutable value_type_1 v1;
1015 mutable value_type_2 v2;
1019 template <
typename ExprT1,
typename T2>
1020 class Expr< MultiplicationOp<ExprT1, ConstExpr<T2> > > {
1024 typedef ConstExpr<T2> ExprT2;
1025 typedef typename ExprT1::value_type value_type_1;
1026 typedef typename ExprT2::value_type value_type_2;
1028 value_type_2>::type value_type;
1030 typedef typename ExprT1::scalar_type scalar_type_1;
1031 typedef typename ExprT2::scalar_type scalar_type_2;
1033 scalar_type_2>::type scalar_type;
1035 typedef typename ExprT1::base_expr_type base_expr_type_1;
1036 typedef typename ExprT2::base_expr_type base_expr_type_2;
1038 base_expr_type_2>::type base_expr_type;
1041 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1042 expr1(expr1_), expr2(expr2_) {}
1046 return expr1.size();
1050 bool updateValue()
const {
1051 return expr1.updateValue();
1055 void cache()
const {
1060 value_type
val()
const {
1061 return expr1.val()*expr2.val();
1065 bool isLinear()
const {
1066 return expr1.isLinear();
1070 bool hasFastAccess()
const {
1071 return expr1.hasFastAccess();
1075 const value_type
dx(
int i)
const {
1076 return expr1.dx(i)*expr2.val();
1081 return expr1.fastAccessDx(i)*expr2.val();
1086 const ExprT1& expr1;
1091 template <
typename T1,
typename ExprT2>
1092 class Expr< MultiplicationOp< ConstExpr<T1>,ExprT2> > {
1096 typedef ConstExpr<T1> ExprT1;
1097 typedef typename ExprT1::value_type value_type_1;
1098 typedef typename ExprT2::value_type value_type_2;
1100 value_type_2>::type value_type;
1102 typedef typename ExprT1::scalar_type scalar_type_1;
1103 typedef typename ExprT2::scalar_type scalar_type_2;
1105 scalar_type_2>::type scalar_type;
1107 typedef typename ExprT1::base_expr_type base_expr_type_1;
1108 typedef typename ExprT2::base_expr_type base_expr_type_2;
1110 base_expr_type_2>::type base_expr_type;
1113 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1114 expr1(expr1_), expr2(expr2_) {}
1118 return expr2.size();
1122 bool updateValue()
const {
1123 return expr2.updateValue();
1127 void cache()
const {
1132 value_type
val()
const {
1133 return expr1.val()*expr2.val();
1137 bool isLinear()
const {
1138 return expr2.isLinear();
1142 bool hasFastAccess()
const {
1143 return expr2.hasFastAccess();
1147 const value_type
dx(
int i)
const {
1148 return expr1.val()*expr2.dx(i);
1153 return expr1.val()*expr2.fastAccessDx(i);
1159 const ExprT2& expr2;
1167 template <
typename ExprT1,
typename ExprT2>
1170 template <
typename ExprT1,
typename ExprT2>
1171 class Expr< DivisionOp<ExprT1,ExprT2> > {
1175 typedef typename ExprT1::value_type value_type_1;
1176 typedef typename ExprT2::value_type value_type_2;
1178 value_type_2>::type value_type;
1180 typedef typename ExprT1::scalar_type scalar_type_1;
1181 typedef typename ExprT2::scalar_type scalar_type_2;
1183 scalar_type_2>::type scalar_type;
1185 typedef typename ExprT1::base_expr_type base_expr_type_1;
1186 typedef typename ExprT2::base_expr_type base_expr_type_2;
1188 base_expr_type_2>::type base_expr_type;
1191 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1192 expr1(expr1_), expr2(expr2_) {}
1196 int sz1 = expr1.size(), sz2 = expr2.size();
1197 return sz1 > sz2 ? sz1 : sz2;
1201 bool updateValue()
const {
1202 return expr1.updateValue() && expr2.updateValue();
1206 void cache()
const {
1209 const value_type_1 v1 = expr1.val();
1210 const value_type_2 v2 = expr2.val();
1211 a = value_type(1)/v2;
1217 value_type
val()
const {
1222 bool isLinear()
const {
1227 bool hasFastAccess()
const {
1228 return expr1.hasFastAccess() && expr2.hasFastAccess();
1232 const value_type
dx(
int i)
const {
1233 if (expr1.size() > 0 && expr2.size() > 0)
1234 return expr1.dx(i)*
a + expr2.dx(i)*b;
1235 else if (expr1.size() > 0)
1236 return expr1.dx(i)*
a;
1238 return expr1.val()*b;
1243 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1248 const ExprT1& expr1;
1249 const ExprT2& expr2;
1250 mutable value_type v;
1251 mutable value_type
a;
1252 mutable value_type b;
1256 template <
typename ExprT1,
typename T2>
1257 class Expr< DivisionOp<ExprT1, ConstExpr<T2> > > {
1261 typedef ConstExpr<T2> ExprT2;
1262 typedef typename ExprT1::value_type value_type_1;
1263 typedef typename ExprT2::value_type value_type_2;
1265 value_type_2>::type value_type;
1267 typedef typename ExprT1::scalar_type scalar_type_1;
1268 typedef typename ExprT2::scalar_type scalar_type_2;
1270 scalar_type_2>::type scalar_type;
1272 typedef typename ExprT1::base_expr_type base_expr_type_1;
1273 typedef typename ExprT2::base_expr_type base_expr_type_2;
1275 base_expr_type_2>::type base_expr_type;
1278 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1279 expr1(expr1_), expr2(expr2_) {}
1283 return expr1.size();
1287 bool updateValue()
const {
1288 return expr1.updateValue();
1292 void cache()
const {
1294 const value_type_1 v1 = expr1.val();
1295 a = value_type(1)/expr2.val();
1300 value_type
val()
const {
1305 bool isLinear()
const {
1306 return expr1.isLinear();
1310 bool hasFastAccess()
const {
1311 return expr1.hasFastAccess();
1315 const value_type
dx(
int i)
const {
1316 return expr1.dx(i)*
a;
1321 return expr1.fastAccessDx(i)*
a;
1326 const ExprT1& expr1;
1328 mutable value_type v;
1329 mutable value_type
a;
1333 template <
typename T1,
typename ExprT2>
1334 class Expr< DivisionOp< ConstExpr<T1>,ExprT2> > {
1338 typedef ConstExpr<T1> ExprT1;
1339 typedef typename ExprT1::value_type value_type_1;
1340 typedef typename ExprT2::value_type value_type_2;
1342 value_type_2>::type value_type;
1344 typedef typename ExprT1::scalar_type scalar_type_1;
1345 typedef typename ExprT2::scalar_type scalar_type_2;
1347 scalar_type_2>::type scalar_type;
1349 typedef typename ExprT1::base_expr_type base_expr_type_1;
1350 typedef typename ExprT2::base_expr_type base_expr_type_2;
1352 base_expr_type_2>::type base_expr_type;
1355 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1356 expr1(expr1_), expr2(expr2_) {}
1360 return expr2.size();
1364 bool updateValue()
const {
1365 return expr2.updateValue();
1369 void cache()
const {
1371 const value_type_2 v2 = expr2.val();
1377 value_type
val()
const {
1382 bool isLinear()
const {
1387 bool hasFastAccess()
const {
1388 return expr2.hasFastAccess();
1392 const value_type
dx(
int i)
const {
1393 return expr2.dx(i)*b;
1398 return expr2.fastAccessDx(i)*b;
1404 const ExprT2& expr2;
1405 mutable value_type v;
1406 mutable value_type b;
1414 template <
typename ExprT1,
typename ExprT2>
1417 template <
typename ExprT1,
typename ExprT2>
1418 class Expr< Atan2Op<ExprT1,ExprT2> > {
1422 typedef typename ExprT1::value_type value_type_1;
1423 typedef typename ExprT2::value_type value_type_2;
1425 value_type_2>::type value_type;
1427 typedef typename ExprT1::scalar_type scalar_type_1;
1428 typedef typename ExprT2::scalar_type scalar_type_2;
1430 scalar_type_2>::type scalar_type;
1432 typedef typename ExprT1::base_expr_type base_expr_type_1;
1433 typedef typename ExprT2::base_expr_type base_expr_type_2;
1435 base_expr_type_2>::type base_expr_type;
1438 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1439 expr1(expr1_), expr2(expr2_) {}
1443 int sz1 = expr1.size(), sz2 = expr2.size();
1444 return sz1 > sz2 ? sz1 : sz2;
1448 bool updateValue()
const {
1449 return expr1.updateValue() && expr2.updateValue();
1453 void cache()
const {
1456 const value_type_1 v1 = expr1.val();
1457 const value_type_2 v2 = expr2.val();
1458 a = value_type(1)/(v1*v1 + v2*v2);
1465 value_type
val()
const {
1470 bool isLinear()
const {
1475 bool hasFastAccess()
const {
1476 return expr1.hasFastAccess() && expr2.hasFastAccess();
1480 const value_type
dx(
int i)
const {
1481 if (expr1.size() > 0 && expr2.size() > 0)
1482 return expr1.dx(i)*
a + expr2.dx(i)*b;
1483 else if (expr1.size() > 0)
1484 return expr1.dx(i)*
a;
1486 return expr1.val()*b;
1491 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1496 const ExprT1& expr1;
1497 const ExprT2& expr2;
1498 mutable value_type v;
1499 mutable value_type
a;
1500 mutable value_type b;
1504 template <
typename ExprT1,
typename T2>
1505 class Expr< Atan2Op<ExprT1, ConstExpr<T2> > > {
1509 typedef ConstExpr<T2> ExprT2;
1510 typedef typename ExprT1::value_type value_type_1;
1511 typedef typename ExprT2::value_type value_type_2;
1513 value_type_2>::type value_type;
1515 typedef typename ExprT1::scalar_type scalar_type_1;
1516 typedef typename ExprT2::scalar_type scalar_type_2;
1518 scalar_type_2>::type scalar_type;
1520 typedef typename ExprT1::base_expr_type base_expr_type_1;
1521 typedef typename ExprT2::base_expr_type base_expr_type_2;
1523 base_expr_type_2>::type base_expr_type;
1526 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1527 expr1(expr1_), expr2(expr2_) {}
1531 return expr1.size();
1535 bool updateValue()
const {
1536 return expr1.updateValue();
1540 void cache()
const {
1542 const value_type_1 v1 = expr1.val();
1543 const value_type_2 v2 = expr2.val();
1544 a = v2/(v1*v1 + v2*v2);
1549 value_type
val()
const {
1554 bool isLinear()
const {
1559 bool hasFastAccess()
const {
1560 return expr1.hasFastAccess();
1564 const value_type
dx(
int i)
const {
1565 return expr1.dx(i)*
a;
1570 return expr1.fastAccessDx(i)*
a;
1575 const ExprT1& expr1;
1577 mutable value_type v;
1578 mutable value_type
a;
1582 template <
typename T1,
typename ExprT2>
1583 class Expr< Atan2Op< ConstExpr<T1>,ExprT2> > {
1587 typedef ConstExpr<T1> ExprT1;
1588 typedef typename ExprT1::value_type value_type_1;
1589 typedef typename ExprT2::value_type value_type_2;
1591 value_type_2>::type value_type;
1593 typedef typename ExprT1::scalar_type scalar_type_1;
1594 typedef typename ExprT2::scalar_type scalar_type_2;
1596 scalar_type_2>::type scalar_type;
1598 typedef typename ExprT1::base_expr_type base_expr_type_1;
1599 typedef typename ExprT2::base_expr_type base_expr_type_2;
1601 base_expr_type_2>::type base_expr_type;
1604 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1605 expr1(expr1_), expr2(expr2_) {}
1609 return expr2.size();
1613 bool updateValue()
const {
1614 return expr2.updateValue();
1618 void cache()
const {
1620 const value_type_1 v1 = expr1.val();
1621 const value_type_2 v2 = expr2.val();
1622 b = -v1/(v1*v1 + v2*v2);
1627 value_type
val()
const {
1632 bool isLinear()
const {
1637 bool hasFastAccess()
const {
1638 return expr2.hasFastAccess();
1642 const value_type
dx(
int i)
const {
1643 return expr2.dx(i)*b;
1648 return expr2.fastAccessDx(i)*b;
1654 const ExprT2& expr2;
1655 mutable value_type v;
1656 mutable value_type b;
1664 template <
typename ExprT1,
typename ExprT2>
1667 template <
typename ExprT1,
typename ExprT2>
1668 class Expr< PowerOp<ExprT1,ExprT2> > {
1672 typedef typename ExprT1::value_type value_type_1;
1673 typedef typename ExprT2::value_type value_type_2;
1675 value_type_2>::type value_type;
1677 typedef typename ExprT1::scalar_type scalar_type_1;
1678 typedef typename ExprT2::scalar_type scalar_type_2;
1680 scalar_type_2>::type scalar_type;
1682 typedef typename ExprT1::base_expr_type base_expr_type_1;
1683 typedef typename ExprT2::base_expr_type base_expr_type_2;
1685 base_expr_type_2>::type base_expr_type;
1688 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1689 expr1(expr1_), expr2(expr2_) {}
1693 int sz1 = expr1.size(), sz2 = expr2.size();
1694 return sz1 > sz2 ? sz1 : sz2;
1698 bool updateValue()
const {
1699 return expr1.updateValue() && expr2.updateValue();
1703 void cache()
const {
1706 const value_type_1 v1 = expr1.val();
1707 const value_type_2 v2 = expr2.val();
1709 if (expr2.size() == 0 && v2 == value_type(1)) {
1713 else if (v1 == value_type(0)) {
1724 value_type
val()
const {
1729 bool isLinear()
const {
1734 bool hasFastAccess()
const {
1735 return expr1.hasFastAccess() && expr2.hasFastAccess();
1739 const value_type
dx(
int i)
const {
1740 if (expr1.size() > 0 && expr2.size() > 0)
1741 return expr1.dx(i)*
a + expr2.dx(i)*b;
1742 else if (expr1.size() > 0)
1743 return expr1.dx(i)*
a;
1745 return expr1.val()*b;
1750 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1755 const ExprT1& expr1;
1756 const ExprT2& expr2;
1757 mutable value_type v;
1758 mutable value_type
a;
1759 mutable value_type b;
1763 template <
typename ExprT1,
typename T2>
1764 class Expr< PowerOp<ExprT1, ConstExpr<T2> > > {
1768 typedef ConstExpr<T2> ExprT2;
1769 typedef typename ExprT1::value_type value_type_1;
1770 typedef typename ExprT2::value_type value_type_2;
1772 value_type_2>::type value_type;
1774 typedef typename ExprT1::scalar_type scalar_type_1;
1775 typedef typename ExprT2::scalar_type scalar_type_2;
1777 scalar_type_2>::type scalar_type;
1779 typedef typename ExprT1::base_expr_type base_expr_type_1;
1780 typedef typename ExprT2::base_expr_type base_expr_type_2;
1782 base_expr_type_2>::type base_expr_type;
1785 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1786 expr1(expr1_), expr2(expr2_) {}
1790 return expr1.size();
1794 bool updateValue()
const {
1795 return expr1.updateValue();
1799 void cache()
const {
1801 const value_type_1 v1 = expr1.val();
1802 const value_type_2 v2 = expr2.val();
1804 if (v2 == value_type_1(1)) {
1807 else if (v1 == value_type_1(0)) {
1816 value_type
val()
const {
1821 bool isLinear()
const {
1826 bool hasFastAccess()
const {
1827 return expr1.hasFastAccess();
1831 const value_type
dx(
int i)
const {
1832 return expr1.dx(i)*
a;
1837 return expr1.fastAccessDx(i)*
a;
1842 const ExprT1& expr1;
1844 mutable value_type v;
1845 mutable value_type
a;
1849 template <
typename T1,
typename ExprT2>
1850 class Expr< PowerOp< ConstExpr<T1>,ExprT2> > {
1854 typedef ConstExpr<T1> ExprT1;
1855 typedef typename ExprT1::value_type value_type_1;
1856 typedef typename ExprT2::value_type value_type_2;
1858 value_type_2>::type value_type;
1860 typedef typename ExprT1::scalar_type scalar_type_1;
1861 typedef typename ExprT2::scalar_type scalar_type_2;
1863 scalar_type_2>::type scalar_type;
1865 typedef typename ExprT1::base_expr_type base_expr_type_1;
1866 typedef typename ExprT2::base_expr_type base_expr_type_2;
1868 base_expr_type_2>::type base_expr_type;
1871 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1872 expr1(expr1_), expr2(expr2_) {}
1876 return expr2.size();
1880 bool updateValue()
const {
1881 return expr2.updateValue();
1885 void cache()
const {
1887 const value_type_1 v1 = expr1.val();
1888 const value_type_2 v2 = expr2.val();
1890 if (v1 == value_type(0)) {
1899 value_type
val()
const {
1904 bool isLinear()
const {
1909 bool hasFastAccess()
const {
1910 return expr2.hasFastAccess();
1914 const value_type
dx(
int i)
const {
1915 return expr2.dx(i)*b;
1920 return expr2.fastAccessDx(i)*b;
1926 const ExprT2& expr2;
1927 mutable value_type v;
1928 mutable value_type b;
1936 template <
typename ExprT1,
typename ExprT2>
1939 template <
typename ExprT1,
typename ExprT2>
1940 class Expr< MaxOp<ExprT1,ExprT2> > {
1944 typedef typename ExprT1::value_type value_type_1;
1945 typedef typename ExprT2::value_type value_type_2;
1947 value_type_2>::type value_type;
1949 typedef typename ExprT1::scalar_type scalar_type_1;
1950 typedef typename ExprT2::scalar_type scalar_type_2;
1952 scalar_type_2>::type scalar_type;
1954 typedef typename ExprT1::base_expr_type base_expr_type_1;
1955 typedef typename ExprT2::base_expr_type base_expr_type_2;
1957 base_expr_type_2>::type base_expr_type;
1960 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1961 expr1(expr1_), expr2(expr2_) {}
1965 int sz1 = expr1.size(), sz2 = expr2.size();
1966 return sz1 > sz2 ? sz1 : sz2;
1970 bool updateValue()
const {
1971 return expr1.updateValue() && expr2.updateValue();
1975 void cache()
const {
1978 const value_type_1 v1 = expr1.val();
1979 const value_type_2 v2 = expr2.val();
1980 max_v1 = (v1 >= v2);
1981 v = max_v1 ? v1 : v2;
1985 value_type
val()
const {
1990 bool isLinear()
const {
1995 bool hasFastAccess()
const {
1996 return expr1.hasFastAccess() && expr2.hasFastAccess();
2000 const value_type
dx(
int i)
const {
2001 return max_v1 ? expr1.dx(i) : expr2.dx(i);
2006 return max_v1 ? expr1.fastAccessDx(i) : expr2.fastAccessDx(i);
2011 const ExprT1& expr1;
2012 const ExprT2& expr2;
2013 mutable value_type v;
2014 mutable bool max_v1;
2018 template <
typename ExprT1,
typename T2>
2019 class Expr< MaxOp<ExprT1, ConstExpr<T2> > > {
2023 typedef ConstExpr<T2> ExprT2;
2024 typedef typename ExprT1::value_type value_type_1;
2025 typedef typename ExprT2::value_type value_type_2;
2027 value_type_2>::type value_type;
2029 typedef typename ExprT1::scalar_type scalar_type_1;
2030 typedef typename ExprT2::scalar_type scalar_type_2;
2032 scalar_type_2>::type scalar_type;
2034 typedef typename ExprT1::base_expr_type base_expr_type_1;
2035 typedef typename ExprT2::base_expr_type base_expr_type_2;
2037 base_expr_type_2>::type base_expr_type;
2040 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2041 expr1(expr1_), expr2(expr2_) {}
2045 return expr1.size();
2049 bool updateValue()
const {
2050 return expr1.updateValue();
2054 void cache()
const {
2056 const value_type_1 v1 = expr1.val();
2057 const value_type_2 v2 = expr2.val();
2058 max_v1 = (v1 >= v2);
2059 v = max_v1 ? v1 : v2;
2063 value_type
val()
const {
2068 bool isLinear()
const {
2073 bool hasFastAccess()
const {
2074 return expr1.hasFastAccess();
2078 const value_type
dx(
int i)
const {
2079 return max_v1 ? expr1.dx(i) : value_type(0);
2084 return max_v1 ? expr1.fastAccessDx(i) : value_type(0);
2089 const ExprT1& expr1;
2091 mutable value_type v;
2092 mutable bool max_v1;
2096 template <
typename T1,
typename ExprT2>
2097 class Expr< MaxOp< ConstExpr<T1>,ExprT2> > {
2101 typedef ConstExpr<T1> ExprT1;
2102 typedef typename ExprT1::value_type value_type_1;
2103 typedef typename ExprT2::value_type value_type_2;
2105 value_type_2>::type value_type;
2107 typedef typename ExprT1::scalar_type scalar_type_1;
2108 typedef typename ExprT2::scalar_type scalar_type_2;
2110 scalar_type_2>::type scalar_type;
2112 typedef typename ExprT1::base_expr_type base_expr_type_1;
2113 typedef typename ExprT2::base_expr_type base_expr_type_2;
2115 base_expr_type_2>::type base_expr_type;
2118 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2119 expr1(expr1_), expr2(expr2_) {}
2123 return expr2.size();
2127 bool updateValue()
const {
2128 return expr2.updateValue();
2132 void cache()
const {
2134 const value_type_1 v1 = expr1.val();
2135 const value_type_2 v2 = expr2.val();
2136 max_v1 = (v1 >= v2);
2137 v = max_v1 ? v1 : v2;
2141 value_type
val()
const {
2146 bool isLinear()
const {
2151 bool hasFastAccess()
const {
2152 return expr2.hasFastAccess();
2156 const value_type
dx(
int i)
const {
2157 return max_v1 ? value_type(0) : expr2.dx(i);
2162 return max_v1 ? value_type(0) : expr2.fastAccessDx(i);
2168 const ExprT2& expr2;
2169 mutable value_type v;
2170 mutable bool max_v1;
2178 template <
typename ExprT1,
typename ExprT2>
2181 template <
typename ExprT1,
typename ExprT2>
2182 class Expr< MinOp<ExprT1,ExprT2> > {
2186 typedef typename ExprT1::value_type value_type_1;
2187 typedef typename ExprT2::value_type value_type_2;
2189 value_type_2>::type value_type;
2191 typedef typename ExprT1::scalar_type scalar_type_1;
2192 typedef typename ExprT2::scalar_type scalar_type_2;
2194 scalar_type_2>::type scalar_type;
2196 typedef typename ExprT1::base_expr_type base_expr_type_1;
2197 typedef typename ExprT2::base_expr_type base_expr_type_2;
2199 base_expr_type_2>::type base_expr_type;
2202 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2203 expr1(expr1_), expr2(expr2_) {}
2207 int sz1 = expr1.size(), sz2 = expr2.size();
2208 return sz1 > sz2 ? sz1 : sz2;
2212 bool updateValue()
const {
2213 return expr1.updateValue() && expr2.updateValue();
2217 void cache()
const {
2220 const value_type_1 v1 = expr1.val();
2221 const value_type_2 v2 = expr2.val();
2222 min_v1 = (v1 <= v2);
2223 v = min_v1 ? v1 : v2;
2227 value_type
val()
const {
2232 bool isLinear()
const {
2237 bool hasFastAccess()
const {
2238 return expr1.hasFastAccess() && expr2.hasFastAccess();
2242 const value_type
dx(
int i)
const {
2243 return min_v1 ? expr1.dx(i) : expr2.dx(i);
2248 return min_v1 ? expr1.fastAccessDx(i) : expr2.fastAccessDx(i);
2253 const ExprT1& expr1;
2254 const ExprT2& expr2;
2255 mutable value_type v;
2256 mutable bool min_v1;
2260 template <
typename ExprT1,
typename T2>
2261 class Expr< MinOp<ExprT1, ConstExpr<T2> > > {
2265 typedef ConstExpr<T2> ExprT2;
2266 typedef typename ExprT1::value_type value_type_1;
2267 typedef typename ExprT2::value_type value_type_2;
2269 value_type_2>::type value_type;
2271 typedef typename ExprT1::scalar_type scalar_type_1;
2272 typedef typename ExprT2::scalar_type scalar_type_2;
2274 scalar_type_2>::type scalar_type;
2276 typedef typename ExprT1::base_expr_type base_expr_type_1;
2277 typedef typename ExprT2::base_expr_type base_expr_type_2;
2279 base_expr_type_2>::type base_expr_type;
2282 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2283 expr1(expr1_), expr2(expr2_) {}
2287 return expr1.size();
2291 bool updateValue()
const {
2292 return expr1.updateValue();
2296 void cache()
const {
2298 const value_type_1 v1 = expr1.val();
2299 const value_type_2 v2 = expr2.val();
2300 min_v1 = (v1 <= v2);
2301 v = min_v1 ? v1 : v2;
2305 value_type
val()
const {
2310 bool isLinear()
const {
2315 bool hasFastAccess()
const {
2316 return expr1.hasFastAccess();
2320 const value_type
dx(
int i)
const {
2321 return min_v1 ? expr1.dx(i) : value_type(0);
2326 return min_v1 ? expr1.fastAccessDx(i) : value_type(0);
2331 const ExprT1& expr1;
2333 mutable value_type v;
2334 mutable bool min_v1;
2338 template <
typename T1,
typename ExprT2>
2339 class Expr< MinOp< ConstExpr<T1>,ExprT2> > {
2343 typedef ConstExpr<T1> ExprT1;
2344 typedef typename ExprT1::value_type value_type_1;
2345 typedef typename ExprT2::value_type value_type_2;
2347 value_type_2>::type value_type;
2349 typedef typename ExprT1::scalar_type scalar_type_1;
2350 typedef typename ExprT2::scalar_type scalar_type_2;
2352 scalar_type_2>::type scalar_type;
2354 typedef typename ExprT1::base_expr_type base_expr_type_1;
2355 typedef typename ExprT2::base_expr_type base_expr_type_2;
2357 base_expr_type_2>::type base_expr_type;
2360 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2361 expr1(expr1_), expr2(expr2_) {}
2365 return expr2.size();
2369 bool updateValue()
const {
2370 return expr2.updateValue();
2374 void cache()
const {
2376 const value_type_1 v1 = expr1.val();
2377 const value_type_2 v2 = expr2.val();
2378 min_v1 = (v1 <= v2);
2379 v = min_v1 ? v1 : v2;
2383 value_type
val()
const {
2388 bool isLinear()
const {
2393 bool hasFastAccess()
const {
2394 return expr2.hasFastAccess();
2398 const value_type
dx(
int i)
const {
2399 return min_v1 ? value_type(0) : expr2.dx(i);
2404 return min_v1 ? value_type(0) : expr2.fastAccessDx(i);
2410 const ExprT2& expr2;
2411 mutable value_type v;
2412 mutable bool min_v1;
2420 #define FAD_BINARYOP_MACRO(OPNAME,OP) \
2421 namespace Sacado { \
2422 namespace CacheFad { \
2424 template <typename T1, typename T2> \
2425 SACADO_INLINE_FUNCTION \
2426 SACADO_FAD_OP_ENABLE_EXPR_EXPR(OP) \
2427 OPNAME (const T1& expr1, const T2& expr2) \
2429 typedef OP< T1, T2 > expr_t; \
2431 return Expr<expr_t>(expr1, expr2); \
2434 template <typename T> \
2435 SACADO_INLINE_FUNCTION \
2436 Expr< OP< Expr<T>, Expr<T> > > \
2437 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
2439 typedef OP< Expr<T>, Expr<T> > expr_t; \
2441 return Expr<expr_t>(expr1, expr2); \
2444 template <typename T> \
2445 SACADO_INLINE_FUNCTION \
2446 Expr< OP< ConstExpr<typename Expr<T>::value_type>, \
2448 OPNAME (const typename Expr<T>::value_type& c, \
2449 const Expr<T>& expr) \
2451 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
2452 typedef OP< ConstT, Expr<T> > expr_t; \
2454 return Expr<expr_t>(ConstT(c), expr); \
2457 template <typename T> \
2458 SACADO_INLINE_FUNCTION \
2459 Expr< OP< Expr<T>, \
2460 ConstExpr<typename Expr<T>::value_type> > > \
2461 OPNAME (const Expr<T>& expr, \
2462 const typename Expr<T>::value_type& c) \
2464 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
2465 typedef OP< Expr<T>, ConstT > expr_t; \
2467 return Expr<expr_t>(expr, ConstT(c)); \
2470 template <typename T> \
2471 SACADO_INLINE_FUNCTION \
2472 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(OP) \
2473 OPNAME (const typename Expr<T>::scalar_type& c, \
2474 const Expr<T>& expr) \
2476 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
2477 typedef OP< ConstT, Expr<T> > expr_t; \
2479 return Expr<expr_t>(ConstT(c), expr); \
2482 template <typename T> \
2483 SACADO_INLINE_FUNCTION \
2484 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(OP) \
2485 OPNAME (const Expr<T>& expr, \
2486 const typename Expr<T>::scalar_type& c) \
2488 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
2489 typedef OP< Expr<T>, ConstT > expr_t; \
2491 return Expr<expr_t>(expr, ConstT(c)); \
2506 #undef FAD_BINARYOP_MACRO
2510 #define FAD_RELOP_MACRO(OP) \
2511 namespace Sacado { \
2512 namespace CacheFad { \
2513 template <typename ExprT1, typename ExprT2> \
2514 SACADO_INLINE_FUNCTION \
2516 operator OP (const Expr<ExprT1>& expr1, \
2517 const Expr<ExprT2>& expr2) \
2521 return expr1.val() OP expr2.val(); \
2524 template <typename ExprT2> \
2525 SACADO_INLINE_FUNCTION \
2527 operator OP (const typename Expr<ExprT2>::value_type& a, \
2528 const Expr<ExprT2>& expr2) \
2531 return a OP expr2.val(); \
2534 template <typename ExprT1> \
2535 SACADO_INLINE_FUNCTION \
2537 operator OP (const Expr<ExprT1>& expr1, \
2538 const typename Expr<ExprT1>::value_type& b) \
2541 return expr1.val() OP b; \
2557 #undef FAD_RELOP_MACRO
2561 namespace CacheFad {
2563 template <
typename ExprT>
2568 return ! expr.val();
2578 namespace CacheFad {
2580 template <
typename ExprT>
2584 bool is_zero = (x.val() == 0.0);
2585 for (
int i=0;
i<x.size();
i++)
2586 is_zero = is_zero && (x.dx(
i) == 0.0);
2594 #define FAD_BOOL_MACRO(OP) \
2595 namespace Sacado { \
2596 namespace CacheFad { \
2597 template <typename ExprT1, typename ExprT2> \
2598 SACADO_INLINE_FUNCTION \
2600 operator OP (const Expr<ExprT1>& expr1, \
2601 const Expr<ExprT2>& expr2) \
2603 return toBool(expr1) OP toBool(expr2); \
2606 template <typename ExprT2> \
2607 SACADO_INLINE_FUNCTION \
2609 operator OP (const typename Expr<ExprT2>::value_type& a, \
2610 const Expr<ExprT2>& expr2) \
2612 return a OP toBool(expr2); \
2615 template <typename ExprT1> \
2616 SACADO_INLINE_FUNCTION \
2618 operator OP (const Expr<ExprT1>& expr1, \
2619 const typename Expr<ExprT1>::value_type& b) \
2621 return toBool(expr1) OP b; \
2629 #undef FAD_BOOL_MACRO
2635 namespace CacheFad {
2637 template <
typename ExprT>
2638 std::ostream& operator << (std::ostream& os, const Expr<ExprT>&
x) {
2640 os <<
x.val() <<
" [";
2642 for (
int i=0;
i<
x.size();
i++) {
2643 os <<
" " <<
x.dx(
i);
2654 #endif // SACADO_CACHEFAD_OPS_HPP
#define FAD_RELOP_MACRO(OP)
ExprT::scalar_type scalar_type
SACADO_INLINE_FUNCTION Expr< AbsOp< Expr< T > > > abs(const Expr< T > &expr)
SACADO_INLINE_FUNCTION bool isLinear() const
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
SACADO_INLINE_FUNCTION Expr(const ExprT &expr_)
#define FAD_UNARYOP_MACRO(OPNAME, OP, USING, VALUE, DX, FASTACCESSDX)
ExprT::value_type value_type
SACADO_INLINE_FUNCTION bool operator!(const Expr< ExprT > &expr)
SACADO_INLINE_FUNCTION bool updateValue() const
ExprT::base_expr_type base_expr_type
ExprT::scalar_type scalar_type
SACADO_INLINE_FUNCTION Expr(const ExprT &expr_)
SACADO_INLINE_FUNCTION bool hasFastAccess() const
SACADO_INLINE_FUNCTION void cache() const
SACADO_INLINE_FUNCTION value_type val() const
SACADO_INLINE_FUNCTION bool isLinear() const
SACADO_INLINE_FUNCTION void cache() const
#define FAD_BOOL_MACRO(OP)
SACADO_INLINE_FUNCTION void cache() const
expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 MultiplicationOp
SACADO_INLINE_FUNCTION const value_type dx(int i) const
SACADO_INLINE_FUNCTION bool isLinear() const
SACADO_INLINE_FUNCTION bool hasFastAccess() const
ExprT::base_expr_type base_expr_type
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
ExprT::value_type value_type
SACADO_INLINE_FUNCTION Expr(const ExprT &expr_)
ExprT::scalar_type scalar_type
SACADO_INLINE_FUNCTION const value_type dx(int i) const
#define FAD_BINARYOP_MACRO(OPNAME, OP, USING, VALUE, DX, CDX1, CDX2, FASTACCESSDX, VAL_CONST_DX_1, VAL_CONST_DX_2, CONST_DX_1, CONST_DX_2, CONST_FASTACCESSDX_1, CONST_FASTACCESSDX_2)
SACADO_INLINE_FUNCTION bool hasFastAccess() const
SACADO_INLINE_FUNCTION const value_type fastAccessDx(int i) const
SACADO_INLINE_FUNCTION value_type val() const
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
SACADO_INLINE_FUNCTION const value_type fastAccessDx(int i) const
SACADO_INLINE_FUNCTION const value_type fastAccessDx(int i) const
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
SACADO_INLINE_FUNCTION Expr< FAbsOp< Expr< T > > > fabs(const Expr< T > &expr)
atan2(expr1.val(), expr2.val())
SACADO_INLINE_FUNCTION Expr(const ExprT &expr_)
SACADO_INLINE_FUNCTION int size() const
SACADO_INLINE_FUNCTION bool toBool(const Expr< ExprT > &x)
ExprT::scalar_type scalar_type
SACADO_INLINE_FUNCTION bool updateValue() const
ExprT::value_type value_type
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
SACADO_INLINE_FUNCTION int size() const
SACADO_INLINE_FUNCTION bool hasFastAccess() const
SACADO_INLINE_FUNCTION const value_type fastAccessDx(int i) const
SACADO_INLINE_FUNCTION T safe_sqrt(const T &x)
SACADO_INLINE_FUNCTION bool updateValue() const
SACADO_INLINE_FUNCTION Expr< UnaryPlusOp< Expr< T > > > operator+(const Expr< T > &expr)
SACADO_INLINE_FUNCTION int size() const
SACADO_INLINE_FUNCTION bool updateValue() const
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)
SACADO_INLINE_FUNCTION int size() const
ExprT::base_expr_type base_expr_type
SACADO_INLINE_FUNCTION value_type val() const
SACADO_INLINE_FUNCTION bool isLinear() const
SACADO_INLINE_FUNCTION void cache() const
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION Expr< UnaryMinusOp< Expr< T > > > operator-(const Expr< T > &expr)
SACADO_INLINE_FUNCTION const value_type dx(int i) const
Wrapper for a generic expression template.
SACADO_INLINE_FUNCTION value_type val() const
ExprT::value_type value_type
SACADO_INLINE_FUNCTION const value_type dx(int i) const
ExprT::base_expr_type base_expr_type
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