44 #include "Teuchos_Assert.hpp" 46 #include "Teuchos_TimeMonitor.hpp" 47 #include "Teuchos_Tuple.hpp" 49 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
54 const Teuchos::RCP<
const PseudoSpectralOperator<ordinal_type, value_type, point_compare_type> >& ps_op_,
55 const Teuchos::RCP<Teuchos::ParameterList>& params_) :
58 sz(ps_op->coeff_size()),
59 nqp(ps_op->point_size()),
64 Teuchos::RCP<Teuchos::ParameterList>
params = params_;
65 if (
params == Teuchos::null)
66 params = Teuchos::rcp(
new Teuchos::ParameterList);
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 95 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- Unary Polynomial Evaluation");
99 SDV a_sdv(Teuchos::View, const_cast<value_type*>(a.
coeff()), pa);
100 ps_op->transformPCE2QP(1.0, a_sdv,
avals, 0.0,
false);
105 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 106 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- Unary Function Evaluation");
117 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 118 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- Unary Polynomial Integration");
122 SDV c_sdv(Teuchos::View, c.
coeff(), pc);
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 154 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PP Binary Polynomial Evaluation");
158 SDV a_sdv(Teuchos::View, const_cast<value_type*>(a.
coeff()), pa);
159 SDV b_sdv(Teuchos::View, const_cast<value_type*>(b.
coeff()), pb);
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 167 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PP Binary Function Evaluation");
177 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 178 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PP Binary Polynomial Integration");
182 SDV c_sdv(Teuchos::View, c.
coeff(), pc);
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 213 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- CP Binary Polynomial Evaluation");
217 SDV b_sdv(Teuchos::View, const_cast<value_type*>(b.
coeff()), pb);
218 ps_op->transformPCE2QP(1.0, b_sdv,
bvals, 0.0,
false);
223 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 224 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- CP Binary Function Evaluation");
234 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 235 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- CP Binary Polynomial Integration");
239 SDV c_sdv(Teuchos::View, c.
coeff(), pc);
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 270 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PC Binary Polynomial Evaluation");
274 SDV a_sdv(Teuchos::View, const_cast<value_type*>(a.
coeff()), pa);
275 ps_op->transformPCE2QP(1.0, a_sdv,
avals, 0.0,
false);
280 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 281 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PC Binary Function Evaluation");
291 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 292 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- PC Binary Polynomial Integration");
296 SDV c_sdv(Teuchos::View, c.
coeff(), pc);
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];
338 for (
int i=0; i<N; i++)
343 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 344 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- N(" << N <<
")-ary Polynomial Evaluation");
348 for (
int i=0; i<N; i++) {
349 SDV sdv(Teuchos::View, const_cast<value_type*>(na[i]->coeff()),
351 ps_op->transformPCE2QP(1.0, sdv,
navals[N][i], 0.0,
false);
357 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 358 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- N(" << N <<
")-ary Function Evaluation");
364 for (
int i=0; i<N; i++)
372 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 373 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- N(" << N <<
")-ary Polynomial Integration");
377 SDV c_sdv(Teuchos::View, c.
coeff(), pc);
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>
416 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
423 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR 424 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::OrthogPolyExpansionBase::divideEqual(OPA)");
441 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
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 482 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::OrthogPolyExpansionBase::divide(OPA,OPA)");
504 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
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>
536 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
545 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
554 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
563 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
572 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
582 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
592 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
602 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
611 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
620 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
629 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
638 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
647 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
656 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
665 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
674 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
683 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
693 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
703 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
713 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
722 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
731 template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
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) {
758 TEUCHOS_TEST_FOR_EXCEPTION(i_it == this->
Cijk->i_end(), std::logic_error,
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>
824 TEUCHOS_TEST_FOR_EXCEPTION(i_it == this->
Cijk->i_end(), std::logic_error,
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 divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void log10(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > basis
Basis.
Teuchos::RCP< Teuchos::ParameterList > params
Parameter list.
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)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
SDV avals
Temporary array for values of first argument at quad points.
void exp(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 compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
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.
ordinal_type nqp
Number of Quad points.
SDV fvals
Temporary array for values of operation at quad points.
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)
bool use_quad_for_times
Use quadrature for times functions.
Abstract base class for multivariate orthogonal polynomials.
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
ordinal_type sz
Expansions size.
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)
bool use_quad_for_division
Use quadrature for division functions.
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
SDV bvals
Temporary array for values of second argument at quad points.
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
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)
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)
Teuchos::Array< Teuchos::Array< SDV > > navals
Temporary array for values of n-ary arguments at quad points.
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)
Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > ps_op
Pseudospectral operator.
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)
Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > Cijk
Triple-product tensor.
ordinal_type size() const
Get expansion size.
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)
Teuchos::SerialDenseVector< ordinal_type, value_type > SDV
Short-hand for SerialDenseVector.