51 namespace TotalOrderBasisUnitTest {
54 template <
typename OrdinalType,
typename ValueType>
73 template <
typename ordinal_type>
106 while (node_stack.size() > 0) {
107 node = node_stack.back();
108 child_index = index_stack.
back();
112 if (node->children.size() > 0) {
113 block_size_expected = 0;
115 block_size_expected += node->children[i]->block_size;
118 block_size_expected = node->terms.size();
128 sum_prev += term_prefix[i];
138 if (child_index < node->terms.size() && node->children.size() > 0)
139 out << node->terms[child_index] <<
" : block_size = "
140 << node->children[child_index]->block_size << std::endl;
143 if (node->children.size() == 0) {
151 out << term <<
" : index = " << index
152 <<
" index expected = " << index_expected << std::endl;
155 node_stack.pop_back();
160 else if (child_index < node->children.size()) {
161 ++index_stack.
back();
162 node = node->children[child_index];
163 node_stack.push_back(node);
169 node_stack.pop_back();
177 template <
typename ordinal_type,
typename value_type>
181 const bool symmetric,
217 typedef typename Cijk_LTB_type::CijkNode
node_type;
222 node_stack.
push_back(Cijk_LTB->getHeadNode());
226 while (node_stack.
size() > 0) {
227 node = node_stack.
back();
228 child_index = index_stack.
back();
234 Cijk_Iterator cijk_iterator(node->p_i, node->p_j, node->p_k, symmetric);
249 <<
"Check: rel_err( C(" << I <<
"," << J <<
"," << K <<
") )"
250 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk2 <<
" ) = "
251 << err <<
" <= " << tol <<
" : ";
252 if (s) out <<
"Passed.";
257 success = success && s;
258 more = cijk_iterator.increment();
267 else if (child_index < node->children.size()) {
268 ++index_stack.
back();
269 node = node->children[child_index];
285 template <
typename ordinal_type,
typename value_type>
289 const bool symmetric,
321 typedef typename Cijk_LTB_type::CijkNode
node_type;
325 node_stack.
push_back(Cijk_LTB->getHeadNode());
329 while (node_stack.
size() > 0) {
330 node = node_stack.
back();
331 child_index = index_stack.
back();
347 if (symmetric && (k0%2 != (i+
j)%2)) ++k0;
355 if (J == K) cijk *= 2.0;
363 <<
"Check: rel_err( C(" << I <<
"," << J <<
","
365 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk2 <<
" ) = "
366 << err <<
" <= " << tol <<
" : ";
367 if (s) out <<
"Passed.";
372 success = success && s;
377 bool s2 = err2 < tol2;
380 <<
"Check: rel_err( C(" << I <<
"," << J <<
","
382 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk3 <<
" ) = "
383 << err <<
" <= " << tol <<
" : ";
384 if (s2) out <<
"Passed.";
389 success = success && s2;
399 else if (child_index < node->children.size()) {
400 ++index_stack.
back();
401 node = node->children[child_index];
417 template <
typename ordinal_type,
typename value_type>
421 const bool symmetric,
464 x(basis), a(basis), b(basis), c1(basis), c2(basis);
475 Stokhos::flatLTB3TensorMultiply<10>(c2, a, b, *flat_Cijk);
491 basis_orders[i] = i+1;
505 basis_orders[i] = i+1;
521 basis_orders[i] = i+1;
551 basis_orders[i] = i+1;
560 basis_orders[i] = i+1;
bool test_lexicographic_tree_sparse_3_tensor_block(const Teuchos::Array< ordinal_type > &basis_orders, const ordinal_type p, const bool symmetric, const value_type sparse_tol, const value_type atol, const value_type rtol, Teuchos::FancyOStream &out)
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< LTBSparse3Tensor< ordinal_type, value_type > > computeTripleProductTensorLTB(const TotalOrderBasis< ordinal_type, value_type, LexographicLess< MultiIndex< ordinal_type > > > &product_basis, bool symmetric=false)
ordinal_type n_choose_k(const ordinal_type &n, const ordinal_type &k)
Compute bionomial coefficient (n ; k) = n!/( k! (n-k)! )
Multivariate orthogonal polynomial basis generated from a total order tensor product of univariate po...
void cos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
ordinal_type dimension() const
Dimension.
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)
bool test_lexicographic_tree_sparse_3_tensor(const Teuchos::Array< ordinal_type > &basis_orders, const ordinal_type p, const bool symmetric, const value_type sparse_tol, const value_type atol, const value_type rtol, Teuchos::FancyOStream &out)
virtual Teuchos::RCP< Stokhos::Dense3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
Orthogonal polynomial expansions limited to algebraic operations.
Teuchos::RCP< LTBSparse3Tensor< ordinal_type, value_type > > computeTripleProductTensorLTBBlockLeaf(const TotalOrderBasis< ordinal_type, value_type, LexographicLess< MultiIndex< ordinal_type > > > &product_basis, bool symmetric=false)
Stokhos::LegendreBasis< int, double > basis_type
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
Data structure storing a sparse 3-tensor C(i,j,k) in a a tree-based format for lexicographically orde...
TEUCHOS_UNIT_TEST(LexicographicTreeCoefficients, Isotropic)
bool test_lexicographic_tree_coeffs(const Teuchos::Array< ordinal_type > &basis_orders, const ordinal_type p, const bool isotropic, Teuchos::FancyOStream &out)
bool test_lexicographic_tree_sparse_3_tensor_multiply(const Teuchos::Array< ordinal_type > &basis_orders, const ordinal_type p, const bool symmetric, const value_type sparse_tol, const value_type atol, const value_type rtol, Teuchos::FancyOStream &out)
Teuchos::RCP< LexicographicTreeBasisNode< ordinal_type > > build_lexicographic_basis_tree(const Teuchos::ArrayView< const ordinal_type > &basis_orders, const ordinal_type total_order, const ordinal_type index_begin=ordinal_type(0), const ordinal_type order_sum=ordinal_type(0), const Stokhos::MultiIndex< ordinal_type > &term_prefix=Stokhos::MultiIndex< ordinal_type >())
static int runUnitTestsFromMain(int argc, char *argv[])
Teuchos::RCP< FlatLTBSparse3Tensor< ordinal_type, value_type > > computeFlatTripleProductTensorLTB(const TotalOrderBasis< ordinal_type, value_type, LexographicLess< MultiIndex< ordinal_type > > > &product_basis, bool symmetric=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
void times(OrthogPolyApprox< ordinal_type, value_type, Stokhos::StandardStorage< ordinal_type, value_type > > &c, const OrthogPolyApprox< ordinal_type, value_type, Stokhos::StandardStorage< ordinal_type, value_type > > &a, const OrthogPolyApprox< ordinal_type, value_type, Stokhos::StandardStorage< ordinal_type, value_type > > &b)
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)
Legendre polynomial basis.
int main(int argc, char **argv)
void push_back(const value_type &x)
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
A comparison functor implementing a strict weak ordering based lexographic ordering.
virtual ordinal_type size() const
Return total size of basis (given by order() + 1).
Orthogonal polynomial expansions based on numerical quadrature.
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...
UnitTestSetup< ordinal_type, value_type > setup