10 #ifndef SACADO_ETPCE_ORTHOGPOLY_OPS_HPP
11 #define SACADO_ETPCE_ORTHOGPOLY_OPS_HPP
13 #include "Sacado_cmath.hpp"
16 #define LINEAR_PCE_UNARYOP_MACRO(OPNAME,OP,OPER) \
20 template <typename ExprT> \
23 template <typename ExprT> \
24 class Expr< OP<ExprT> > { \
27 typedef typename ExprT::value_type value_type; \
28 typedef typename ExprT::approx_type approx_type; \
29 typedef typename ExprT::expansion_type expansion_type; \
30 typedef typename ExprT::quad_expansion_type quad_expansion_type; \
31 typedef typename ExprT::storage_type storage_type; \
32 typedef typename ExprT::base_expr_type base_expr_type; \
34 static const int num_args = ExprT::num_args; \
36 Expr(const ExprT& expr_) : expr(expr_) {} \
38 std::string name() const { \
39 return std::string(#OPER) + expr.name(); \
42 int size() const { return expr.size(); } \
44 const approx_type& getArg(int i) const { return expr.getArg(i); } \
46 bool has_nonconst_expansion() const { \
47 return expr.has_nonconst_expansion(); \
50 Teuchos::RCP<expansion_type> expansion() const { \
51 return expr.expansion(); \
54 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
55 return expr.quad_expansion(); \
58 bool has_fast_access(int sz) const { return expr.has_fast_access(sz); } \
60 int order() const { return expr.order(); } \
62 value_type val() const { return OPER (expr.val()); } \
64 value_type fast_higher_order_coeff(int i) const { \
65 return OPER (expr.fast_higher_order_coeff(i)); \
68 value_type higher_order_coeff(int i) const { \
69 return OPER (expr.higher_order_coeff(i)); \
72 template <int offset, typename tuple_type> \
73 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
74 return OPER (expr.template eval_sample<offset,tuple_type>(x)); \
83 template <typename T> \
84 inline Expr< OP< Expr<T> > > \
85 OPNAME (const Expr<T>& expr) \
87 typedef OP< Expr<T> > expr_t; \
89 return Expr<expr_t>(expr); \
94 #define NONLINEAR_PCE_UNARYOP_MACRO(OPNAME,OP,OPER) \
98 template <typename ExprT> \
101 template <typename ExprT> \
102 class Expr< OP<ExprT> > { \
105 typedef typename ExprT::value_type value_type; \
106 typedef typename ExprT::approx_type approx_type; \
107 typedef typename ExprT::expansion_type expansion_type; \
108 typedef typename ExprT::quad_expansion_type quad_expansion_type; \
109 typedef typename ExprT::storage_type storage_type; \
110 typedef typename ExprT::base_expr_type base_expr_type; \
112 static const int num_args = ExprT::num_args; \
114 Expr(const ExprT& expr_) : expr(expr_) {} \
116 std::string name() const { \
117 return std::string(#OPER) + std::string("(") + expr.name() + \
122 if (expr.size() == 1) \
125 return expansion()->size(); \
128 const approx_type& getArg(int i) const { return expr.getArg(i); } \
130 bool has_nonconst_expansion() const { \
131 return expr.has_nonconst_expansion(); \
134 Teuchos::RCP<expansion_type> expansion() const { \
135 return expr.expansion(); \
138 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
139 return expr.quad_expansion(); \
142 bool has_fast_access(int sz) const { return false; } \
144 int order() const { return size() == 0 ? 0 : 100; } \
146 value_type val() const { return OPER (expr.val()); } \
148 value_type fast_higher_order_coeff(int i) const { \
149 return value_type(0); \
152 value_type higher_order_coeff(int i) const { \
153 return value_type(0); \
156 template <int offset, typename tuple_type> \
157 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
158 return OPER (expr.template eval_sample<offset,tuple_type>(x)); \
167 template <typename T> \
168 inline Expr< OP< Expr<T> > > \
169 OPNAME (const Expr<T>& expr) \
171 typedef OP< Expr<T> > expr_t; \
173 return Expr<expr_t>(expr); \
201 #undef LINEAR_PCE_UNARYOP_MACRO
202 #undef NONLINEAR_PCE_UNARYOP_MACRO
204 #define LINEAR_PCE_BINARYOP_MACRO(OPNAME,OP,OPER) \
208 template <typename ExprT1, typename ExprT2> \
211 template <typename T1, typename T2> \
212 class Expr< OP< Expr<T1>, Expr<T2> > > { \
216 typedef Expr<T1> ExprT1; \
217 typedef Expr<T2> ExprT2; \
218 typedef typename ExprT1::value_type value_type_1; \
219 typedef typename ExprT2::value_type value_type_2; \
220 typedef typename Sacado::Promote<value_type_1, \
221 value_type_2>::type value_type; \
223 typedef typename ExprT1::approx_type approx_type; \
224 typedef typename ExprT1::expansion_type expansion_type; \
225 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
226 typedef typename ExprT1::storage_type storage_type; \
227 typedef typename ExprT1::base_expr_type base_expr_type; \
229 static const int num_args1 = ExprT1::num_args; \
230 static const int num_args2 = ExprT2::num_args; \
231 static const int num_args = num_args1 + num_args2; \
233 Expr(const ExprT1& expr1_, const ExprT2& expr2_) : \
234 expr1(expr1_), expr2(expr2_) {} \
236 std::string name() const { \
237 return expr1.name() + std::string(#OPER) + expr2.name(); \
241 int sz1 = expr1.size(), sz2 = expr2.size(); \
242 return sz1 > sz2 ? sz1 : sz2; \
245 const approx_type& getArg(int i) const { \
247 return expr1.getArg(i); \
249 return expr2.getArg(i-num_args1); \
252 bool has_nonconst_expansion() const { \
253 return expr1.has_nonconst_expansion() || \
254 expr2.has_nonconst_expansion(); \
257 Teuchos::RCP<expansion_type> expansion() const { \
258 return expr1.has_nonconst_expansion() ? expr1.expansion() : \
262 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
263 return expr1.quad_expansion() != Teuchos::null ? \
264 expr1.quad_expansion() : \
265 expr2.quad_expansion(); \
268 bool has_fast_access(int sz) const { \
269 return expr1.has_fast_access(sz) && expr2.has_fast_access(sz); \
272 int order() const { \
273 int o1 = expr1.order(), o2 = expr2.order(); \
274 return o1 > o2 ? o1 : o2; \
277 value_type val() const { \
278 return expr1.val() OPER expr2.val(); \
281 value_type fast_higher_order_coeff(int i) const { \
282 return expr1.fast_higher_order_coeff(i) OPER \
283 expr2.fast_higher_order_coeff(i); \
286 value_type higher_order_coeff(int i) const { \
287 return expr1.higher_order_coeff(i) OPER \
288 expr2.higher_order_coeff(i); \
291 template <int offset, typename tuple_type> \
292 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
293 return expr1.template eval_sample<offset,tuple_type>(x) OPER \
294 expr2.template eval_sample<offset+num_args1,tuple_type>(x); \
299 const ExprT1& expr1; \
300 const ExprT2& expr2; \
304 template <typename T1> \
305 class Expr< OP< Expr<T1>, typename Expr<T1>::value_type> > { \
309 typedef Expr<T1> ExprT1; \
310 typedef typename ExprT1::value_type value_type; \
311 typedef typename ExprT1::value_type ConstT; \
313 typedef typename ExprT1::approx_type approx_type; \
314 typedef typename ExprT1::expansion_type expansion_type; \
315 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
316 typedef typename ExprT1::storage_type storage_type; \
317 typedef typename ExprT1::base_expr_type base_expr_type; \
319 static const int num_args = ExprT1::num_args; \
321 Expr(const ExprT1& expr1_, const ConstT& c_) : \
322 expr1(expr1_), c(c_) {} \
324 std::string name() const { \
325 return expr1.name() + std::string(#OPER) + std::string("c"); \
328 int size() const { return expr1.size(); } \
330 const approx_type& getArg(int i) const { \
331 return expr1.getArg(i); \
334 bool has_nonconst_expansion() const { \
335 return expr1.has_nonconst_expansion(); \
338 Teuchos::RCP<expansion_type> expansion() const { \
339 return expr1.expansion(); \
342 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
343 return expr1.quad_expansion(); \
346 bool has_fast_access(int sz) const { return expr1.has_fast_access(sz); } \
348 int order() const { return expr1.order(); } \
350 value_type val() const { \
351 return expr1.val() OPER c; \
354 value_type fast_higher_order_coeff(int i) const { \
355 return expr1.fast_higher_order_coeff(i); \
358 value_type higher_order_coeff(int i) const { \
359 return expr1.higher_order_coeff(i); \
362 template <int offset, typename tuple_type> \
363 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
364 return expr1.template eval_sample<offset,tuple_type>(x) OPER c; \
369 const ExprT1& expr1; \
373 template <typename T2> \
374 class Expr< OP< typename Expr<T2>::value_type, Expr<T2> > > { \
378 typedef Expr<T2> ExprT2; \
379 typedef typename ExprT2::value_type value_type; \
380 typedef typename ExprT2::value_type ConstT; \
382 typedef typename ExprT2::approx_type approx_type; \
383 typedef typename ExprT2::expansion_type expansion_type; \
384 typedef typename ExprT2::quad_expansion_type quad_expansion_type; \
385 typedef typename ExprT2::storage_type storage_type; \
386 typedef typename ExprT2::base_expr_type base_expr_type; \
388 static const int num_args = ExprT2::num_args; \
390 Expr(const ConstT& c_, const ExprT2& expr2_) : \
391 c(c_), expr2(expr2_) {} \
393 std::string name() const { \
394 return std::string("c") + std::string(#OPER) + expr2.name(); \
397 int size() const { return expr2.size(); } \
399 const approx_type& getArg(int i) const { return expr2.getArg(i); } \
401 bool has_nonconst_expansion() const { \
402 return expr2.has_nonconst_expansion(); \
405 Teuchos::RCP<expansion_type> expansion() const { \
406 return expr2.expansion(); \
409 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
410 return expr2.quad_expansion(); \
413 bool has_fast_access(int sz) const { return expr2.has_fast_access(sz); } \
415 int order() const { return expr2.order(); } \
417 value_type val() const { \
418 return c OPER expr2.val(); \
421 value_type fast_higher_order_coeff(int i) const { \
422 return OPER expr2.fast_higher_order_coeff(i); \
425 value_type higher_order_coeff(int i) const { \
426 return OPER expr2.higher_order_coeff(i); \
429 template <int offset, typename tuple_type> \
430 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
431 return c OPER expr2.template eval_sample<offset,tuple_type>(x); \
437 const ExprT2& expr2; \
440 template <typename T1, typename T2> \
441 inline Expr< OP< Expr<T1>, Expr<T2> > > \
442 OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
444 typedef OP< Expr<T1>, Expr<T2> > expr_t; \
446 return Expr<expr_t>(expr1, expr2); \
449 template <typename T> \
450 inline Expr< OP< Expr<T>, Expr<T> > > \
451 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
453 typedef OP< Expr<T>, Expr<T> > expr_t; \
455 return Expr<expr_t>(expr1, expr2); \
458 template <typename T> \
459 inline Expr< OP< typename Expr<T>::value_type, Expr<T> > > \
460 OPNAME (const typename Expr<T>::value_type& c, \
461 const Expr<T>& expr) \
463 typedef typename Expr<T>::value_type ConstT; \
464 typedef OP< ConstT, Expr<T> > expr_t; \
466 return Expr<expr_t>(c, expr); \
469 template <typename T> \
470 inline Expr< OP< Expr<T>, typename Expr<T>::value_type > > \
471 OPNAME (const Expr<T>& expr, \
472 const typename Expr<T>::value_type& c) \
474 typedef typename Expr<T>::value_type ConstT; \
475 typedef OP< Expr<T>, ConstT > expr_t; \
477 return Expr<expr_t>(expr, c); \
482 #define NONLINEAR_PCE_BINARYOP_MACRO(OPNAME,OP,OPER) \
486 template <typename ExprT1, typename ExprT2> \
489 template <typename T1, typename T2> \
490 class Expr< OP< Expr<T1>, Expr<T2> > > { \
494 typedef Expr<T1> ExprT1; \
495 typedef Expr<T2> ExprT2; \
496 typedef typename ExprT1::value_type value_type_1; \
497 typedef typename ExprT2::value_type value_type_2; \
498 typedef typename Sacado::Promote<value_type_1, \
499 value_type_2>::type value_type; \
501 typedef typename ExprT1::approx_type approx_type; \
502 typedef typename ExprT1::expansion_type expansion_type; \
503 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
504 typedef typename ExprT1::storage_type storage_type; \
505 typedef typename ExprT1::base_expr_type base_expr_type; \
507 static const int num_args1 = ExprT1::num_args; \
508 static const int num_args2 = ExprT2::num_args; \
509 static const int num_args = num_args1 + num_args2; \
511 Expr(const ExprT1& expr1_, const ExprT2& expr2_) : \
512 expr1(expr1_), expr2(expr2_) {} \
514 std::string name() const { \
515 return std::string(#OPER) + std::string("(") + expr1.name() + \
516 std::string(",") + expr2.name() + std::string(")"); \
520 if (expr1.size() == 1 && expr2.size() == 1) \
523 return expansion()->size(); \
526 const approx_type& getArg(int i) const { \
528 return expr1.getArg(i); \
530 return expr2.getArg(i-num_args1); \
533 bool has_nonconst_expansion() const { \
534 return expr1.has_nonconst_expansion() || \
535 expr2.has_nonconst_expansion(); \
538 Teuchos::RCP<expansion_type> expansion() const { \
539 return expr1.has_nonconst_expansion() ? expr1.expansion() : \
543 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
544 return expr1.quad_expansion() != Teuchos::null ? \
545 expr1.quad_expansion() : \
546 expr2.quad_expansion(); \
549 bool has_fast_access(int sz) const { return false; } \
551 int order() const { return size() == 0 ? 0 : 100; } \
553 value_type val() const { \
554 return OPER (expr1.val(), expr2.val()); \
557 value_type fast_higher_order_coeff(int i) const { \
558 return value_type(0); \
561 value_type higher_order_coeff(int i) const { \
562 return value_type(0); \
565 template <int offset, typename tuple_type> \
566 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
567 return OPER (expr1.template eval_sample<offset,tuple_type>(x), \
568 expr2.template eval_sample<offset+num_args1,tuple_type>(x)); \
573 const ExprT1& expr1; \
574 const ExprT2& expr2; \
578 template <typename T1> \
579 class Expr< OP< Expr<T1>, typename Expr<T1>::value_type> > { \
583 typedef Expr<T1> ExprT1; \
584 typedef typename ExprT1::value_type value_type; \
585 typedef typename ExprT1::value_type ConstT; \
587 typedef typename ExprT1::approx_type approx_type; \
588 typedef typename ExprT1::expansion_type expansion_type; \
589 typedef typename ExprT1::quad_expansion_type quad_expansion_type; \
590 typedef typename ExprT1::storage_type storage_type; \
591 typedef typename ExprT1::base_expr_type base_expr_type; \
593 static const int num_args = ExprT1::num_args; \
595 Expr(const ExprT1& expr1_, const ConstT& c_) : \
596 expr1(expr1_), c(c_) {} \
598 std::string name() const { \
599 return std::string(#OPER) + std::string("(") + expr1.name() + \
600 std::string(",c)"); \
604 if (expr1.size() == 1) \
607 return expansion()->size(); \
610 const approx_type& getArg(int i) const { \
611 return expr1.getArg(i); \
614 bool has_nonconst_expansion() const { \
615 return expr1.has_nonconst_expansion(); \
618 Teuchos::RCP<expansion_type> expansion() const { \
619 return expr1.expansion(); \
622 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
623 return expr1.quad_expansion(); \
626 bool has_fast_access(int sz) const { return false; } \
628 int order() const { return size() == 0 ? 0 : 100; } \
630 value_type val() const { \
631 return OPER (expr1.val(), c); \
634 value_type fast_higher_order_coeff(int i) const { \
635 return value_type(0); \
638 value_type higher_order_coeff(int i) const { \
639 return value_type(0); \
642 template <int offset, typename tuple_type> \
643 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
644 return OPER (expr1.template eval_sample<offset,tuple_type>(x), c); \
649 const ExprT1& expr1; \
653 template <typename T2> \
654 class Expr< OP< typename Expr<T2>::value_type, Expr<T2> > > { \
658 typedef Expr<T2> ExprT2; \
659 typedef typename ExprT2::value_type value_type; \
660 typedef typename ExprT2::value_type ConstT; \
662 typedef typename ExprT2::approx_type approx_type; \
663 typedef typename ExprT2::expansion_type expansion_type; \
664 typedef typename ExprT2::quad_expansion_type quad_expansion_type; \
665 typedef typename ExprT2::storage_type storage_type; \
666 typedef typename ExprT2::base_expr_type base_expr_type; \
668 static const int num_args = ExprT2::num_args; \
670 Expr(const ConstT& c_, const ExprT2& expr2_) : \
671 c(c_), expr2(expr2_) {} \
673 std::string name() const { \
674 return std::string(#OPER) + std::string("(c,") + \
675 expr2.name() + std::string(")"); \
679 if (expr2.size() == 1) \
682 return expansion()->size(); \
685 const approx_type& getArg(int i) const { return expr2.getArg(i); } \
687 Teuchos::RCP<expansion_type> expansion() const { \
688 return expr2.expansion(); \
691 bool has_nonconst_expansion() const { \
692 return expr2.has_nonconst_expansion(); \
695 Teuchos::RCP<quad_expansion_type> quad_expansion() const { \
696 return expr2.quad_expansion(); \
699 bool has_fast_access(int sz) const { return false; } \
701 int order() const { return size() == 0 ? 0 : 100; } \
703 value_type val() const { \
704 return OPER (c, expr2.val()); \
707 value_type fast_higher_order_coeff(int i) const { \
708 return value_type(0); \
711 value_type higher_order_coeff(int i) const { \
712 return value_type(0); \
715 template <int offset, typename tuple_type> \
716 KERNEL_PREFIX value_type eval_sample(tuple_type x) const { \
717 return OPER (c, expr2.template eval_sample<offset,tuple_type>(x)); \
723 const ExprT2& expr2; \
726 template <typename T1, typename T2> \
727 inline Expr< OP< Expr<T1>, Expr<T2> > > \
728 OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
730 typedef OP< Expr<T1>, Expr<T2> > expr_t; \
732 return Expr<expr_t>(expr1, expr2); \
735 template <typename T> \
736 inline Expr< OP< Expr<T>, Expr<T> > > \
737 OPNAME (const Expr<T>& expr1, const Expr<T>& expr2) \
739 typedef OP< Expr<T>, Expr<T> > expr_t; \
741 return Expr<expr_t>(expr1, expr2); \
744 template <typename T> \
745 inline Expr< OP< typename Expr<T>::value_type, Expr<T> > > \
746 OPNAME (const typename Expr<T>::value_type& c, \
747 const Expr<T>& expr) \
749 typedef typename Expr<T>::value_type ConstT; \
750 typedef OP< ConstT, Expr<T> > expr_t; \
752 return Expr<expr_t>(c, expr); \
755 template <typename T> \
756 inline Expr< OP< Expr<T>, typename Expr<T>::value_type > > \
757 OPNAME (const Expr<T>& expr, \
758 const typename Expr<T>::value_type& c) \
760 typedef typename Expr<T>::value_type ConstT; \
761 typedef OP< Expr<T>, ConstT > expr_t; \
763 return Expr<expr_t>(expr, c); \
776 #undef LINEAR_PCE_BINARYOP_MACRO
777 #undef NONLINEAR_PCE_BINARYOP_MACRO
784 template <
typename ExprT1,
typename ExprT2>
787 template <
typename T1,
typename T2>
805 static const int num_args1 = ExprT1::num_args;
806 static const int num_args2 = ExprT2::num_args;
807 static const int num_args = num_args1 + num_args2;
810 expr1(expr1_), expr2(expr2_) {}
813 return expr1.name() + std::string(
"*") + expr2.name();
817 int sz1 = expr1.size();
818 int sz2 = expr2.size();
819 if (sz1 > 1 && sz2 > 1)
820 return expansion()->size();
827 return expr1.getArg(i);
829 return expr2.getArg(i-num_args1);
833 return expr1.has_nonconst_expansion() || expr2.has_nonconst_expansion();
837 return expr1.has_nonconst_expansion() ? expr1.expansion() :
843 expr1.quad_expansion() :
844 expr2.quad_expansion();
848 return expr1.has_fast_access(sz) && expr2.has_fast_access(sz);
851 int order()
const {
return expr1.order() + expr2.order(); }
855 return expr1.val() * expr2.val();
857 return quad_expansion()->compute_times_coeff(0,expr1,expr2);
861 return quad_expansion()->fast_compute_times_coeff(i,expr1,expr2);
865 return quad_expansion()->compute_times_coeff(i,expr1,expr2);
868 template <
int offset,
typename tuple_type>
870 return expr1.template eval_sample<offset,tuple_type>(x) *
871 expr2.template eval_sample<offset+num_args1,tuple_type>(x);
881 template <
typename T1>
896 static const int num_args = ExprT1::num_args;
899 expr1(expr1_), c(c_) {}
902 return expr1.name() + std::string(
"*c");
905 int size()
const {
return expr1.size(); }
908 return expr1.getArg(i);
912 return expr1.has_nonconst_expansion();
916 return expr1.expansion();
920 return expr1.quad_expansion();
925 int order()
const {
return expr1.order(); }
928 return expr1.val() * c;
932 return expr1.fast_higher_order_coeff(i) * c;
936 return expr1.higher_order_coeff(i) * c;
939 template <
int offset,
typename tuple_type>
941 return expr1.template eval_sample<offset,tuple_type>(x) * c;
950 template <
typename T2>
965 static const int num_args = ExprT2::num_args;
968 c(c_), expr2(expr2_) {}
971 return std::string(
"c*") + expr2.name();
974 int size()
const {
return expr2.size(); }
979 return expr2.has_nonconst_expansion();
983 return expr2.expansion();
987 return expr2.quad_expansion();
992 int order()
const {
return expr2.order(); }
995 return c * expr2.val();
999 return c * expr2.fast_higher_order_coeff(i);
1003 return c * expr2.higher_order_coeff(i);
1006 template <
int offset,
typename tuple_type>
1008 return c * expr2.template eval_sample<offset,tuple_type>(x);
1017 template <
typename T1,
typename T2>
1026 template <
typename T>
1027 inline Expr< MultiplicationOp< Expr<T>, Expr<T> > >
1035 template <
typename T>
1046 template <
typename T>
1064 template <
typename ExprT1,
typename ExprT2>
1067 template <
typename T1,
typename T2>
1085 static const int num_args1 = ExprT1::num_args;
1086 static const int num_args2 = ExprT2::num_args;
1087 static const int num_args = num_args1 + num_args2;
1090 expr1(expr1_), expr2(expr2_) {}
1093 return expr1.name() + std::string(
"/") + expr2.name();
1097 if (expr2.size() == 1)
1098 return expr1.size();
1100 return expansion()->size();
1105 return expr1.getArg(i);
1107 return expr2.getArg(i-num_args1);
1111 return expr1.has_nonconst_expansion() || expr2.has_nonconst_expansion();
1115 return expr1.has_nonconst_expansion() ? expr1.expansion() :
1121 expr1.quad_expansion() :
1122 expr2.quad_expansion();
1126 return expr1.has_fast_access(sz) && (expr2.order() == 0);
1129 int order()
const {
return expr2.order() == 0 ? expr1.order() : 100; }
1132 return expr1.val() / expr2.val();
1136 return expr1.fast_higher_order_coeff(i) / expr2.val();
1140 return expr1.higher_order_coeff(i) / expr2.val();
1143 template <
int offset,
typename tuple_type>
1145 return expr1.template eval_sample<offset,tuple_type>(x) /
1146 expr2.template eval_sample<offset+num_args1,tuple_type>(x);
1156 template <
typename T1>
1171 static const int num_args = ExprT1::num_args;
1174 expr1(expr1_), c(c_) {}
1177 return expr1.name() + std::string(
"/c");
1180 int size()
const {
return expr1.size(); }
1183 return expr1.getArg(i);
1187 return expr1.has_nonconst_expansion();
1191 return expr1.expansion();
1195 return expr1.quad_expansion();
1200 int order()
const {
return expr1.order(); }
1203 return expr1.val() / c;
1207 return expr1.fast_higher_order_coeff(i) / c;
1211 return expr1.higher_order_coeff(i) / c;
1214 template <
int offset,
typename tuple_type>
1216 return expr1.template eval_sample<offset,tuple_type>(x) / c;
1225 template <
typename T2>
1240 static const int num_args = ExprT2::num_args;
1243 c(c_), expr2(expr2_) {}
1246 return std::string(
"c/") + expr2.name();
1250 if (expr2.size() == 1)
1253 return expansion()->size();
1259 return expr2.has_nonconst_expansion();
1263 return expr2.expansion();
1267 return expr2.quad_expansion();
1272 int order()
const {
return expr2.order() == 0 ? 0 : 100; }
1275 return c / expr2.val();
1286 template <
int offset,
typename tuple_type>
1288 return c / expr2.template eval_sample<offset,tuple_type>(x);
1297 template <
typename T1,
typename T2>
1306 template <
typename T>
1307 inline Expr< DivisionOp< Expr<T>, Expr<T> > >
1315 template <
typename T>
1326 template <
typename T>
1341 #define PCE_RELOP_MACRO(OP) \
1342 namespace Sacado { \
1344 template <typename ExprT1, typename ExprT2> \
1346 operator OP (const Expr<ExprT1>& expr1, \
1347 const Expr<ExprT2>& expr2) \
1349 return expr1.val() OP expr2.val(); \
1352 template <typename ExprT2> \
1354 operator OP (const typename Expr<ExprT2>::value_type& a, \
1355 const Expr<ExprT2>& expr2) \
1357 return a OP expr2.val(); \
1360 template <typename ExprT1> \
1362 operator OP (const Expr<ExprT1>& expr1, \
1363 const typename Expr<ExprT1>::value_type& b) \
1365 return expr1.val() OP b; \
1381 #undef PCE_RELOP_MACRO
1387 template <
typename ExprT>
1390 return ! expr.val();
1402 template <
typename ExprT>
1404 bool is_zero =
true;
1405 for (
int i=0; i<x.size(); i++)
1406 is_zero = is_zero && (x.coeff(i) == 0.0);
1414 #define PCE_BOOL_MACRO(OP) \
1415 namespace Sacado { \
1417 template <typename ExprT1, typename ExprT2> \
1419 operator OP (const Expr<ExprT1>& expr1, \
1420 const Expr<ExprT2>& expr2) \
1422 return toBool(expr1) OP toBool(expr2); \
1425 template <typename ExprT2> \
1427 operator OP (const typename Expr<ExprT2>::value_type& a, \
1428 const Expr<ExprT2>& expr2) \
1430 return a OP toBool(expr2); \
1433 template <typename ExprT1> \
1435 operator OP (const Expr<ExprT1>& expr1, \
1436 const typename Expr<ExprT1>::value_type& b) \
1438 return toBool(expr1) OP b; \
1446 #undef PCE_BOOL_MACRO
1454 template <
typename ExprT>
1455 std::ostream& operator << (std::ostream& os, const Expr<ExprT>& x) {
1470 #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