37 template <
typename Func>
124 #define LANCZOS_UNIT_TESTS(BASENAME, TAG, FUNC, NORMALIZE) \
125 namespace BASENAME ## TAG { \
127 Lanczos_PCE_Setup< FUNC<int,double> > setup(NORMALIZE); \
129 TEUCHOS_UNIT_TEST( BASENAME, TAG ## Map ) { \
130 Stokhos::OrthogPolyApprox<int,double> u2(setup.basis); \
131 setup.st_1d_proj_basis->transformCoeffs( \
132 setup.u_st.coeff(), \
134 success = Stokhos::comparePCEs(setup.u, "u", u2, "u2", \
135 setup.rtol, setup.atol, out); \
138 TEUCHOS_UNIT_TEST( BASENAME, TAG ## Orthog ) { \
139 const Teuchos::Array<double>& norms = \
140 setup.st_bases[0]->norm_squared(); \
141 const Teuchos::Array<double>& weights = \
142 setup.st_quad->getQuadWeights(); \
143 const Teuchos::Array< Teuchos::Array<double> >& values = \
144 setup.st_quad->getBasisAtQuadPoints(); \
145 Teuchos::SerialDenseMatrix<int,double> mat(setup.st_sz, \
147 for (int i=0; i<setup.st_sz; i++) { \
148 for (int j=0; j<setup.st_sz; j++) { \
149 for (unsigned int k=0; k<weights.size(); k++) \
150 mat(i,j) += weights[k]*values[k][i]*values[k][j]; \
151 mat(i,j) /= std::sqrt(norms[i]*norms[j]); \
155 success = mat.normInf() < setup.atol; \
157 out << "\n Error, mat.normInf() < atol = " << mat.normInf() \
158 << " < " << setup.atol << ": failed!\n"; \
159 out << "mat = " << mat << std::endl; \
163 TEUCHOS_UNIT_TEST( BASENAME, TAG ## PCE ) { \
164 Stokhos::OrthogPolyApprox<int,double> v2(setup.basis); \
165 lanczos_pce_quad_func quad_func(setup.v_st, *setup.st_basis); \
166 setup.exp->unary_op(quad_func, v2, setup.u); \
167 success = comparePCEs(setup.v, "v", v2, "v2", setup.rtol, \
171 TEUCHOS_UNIT_TEST( BASENAME, TAG ## Mean ) { \
172 success = Teuchos::testRelErr( \
173 "v.mean()", setup.v.mean(), \
174 "v_st.mean()", setup.v_st.mean(), \
175 "rtol", setup.rtol, \
176 "rtol", setup.rtol, \
177 Teuchos::Ptr<std::ostream>(out.getOStream().get())); \
181 TEUCHOS_UNIT_TEST( BASENAME, TAG ## StandardDeviation ) { \
182 success = Teuchos::testRelErr( \
183 "v.standard_deviation()", \
184 setup.v.standard_deviation(), \
185 "v_st.standard_devaition()", \
186 setup.v_st.standard_deviation(), \
189 Teuchos::Ptr<std::ostream>(out.getOStream().get())); \
198 template <
typename Ordinal_Type,
typename Value_Type>
202 static const bool is_even =
true;
217 template <typename Ordinal_Type, typename Value_Type>
221 static const bool is_even =
false;
237 template <typename Ordinal_Type, typename Value_Type>
241 static const bool is_even =
false;
static const bool is_even
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
const Stokhos::OrthogPolyApprox< int, double > & pce
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)
lanczos_pce_quad_func(const Stokhos::OrthogPolyApprox< int, double > &pce_, const Stokhos::OrthogPolyBasis< int, double > &basis_)
value_type evaluate(const Teuchos::Array< value_type > &point) const
Evaluate polynomial approximation at a point.
Teuchos::RCP< const Stokhos::HouseTriDiagPCEBasis< OrdinalType, ValueType > > st_1d_proj_basis
void exp(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)
value_type getNewCoeffs(ordinal_type i) const
Get new coefficients in this new basis.
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > v_st
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > st_basis
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, ordinal_type sz=0)
Reset to a new basis.
Teuchos::RCP< const Stokhos::Quadrature< OrdinalType, ValueType > > st_quad
Teuchos::Array< double > vec
const Stokhos::OrthogPolyBasis< int, double > & basis
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
Teuchos::RCP< const Stokhos::MonoProjPCEBasis< OrdinalType, ValueType > > st_1d_proj_basis
void resize(size_type new_size, const value_type &x=value_type())
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > u_st
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
int main(int argc, char **argv)
Teuchos::RCP< Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > > exp
virtual ordinal_type size() const
Return total size of basis.
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > basis
void eval(Stokhos::QuadOrthogPolyExpansion< OrdinalType, ValueType > &exp, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &x, Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &u)
Teuchos::Array< Teuchos::RCP< const Stokhos::OneDOrthogPolyBasis< OrdinalType, ValueType > > > st_bases
Func::ValueType ValueType
Func::OrdinalType OrdinalType
Lanczos_PCE_Setup(bool normalize)
double operator()(const double &a) const
#define LANCZOS_UNIT_TESTS(BASENAME, TAG, FUNC, NORMALIZE)
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...
Stokhos::OrthogPolyApprox< OrdinalType, ValueType > v
reference term(ordinal_type dimension, ordinal_type order)
Get coefficient term for given dimension and order.