60 "This example generates partitions the Cijk tensor for a lexicographic tree basis.\n");
62 CLP.setOption(
"dimension", &d,
"Stochastic dimension");
64 CLP.setOption(
"order", &p,
"Polynomial order");
65 double drop = 1.0e-12;
66 CLP.setOption(
"drop", &drop,
"Drop tolerance");
67 bool symmetric =
true;
68 CLP.setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
70 CLP.setOption(
"a_size", &a_size,
"Size of a (matrix) partition");
72 CLP.setOption(
"x_size", &x_size,
"Size of x (input vector) partition");
74 CLP.setOption(
"y_size", &y_size,
"Size of y (output vector) partition");
75 bool save_3tensor =
false;
76 CLP.setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
77 "Save full 3tensor to file");
78 std::string file_3tensor =
"Cijk.dat";
79 CLP.setOption(
"filename_3tensor", &file_3tensor,
80 "Filename to store full 3-tensor");
87 const double alpha = 1.0;
88 const double beta = symmetric ? 1.0 : 2.0 ;
89 for (
int i=0; i<d; i++) {
91 p, alpha, beta,
true));
99 typedef Cijk_LTB_type::CijkNode
node_type;
103 int sz = basis->
size();
104 std::cout <<
"basis size = " << sz
105 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
109 if (a_size > sz) a_size = sz;
110 if (x_size > sz) x_size = sz;
111 if (y_size > sz) y_size = sz;
115 node_stack.
push_back(Cijk->getHeadNode());
120 while (node_stack.
size() > 0) {
121 node = node_stack.
back();
122 child_index = index_stack.
back();
132 else if (node->i_size <= y_size &&
133 node->j_size <= a_size &&
134 node->k_size <= x_size) {
141 else if (child_index < node->children.size()) {
142 ++index_stack.
back();
143 node = node->children[child_index];
156 std::cout <<
"num partitions = " << partition_stack.
size() << std::endl;
174 for (
int part=0; part<partition_stack.
size(); ++part) {
175 node = partition_stack[part];
178 while (node_stack.
size() > 0) {
179 node = node_stack.
back();
180 child_index = index_stack.
back();
184 Cijk_Iterator cijk_iterator(node->p_i,
191 int I = node->i_begin + cijk_iterator.i;
192 int J = node->j_begin + cijk_iterator.j;
193 int K = node->k_begin + cijk_iterator.k;
199 more = cijk_iterator.increment();
206 else if (child_index < node->children.size()) {
207 ++index_stack.
back();
208 node = node->children[child_index];
224 std::ofstream cijk_file(file_3tensor.c_str());
225 cijk_file.precision(14);
226 cijk_file.setf(std::ios::scientific);
227 cijk_file <<
"i, j, k, part" << std::endl;
228 for (
int i=0; i<tuples.
size(); ++i) {
229 cijk_file << tuples[i][0] <<
", " 230 << tuples[i][1] <<
", " 231 << tuples[i][2] <<
", " 232 << tuples[i][3] << std::endl;
238 catch (std::exception& e) {
239 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...
virtual ordinal_type size() const
Return total size of basis (given by order() + 1).
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)
int main(int argc, char **argv)
void push_back(const value_type &x)
A comparison functor implementing a strict weak ordering based lexographic ordering.