19 namespace TotalOrderBasisUnitTest {
22 template <
typename OrdinalType,
typename ValueType>
41 template <
typename ordinal_type>
74 while (node_stack.size() > 0) {
75 node = node_stack.back();
76 child_index = index_stack.
back();
80 if (node->children.size() > 0) {
81 block_size_expected = 0;
83 block_size_expected += node->children[i]->block_size;
86 block_size_expected = node->terms.size();
96 sum_prev += term_prefix[i];
106 if (child_index < node->terms.size() && node->children.size() > 0)
107 out << node->terms[child_index] <<
" : block_size = "
108 << node->children[child_index]->block_size << std::endl;
111 if (node->children.size() == 0) {
119 out << term <<
" : index = " << index
120 <<
" index expected = " << index_expected << std::endl;
123 node_stack.pop_back();
128 else if (child_index < node->children.size()) {
129 ++index_stack.
back();
130 node = node->children[child_index];
131 node_stack.push_back(node);
137 node_stack.pop_back();
145 template <
typename ordinal_type,
typename value_type>
149 const bool symmetric,
185 typedef typename Cijk_LTB_type::CijkNode
node_type;
190 node_stack.
push_back(Cijk_LTB->getHeadNode());
194 while (node_stack.
size() > 0) {
195 node = node_stack.
back();
196 child_index = index_stack.
back();
202 Cijk_Iterator cijk_iterator(node->p_i, node->p_j, node->p_k, symmetric);
217 <<
"Check: rel_err( C(" << I <<
"," << J <<
"," << K <<
") )"
218 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk2 <<
" ) = "
219 << err <<
" <= " << tol <<
" : ";
220 if (s) out <<
"Passed.";
225 success = success && s;
226 more = cijk_iterator.increment();
235 else if (child_index < node->children.size()) {
236 ++index_stack.
back();
237 node = node->children[child_index];
253 template <
typename ordinal_type,
typename value_type>
257 const bool symmetric,
289 typedef typename Cijk_LTB_type::CijkNode
node_type;
293 node_stack.
push_back(Cijk_LTB->getHeadNode());
297 while (node_stack.
size() > 0) {
298 node = node_stack.
back();
299 child_index = index_stack.
back();
315 if (symmetric && (k0%2 != (i+
j)%2)) ++k0;
323 if (J == K) cijk *= 2.0;
331 <<
"Check: rel_err( C(" << I <<
"," << J <<
","
333 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk2 <<
" ) = "
334 << err <<
" <= " << tol <<
" : ";
335 if (s) out <<
"Passed.";
340 success = success && s;
345 bool s2 = err2 < tol2;
348 <<
"Check: rel_err( C(" << I <<
"," << J <<
","
350 <<
" = " <<
"rel_err( " << cijk <<
", " << cijk3 <<
" ) = "
351 << err <<
" <= " << tol <<
" : ";
352 if (s2) out <<
"Passed.";
357 success = success && s2;
367 else if (child_index < node->children.size()) {
368 ++index_stack.
back();
369 node = node->children[child_index];
385 template <
typename ordinal_type,
typename value_type>
389 const bool symmetric,
432 x(basis), a(basis), b(basis), c1(basis), c2(basis);
443 Stokhos::flatLTB3TensorMultiply<10>(c2, a, b, *flat_Cijk);
459 basis_orders[i] = i+1;
473 basis_orders[i] = i+1;
489 basis_orders[i] = i+1;
519 basis_orders[i] = i+1;
528 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