52 #ifndef SACADO_CACHEFAD_OPS_HPP
53 #define SACADO_CACHEFAD_OPS_HPP
67 template <
typename ExprT>
70 template <
typename ExprT>
79 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
82 int size()
const {
return expr.size(); }
99 return expr.isLinear();
104 return expr.hasFastAccess();
114 return expr.fastAccessDx(i);
122 template <
typename T>
135 template <
typename ExprT>
138 template <
typename ExprT>
147 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
150 int size()
const {
return expr.size(); }
167 return expr.isLinear();
172 return expr.hasFastAccess();
182 return -expr.fastAccessDx(i);
190 template <
typename T>
204 template <
typename ExprT>
207 template <
typename ExprT>
216 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
219 int size()
const {
return expr.size(); }
243 return expr.hasFastAccess();
248 return v_pos ? expr.dx(i) :
value_type(-expr.dx(i));
253 return v_pos ? expr.fastAccessDx(i) :
value_type(-expr.fastAccessDx(i));
263 template <
typename T>
277 template <
typename ExprT>
280 template <
typename ExprT>
289 explicit Expr(
const ExprT& expr_) : expr(expr_) {}
292 int size()
const {
return expr.size(); }
316 return expr.hasFastAccess();
321 return v_pos ? expr.dx(i) :
value_type(-expr.dx(i));
326 return v_pos ? expr.fastAccessDx(i) :
value_type(-expr.fastAccessDx(i));
336 template <
typename T>
349 #define FAD_UNARYOP_MACRO(OPNAME,OP,PARTIAL,VALUE) \
351 namespace CacheFad { \
353 template <typename ExprT> \
356 template <typename ExprT> \
357 class Expr< OP<ExprT> > { \
360 typedef typename ExprT::value_type value_type; \
361 typedef typename ExprT::scalar_type scalar_type; \
362 typedef typename ExprT::base_expr_type base_expr_type; \
364 SACADO_INLINE_FUNCTION \
365 explicit Expr(const ExprT& expr_) : expr(expr_) {} \
367 SACADO_INLINE_FUNCTION \
368 int size() const { return expr.size(); } \
370 SACADO_INLINE_FUNCTION \
371 bool hasFastAccess() const { return expr.hasFastAccess(); } \
373 SACADO_INLINE_FUNCTION \
374 bool isPassive() const { return expr.isPassive();} \
376 SACADO_INLINE_FUNCTION \
377 bool updateValue() const { return expr.updateValue(); } \
379 SACADO_INLINE_FUNCTION \
380 void cache() const { \
386 SACADO_INLINE_FUNCTION \
387 value_type val() const { \
391 SACADO_INLINE_FUNCTION \
392 value_type dx(int i) const { \
393 return expr.dx(i)*a; \
396 SACADO_INLINE_FUNCTION \
397 value_type fastAccessDx(int i) const { \
398 return expr.fastAccessDx(i)*a; \
404 mutable value_type v; \
405 mutable value_type a; \
408 template <typename T> \
409 SACADO_INLINE_FUNCTION \
410 Expr< OP< Expr<T> > > \
411 OPNAME (const Expr<T>& expr) \
413 typedef OP< Expr<T> > expr_t; \
415 return Expr<expr_t>(expr); \
430 a = value_type(1)/(std::log(value_type(10))*v),
434 a = value_type(1)/(value_type(2)*std::sqrt(v)),
438 a = (v == value_type(0.0) ? value_type(0.0) : value_type(value_type(1)/(value_type(2)*std::sqrt(v)))),
450 a = value_type(1)+std::tan(v)*std::tan(v),
454 a = value_type(-1)/std::sqrt(value_type(1)-v*v),
458 a = value_type(1)/std::sqrt(value_type(1)-v*v),
462 a = value_type(1)/(value_type(1)+v*v),
474 a = value_type(1)-std::tanh(v)*std::tanh(v),
478 a = value_type(1)/std::sqrt((v-value_type(1))*(v+value_type(1))),
482 a = value_type(1)/std::sqrt(value_type(1)+v*v),
486 a = value_type(1)/(value_type(1)-v*v),
490 a = value_type(1)/(value_type(3)*std::cbrt(v*v)),
493 #undef FAD_UNARYOP_MACRO
505 template <
typename ExprT1,
typename ExprT2>
508 template <
typename ExprT1,
typename ExprT2>
509 class Expr< AdditionOp<ExprT1,ExprT2> > {
513 typedef typename ExprT1::value_type value_type_1;
514 typedef typename ExprT2::value_type value_type_2;
516 value_type_2>::type value_type;
518 typedef typename ExprT1::scalar_type scalar_type_1;
519 typedef typename ExprT2::scalar_type scalar_type_2;
521 scalar_type_2>::type scalar_type;
523 typedef typename ExprT1::base_expr_type base_expr_type_1;
524 typedef typename ExprT2::base_expr_type base_expr_type_2;
526 base_expr_type_2>::type base_expr_type;
529 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
530 expr1(expr1_), expr2(expr2_) {}
534 int sz1 = expr1.size(), sz2 = expr2.size();
535 return sz1 > sz2 ? sz1 : sz2;
539 bool updateValue()
const {
540 return expr1.updateValue() && expr2.updateValue();
550 value_type
val()
const {
551 return expr1.val()+expr2.val();
555 bool isLinear()
const {
556 return expr1.isLinear() && expr2.isLinear();
560 bool hasFastAccess()
const {
561 return expr1.hasFastAccess() && expr2.hasFastAccess();
565 const value_type
dx(
int i)
const {
566 return expr1.dx(i) + expr2.dx(i);
571 return expr1.fastAccessDx(i) + expr2.fastAccessDx(i);
581 template <
typename ExprT1,
typename T2>
582 class Expr< AdditionOp<ExprT1, ConstExpr<T2> > > {
586 typedef ConstExpr<T2> ExprT2;
587 typedef typename ExprT1::value_type value_type_1;
588 typedef typename ExprT2::value_type value_type_2;
590 value_type_2>::type value_type;
592 typedef typename ExprT1::scalar_type scalar_type_1;
593 typedef typename ExprT2::scalar_type scalar_type_2;
595 scalar_type_2>::type scalar_type;
597 typedef typename ExprT1::base_expr_type base_expr_type_1;
598 typedef typename ExprT2::base_expr_type base_expr_type_2;
600 base_expr_type_2>::type base_expr_type;
603 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
604 expr1(expr1_), expr2(expr2_) {}
612 bool updateValue()
const {
613 return expr1.updateValue();
622 value_type
val()
const {
623 return expr1.val() + expr2.val();
627 bool isLinear()
const {
628 return expr1.isLinear();
632 bool hasFastAccess()
const {
633 return expr1.hasFastAccess();
637 const value_type
dx(
int i)
const {
643 return expr1.fastAccessDx(i);
653 template <
typename T1,
typename ExprT2>
654 class Expr< AdditionOp< ConstExpr<T1>,ExprT2> > {
658 typedef ConstExpr<T1> ExprT1;
659 typedef typename ExprT1::value_type value_type_1;
660 typedef typename ExprT2::value_type value_type_2;
662 value_type_2>::type value_type;
664 typedef typename ExprT1::scalar_type scalar_type_1;
665 typedef typename ExprT2::scalar_type scalar_type_2;
667 scalar_type_2>::type scalar_type;
669 typedef typename ExprT1::base_expr_type base_expr_type_1;
670 typedef typename ExprT2::base_expr_type base_expr_type_2;
672 base_expr_type_2>::type base_expr_type;
675 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
676 expr1(expr1_), expr2(expr2_) {}
684 bool updateValue()
const {
685 return expr2.updateValue();
694 value_type
val()
const {
695 return expr1.val() + expr2.val();
699 bool isLinear()
const {
700 return expr2.isLinear();
704 bool hasFastAccess()
const {
705 return expr2.hasFastAccess();
709 const value_type
dx(
int i)
const {
715 return expr2.fastAccessDx(i);
729 template <
typename ExprT1,
typename ExprT2>
732 template <
typename ExprT1,
typename ExprT2>
733 class Expr< SubtractionOp<ExprT1,ExprT2> > {
737 typedef typename ExprT1::value_type value_type_1;
738 typedef typename ExprT2::value_type value_type_2;
740 value_type_2>::type value_type;
742 typedef typename ExprT1::scalar_type scalar_type_1;
743 typedef typename ExprT2::scalar_type scalar_type_2;
745 scalar_type_2>::type scalar_type;
747 typedef typename ExprT1::base_expr_type base_expr_type_1;
748 typedef typename ExprT2::base_expr_type base_expr_type_2;
750 base_expr_type_2>::type base_expr_type;
753 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
754 expr1(expr1_), expr2(expr2_) {}
758 int sz1 = expr1.size(), sz2 = expr2.size();
759 return sz1 > sz2 ? sz1 : sz2;
763 bool updateValue()
const {
764 return expr1.updateValue() && expr2.updateValue();
774 value_type
val()
const {
775 return expr1.val()-expr2.val();
779 bool isLinear()
const {
780 return expr1.isLinear() && expr2.isLinear();
784 bool hasFastAccess()
const {
785 return expr1.hasFastAccess() && expr2.hasFastAccess();
789 const value_type
dx(
int i)
const {
790 return expr1.dx(i) - expr2.dx(i);
795 return expr1.fastAccessDx(i) - expr2.fastAccessDx(i);
805 template <
typename ExprT1,
typename T2>
806 class Expr< SubtractionOp<ExprT1, ConstExpr<T2> > > {
810 typedef ConstExpr<T2> ExprT2;
811 typedef typename ExprT1::value_type value_type_1;
812 typedef typename ExprT2::value_type value_type_2;
814 value_type_2>::type value_type;
816 typedef typename ExprT1::scalar_type scalar_type_1;
817 typedef typename ExprT2::scalar_type scalar_type_2;
819 scalar_type_2>::type scalar_type;
821 typedef typename ExprT1::base_expr_type base_expr_type_1;
822 typedef typename ExprT2::base_expr_type base_expr_type_2;
824 base_expr_type_2>::type base_expr_type;
827 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
828 expr1(expr1_), expr2(expr2_) {}
836 bool updateValue()
const {
837 return expr1.updateValue();
846 value_type
val()
const {
847 return expr1.val() - expr2.val();
851 bool isLinear()
const {
852 return expr1.isLinear();
856 bool hasFastAccess()
const {
857 return expr1.hasFastAccess();
861 const value_type
dx(
int i)
const {
867 return expr1.fastAccessDx(i);
877 template <
typename T1,
typename ExprT2>
878 class Expr< SubtractionOp< ConstExpr<T1>,ExprT2> > {
882 typedef ConstExpr<T1> ExprT1;
883 typedef typename ExprT1::value_type value_type_1;
884 typedef typename ExprT2::value_type value_type_2;
886 value_type_2>::type value_type;
888 typedef typename ExprT1::scalar_type scalar_type_1;
889 typedef typename ExprT2::scalar_type scalar_type_2;
891 scalar_type_2>::type scalar_type;
893 typedef typename ExprT1::base_expr_type base_expr_type_1;
894 typedef typename ExprT2::base_expr_type base_expr_type_2;
896 base_expr_type_2>::type base_expr_type;
899 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
900 expr1(expr1_), expr2(expr2_) {}
908 bool updateValue()
const {
909 return expr2.updateValue();
918 value_type
val()
const {
919 return expr1.val() - expr2.val();
923 bool isLinear()
const {
924 return expr2.isLinear();
928 bool hasFastAccess()
const {
929 return expr2.hasFastAccess();
933 const value_type
dx(
int i)
const {
939 return -expr2.fastAccessDx(i);
953 template <
typename ExprT1,
typename ExprT2>
956 template <
typename ExprT1,
typename ExprT2>
957 class Expr< MultiplicationOp<ExprT1,ExprT2> > {
961 typedef typename ExprT1::value_type value_type_1;
962 typedef typename ExprT2::value_type value_type_2;
964 value_type_2>::type value_type;
966 typedef typename ExprT1::scalar_type scalar_type_1;
967 typedef typename ExprT2::scalar_type scalar_type_2;
969 scalar_type_2>::type scalar_type;
971 typedef typename ExprT1::base_expr_type base_expr_type_1;
972 typedef typename ExprT2::base_expr_type base_expr_type_2;
974 base_expr_type_2>::type base_expr_type;
977 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
978 expr1(expr1_), expr2(expr2_) {}
982 int sz1 = expr1.size(), sz2 = expr2.size();
983 return sz1 > sz2 ? sz1 : sz2;
987 bool updateValue()
const {
988 return expr1.updateValue() && expr2.updateValue();
1000 value_type
val()
const {
1005 bool isLinear()
const {
1010 bool hasFastAccess()
const {
1011 return expr1.hasFastAccess() && expr2.hasFastAccess();
1015 const value_type
dx(
int i)
const {
1016 if (expr1.size() > 0 && expr2.size() > 0)
1017 return v1*expr2.dx(i) + expr1.dx(i)*v2;
1018 else if (expr1.size() > 0)
1019 return expr1.dx(i)*v2;
1021 return v1*expr2.dx(i);
1026 return v1*expr2.fastAccessDx(i) + expr1.fastAccessDx(i)*v2;
1031 const ExprT1& expr1;
1032 const ExprT2& expr2;
1033 mutable value_type_1 v1;
1034 mutable value_type_2 v2;
1038 template <
typename ExprT1,
typename T2>
1039 class Expr< MultiplicationOp<ExprT1, ConstExpr<T2> > > {
1043 typedef ConstExpr<T2> ExprT2;
1044 typedef typename ExprT1::value_type value_type_1;
1045 typedef typename ExprT2::value_type value_type_2;
1047 value_type_2>::type value_type;
1049 typedef typename ExprT1::scalar_type scalar_type_1;
1050 typedef typename ExprT2::scalar_type scalar_type_2;
1052 scalar_type_2>::type scalar_type;
1054 typedef typename ExprT1::base_expr_type base_expr_type_1;
1055 typedef typename ExprT2::base_expr_type base_expr_type_2;
1057 base_expr_type_2>::type base_expr_type;
1060 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1061 expr1(expr1_), expr2(expr2_) {}
1065 return expr1.size();
1069 bool updateValue()
const {
1070 return expr1.updateValue();
1074 void cache()
const {
1079 value_type
val()
const {
1080 return expr1.val()*expr2.val();
1084 bool isLinear()
const {
1085 return expr1.isLinear();
1089 bool hasFastAccess()
const {
1090 return expr1.hasFastAccess();
1094 const value_type
dx(
int i)
const {
1095 return expr1.dx(i)*expr2.val();
1100 return expr1.fastAccessDx(i)*expr2.val();
1105 const ExprT1& expr1;
1110 template <
typename T1,
typename ExprT2>
1111 class Expr< MultiplicationOp< ConstExpr<T1>,ExprT2> > {
1115 typedef ConstExpr<T1> ExprT1;
1116 typedef typename ExprT1::value_type value_type_1;
1117 typedef typename ExprT2::value_type value_type_2;
1119 value_type_2>::type value_type;
1121 typedef typename ExprT1::scalar_type scalar_type_1;
1122 typedef typename ExprT2::scalar_type scalar_type_2;
1124 scalar_type_2>::type scalar_type;
1126 typedef typename ExprT1::base_expr_type base_expr_type_1;
1127 typedef typename ExprT2::base_expr_type base_expr_type_2;
1129 base_expr_type_2>::type base_expr_type;
1132 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1133 expr1(expr1_), expr2(expr2_) {}
1137 return expr2.size();
1141 bool updateValue()
const {
1142 return expr2.updateValue();
1146 void cache()
const {
1151 value_type
val()
const {
1152 return expr1.val()*expr2.val();
1156 bool isLinear()
const {
1157 return expr2.isLinear();
1161 bool hasFastAccess()
const {
1162 return expr2.hasFastAccess();
1166 const value_type
dx(
int i)
const {
1167 return expr1.val()*expr2.dx(i);
1172 return expr1.val()*expr2.fastAccessDx(i);
1178 const ExprT2& expr2;
1186 template <
typename ExprT1,
typename ExprT2>
1189 template <
typename ExprT1,
typename ExprT2>
1190 class Expr< DivisionOp<ExprT1,ExprT2> > {
1194 typedef typename ExprT1::value_type value_type_1;
1195 typedef typename ExprT2::value_type value_type_2;
1197 value_type_2>::type value_type;
1199 typedef typename ExprT1::scalar_type scalar_type_1;
1200 typedef typename ExprT2::scalar_type scalar_type_2;
1202 scalar_type_2>::type scalar_type;
1204 typedef typename ExprT1::base_expr_type base_expr_type_1;
1205 typedef typename ExprT2::base_expr_type base_expr_type_2;
1207 base_expr_type_2>::type base_expr_type;
1210 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1211 expr1(expr1_), expr2(expr2_) {}
1215 int sz1 = expr1.size(), sz2 = expr2.size();
1216 return sz1 > sz2 ? sz1 : sz2;
1220 bool updateValue()
const {
1221 return expr1.updateValue() && expr2.updateValue();
1225 void cache()
const {
1228 const value_type_1 v1 = expr1.val();
1229 const value_type_2 v2 = expr2.val();
1230 a = value_type(1)/v2;
1236 value_type
val()
const {
1241 bool isLinear()
const {
1246 bool hasFastAccess()
const {
1247 return expr1.hasFastAccess() && expr2.hasFastAccess();
1251 const value_type
dx(
int i)
const {
1252 if (expr1.size() > 0 && expr2.size() > 0)
1253 return expr1.dx(i)*
a + expr2.dx(i)*b;
1254 else if (expr1.size() > 0)
1255 return expr1.dx(i)*
a;
1257 return expr1.val()*b;
1262 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1267 const ExprT1& expr1;
1268 const ExprT2& expr2;
1269 mutable value_type v;
1270 mutable value_type
a;
1271 mutable value_type b;
1275 template <
typename ExprT1,
typename T2>
1276 class Expr< DivisionOp<ExprT1, ConstExpr<T2> > > {
1280 typedef ConstExpr<T2> ExprT2;
1281 typedef typename ExprT1::value_type value_type_1;
1282 typedef typename ExprT2::value_type value_type_2;
1284 value_type_2>::type value_type;
1286 typedef typename ExprT1::scalar_type scalar_type_1;
1287 typedef typename ExprT2::scalar_type scalar_type_2;
1289 scalar_type_2>::type scalar_type;
1291 typedef typename ExprT1::base_expr_type base_expr_type_1;
1292 typedef typename ExprT2::base_expr_type base_expr_type_2;
1294 base_expr_type_2>::type base_expr_type;
1297 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1298 expr1(expr1_), expr2(expr2_) {}
1302 return expr1.size();
1306 bool updateValue()
const {
1307 return expr1.updateValue();
1311 void cache()
const {
1313 const value_type_1 v1 = expr1.val();
1314 a = value_type(1)/expr2.val();
1319 value_type
val()
const {
1324 bool isLinear()
const {
1325 return expr1.isLinear();
1329 bool hasFastAccess()
const {
1330 return expr1.hasFastAccess();
1334 const value_type
dx(
int i)
const {
1335 return expr1.dx(i)*
a;
1340 return expr1.fastAccessDx(i)*
a;
1345 const ExprT1& expr1;
1347 mutable value_type v;
1348 mutable value_type
a;
1352 template <
typename T1,
typename ExprT2>
1353 class Expr< DivisionOp< ConstExpr<T1>,ExprT2> > {
1357 typedef ConstExpr<T1> ExprT1;
1358 typedef typename ExprT1::value_type value_type_1;
1359 typedef typename ExprT2::value_type value_type_2;
1361 value_type_2>::type value_type;
1363 typedef typename ExprT1::scalar_type scalar_type_1;
1364 typedef typename ExprT2::scalar_type scalar_type_2;
1366 scalar_type_2>::type scalar_type;
1368 typedef typename ExprT1::base_expr_type base_expr_type_1;
1369 typedef typename ExprT2::base_expr_type base_expr_type_2;
1371 base_expr_type_2>::type base_expr_type;
1374 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1375 expr1(expr1_), expr2(expr2_) {}
1379 return expr2.size();
1383 bool updateValue()
const {
1384 return expr2.updateValue();
1388 void cache()
const {
1390 const value_type_2 v2 = expr2.val();
1396 value_type
val()
const {
1401 bool isLinear()
const {
1406 bool hasFastAccess()
const {
1407 return expr2.hasFastAccess();
1411 const value_type
dx(
int i)
const {
1412 return expr2.dx(i)*b;
1417 return expr2.fastAccessDx(i)*b;
1423 const ExprT2& expr2;
1424 mutable value_type v;
1425 mutable value_type b;
1433 template <
typename ExprT1,
typename ExprT2>
1436 template <
typename ExprT1,
typename ExprT2>
1437 class Expr< Atan2Op<ExprT1,ExprT2> > {
1441 typedef typename ExprT1::value_type value_type_1;
1442 typedef typename ExprT2::value_type value_type_2;
1444 value_type_2>::type value_type;
1446 typedef typename ExprT1::scalar_type scalar_type_1;
1447 typedef typename ExprT2::scalar_type scalar_type_2;
1449 scalar_type_2>::type scalar_type;
1451 typedef typename ExprT1::base_expr_type base_expr_type_1;
1452 typedef typename ExprT2::base_expr_type base_expr_type_2;
1454 base_expr_type_2>::type base_expr_type;
1457 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1458 expr1(expr1_), expr2(expr2_) {}
1462 int sz1 = expr1.size(), sz2 = expr2.size();
1463 return sz1 > sz2 ? sz1 : sz2;
1467 bool updateValue()
const {
1468 return expr1.updateValue() && expr2.updateValue();
1472 void cache()
const {
1475 const value_type_1 v1 = expr1.val();
1476 const value_type_2 v2 = expr2.val();
1477 a = value_type(1)/(v1*v1 + v2*v2);
1484 value_type
val()
const {
1489 bool isLinear()
const {
1494 bool hasFastAccess()
const {
1495 return expr1.hasFastAccess() && expr2.hasFastAccess();
1499 const value_type
dx(
int i)
const {
1500 if (expr1.size() > 0 && expr2.size() > 0)
1501 return expr1.dx(i)*
a + expr2.dx(i)*b;
1502 else if (expr1.size() > 0)
1503 return expr1.dx(i)*
a;
1505 return expr1.val()*b;
1510 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1515 const ExprT1& expr1;
1516 const ExprT2& expr2;
1517 mutable value_type v;
1518 mutable value_type
a;
1519 mutable value_type b;
1523 template <
typename ExprT1,
typename T2>
1524 class Expr< Atan2Op<ExprT1, ConstExpr<T2> > > {
1528 typedef ConstExpr<T2> ExprT2;
1529 typedef typename ExprT1::value_type value_type_1;
1530 typedef typename ExprT2::value_type value_type_2;
1532 value_type_2>::type value_type;
1534 typedef typename ExprT1::scalar_type scalar_type_1;
1535 typedef typename ExprT2::scalar_type scalar_type_2;
1537 scalar_type_2>::type scalar_type;
1539 typedef typename ExprT1::base_expr_type base_expr_type_1;
1540 typedef typename ExprT2::base_expr_type base_expr_type_2;
1542 base_expr_type_2>::type base_expr_type;
1545 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1546 expr1(expr1_), expr2(expr2_) {}
1550 return expr1.size();
1554 bool updateValue()
const {
1555 return expr1.updateValue();
1559 void cache()
const {
1561 const value_type_1 v1 = expr1.val();
1562 const value_type_2 v2 = expr2.val();
1563 a = v2/(v1*v1 + v2*v2);
1568 value_type
val()
const {
1573 bool isLinear()
const {
1578 bool hasFastAccess()
const {
1579 return expr1.hasFastAccess();
1583 const value_type
dx(
int i)
const {
1584 return expr1.dx(i)*
a;
1589 return expr1.fastAccessDx(i)*
a;
1594 const ExprT1& expr1;
1596 mutable value_type v;
1597 mutable value_type
a;
1601 template <
typename T1,
typename ExprT2>
1602 class Expr< Atan2Op< ConstExpr<T1>,ExprT2> > {
1606 typedef ConstExpr<T1> ExprT1;
1607 typedef typename ExprT1::value_type value_type_1;
1608 typedef typename ExprT2::value_type value_type_2;
1610 value_type_2>::type value_type;
1612 typedef typename ExprT1::scalar_type scalar_type_1;
1613 typedef typename ExprT2::scalar_type scalar_type_2;
1615 scalar_type_2>::type scalar_type;
1617 typedef typename ExprT1::base_expr_type base_expr_type_1;
1618 typedef typename ExprT2::base_expr_type base_expr_type_2;
1620 base_expr_type_2>::type base_expr_type;
1623 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1624 expr1(expr1_), expr2(expr2_) {}
1628 return expr2.size();
1632 bool updateValue()
const {
1633 return expr2.updateValue();
1637 void cache()
const {
1639 const value_type_1 v1 = expr1.val();
1640 const value_type_2 v2 = expr2.val();
1641 b = -v1/(v1*v1 + v2*v2);
1646 value_type
val()
const {
1651 bool isLinear()
const {
1656 bool hasFastAccess()
const {
1657 return expr2.hasFastAccess();
1661 const value_type
dx(
int i)
const {
1662 return expr2.dx(i)*b;
1667 return expr2.fastAccessDx(i)*b;
1673 const ExprT2& expr2;
1674 mutable value_type v;
1675 mutable value_type b;
1683 template <
typename ExprT1,
typename ExprT2>
1686 template <
typename ExprT1,
typename ExprT2>
1687 class Expr< PowerOp<ExprT1,ExprT2> > {
1691 typedef typename ExprT1::value_type value_type_1;
1692 typedef typename ExprT2::value_type value_type_2;
1694 value_type_2>::type value_type;
1696 typedef typename ExprT1::scalar_type scalar_type_1;
1697 typedef typename ExprT2::scalar_type scalar_type_2;
1699 scalar_type_2>::type scalar_type;
1701 typedef typename ExprT1::base_expr_type base_expr_type_1;
1702 typedef typename ExprT2::base_expr_type base_expr_type_2;
1704 base_expr_type_2>::type base_expr_type;
1707 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1708 expr1(expr1_), expr2(expr2_) {}
1712 int sz1 = expr1.size(), sz2 = expr2.size();
1713 return sz1 > sz2 ? sz1 : sz2;
1717 bool updateValue()
const {
1718 return expr1.updateValue() && expr2.updateValue();
1722 void cache()
const {
1725 const value_type_1 v1 = expr1.val();
1726 const value_type_2 v2 = expr2.val();
1728 if (expr2.size() == 0 && v2 == value_type(1)) {
1732 else if (v1 == value_type(0)) {
1743 value_type
val()
const {
1748 bool isLinear()
const {
1753 bool hasFastAccess()
const {
1754 return expr1.hasFastAccess() && expr2.hasFastAccess();
1758 const value_type
dx(
int i)
const {
1759 if (expr1.size() > 0 && expr2.size() > 0)
1760 return expr1.dx(i)*
a + expr2.dx(i)*b;
1761 else if (expr1.size() > 0)
1762 return expr1.dx(i)*
a;
1764 return expr1.val()*b;
1769 return expr1.fastAccessDx(i)*
a + expr2.fastAccessDx(i)*b;
1774 const ExprT1& expr1;
1775 const ExprT2& expr2;
1776 mutable value_type v;
1777 mutable value_type
a;
1778 mutable value_type b;
1782 template <
typename ExprT1,
typename T2>
1783 class Expr< PowerOp<ExprT1, ConstExpr<T2> > > {
1787 typedef ConstExpr<T2> ExprT2;
1788 typedef typename ExprT1::value_type value_type_1;
1789 typedef typename ExprT2::value_type value_type_2;
1791 value_type_2>::type value_type;
1793 typedef typename ExprT1::scalar_type scalar_type_1;
1794 typedef typename ExprT2::scalar_type scalar_type_2;
1796 scalar_type_2>::type scalar_type;
1798 typedef typename ExprT1::base_expr_type base_expr_type_1;
1799 typedef typename ExprT2::base_expr_type base_expr_type_2;
1801 base_expr_type_2>::type base_expr_type;
1804 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1805 expr1(expr1_), expr2(expr2_) {}
1809 return expr1.size();
1813 bool updateValue()
const {
1814 return expr1.updateValue();
1818 void cache()
const {
1820 const value_type_1 v1 = expr1.val();
1821 const value_type_2 v2 = expr2.val();
1823 if (v2 == value_type_1(1)) {
1826 else if (v1 == value_type_1(0)) {
1835 value_type
val()
const {
1840 bool isLinear()
const {
1845 bool hasFastAccess()
const {
1846 return expr1.hasFastAccess();
1850 const value_type
dx(
int i)
const {
1851 return expr1.dx(i)*
a;
1856 return expr1.fastAccessDx(i)*
a;
1861 const ExprT1& expr1;
1863 mutable value_type v;
1864 mutable value_type
a;
1868 template <
typename T1,
typename ExprT2>
1869 class Expr< PowerOp< ConstExpr<T1>,ExprT2> > {
1873 typedef ConstExpr<T1> ExprT1;
1874 typedef typename ExprT1::value_type value_type_1;
1875 typedef typename ExprT2::value_type value_type_2;
1877 value_type_2>::type value_type;
1879 typedef typename ExprT1::scalar_type scalar_type_1;
1880 typedef typename ExprT2::scalar_type scalar_type_2;
1882 scalar_type_2>::type scalar_type;
1884 typedef typename ExprT1::base_expr_type base_expr_type_1;
1885 typedef typename ExprT2::base_expr_type base_expr_type_2;
1887 base_expr_type_2>::type base_expr_type;
1890 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1891 expr1(expr1_), expr2(expr2_) {}
1895 return expr2.size();
1899 bool updateValue()
const {
1900 return expr2.updateValue();
1904 void cache()
const {
1906 const value_type_1 v1 = expr1.val();
1907 const value_type_2 v2 = expr2.val();
1909 if (v1 == value_type(0)) {
1918 value_type
val()
const {
1923 bool isLinear()
const {
1928 bool hasFastAccess()
const {
1929 return expr2.hasFastAccess();
1933 const value_type
dx(
int i)
const {
1934 return expr2.dx(i)*b;
1939 return expr2.fastAccessDx(i)*b;
1945 const ExprT2& expr2;
1946 mutable value_type v;
1947 mutable value_type b;
1955 template <
typename ExprT1,
typename ExprT2>
1958 template <
typename ExprT1,
typename ExprT2>
1959 class Expr< MaxOp<ExprT1,ExprT2> > {
1963 typedef typename ExprT1::value_type value_type_1;
1964 typedef typename ExprT2::value_type value_type_2;
1966 value_type_2>::type value_type;
1968 typedef typename ExprT1::scalar_type scalar_type_1;
1969 typedef typename ExprT2::scalar_type scalar_type_2;
1971 scalar_type_2>::type scalar_type;
1973 typedef typename ExprT1::base_expr_type base_expr_type_1;
1974 typedef typename ExprT2::base_expr_type base_expr_type_2;
1976 base_expr_type_2>::type base_expr_type;
1979 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
1980 expr1(expr1_), expr2(expr2_) {}
1984 int sz1 = expr1.size(), sz2 = expr2.size();
1985 return sz1 > sz2 ? sz1 : sz2;
1989 bool updateValue()
const {
1990 return expr1.updateValue() && expr2.updateValue();
1994 void cache()
const {
1997 const value_type_1 v1 = expr1.val();
1998 const value_type_2 v2 = expr2.val();
1999 max_v1 = (v1 >= v2);
2000 v = max_v1 ? v1 : v2;
2004 value_type
val()
const {
2009 bool isLinear()
const {
2014 bool hasFastAccess()
const {
2015 return expr1.hasFastAccess() && expr2.hasFastAccess();
2019 const value_type
dx(
int i)
const {
2020 return max_v1 ? expr1.dx(i) : expr2.dx(i);
2025 return max_v1 ? expr1.fastAccessDx(i) : expr2.fastAccessDx(i);
2030 const ExprT1& expr1;
2031 const ExprT2& expr2;
2032 mutable value_type v;
2033 mutable bool max_v1;
2037 template <
typename ExprT1,
typename T2>
2038 class Expr< MaxOp<ExprT1, ConstExpr<T2> > > {
2042 typedef ConstExpr<T2> ExprT2;
2043 typedef typename ExprT1::value_type value_type_1;
2044 typedef typename ExprT2::value_type value_type_2;
2046 value_type_2>::type value_type;
2048 typedef typename ExprT1::scalar_type scalar_type_1;
2049 typedef typename ExprT2::scalar_type scalar_type_2;
2051 scalar_type_2>::type scalar_type;
2053 typedef typename ExprT1::base_expr_type base_expr_type_1;
2054 typedef typename ExprT2::base_expr_type base_expr_type_2;
2056 base_expr_type_2>::type base_expr_type;
2059 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2060 expr1(expr1_), expr2(expr2_) {}
2064 return expr1.size();
2068 bool updateValue()
const {
2069 return expr1.updateValue();
2073 void cache()
const {
2075 const value_type_1 v1 = expr1.val();
2076 const value_type_2 v2 = expr2.val();
2077 max_v1 = (v1 >= v2);
2078 v = max_v1 ? v1 : v2;
2082 value_type
val()
const {
2087 bool isLinear()
const {
2092 bool hasFastAccess()
const {
2093 return expr1.hasFastAccess();
2097 const value_type
dx(
int i)
const {
2098 return max_v1 ? expr1.dx(i) : value_type(0);
2103 return max_v1 ? expr1.fastAccessDx(i) : value_type(0);
2108 const ExprT1& expr1;
2110 mutable value_type v;
2111 mutable bool max_v1;
2115 template <
typename T1,
typename ExprT2>
2116 class Expr< MaxOp< ConstExpr<T1>,ExprT2> > {
2120 typedef ConstExpr<T1> ExprT1;
2121 typedef typename ExprT1::value_type value_type_1;
2122 typedef typename ExprT2::value_type value_type_2;
2124 value_type_2>::type value_type;
2126 typedef typename ExprT1::scalar_type scalar_type_1;
2127 typedef typename ExprT2::scalar_type scalar_type_2;
2129 scalar_type_2>::type scalar_type;
2131 typedef typename ExprT1::base_expr_type base_expr_type_1;
2132 typedef typename ExprT2::base_expr_type base_expr_type_2;
2134 base_expr_type_2>::type base_expr_type;
2137 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2138 expr1(expr1_), expr2(expr2_) {}
2142 return expr2.size();
2146 bool updateValue()
const {
2147 return expr2.updateValue();
2151 void cache()
const {
2153 const value_type_1 v1 = expr1.val();
2154 const value_type_2 v2 = expr2.val();
2155 max_v1 = (v1 >= v2);
2156 v = max_v1 ? v1 : v2;
2160 value_type
val()
const {
2165 bool isLinear()
const {
2170 bool hasFastAccess()
const {
2171 return expr2.hasFastAccess();
2175 const value_type
dx(
int i)
const {
2176 return max_v1 ? value_type(0) : expr2.dx(i);
2181 return max_v1 ? value_type(0) : expr2.fastAccessDx(i);
2187 const ExprT2& expr2;
2188 mutable value_type v;
2189 mutable bool max_v1;
2197 template <
typename ExprT1,
typename ExprT2>
2200 template <
typename ExprT1,
typename ExprT2>
2201 class Expr< MinOp<ExprT1,ExprT2> > {
2205 typedef typename ExprT1::value_type value_type_1;
2206 typedef typename ExprT2::value_type value_type_2;
2208 value_type_2>::type value_type;
2210 typedef typename ExprT1::scalar_type scalar_type_1;
2211 typedef typename ExprT2::scalar_type scalar_type_2;
2213 scalar_type_2>::type scalar_type;
2215 typedef typename ExprT1::base_expr_type base_expr_type_1;
2216 typedef typename ExprT2::base_expr_type base_expr_type_2;
2218 base_expr_type_2>::type base_expr_type;
2221 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2222 expr1(expr1_), expr2(expr2_) {}
2226 int sz1 = expr1.size(), sz2 = expr2.size();
2227 return sz1 > sz2 ? sz1 : sz2;
2231 bool updateValue()
const {
2232 return expr1.updateValue() && expr2.updateValue();
2236 void cache()
const {
2239 const value_type_1 v1 = expr1.val();
2240 const value_type_2 v2 = expr2.val();
2241 min_v1 = (v1 <= v2);
2242 v = min_v1 ? v1 : v2;
2246 value_type
val()
const {
2251 bool isLinear()
const {
2256 bool hasFastAccess()
const {
2257 return expr1.hasFastAccess() && expr2.hasFastAccess();
2261 const value_type
dx(
int i)
const {
2262 return min_v1 ? expr1.dx(i) : expr2.dx(i);
2267 return min_v1 ? expr1.fastAccessDx(i) : expr2.fastAccessDx(i);
2272 const ExprT1& expr1;
2273 const ExprT2& expr2;
2274 mutable value_type v;
2275 mutable bool min_v1;
2279 template <
typename ExprT1,
typename T2>
2280 class Expr< MinOp<ExprT1, ConstExpr<T2> > > {
2284 typedef ConstExpr<T2> ExprT2;
2285 typedef typename ExprT1::value_type value_type_1;
2286 typedef typename ExprT2::value_type value_type_2;
2288 value_type_2>::type value_type;
2290 typedef typename ExprT1::scalar_type scalar_type_1;
2291 typedef typename ExprT2::scalar_type scalar_type_2;
2293 scalar_type_2>::type scalar_type;
2295 typedef typename ExprT1::base_expr_type base_expr_type_1;
2296 typedef typename ExprT2::base_expr_type base_expr_type_2;
2298 base_expr_type_2>::type base_expr_type;
2301 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2302 expr1(expr1_), expr2(expr2_) {}
2306 return expr1.size();
2310 bool updateValue()
const {
2311 return expr1.updateValue();
2315 void cache()
const {
2317 const value_type_1 v1 = expr1.val();
2318 const value_type_2 v2 = expr2.val();
2319 min_v1 = (v1 <= v2);
2320 v = min_v1 ? v1 : v2;
2324 value_type
val()
const {
2329 bool isLinear()
const {
2334 bool hasFastAccess()
const {
2335 return expr1.hasFastAccess();
2339 const value_type
dx(
int i)
const {
2340 return min_v1 ? expr1.dx(i) : value_type(0);
2345 return min_v1 ? expr1.fastAccessDx(i) : value_type(0);
2350 const ExprT1& expr1;
2352 mutable value_type v;
2353 mutable bool min_v1;
2357 template <
typename T1,
typename ExprT2>
2358 class Expr< MinOp< ConstExpr<T1>,ExprT2> > {
2362 typedef ConstExpr<T1> ExprT1;
2363 typedef typename ExprT1::value_type value_type_1;
2364 typedef typename ExprT2::value_type value_type_2;
2366 value_type_2>::type value_type;
2368 typedef typename ExprT1::scalar_type scalar_type_1;
2369 typedef typename ExprT2::scalar_type scalar_type_2;
2371 scalar_type_2>::type scalar_type;
2373 typedef typename ExprT1::base_expr_type base_expr_type_1;
2374 typedef typename ExprT2::base_expr_type base_expr_type_2;
2376 base_expr_type_2>::type base_expr_type;
2379 Expr(
const ExprT1& expr1_,
const ExprT2& expr2_) :
2380 expr1(expr1_), expr2(expr2_) {}
2384 return expr2.size();
2388 bool updateValue()
const {
2389 return expr2.updateValue();
2393 void cache()
const {
2395 const value_type_1 v1 = expr1.val();
2396 const value_type_2 v2 = expr2.val();
2397 min_v1 = (v1 <= v2);
2398 v = min_v1 ? v1 : v2;
2402 value_type
val()
const {
2407 bool isLinear()
const {
2412 bool hasFastAccess()
const {
2413 return expr2.hasFastAccess();
2417 const value_type
dx(
int i)
const {
2418 return min_v1 ? value_type(0) : expr2.dx(i);
2423 return min_v1 ? value_type(0) : expr2.fastAccessDx(i);
2429 const ExprT2& expr2;
2430 mutable value_type v;
2431 mutable bool min_v1;
2439 #define FAD_BINARYOP_MACRO(OPNAME,OP) \
2440 namespace Sacado { \
2441 namespace CacheFad { \
2443 template <typename T1, typename T2> \
2444 SACADO_INLINE_FUNCTION \
2445 SACADO_FAD_OP_ENABLE_EXPR_EXPR(OP) \
2446 OPNAME (const T1& expr1, const T2& expr2) \
2448 typedef OP< T1, T2 > expr_t; \
2450 return Expr<expr_t>(expr1, expr2); \
2453 template <typename T> \
2454 SACADO_INLINE_FUNCTION \
2455 Expr< OP< Expr<T>, Expr<T> > > \
2456 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
2458 typedef OP< Expr<T>, Expr<T> > expr_t; \
2460 return Expr<expr_t>(expr1, expr2); \
2463 template <typename T> \
2464 SACADO_INLINE_FUNCTION \
2465 Expr< OP< ConstExpr<typename Expr<T>::value_type>, \
2467 OPNAME (const typename Expr<T>::value_type& c, \
2468 const Expr<T>& expr) \
2470 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
2471 typedef OP< ConstT, Expr<T> > expr_t; \
2473 return Expr<expr_t>(ConstT(c), expr); \
2476 template <typename T> \
2477 SACADO_INLINE_FUNCTION \
2478 Expr< OP< Expr<T>, \
2479 ConstExpr<typename Expr<T>::value_type> > > \
2480 OPNAME (const Expr<T>& expr, \
2481 const typename Expr<T>::value_type& c) \
2483 typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
2484 typedef OP< Expr<T>, ConstT > expr_t; \
2486 return Expr<expr_t>(expr, ConstT(c)); \
2489 template <typename T> \
2490 SACADO_INLINE_FUNCTION \
2491 SACADO_FAD_OP_ENABLE_SCALAR_EXPR(OP) \
2492 OPNAME (const typename Expr<T>::scalar_type& c, \
2493 const Expr<T>& expr) \
2495 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
2496 typedef OP< ConstT, Expr<T> > expr_t; \
2498 return Expr<expr_t>(ConstT(c), expr); \
2501 template <typename T> \
2502 SACADO_INLINE_FUNCTION \
2503 SACADO_FAD_OP_ENABLE_EXPR_SCALAR(OP) \
2504 OPNAME (const Expr<T>& expr, \
2505 const typename Expr<T>::scalar_type& c) \
2507 typedef ConstExpr<typename Expr<T>::scalar_type> ConstT; \
2508 typedef OP< Expr<T>, ConstT > expr_t; \
2510 return Expr<expr_t>(expr, ConstT(c)); \
2525 #undef FAD_BINARYOP_MACRO
2529 #define FAD_RELOP_MACRO(OP) \
2530 namespace Sacado { \
2531 namespace CacheFad { \
2532 template <typename ExprT1, typename ExprT2> \
2533 SACADO_INLINE_FUNCTION \
2535 operator OP (const Expr<ExprT1>& expr1, \
2536 const Expr<ExprT2>& expr2) \
2540 return expr1.val() OP expr2.val(); \
2543 template <typename ExprT2> \
2544 SACADO_INLINE_FUNCTION \
2546 operator OP (const typename Expr<ExprT2>::value_type& a, \
2547 const Expr<ExprT2>& expr2) \
2550 return a OP expr2.val(); \
2553 template <typename ExprT1> \
2554 SACADO_INLINE_FUNCTION \
2556 operator OP (const Expr<ExprT1>& expr1, \
2557 const typename Expr<ExprT1>::value_type& b) \
2560 return expr1.val() OP b; \
2576 #undef FAD_RELOP_MACRO
2580 namespace CacheFad {
2582 template <
typename ExprT>
2587 return ! expr.val();
2597 namespace CacheFad {
2599 template <
typename ExprT>
2603 bool is_zero = (x.val() == 0.0);
2604 for (
int i=0;
i<x.size();
i++)
2605 is_zero = is_zero && (x.dx(
i) == 0.0);
2613 #define FAD_BOOL_MACRO(OP) \
2614 namespace Sacado { \
2615 namespace CacheFad { \
2616 template <typename ExprT1, typename ExprT2> \
2617 SACADO_INLINE_FUNCTION \
2619 operator OP (const Expr<ExprT1>& expr1, \
2620 const Expr<ExprT2>& expr2) \
2622 return toBool(expr1) OP toBool(expr2); \
2625 template <typename ExprT2> \
2626 SACADO_INLINE_FUNCTION \
2628 operator OP (const typename Expr<ExprT2>::value_type& a, \
2629 const Expr<ExprT2>& expr2) \
2631 return a OP toBool(expr2); \
2634 template <typename ExprT1> \
2635 SACADO_INLINE_FUNCTION \
2637 operator OP (const Expr<ExprT1>& expr1, \
2638 const typename Expr<ExprT1>::value_type& b) \
2640 return toBool(expr1) OP b; \
2648 #undef FAD_BOOL_MACRO
2654 namespace CacheFad {
2656 template <
typename ExprT>
2657 std::ostream& operator << (std::ostream& os, const Expr<ExprT>&
x) {
2659 os <<
x.val() <<
" [";
2661 for (
int i=0;
i<
x.size();
i++) {
2662 os <<
" " <<
x.dx(
i);
2673 #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