31 "This example generates partitions the Cijk tensor for a lexicographic tree basis.\n");
33 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
35 CLP.
setOption(
"order", &p,
"Polynomial order");
36 double drop = 1.0e-12;
37 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
38 bool symmetric =
true;
39 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
41 CLP.
setOption(
"level", &level,
"Level to partition");
42 bool save_3tensor =
false;
43 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
44 "Save full 3tensor to file");
45 std::string file_3tensor =
"Cijk.dat";
46 CLP.
setOption(
"filename_3tensor", &file_3tensor,
47 "Filename to store full 3-tensor");
50 CLP.
parse( argc, argv );
54 const double alpha = 1.0;
55 const double beta = symmetric ? 1.0 : 2.0 ;
56 for (
int i=0; i<d; i++) {
58 p, alpha, beta,
true));
66 typedef Cijk_LTB_type::CijkNode
node_type;
70 int sz = basis->
size();
71 std::cout <<
"basis size = " << sz
72 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
78 node_stack.
push_back(Cijk->getHeadNode());
84 while (node_stack.
size() > 0) {
85 node = node_stack.
back();
86 child_index = index_stack.
back();
97 else if (my_level == level) {
105 else if (child_index < node->children.size()) {
106 ++index_stack.
back();
107 node = node->children[child_index];
123 int max_i_size = 0, max_j_size = 0, max_k_size = 0;
124 for (
int part=0; part<partition_stack.
size(); ++part) {
125 node = partition_stack[part];
126 if (node->i_size > max_i_size) max_i_size = node->i_size;
127 if (node->j_size > max_j_size) max_j_size = node->j_size;
128 if (node->k_size > max_k_size) max_k_size = node->k_size;
130 std::cout <<
"num partitions = " << partition_stack.
size() << std::endl
131 <<
"max i size = " << max_i_size << std::endl
132 <<
"max j size = " << max_j_size << std::endl
133 <<
"max k size = " << max_k_size << std::endl;
138 for (
int part=0; part<partition_stack.
size(); ++part) {
139 node = partition_stack[part];
142 while (node_stack.
size() > 0) {
143 node = node_stack.
back();
144 child_index = index_stack.
back();
148 Cijk_Iterator cijk_iterator(node->p_i,
155 int I = node->i_begin + cijk_iterator.i;
156 int J = node->j_begin + cijk_iterator.j;
157 int K = node->k_begin + cijk_iterator.k;
163 more = cijk_iterator.increment();
170 else if (child_index < node->children.size()) {
171 ++index_stack.
back();
172 node = node->children[child_index];
188 std::ofstream cijk_file(file_3tensor.c_str());
189 cijk_file.precision(14);
190 cijk_file.setf(std::ios::scientific);
191 cijk_file <<
"i, j, k, part" << std::endl;
192 for (
int i=0; i<tuples.
size(); ++i) {
193 cijk_file << tuples[i][0] <<
", "
194 << tuples[i][1] <<
", "
195 << tuples[i][2] <<
", "
196 << tuples[i][3] << std::endl;
202 catch (std::exception& e) {
203 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).