64 "This example generates partitions the Cijk tensor for a lexicographic tree basis.\n");
66 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
68 CLP.
setOption(
"order", &p,
"Polynomial order");
69 double drop = 1.0e-12;
70 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
71 bool symmetric =
true;
72 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
74 CLP.
setOption(
"a_size", &a_size,
"Size of a (matrix) partition");
76 CLP.
setOption(
"x_size", &x_size,
"Size of x (input vector) partition");
78 CLP.
setOption(
"y_size", &y_size,
"Size of y (output vector) partition");
79 bool save_3tensor =
false;
80 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
81 "Save full 3tensor to file");
82 std::string file_3tensor =
"Cijk.dat";
83 CLP.
setOption(
"filename_3tensor", &file_3tensor,
84 "Filename to store full 3-tensor");
87 CLP.
parse( argc, argv );
91 const double alpha = 1.0;
92 const double beta = symmetric ? 1.0 : 2.0 ;
93 for (
int i=0; i<d; i++) {
95 p, alpha, beta,
true));
103 typedef Cijk_LTB_type::CijkNode
node_type;
107 int sz = basis->
size();
108 std::cout <<
"basis size = " << sz
109 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
113 if (a_size > sz) a_size = sz;
114 if (x_size > sz) x_size = sz;
115 if (y_size > sz) y_size = sz;
119 node_stack.
push_back(Cijk->getHeadNode());
124 while (node_stack.
size() > 0) {
125 node = node_stack.
back();
126 child_index = index_stack.
back();
136 else if (node->i_size <= y_size &&
137 node->j_size <= a_size &&
138 node->k_size <= x_size) {
145 else if (child_index < node->children.size()) {
146 ++index_stack.
back();
147 node = node->children[child_index];
160 std::cout <<
"num partitions = " << partition_stack.
size() << std::endl;
178 for (
int part=0; part<partition_stack.
size(); ++part) {
179 node = partition_stack[part];
182 while (node_stack.
size() > 0) {
183 node = node_stack.
back();
184 child_index = index_stack.
back();
188 Cijk_Iterator cijk_iterator(node->p_i,
195 int I = node->i_begin + cijk_iterator.i;
196 int J = node->j_begin + cijk_iterator.j;
197 int K = node->k_begin + cijk_iterator.k;
203 more = cijk_iterator.increment();
210 else if (child_index < node->children.size()) {
211 ++index_stack.
back();
212 node = node->children[child_index];
228 std::ofstream cijk_file(file_3tensor.c_str());
229 cijk_file.precision(14);
230 cijk_file.setf(std::ios::scientific);
231 cijk_file <<
"i, j, k, part" << std::endl;
232 for (
int i=0; i<tuples.
size(); ++i) {
233 cijk_file << tuples[i][0] <<
", "
234 << tuples[i][1] <<
", "
235 << tuples[i][2] <<
", "
236 << tuples[i][3] << std::endl;
242 catch (std::exception& e) {
243 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).