44 #include "Teuchos_UnitTestHarness.hpp" 45 #include "Teuchos_TestingHelpers.hpp" 46 #include "Teuchos_UnitTestRepository.hpp" 47 #include "Teuchos_GlobalMPISession.hpp" 66 mutable Teuchos::Array<double>
vec;
71 template <
typename Func>
79 Teuchos::RCP<const Stokhos::CompletePolynomialBasis<OrdinalType,ValueType> >
basis;
80 Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion<OrdinalType,ValueType> >
exp;
81 Teuchos::RCP<const Stokhos::StieltjesPCEBasis<OrdinalType,ValueType> >
st_1d_basis;
82 Teuchos::RCP<const Stokhos::CompletePolynomialBasis<OrdinalType,ValueType> >
st_basis;
83 Teuchos::RCP<const Stokhos::Quadrature<OrdinalType,ValueType> >
st_quad;
95 Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<OrdinalType,ValueType> > > bases(d);
109 Teuchos::RCP<const Stokhos::Quadrature<OrdinalType,ValueType> > quad =
113 Teuchos::RCP<Stokhos::Sparse3Tensor<int,double> > Cijk =
114 basis->computeTripleProductTensor();
129 Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<OrdinalType,ValueType> > > st_bases(1);
144 Teuchos::RCP<Stokhos::Sparse3Tensor<int,double> > st_Cijk =
145 st_basis->computeTripleProductTensor();
163 template <
typename Ordinal_Type,
typename Value_Type>
180 setup.st_1d_basis->transformCoeffsFromStieltjes(
setup.u_st.coeff(),
187 const Teuchos::Array<double>& norms =
setup.st_1d_basis->norm_squared();
188 const Teuchos::Array<double>& weights =
setup.st_quad->getQuadWeights();
189 const Teuchos::Array< Teuchos::Array<double> >& values =
190 setup.st_quad->getBasisAtQuadPoints();
191 Teuchos::SerialDenseMatrix<int,double> mat(
setup.st_sz,
193 for (
int i=0; i<
setup.st_sz; i++) {
195 for (
unsigned int k=0; k<weights.size(); k++)
196 mat(i,
j) += weights[k]*values[k][i]*values[k][
j];
201 success = mat.normInf() <
setup.atol;
203 out <<
"\n Error, mat.normInf() < atol = " << mat.normInf()
204 <<
" < " <<
setup.atol <<
": failed!\n";
205 out <<
"mat = " <<
printMat(mat) << std::endl;
219 success = Teuchos::testRelErr(
"v.mean()",
setup.v.mean(),
220 "v_st.mean()",
setup.v_st.mean(),
223 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
229 success = Teuchos::testRelErr(
"v.standard_deviation()",
230 setup.v.standard_deviation(),
231 "v_st.standard_devaition()",
232 setup.v_st.standard_deviation(),
235 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
246 template <
typename Ordinal_Type,
typename Value_Type>
263 setup.st_1d_basis->transformCoeffsFromStieltjes(
setup.u_st.coeff(),
270 const Teuchos::Array<double>& norms =
setup.st_1d_basis->norm_squared();
271 const Teuchos::Array<double>& weights =
setup.st_quad->getQuadWeights();
272 const Teuchos::Array< Teuchos::Array<double> >& values =
273 setup.st_quad->getBasisAtQuadPoints();
274 Teuchos::SerialDenseMatrix<int,double> mat(
setup.st_sz,
276 for (
int i=0; i<
setup.st_sz; i++) {
278 for (
unsigned int k=0; k<weights.size(); k++)
279 mat(i,
j) += weights[k]*values[k][i]*values[k][
j];
284 success = mat.normInf() <
setup.atol;
286 out <<
"\n Error, mat.normInf() < atol = " << mat.normInf()
287 <<
" < " <<
setup.atol <<
": failed!\n";
288 out <<
"mat = " <<
printMat(mat) << std::endl;
302 success = Teuchos::testRelErr(
"v.mean()",
setup.v.mean(),
303 "v_st.mean()",
setup.v_st.mean(),
306 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
311 success = Teuchos::testRelErr(
"v.standard_deviation()",
312 setup.v.standard_deviation(),
313 "v_st.standard_devaition()",
314 setup.v_st.standard_deviation(),
317 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
329 template <
typename Ordinal_Type,
typename Value_Type>
346 setup.st_1d_basis->transformCoeffsFromStieltjes(
setup.u_st.coeff(),
353 const Teuchos::Array<double>& norms =
setup.st_1d_basis->norm_squared();
354 const Teuchos::Array<double>& weights =
setup.st_quad->getQuadWeights();
355 const Teuchos::Array< Teuchos::Array<double> >& values =
356 setup.st_quad->getBasisAtQuadPoints();
357 Teuchos::SerialDenseMatrix<int,double> mat(
setup.st_sz,
359 for (
int i=0; i<
setup.st_sz; i++) {
361 for (
unsigned int k=0; k<weights.size(); k++)
362 mat(i,
j) += weights[k]*values[k][i]*values[k][
j];
367 success = mat.normInf() <
setup.atol;
369 out <<
"\n Error, mat.normInf() < atol = " << mat.normInf()
370 <<
" < " <<
setup.atol <<
": failed!\n";
371 out <<
"mat = " <<
printMat(mat) << std::endl;
385 success = Teuchos::testRelErr(
"v.mean()",
setup.v.mean(),
386 "v_st.mean()",
setup.v_st.mean(),
389 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
394 success = Teuchos::testRelErr(
"v.standard_deviation()",
395 setup.v.standard_deviation(),
396 "v_st.standard_devaition()",
397 setup.v_st.standard_deviation(),
400 Teuchos::Ptr<std::ostream>(out.getOStream().get()));
406 Teuchos::GlobalMPISession mpiSession(&argc, &
argv);
407 return Teuchos::UnitTestRepository::runUnitTestsFromMain(argc,
argv);
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
Teuchos::RCP< const Stokhos::Quadrature< OrdinalType, ValueType > > st_quad
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)
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)
static const bool is_even
void printMat(const char *name, Epetra_IntSerialDenseMatrix &matrix)
TEUCHOS_UNIT_TEST(Stokhos_StieltjesPCEBasis, ExpMap)
Stieltjes_PCE_Setup< Stieltjes_Sin_Func< int, double > > setup(true)
bool comparePCEs(const PCEType &a1, const std::string &a1_name, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
pointer coeff()
Return coefficient array.
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)
Stieltjes_PCE_Setup< Stieltjes_Cos_Func< int, double > > setup(true)
Generates three-term recurrence using the Discretized Stieltjes procedure applied to a polynomial cha...
static const bool is_even
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, ordinal_type sz=0)
Reset to a new basis.
Stieltjes_PCE_Setup(bool use_pce_quad_points_)
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u_st
TEUCHOS_UNIT_TEST(Stokhos_StieltjesPCEBasis, CosMap)
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > st_basis
Multivariate orthogonal polynomial basis generated from a total-order complete-polynomial tensor prod...
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u
Teuchos::Array< double > vec
Teuchos::RCP< const Stokhos::StieltjesPCEBasis< OrdinalType, ValueType > > st_1d_basis
double operator()(const double &a) const
value_type mean() const
Compute mean of expansion.
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > v
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > > exp
Func::ValueType ValueType
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > v_st
const Stokhos::OrthogPolyBasis< int, double > & basis
stieltjes_pce_quad_func(const Stokhos::OrthogPolyApprox< int, double > &pce_, const Stokhos::OrthogPolyBasis< int, double > &basis_)
int main(int argc, char *argv[])
TEUCHOS_UNIT_TEST(Stokhos_StieltjesPCEBasis, SinMap)
static const bool is_even
value_type evaluate(const Teuchos::Array< value_type > &point) const
Evaluate polynomial approximation at a point.
const Stokhos::OrthogPolyApprox< int, double > & pce
Orthogonal polynomial expansions based on numerical quadrature.
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > basis
Stieltjes_PCE_Setup< Stieltjes_Exp_Func< int, double > > setup(false)
Func::OrdinalType OrdinalType
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)