32 "This example generates partitions the Cijk tensor for a lexicographic tree basis.\n");
34 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
36 CLP.
setOption(
"order", &p,
"Polynomial order");
37 double drop = 1.0e-12;
38 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
39 bool symmetric =
true;
40 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
42 CLP.
setOption(
"a_size", &a_size,
"Size of a (matrix) partition");
44 CLP.
setOption(
"x_size", &x_size,
"Size of x (input vector) partition");
46 CLP.
setOption(
"y_size", &y_size,
"Size of y (output vector) partition");
47 bool save_3tensor =
false;
48 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
49 "Save full 3tensor to file");
50 std::string file_3tensor =
"Cijk.dat";
51 CLP.
setOption(
"filename_3tensor", &file_3tensor,
52 "Filename to store full 3-tensor");
55 CLP.
parse( argc, argv );
59 const double alpha = 1.0;
60 const double beta = symmetric ? 1.0 : 2.0 ;
61 for (
int i=0; i<d; i++) {
63 p, alpha, beta,
true));
71 typedef Cijk_LTB_type::CijkNode
node_type;
75 int sz = basis->
size();
76 std::cout <<
"basis size = " << sz
77 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
81 if (a_size > sz) a_size = sz;
82 if (x_size > sz) x_size = sz;
83 if (y_size > sz) y_size = sz;
87 node_stack.
push_back(Cijk->getHeadNode());
92 while (node_stack.
size() > 0) {
93 node = node_stack.
back();
94 child_index = index_stack.
back();
104 else if (node->i_size <= y_size &&
105 node->j_size <= a_size &&
106 node->k_size <= x_size) {
113 else if (child_index < node->children.size()) {
114 ++index_stack.
back();
115 node = node->children[child_index];
128 std::cout <<
"num partitions = " << partition_stack.
size() << std::endl;
146 for (
int part=0; part<partition_stack.
size(); ++part) {
147 node = partition_stack[part];
150 while (node_stack.
size() > 0) {
151 node = node_stack.
back();
152 child_index = index_stack.
back();
156 Cijk_Iterator cijk_iterator(node->p_i,
163 int I = node->i_begin + cijk_iterator.i;
164 int J = node->j_begin + cijk_iterator.j;
165 int K = node->k_begin + cijk_iterator.k;
171 more = cijk_iterator.increment();
178 else if (child_index < node->children.size()) {
179 ++index_stack.
back();
180 node = node->children[child_index];
196 std::ofstream cijk_file(file_3tensor.c_str());
197 cijk_file.precision(14);
198 cijk_file.setf(std::ios::scientific);
199 cijk_file <<
"i, j, k, part" << std::endl;
200 for (
int i=0; i<tuples.
size(); ++i) {
201 cijk_file << tuples[i][0] <<
", "
202 << tuples[i][1] <<
", "
203 << tuples[i][2] <<
", "
204 << tuples[i][3] << std::endl;
210 catch (std::exception& e) {
211 std::cout << e.what() << std::endl;
Teuchos::RCP< LTBSparse3Tensor< ordinal_type, value_type > > computeTripleProductTensorLTB(const TotalOrderBasis< ordinal_type, value_type, LexographicLess< MultiIndex< ordinal_type > > > &product_basis, bool symmetric=false)
Multivariate orthogonal polynomial basis generated from a total order tensor product of univariate po...
Stokhos::LegendreBasis< int, double > basis_type
Data structure storing a sparse 3-tensor C(i,j,k) in a a tree-based format for lexicographically orde...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
int main(int argc, char **argv)
void push_back(const value_type &x)
void setDocString(const char doc_string[])
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).