42 #ifndef SACADO_ETPCE_ORTHOGPOLY_OPS_HPP
43 #define SACADO_ETPCE_ORTHOGPOLY_OPS_HPP
45 #include "Sacado_cmath.hpp"
48 #define LINEAR_PCE_UNARYOP_MACRO(OPNAME,OP,OPER) \
52 template <typename ExprT> \
55 template <typename ExprT> \
56 class Expr< OP<ExprT> > { \
59 typedef typename ExprT::value_type value_type; \
60 typedef typename ExprT::approx_type approx_type; \
61 typedef typename ExprT::expansion_type expansion_type; \
62 typedef typename ExprT::quad_expansion_type quad_expansion_type; \
63 typedef typename ExprT::storage_type storage_type; \
64 typedef typename ExprT::base_expr_type base_expr_type; \
66 static const int num_args = ExprT::num_args; \
68 Expr(const ExprT& expr_) : expr(expr_) {} \
70 std::string name() const { \
71 return std::string(#OPER) + expr.name(); \
74 int size() const { return expr.size(); } \
76 const approx_type& getArg(int i) const { return expr.getArg(i); } \
78 bool has_nonconst_expansion() const { \
79 return expr.has_nonconst_expansion(); \
82 Teuchos::RCP<expansion_type> expansion() const { \
83 return expr.expansion(); \
86 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
87 return expr.quad_expansion(); \
90 bool has_fast_access(int sz) const { return expr.has_fast_access(sz); } \
92 int order() const { return expr.order(); } \
94 value_type val() const { return OPER (expr.val()); } \
96 value_type fast_higher_order_coeff(int i) const { \
97 return OPER (expr.fast_higher_order_coeff(i)); \
100 value_type higher_order_coeff(int i) const { \
101 return OPER (expr.higher_order_coeff(i)); \
104 template <int offset, typename tuple_type> \
105 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
106 return OPER (expr.template eval_sample<offset,tuple_type>(x)); \
115 template <typename T> \
116 inline Expr< OP< Expr<T> > > \
117 OPNAME (const Expr<T>& expr) \
119 typedef OP< Expr<T> > expr_t; \
121 return Expr<expr_t>(expr); \
126 #define NONLINEAR_PCE_UNARYOP_MACRO(OPNAME,OP,OPER) \
130 template <typename ExprT> \
133 template <typename ExprT> \
134 class Expr< OP<ExprT> > { \
137 typedef typename ExprT::value_type value_type; \
138 typedef typename ExprT::approx_type approx_type; \
139 typedef typename ExprT::expansion_type expansion_type; \
140 typedef typename ExprT::quad_expansion_type quad_expansion_type; \
141 typedef typename ExprT::storage_type storage_type; \
142 typedef typename ExprT::base_expr_type base_expr_type; \
144 static const int num_args = ExprT::num_args; \
146 Expr(const ExprT& expr_) : expr(expr_) {} \
148 std::string name() const { \
149 return std::string(#OPER) + std::string("(") + expr.name() + \
154 if (expr.size() == 1) \
157 return expansion()->size(); \
160 const approx_type& getArg(int i) const { return expr.getArg(i); } \
162 bool has_nonconst_expansion() const { \
163 return expr.has_nonconst_expansion(); \
166 Teuchos::RCP<expansion_type> expansion() const { \
167 return expr.expansion(); \
170 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
171 return expr.quad_expansion(); \
174 bool has_fast_access(int sz) const { return false; } \
176 int order() const { return size() == 0 ? 0 : 100; } \
178 value_type val() const { return OPER (expr.val()); } \
180 value_type fast_higher_order_coeff(int i) const { \
181 return value_type(0); \
184 value_type higher_order_coeff(int i) const { \
185 return value_type(0); \
188 template <int offset, typename tuple_type> \
189 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
190 return OPER (expr.template eval_sample<offset,tuple_type>(x)); \
199 template <typename T> \
200 inline Expr< OP< Expr<T> > > \
201 OPNAME (const Expr<T>& expr) \
203 typedef OP< Expr<T> > expr_t; \
205 return Expr<expr_t>(expr); \
233 #undef LINEAR_PCE_UNARYOP_MACRO
234 #undef NONLINEAR_PCE_UNARYOP_MACRO
236 #define LINEAR_PCE_BINARYOP_MACRO(OPNAME,OP,OPER) \
240 template <typename ExprT1, typename ExprT2> \
243 template <typename T1, typename T2> \
244 class Expr< OP< Expr<T1>, Expr<T2> > > { \
248 typedef Expr<T1> ExprT1; \
249 typedef Expr<T2> ExprT2; \
250 typedef typename ExprT1::value_type value_type_1; \
251 typedef typename ExprT2::value_type value_type_2; \
252 typedef typename Sacado::Promote<value_type_1, \
253 value_type_2>::type value_type; \
255 typedef typename ExprT1::approx_type approx_type; \
256 typedef typename ExprT1::expansion_type expansion_type; \
257 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
258 typedef typename ExprT1::storage_type storage_type; \
259 typedef typename ExprT1::base_expr_type base_expr_type; \
261 static const int num_args1 = ExprT1::num_args; \
262 static const int num_args2 = ExprT2::num_args; \
263 static const int num_args = num_args1 + num_args2; \
265 Expr(const ExprT1& expr1_, const ExprT2& expr2_) : \
266 expr1(expr1_), expr2(expr2_) {} \
268 std::string name() const { \
269 return expr1.name() + std::string(#OPER) + expr2.name(); \
273 int sz1 = expr1.size(), sz2 = expr2.size(); \
274 return sz1 > sz2 ? sz1 : sz2; \
277 const approx_type& getArg(int i) const { \
279 return expr1.getArg(i); \
281 return expr2.getArg(i-num_args1); \
284 bool has_nonconst_expansion() const { \
285 return expr1.has_nonconst_expansion() || \
286 expr2.has_nonconst_expansion(); \
289 Teuchos::RCP<expansion_type> expansion() const { \
290 return expr1.has_nonconst_expansion() ? expr1.expansion() : \
294 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
295 return expr1.quad_expansion() != Teuchos::null ? \
296 expr1.quad_expansion() : \
297 expr2.quad_expansion(); \
300 bool has_fast_access(int sz) const { \
301 return expr1.has_fast_access(sz) && expr2.has_fast_access(sz); \
304 int order() const { \
305 int o1 = expr1.order(), o2 = expr2.order(); \
306 return o1 > o2 ? o1 : o2; \
309 value_type val() const { \
310 return expr1.val() OPER expr2.val(); \
313 value_type fast_higher_order_coeff(int i) const { \
314 return expr1.fast_higher_order_coeff(i) OPER \
315 expr2.fast_higher_order_coeff(i); \
318 value_type higher_order_coeff(int i) const { \
319 return expr1.higher_order_coeff(i) OPER \
320 expr2.higher_order_coeff(i); \
323 template <int offset, typename tuple_type> \
324 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
325 return expr1.template eval_sample<offset,tuple_type>(x) OPER \
326 expr2.template eval_sample<offset+num_args1,tuple_type>(x); \
331 const ExprT1& expr1; \
332 const ExprT2& expr2; \
336 template <typename T1> \
337 class Expr< OP< Expr<T1>, typename Expr<T1>::value_type> > { \
341 typedef Expr<T1> ExprT1; \
342 typedef typename ExprT1::value_type value_type; \
343 typedef typename ExprT1::value_type ConstT; \
345 typedef typename ExprT1::approx_type approx_type; \
346 typedef typename ExprT1::expansion_type expansion_type; \
347 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
348 typedef typename ExprT1::storage_type storage_type; \
349 typedef typename ExprT1::base_expr_type base_expr_type; \
351 static const int num_args = ExprT1::num_args; \
353 Expr(const ExprT1& expr1_, const ConstT& c_) : \
354 expr1(expr1_), c(c_) {} \
356 std::string name() const { \
357 return expr1.name() + std::string(#OPER) + std::string("c"); \
360 int size() const { return expr1.size(); } \
362 const approx_type& getArg(int i) const { \
363 return expr1.getArg(i); \
366 bool has_nonconst_expansion() const { \
367 return expr1.has_nonconst_expansion(); \
370 Teuchos::RCP<expansion_type> expansion() const { \
371 return expr1.expansion(); \
374 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
375 return expr1.quad_expansion(); \
378 bool has_fast_access(int sz) const { return expr1.has_fast_access(sz); } \
380 int order() const { return expr1.order(); } \
382 value_type val() const { \
383 return expr1.val() OPER c; \
386 value_type fast_higher_order_coeff(int i) const { \
387 return expr1.fast_higher_order_coeff(i); \
390 value_type higher_order_coeff(int i) const { \
391 return expr1.higher_order_coeff(i); \
394 template <int offset, typename tuple_type> \
395 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
396 return expr1.template eval_sample<offset,tuple_type>(x) OPER c; \
401 const ExprT1& expr1; \
405 template <typename T2> \
406 class Expr< OP< typename Expr<T2>::value_type, Expr<T2> > > { \
410 typedef Expr<T2> ExprT2; \
411 typedef typename ExprT2::value_type value_type; \
412 typedef typename ExprT2::value_type ConstT; \
414 typedef typename ExprT2::approx_type approx_type; \
415 typedef typename ExprT2::expansion_type expansion_type; \
416 typedef typename ExprT2::quad_expansion_type quad_expansion_type; \
417 typedef typename ExprT2::storage_type storage_type; \
418 typedef typename ExprT2::base_expr_type base_expr_type; \
420 static const int num_args = ExprT2::num_args; \
422 Expr(const ConstT& c_, const ExprT2& expr2_) : \
423 c(c_), expr2(expr2_) {} \
425 std::string name() const { \
426 return std::string("c") + std::string(#OPER) + expr2.name(); \
429 int size() const { return expr2.size(); } \
431 const approx_type& getArg(int i) const { return expr2.getArg(i); } \
433 bool has_nonconst_expansion() const { \
434 return expr2.has_nonconst_expansion(); \
437 Teuchos::RCP<expansion_type> expansion() const { \
438 return expr2.expansion(); \
441 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
442 return expr2.quad_expansion(); \
445 bool has_fast_access(int sz) const { return expr2.has_fast_access(sz); } \
447 int order() const { return expr2.order(); } \
449 value_type val() const { \
450 return c OPER expr2.val(); \
453 value_type fast_higher_order_coeff(int i) const { \
454 return OPER expr2.fast_higher_order_coeff(i); \
457 value_type higher_order_coeff(int i) const { \
458 return OPER expr2.higher_order_coeff(i); \
461 template <int offset, typename tuple_type> \
462 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
463 return c OPER expr2.template eval_sample<offset,tuple_type>(x); \
469 const ExprT2& expr2; \
472 template <typename T1, typename T2> \
473 inline Expr< OP< Expr<T1>, Expr<T2> > > \
474 OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
476 typedef OP< Expr<T1>, Expr<T2> > expr_t; \
478 return Expr<expr_t>(expr1, expr2); \
481 template <typename T> \
482 inline Expr< OP< Expr<T>, Expr<T> > > \
483 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
485 typedef OP< Expr<T>, Expr<T> > expr_t; \
487 return Expr<expr_t>(expr1, expr2); \
490 template <typename T> \
491 inline Expr< OP< typename Expr<T>::value_type, Expr<T> > > \
492 OPNAME (const typename Expr<T>::value_type& c, \
493 const Expr<T>& expr) \
495 typedef typename Expr<T>::value_type ConstT; \
496 typedef OP< ConstT, Expr<T> > expr_t; \
498 return Expr<expr_t>(c, expr); \
501 template <typename T> \
502 inline Expr< OP< Expr<T>, typename Expr<T>::value_type > > \
503 OPNAME (const Expr<T>& expr, \
504 const typename Expr<T>::value_type& c) \
506 typedef typename Expr<T>::value_type ConstT; \
507 typedef OP< Expr<T>, ConstT > expr_t; \
509 return Expr<expr_t>(expr, c); \
514 #define NONLINEAR_PCE_BINARYOP_MACRO(OPNAME,OP,OPER) \
518 template <typename ExprT1, typename ExprT2> \
521 template <typename T1, typename T2> \
522 class Expr< OP< Expr<T1>, Expr<T2> > > { \
526 typedef Expr<T1> ExprT1; \
527 typedef Expr<T2> ExprT2; \
528 typedef typename ExprT1::value_type value_type_1; \
529 typedef typename ExprT2::value_type value_type_2; \
530 typedef typename Sacado::Promote<value_type_1, \
531 value_type_2>::type value_type; \
533 typedef typename ExprT1::approx_type approx_type; \
534 typedef typename ExprT1::expansion_type expansion_type; \
535 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
536 typedef typename ExprT1::storage_type storage_type; \
537 typedef typename ExprT1::base_expr_type base_expr_type; \
539 static const int num_args1 = ExprT1::num_args; \
540 static const int num_args2 = ExprT2::num_args; \
541 static const int num_args = num_args1 + num_args2; \
543 Expr(const ExprT1& expr1_, const ExprT2& expr2_) : \
544 expr1(expr1_), expr2(expr2_) {} \
546 std::string name() const { \
547 return std::string(#OPER) + std::string("(") + expr1.name() + \
548 std::string(",") + expr2.name() + std::string(")"); \
552 if (expr1.size() == 1 && expr2.size() == 1) \
555 return expansion()->size(); \
558 const approx_type& getArg(int i) const { \
560 return expr1.getArg(i); \
562 return expr2.getArg(i-num_args1); \
565 bool has_nonconst_expansion() const { \
566 return expr1.has_nonconst_expansion() || \
567 expr2.has_nonconst_expansion(); \
570 Teuchos::RCP<expansion_type> expansion() const { \
571 return expr1.has_nonconst_expansion() ? expr1.expansion() : \
575 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
576 return expr1.quad_expansion() != Teuchos::null ? \
577 expr1.quad_expansion() : \
578 expr2.quad_expansion(); \
581 bool has_fast_access(int sz) const { return false; } \
583 int order() const { return size() == 0 ? 0 : 100; } \
585 value_type val() const { \
586 return OPER (expr1.val(), expr2.val()); \
589 value_type fast_higher_order_coeff(int i) const { \
590 return value_type(0); \
593 value_type higher_order_coeff(int i) const { \
594 return value_type(0); \
597 template <int offset, typename tuple_type> \
598 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
599 return OPER (expr1.template eval_sample<offset,tuple_type>(x), \
600 expr2.template eval_sample<offset+num_args1,tuple_type>(x)); \
605 const ExprT1& expr1; \
606 const ExprT2& expr2; \
610 template <typename T1> \
611 class Expr< OP< Expr<T1>, typename Expr<T1>::value_type> > { \
615 typedef Expr<T1> ExprT1; \
616 typedef typename ExprT1::value_type value_type; \
617 typedef typename ExprT1::value_type ConstT; \
619 typedef typename ExprT1::approx_type approx_type; \
620 typedef typename ExprT1::expansion_type expansion_type; \
621 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
622 typedef typename ExprT1::storage_type storage_type; \
623 typedef typename ExprT1::base_expr_type base_expr_type; \
625 static const int num_args = ExprT1::num_args; \
627 Expr(const ExprT1& expr1_, const ConstT& c_) : \
628 expr1(expr1_), c(c_) {} \
630 std::string name() const { \
631 return std::string(#OPER) + std::string("(") + expr1.name() + \
632 std::string(",c)"); \
636 if (expr1.size() == 1) \
639 return expansion()->size(); \
642 const approx_type& getArg(int i) const { \
643 return expr1.getArg(i); \
646 bool has_nonconst_expansion() const { \
647 return expr1.has_nonconst_expansion(); \
650 Teuchos::RCP<expansion_type> expansion() const { \
651 return expr1.expansion(); \
654 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
655 return expr1.quad_expansion(); \
658 bool has_fast_access(int sz) const { return false; } \
660 int order() const { return size() == 0 ? 0 : 100; } \
662 value_type val() const { \
663 return OPER (expr1.val(), c); \
666 value_type fast_higher_order_coeff(int i) const { \
667 return value_type(0); \
670 value_type higher_order_coeff(int i) const { \
671 return value_type(0); \
674 template <int offset, typename tuple_type> \
675 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
676 return OPER (expr1.template eval_sample<offset,tuple_type>(x), c); \
681 const ExprT1& expr1; \
685 template <typename T2> \
686 class Expr< OP< typename Expr<T2>::value_type, Expr<T2> > > { \
690 typedef Expr<T2> ExprT2; \
691 typedef typename ExprT2::value_type value_type; \
692 typedef typename ExprT2::value_type ConstT; \
694 typedef typename ExprT2::approx_type approx_type; \
695 typedef typename ExprT2::expansion_type expansion_type; \
696 typedef typename ExprT2::quad_expansion_type quad_expansion_type; \
697 typedef typename ExprT2::storage_type storage_type; \
698 typedef typename ExprT2::base_expr_type base_expr_type; \
700 static const int num_args = ExprT2::num_args; \
702 Expr(const ConstT& c_, const ExprT2& expr2_) : \
703 c(c_), expr2(expr2_) {} \
705 std::string name() const { \
706 return std::string(#OPER) + std::string("(c,") + \
707 expr2.name() + std::string(")"); \
711 if (expr2.size() == 1) \
714 return expansion()->size(); \
717 const approx_type& getArg(int i) const { return expr2.getArg(i); } \
719 Teuchos::RCP<expansion_type> expansion() const { \
720 return expr2.expansion(); \
723 bool has_nonconst_expansion() const { \
724 return expr2.has_nonconst_expansion(); \
727 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
728 return expr2.quad_expansion(); \
731 bool has_fast_access(int sz) const { return false; } \
733 int order() const { return size() == 0 ? 0 : 100; } \
735 value_type val() const { \
736 return OPER (c, expr2.val()); \
739 value_type fast_higher_order_coeff(int i) const { \
740 return value_type(0); \
743 value_type higher_order_coeff(int i) const { \
744 return value_type(0); \
747 template <int offset, typename tuple_type> \
748 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
749 return OPER (c, expr2.template eval_sample<offset,tuple_type>(x)); \
755 const ExprT2& expr2; \
758 template <typename T1, typename T2> \
759 inline Expr< OP< Expr<T1>, Expr<T2> > > \
760 OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
762 typedef OP< Expr<T1>, Expr<T2> > expr_t; \
764 return Expr<expr_t>(expr1, expr2); \
767 template <typename T> \
768 inline Expr< OP< Expr<T>, Expr<T> > > \
769 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
771 typedef OP< Expr<T>, Expr<T> > expr_t; \
773 return Expr<expr_t>(expr1, expr2); \
776 template <typename T> \
777 inline Expr< OP< typename Expr<T>::value_type, Expr<T> > > \
778 OPNAME (const typename Expr<T>::value_type& c, \
779 const Expr<T>& expr) \
781 typedef typename Expr<T>::value_type ConstT; \
782 typedef OP< ConstT, Expr<T> > expr_t; \
784 return Expr<expr_t>(c, expr); \
787 template <typename T> \
788 inline Expr< OP< Expr<T>, typename Expr<T>::value_type > > \
789 OPNAME (const Expr<T>& expr, \
790 const typename Expr<T>::value_type& c) \
792 typedef typename Expr<T>::value_type ConstT; \
793 typedef OP< Expr<T>, ConstT > expr_t; \
795 return Expr<expr_t>(expr, c); \
808 #undef LINEAR_PCE_BINARYOP_MACRO
809 #undef NONLINEAR_PCE_BINARYOP_MACRO
816 template <
typename ExprT1,
typename ExprT2>
819 template <
typename T1,
typename T2>
837 static const int num_args1 = ExprT1::num_args;
838 static const int num_args2 = ExprT2::num_args;
839 static const int num_args = num_args1 + num_args2;
842 expr1(expr1_), expr2(expr2_) {}
845 return expr1.name() + std::string(
"*") + expr2.name();
849 int sz1 = expr1.size();
850 int sz2 = expr2.size();
851 if (sz1 > 1 && sz2 > 1)
852 return expansion()->size();
859 return expr1.getArg(i);
861 return expr2.getArg(i-num_args1);
865 return expr1.has_nonconst_expansion() || expr2.has_nonconst_expansion();
869 return expr1.has_nonconst_expansion() ? expr1.expansion() :
875 expr1.quad_expansion() :
876 expr2.quad_expansion();
880 return expr1.has_fast_access(sz) && expr2.has_fast_access(sz);
883 int order()
const {
return expr1.order() + expr2.order(); }
887 return expr1.val() * expr2.val();
889 return quad_expansion()->compute_times_coeff(0,expr1,expr2);
893 return quad_expansion()->fast_compute_times_coeff(i,expr1,expr2);
897 return quad_expansion()->compute_times_coeff(i,expr1,expr2);
900 template <
int offset,
typename tuple_type>
902 return expr1.template eval_sample<offset,tuple_type>(x) *
903 expr2.template eval_sample<offset+num_args1,tuple_type>(x);
913 template <
typename T1>
928 static const int num_args = ExprT1::num_args;
931 expr1(expr1_), c(c_) {}
934 return expr1.name() + std::string(
"*c");
937 int size()
const {
return expr1.size(); }
940 return expr1.getArg(i);
944 return expr1.has_nonconst_expansion();
948 return expr1.expansion();
952 return expr1.quad_expansion();
957 int order()
const {
return expr1.order(); }
960 return expr1.val() * c;
964 return expr1.fast_higher_order_coeff(i) * c;
968 return expr1.higher_order_coeff(i) * c;
971 template <
int offset,
typename tuple_type>
973 return expr1.template eval_sample<offset,tuple_type>(x) * c;
982 template <
typename T2>
997 static const int num_args = ExprT2::num_args;
1000 c(c_), expr2(expr2_) {}
1003 return std::string(
"c*") + expr2.name();
1006 int size()
const {
return expr2.size(); }
1011 return expr2.has_nonconst_expansion();
1015 return expr2.expansion();
1019 return expr2.quad_expansion();
1024 int order()
const {
return expr2.order(); }
1027 return c * expr2.val();
1031 return c * expr2.fast_higher_order_coeff(i);
1035 return c * expr2.higher_order_coeff(i);
1038 template <
int offset,
typename tuple_type>
1040 return c * expr2.template eval_sample<offset,tuple_type>(x);
1049 template <
typename T1,
typename T2>
1058 template <
typename T>
1059 inline Expr< MultiplicationOp< Expr<T>, Expr<T> > >
1067 template <
typename T>
1078 template <
typename T>
1096 template <
typename ExprT1,
typename ExprT2>
1099 template <
typename T1,
typename T2>
1117 static const int num_args1 = ExprT1::num_args;
1118 static const int num_args2 = ExprT2::num_args;
1119 static const int num_args = num_args1 + num_args2;
1122 expr1(expr1_), expr2(expr2_) {}
1125 return expr1.name() + std::string(
"/") + expr2.name();
1129 if (expr2.size() == 1)
1130 return expr1.size();
1132 return expansion()->size();
1137 return expr1.getArg(i);
1139 return expr2.getArg(i-num_args1);
1143 return expr1.has_nonconst_expansion() || expr2.has_nonconst_expansion();
1147 return expr1.has_nonconst_expansion() ? expr1.expansion() :
1153 expr1.quad_expansion() :
1154 expr2.quad_expansion();
1158 return expr1.has_fast_access(sz) && (expr2.order() == 0);
1161 int order()
const {
return expr2.order() == 0 ? expr1.order() : 100; }
1164 return expr1.val() / expr2.val();
1168 return expr1.fast_higher_order_coeff(i) / expr2.val();
1172 return expr1.higher_order_coeff(i) / expr2.val();
1175 template <
int offset,
typename tuple_type>
1177 return expr1.template eval_sample<offset,tuple_type>(x) /
1178 expr2.template eval_sample<offset+num_args1,tuple_type>(x);
1188 template <
typename T1>
1203 static const int num_args = ExprT1::num_args;
1206 expr1(expr1_), c(c_) {}
1209 return expr1.name() + std::string(
"/c");
1212 int size()
const {
return expr1.size(); }
1215 return expr1.getArg(i);
1219 return expr1.has_nonconst_expansion();
1223 return expr1.expansion();
1227 return expr1.quad_expansion();
1232 int order()
const {
return expr1.order(); }
1235 return expr1.val() / c;
1239 return expr1.fast_higher_order_coeff(i) / c;
1243 return expr1.higher_order_coeff(i) / c;
1246 template <
int offset,
typename tuple_type>
1248 return expr1.template eval_sample<offset,tuple_type>(x) / c;
1257 template <
typename T2>
1272 static const int num_args = ExprT2::num_args;
1275 c(c_), expr2(expr2_) {}
1278 return std::string(
"c/") + expr2.name();
1282 if (expr2.size() == 1)
1285 return expansion()->size();
1291 return expr2.has_nonconst_expansion();
1295 return expr2.expansion();
1299 return expr2.quad_expansion();
1304 int order()
const {
return expr2.order() == 0 ? 0 : 100; }
1307 return c / expr2.val();
1318 template <
int offset,
typename tuple_type>
1320 return c / expr2.template eval_sample<offset,tuple_type>(x);
1329 template <
typename T1,
typename T2>
1338 template <
typename T>
1339 inline Expr< DivisionOp< Expr<T>, Expr<T> > >
1347 template <
typename T>
1358 template <
typename T>
1373 #define PCE_RELOP_MACRO(OP) \
1374 namespace Sacado { \
1376 template <typename ExprT1, typename ExprT2> \
1378 operator OP (const Expr<ExprT1>& expr1, \
1379 const Expr<ExprT2>& expr2) \
1381 return expr1.val() OP expr2.val(); \
1384 template <typename ExprT2> \
1386 operator OP (const typename Expr<ExprT2>::value_type& a, \
1387 const Expr<ExprT2>& expr2) \
1389 return a OP expr2.val(); \
1392 template <typename ExprT1> \
1394 operator OP (const Expr<ExprT1>& expr1, \
1395 const typename Expr<ExprT1>::value_type& b) \
1397 return expr1.val() OP b; \
1413 #undef PCE_RELOP_MACRO
1419 template <
typename ExprT>
1422 return ! expr.val();
1434 template <
typename ExprT>
1436 bool is_zero =
true;
1437 for (
int i=0; i<x.size(); i++)
1438 is_zero = is_zero && (x.coeff(i) == 0.0);
1446 #define PCE_BOOL_MACRO(OP) \
1447 namespace Sacado { \
1449 template <typename ExprT1, typename ExprT2> \
1451 operator OP (const Expr<ExprT1>& expr1, \
1452 const Expr<ExprT2>& expr2) \
1454 return toBool(expr1) OP toBool(expr2); \
1457 template <typename ExprT2> \
1459 operator OP (const typename Expr<ExprT2>::value_type& a, \
1460 const Expr<ExprT2>& expr2) \
1462 return a OP toBool(expr2); \
1465 template <typename ExprT1> \
1467 operator OP (const Expr<ExprT1>& expr1, \
1468 const typename Expr<ExprT1>::value_type& b) \
1470 return toBool(expr1) OP b; \
1478 #undef PCE_BOOL_MACRO
1486 template <
typename ExprT>
1487 std::ostream& operator << (std::ostream& os, const Expr<ExprT>& x) {
1502 #endif // SACADO_ETPCE_ORTHOGPOLY_OPS_HPP
ExprT2::quad_expansion_type quad_expansion_type
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
bool operator!(const Expr< ExprT > &expr)
ExprT1::value_type ConstT
Stokhos::StandardStorage< int, double > storage_type
bool has_nonconst_expansion() const
value_type fast_higher_order_coeff(int i) const
ExprT1::value_type ConstT
ExprT1::value_type value_type
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
ExprT2::value_type value_type_2
value_type higher_order_coeff(int i) const
ExprT1::expansion_type expansion_type
const approx_type & getArg(int i) const
Expr< MultiplicationOp< Expr< T1 >, Expr< T2 > > > operator*(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
bool has_fast_access(int sz) const
Expr(const ConstT &c_, const ExprT2 &expr2_)
value_type fast_higher_order_coeff(int i) const
Teuchos::RCP< quad_expansion_type > quad_expansion() const
ExprT2::quad_expansion_type quad_expansion_type
ExprT1::quad_expansion_type quad_expansion_type
const approx_type & getArg(int i) const
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
ExprT2::expansion_type expansion_type
bool has_nonconst_expansion() const
ExprT1::approx_type approx_type
Expr(const ExprT1 &expr1_, const ConstT &c_)
bool has_fast_access(int sz) const
ExprT1::value_type value_type_1
#define LINEAR_PCE_UNARYOP_MACRO(OPNAME, OP, OPER)
ExprT1::approx_type approx_type
ExprT2::value_type value_type
value_type higher_order_coeff(int i) const
Expr(const ExprT1 &expr1_, const ExprT2 &expr2_)
value_type higher_order_coeff(int i) const
ExprT2::base_expr_type base_expr_type
#define PCE_RELOP_MACRO(OP)
bool has_nonconst_expansion() const
const approx_type & getArg(int i) const
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
Expr(const ExprT1 &expr1_, const ExprT2 &expr2_)
Teuchos::RCP< expansion_type > expansion() const
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
atan2(expr1.val(), expr2.val())
#define NONLINEAR_PCE_BINARYOP_MACRO(OPNAME, OP, OPER)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
#define LINEAR_PCE_BINARYOP_MACRO(OPNAME, OP, OPER)
Teuchos::RCP< quad_expansion_type > quad_expansion() const
ExprT2::approx_type approx_type
ExprT2::value_type value_type_2
value_type higher_order_coeff(int i) const
Sacado::Promote< value_type_1, value_type_2 >::type value_type
expr2 j expr1 expr1 expr2 expr2 j expr1 c c c c MaxOp
Expr< DivisionOp< Expr< T1 >, Expr< T2 > > > operator/(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
ExprT1::quad_expansion_type quad_expansion_type
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 j expr1 expr1 expr1 expr1 j expr1 c *expr2 expr1 c expr1 c expr1 c expr1 expr1 expr1 expr1 j *expr1 expr2 expr1 expr1 j *expr1 c expr2 expr1 c expr1 expr2 expr1 expr2 expr1 Atan2Op
ExprT1::expansion_type expansion_type
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
ExprT1::quad_expansion_type quad_expansion_type
Teuchos::RCP< quad_expansion_type > quad_expansion() const
value_type fast_higher_order_coeff(int i) const
ExprT1::approx_type approx_type
ExprT1::base_expr_type base_expr_type
ExprT2::value_type value_type
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
bool has_fast_access(int sz) const
value_type higher_order_coeff(int i) const
bool has_nonconst_expansion() const
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
ExprT1::value_type value_type_1
value_type fast_higher_order_coeff(int i) const
ExprT1::base_expr_type base_expr_type
const approx_type & getArg(int i) const
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
value_type higher_order_coeff(int i) const
Teuchos::RCP< expansion_type > expansion() const
Teuchos::RCP< expansion_type > expansion() const
bool has_fast_access(int sz) const
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
const approx_type & getArg(int i) const
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
ExprT2::storage_type storage_type
ExprT1::expansion_type expansion_type
Teuchos::RCP< expansion_type > expansion() const
expr2 j expr1 expr1 expr2 expr2 j expr1 c c c c MinOp
ExprT2::value_type ConstT
bool has_fast_access(int sz) const
bool toBool(const Expr< ExprT > &x)
ExprT2::storage_type storage_type
value_type fast_higher_order_coeff(int i) const
bool has_nonconst_expansion() const
Sacado::Promote< value_type_1, value_type_2 >::type value_type
ExprT1::value_type value_type
KERNEL_PREFIX value_type eval_sample(tuple_type x) const
ExprT1::base_expr_type base_expr_type
ExprT1::storage_type storage_type
ExprT1::storage_type storage_type
#define NONLINEAR_PCE_UNARYOP_MACRO(OPNAME, OP, OPER)
ExprT1::approx_type approx_type
expr expr expr expr ExpOp
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
Expr(const ExprT1 &expr1_, const ConstT &c_)
ExprT1::storage_type storage_type
const approx_type & getArg(int i) const
Teuchos::RCP< expansion_type > expansion() const
ExprT2::base_expr_type base_expr_type
Teuchos::RCP< quad_expansion_type > quad_expansion() const
Expr(const ConstT &c_, const ExprT2 &expr2_)
ExprT2::value_type ConstT
Teuchos::RCP< quad_expansion_type > quad_expansion() const
bool has_fast_access(int sz) const
ExprT1::expansion_type expansion_type
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
Teuchos::RCP< expansion_type > expansion() const
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
ExprT1::quad_expansion_type quad_expansion_type
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
ExprT2::expansion_type expansion_type
Teuchos::RCP< quad_expansion_type > quad_expansion() const
ExprT2::approx_type approx_type
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
ExprT1::base_expr_type base_expr_type
#define PCE_BOOL_MACRO(OP)
bool has_nonconst_expansion() const
value_type fast_higher_order_coeff(int i) const
ExprT1::storage_type storage_type