44#include "Teuchos_Assert.hpp"
46#include "Teuchos_TimeMonitor.hpp"
47#include "Teuchos_Tuple.hpp"
49template <
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);
67 use_quad_for_times = params->get(
"Use Quadrature for Times",
false);
68 use_quad_for_division = params->get(
"Use Quadrature for Division",
true);
71template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
72template <
typename FuncT>
94#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
95 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos::PSExp -- Unary Polynomial Evaluation");
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);
128template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
129template <
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");
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);
188template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
189template <
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");
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);
245template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
246template <
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");
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);
302template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
303template <
typename FuncT>
310 const int N = FuncT::N;
311 bool is_constant =
true;
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);
383template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
393template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
403template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
416template <
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)");
441template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
454template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
464template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
474template <
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)");
504template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
517template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
527template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
536template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
545template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
554template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
563template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
572template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
582template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
592template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
602template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
611template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
620template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
629template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
638template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
647template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
656template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
665template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
674template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
683template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
693template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
703template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
713template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
722template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
731template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
740template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
741template <
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);
816template <
typename ordinal_type,
typename value_type,
typename po
int_compare_type,
typename node_type>
817template <
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);
Class to store coefficients of a projection onto an orthogonal polynomial basis.
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved).
pointer coeff()
Return coefficient array.
ordinal_type size() const
Return size.
Abstract base class for multivariate orthogonal polynomials.
Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > Cijk
Triple-product tensor.
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
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)
Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > basis
Basis.
ordinal_type size() const
Get expansion size.
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)
ordinal_type size() const
Return size.
SDV bvals
Temporary array for values of second argument at quad points.
Teuchos::Array< Teuchos::Array< SDV > > navals
Temporary array for values of n-ary arguments at quad points.
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 asinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void asin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
value_type fast_compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
value_type compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > ps_op
Pseudospectral operator.
void acosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void cos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void tanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
SDV fvals
Temporary array for values of operation at quad points.
SDV avals
Temporary array for values of first argument at quad points.
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)
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)
bool use_quad_for_division
Use quadrature for division functions.
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 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 nary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > **a)
void sin(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)
void cbrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void acos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void log(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
ordinal_type sz
Expansions size.
void atan(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.
void sqrt(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)
bool use_quad_for_times
Use quadrature for times functions.
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
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 atanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
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.
ordinal_type nqp
Number of Quad points.
void exp(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void log10(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)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
j_sparse_array::const_iterator ikj_iterator
Iterator for looping over j entries given i and k.
kj_sparse_array::const_iterator ik_iterator
Iterator for looping over k entries given i.
ikj_sparse_array::const_iterator i_iterator
Iterator for looping over i entries.
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)
SparseArrayIterator< index_iterator, value_iterator >::value_type index(const SparseArrayIterator< index_iterator, value_iterator > &it)