49 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
58 sz(ps_op->coeff_size()),
59 nqp(ps_op->point_size()),
65 if (params == Teuchos::null)
67 use_quad_for_times = params->
get(
"Use Quadrature for Times",
false);
68 use_quad_for_division = params->
get(
"Use Quadrature for Division",
true);
71 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
72 template <
typename FuncT>
94 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 100 ps_op->transformPCE2QP(1.0, a_sdv, avals, 0.0,
false);
105 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 111 fvals[qp] = func(avals[qp]);
117 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 123 ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0,
false);
128 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
129 template <
typename FuncT>
140 if (pa == 1 && pb == 1)
148 c[0] = func(a[0], b[0]);
153 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 160 ps_op->transformPCE2QP(1.0, a_sdv, avals, 0.0,
false);
161 ps_op->transformPCE2QP(1.0, b_sdv, bvals, 0.0,
false);
166 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 172 fvals[qp] = func(avals[qp], bvals[qp]);
177 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 183 ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0,
false);
188 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
189 template <
typename FuncT>
207 c[0] = func(a, b[0]);
212 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 218 ps_op->transformPCE2QP(1.0, b_sdv, bvals, 0.0,
false);
223 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 229 fvals[qp] = func(a, bvals[qp]);
234 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 240 ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0,
false);
245 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
246 template <
typename FuncT>
264 c[0] = func(a[0], b);
269 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 275 ps_op->transformPCE2QP(1.0, a_sdv, avals, 0.0,
false);
280 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 286 fvals[qp] = func(avals[qp], b);
291 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 297 ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0,
false);
302 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
303 template <
typename FuncT>
310 const int N = FuncT::N;
312 for (
int i=0; i<N; i++) {
313 if (na[i]->size() > 1) {
328 for (
int i=0; i<N; i++)
329 val[i] = (*na[i])[0];
334 if (N >= navals.size())
336 if (navals[N].size() != N) {
338 for (
int i=0; i<N; i++)
339 navals[N][i].resize(nqp);
343 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 348 for (
int i=0; i<N; i++) {
351 ps_op->transformPCE2QP(1.0, sdv, navals[N][i], 0.0,
false);
357 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 364 for (
int i=0; i<N; i++)
365 val[i] = navals[N][i][qp];
366 fvals[qp] = func(
val);
372 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 378 ps_op->transformQP2PCE(1.0, fvals, c_sdv, 0.0,
false);
383 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
393 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
403 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
410 if (use_quad_for_times)
411 binary_op(times_quad_func(), c, c,
x);
416 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
423 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 434 if (use_quad_for_division)
435 binary_op(div_quad_func(), c, c,
x);
441 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
448 if (use_quad_for_times)
449 binary_op(times_quad_func(), c, a, b);
454 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
464 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
474 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
481 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 497 if (use_quad_for_division)
498 binary_op(div_quad_func(), c, a, b);
504 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
511 if (use_quad_for_division)
512 binary_op(div_quad_func(), c, a, b);
517 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
527 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
533 unary_op(exp_quad_func(), c, a);
536 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
542 unary_op(log_quad_func(), c, a);
545 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
551 unary_op(log10_quad_func(), c, a);
554 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
560 unary_op(sqrt_quad_func(), c, a);
563 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
569 unary_op(cbrt_quad_func(), c, a);
572 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
579 binary_op(pow_quad_func(), c, a, b);
582 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
589 binary_op(pow_quad_func(), c, a, b);
592 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
599 binary_op(pow_quad_func(), c, a, b);
602 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
608 unary_op(sin_quad_func(), s, a);
611 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
617 unary_op(cos_quad_func(), c, a);
620 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
626 unary_op(tan_quad_func(), t, a);
629 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
635 unary_op(sinh_quad_func(), s, a);
638 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
644 unary_op(cosh_quad_func(), c, a);
647 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
653 unary_op(tanh_quad_func(), t, a);
656 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
662 unary_op(acos_quad_func(), c, a);
665 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
671 unary_op(asin_quad_func(), c, a);
674 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
680 unary_op(atan_quad_func(), c, a);
683 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
690 binary_op(atan2_quad_func(), c, a, b);
693 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
700 binary_op(atan2_quad_func(), c, a, b);
703 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
710 binary_op(atan2_quad_func(), c, a, b);
713 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
719 unary_op(acosh_quad_func(), c, a);
722 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
728 unary_op(asinh_quad_func(), c, a);
731 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
737 unary_op(atanh_quad_func(), c, a);
740 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
741 template <
typename ExprT1,
typename ExprT2>
749 if (pa > 1 && pb > 1) {
759 "Stokhos::PseudoSpectralOrthogPolyExpansion::compute_times_coeff()" 760 <<
": Index " << i <<
" is out of range [0," 761 << this->Cijk->num_i() <<
")!");
767 k_it != this->Cijk->k_end(i_it); ++k_it) {
774 aa = a.higher_order_coeff(k);
780 aa = b.higher_order_coeff(k);
783 j_it != this->Cijk->j_end(k_it); ++j_it) {
791 bb = b.higher_order_coeff(
j);
797 bb = a.higher_order_coeff(
j);
804 return cc / this->basis->norm_squared(i);
807 return a.val() * b.val();
809 return a.higher_order_coeff(i)*b.val();
812 return a.val()*b.higher_order_coeff(i);
816 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
817 template <
typename ExprT1,
typename ExprT2>
825 "Stokhos::PseudoSpectralOrthogPolyExpansion::fast_ompute_times_coeff()" 826 <<
": Index " << i <<
" is out of range [0," 827 << this->Cijk->num_i() <<
")!");
833 k_it != this->Cijk->k_end(i_it); ++k_it) {
838 aa = a.higher_order_coeff(k);
840 j_it != this->Cijk->j_end(k_it); ++j_it) {
846 bb = b.higher_order_coeff(
j);
851 return cc / this->basis->norm_squared(i);
void log10(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved)
void tanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
SparseArrayIterator< index_iterator, value_iterator >::value_type index(const SparseArrayIterator< index_iterator, value_iterator > &it)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
T & get(ParameterList &l, const std::string &name)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void exp(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Base class for consolidating common expansion implementations.
value_type compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void nary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > **a)
void divide(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
value_type fast_compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void acos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
pointer coeff()
Return coefficient array.
PseudoSpectralOrthogPolyExpansion(const Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > &basis, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk, const Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > &ps_op, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor.
void sqrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
ordinal_type size() const
Return size.
void log(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Bi-directional iterator for traversing a sparse array.
void atan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Abstract base class for multivariate orthogonal polynomials.
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void binary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
Nonlinear binary function.
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void pow(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void atan2(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
void atanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
void cos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void cosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Class to store coefficients of a projection onto an orthogonal polynomial basis.
void cbrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void times(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void asinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void sinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void unary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Nonlinear unary function.
void asin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void acosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)