63 "This example generates partitions the Cijk tensor for a lexicographic tree basis.\n");
65 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
67 CLP.
setOption(
"order", &p,
"Polynomial order");
68 double drop = 1.0e-12;
69 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
70 bool symmetric =
true;
71 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
73 CLP.
setOption(
"level", &level,
"Level to partition");
74 bool save_3tensor =
false;
75 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
76 "Save full 3tensor to file");
77 std::string file_3tensor =
"Cijk.dat";
78 CLP.
setOption(
"filename_3tensor", &file_3tensor,
79 "Filename to store full 3-tensor");
82 CLP.
parse( argc, argv );
86 const double alpha = 1.0;
87 const double beta = symmetric ? 1.0 : 2.0 ;
88 for (
int i=0; i<d; i++) {
90 p, alpha, beta,
true));
98 typedef Cijk_LTB_type::CijkNode
node_type;
102 int sz = basis->
size();
103 std::cout <<
"basis size = " << sz
104 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
110 node_stack.
push_back(Cijk->getHeadNode());
116 while (node_stack.
size() > 0) {
117 node = node_stack.
back();
118 child_index = index_stack.
back();
129 else if (my_level == level) {
137 else if (child_index < node->children.size()) {
138 ++index_stack.
back();
139 node = node->children[child_index];
155 int max_i_size = 0, max_j_size = 0, max_k_size = 0;
156 for (
int part=0; part<partition_stack.
size(); ++part) {
157 node = partition_stack[part];
158 if (node->i_size > max_i_size) max_i_size = node->i_size;
159 if (node->j_size > max_j_size) max_j_size = node->j_size;
160 if (node->k_size > max_k_size) max_k_size = node->k_size;
162 std::cout <<
"num partitions = " << partition_stack.
size() << std::endl
163 <<
"max i size = " << max_i_size << std::endl
164 <<
"max j size = " << max_j_size << std::endl
165 <<
"max k size = " << max_k_size << std::endl;
170 for (
int part=0; part<partition_stack.
size(); ++part) {
171 node = partition_stack[part];
174 while (node_stack.
size() > 0) {
175 node = node_stack.
back();
176 child_index = index_stack.
back();
180 Cijk_Iterator cijk_iterator(node->p_i,
187 int I = node->i_begin + cijk_iterator.i;
188 int J = node->j_begin + cijk_iterator.j;
189 int K = node->k_begin + cijk_iterator.k;
195 more = cijk_iterator.increment();
202 else if (child_index < node->children.size()) {
203 ++index_stack.
back();
204 node = node->children[child_index];
220 std::ofstream cijk_file(file_3tensor.c_str());
221 cijk_file.precision(14);
222 cijk_file.setf(std::ios::scientific);
223 cijk_file <<
"i, j, k, part" << std::endl;
224 for (
int i=0; i<tuples.
size(); ++i) {
225 cijk_file << tuples[i][0] <<
", "
226 << tuples[i][1] <<
", "
227 << tuples[i][2] <<
", "
228 << tuples[i][3] << std::endl;
234 catch (std::exception& e) {
235 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).