45 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
46 template <
typename index_set_type>
50 const index_set_type& index_set,
52 const ordering_type& coeff_compare) :
57 sparse_tol(sparse_tol_),
59 basis_set(coeff_compare),
90 typedef std::map<multiindex_type,ordinal_type,index_compare> index_map_type;
92 alpha_set_type alpha_set(dim, 1);
93 typename alpha_set_type::iterator alpha_begin = alpha_set.begin();
94 typename alpha_set_type::iterator alpha_end = alpha_set.end();
95 typename index_set_type::iterator index_iterator = index_set.begin();
96 typename index_set_type::iterator index_end = index_set.end();
98 index_map_type index_map;
99 for (; index_iterator != index_end; ++index_iterator) {
100 for (
typename alpha_set_type::iterator alpha = alpha_begin;
101 alpha != alpha_end; ++alpha) {
102 bool valid_index =
true;
104 diff[i] = (*index_iterator)[i] - (*alpha)[i];
113 if (alpha_order % 2 == 0)
117 typename index_map_type::iterator index_map_iterator =
118 index_map.find(diff);
119 if (index_map_iterator == index_map.end())
120 index_map[diff] = val;
122 index_map_iterator->second +=
val;
128 typename index_map_type::iterator index_map_iterator = index_map.begin();
129 typename index_map_type::iterator index_map_end = index_map.end();
130 for (; index_map_iterator != index_map_end; ++index_map_iterator) {
133 if (index_map_iterator->second == 0)
139 coeff_growth_index[i] =
140 bases[i]->coefficientGrowth(index_map_iterator->first[i]);
162 for (
typename coeff_set_type::iterator i =
basis_set.begin();
200 name =
"Smolyak basis (";
211 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
217 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
225 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
233 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
241 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
249 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
257 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
262 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
267 bases, basis_set, basis_map, sm_pred, sm_pred, sparse_tol);
270 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
275 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
280 for (
ordinal_type i=0; i<sm_pred.tp_preds.size(); ++i) {
286 bases, basis_set, basis_map, sm_pred, k_pred, sparse_tol);
289 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
298 z = z * bases[
j]->evaluate(
value_type(0.0), basis_map[i][
j]);
303 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
310 bases[
j]->evaluateBases(point[
j], basis_eval_tmp[j]);
316 t *= basis_eval_tmp[j][basis_map[i][j]];
321 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
326 os <<
"Smolyak basis of order " << p <<
", dimension " << d
327 <<
", and size " << sz <<
". Component bases:\n";
330 os <<
"Basis vector norms (squared):\n\t";
331 for (
ordinal_type i=0; i<static_cast<ordinal_type>(norms.size()); i++)
332 os << norms[i] <<
" ";
336 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
344 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
349 typename coeff_set_type::const_iterator it = basis_set.find(term);
351 "Invalid term " << term);
355 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
363 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
371 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
virtual value_type evaluateZero(ordinal_type i) const
Evaluate basis polynomial i at zero.
coeff_type max_orders
Maximum orders for each dimension.
Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > getCoordinateBases() const
Return coordinate bases.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor(const Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > &bases, const basis_set_type &basis_set, const basis_map_type &basis_map, const coeff_predicate_type &coeff_pred, const k_coeff_predicate_type &k_coeff_pred, const value_type sparse_tol=1.0e-12)
coeff_set_type basis_set
Basis set.
ordinal_type sz
Total size of basis.
SmolyakPredicate< TensorProductPredicate< ordinal_type > > sm_pred
Predicate for building sparse triple products.
ordinal_type p
Total order of basis.
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const
Get orders of each coordinate polynomial given an index i.
std::string name
Name of basis.
Teuchos::Array< value_type > norms
Norms.
virtual MultiIndex< ordinal_type > getMaxOrders() const
Return maximum order allowable for each coordinate basis.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeLinearTripleProductTensor() const
Compute linear triple product tensor where k = 0,1,..,d.
virtual void evaluateBases(const Teuchos::ArrayView< const value_type > &point, Teuchos::Array< value_type > &basis_vals) const
Evaluate basis polynomials at given point point.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Array< Teuchos::RCP< tensor_product_basis_type > > tp_bases
Tensor product bases comprising Smolyak set.
virtual ~SmolyakBasis()
Destructor.
Teuchos::Array< ordinal_type > smolyak_coeffs
Smolyak coefficients.
SmolyakBasis(const Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > &bases, const index_set_type &index_set, const value_type &sparse_tol=1.0e-12, const coeff_compare_type &coeff_compare=coeff_compare_type())
Constructor.
void resize(size_type new_size, const value_type &x=value_type())
virtual const std::string & getName() const
Return string name of basis.
Predicate functor for building sparse triple products.
Predicate functor for building sparse triple products based on total order.
ordinal_type dimension() const
Return dimension of basis.
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const
Get orders of each coordinate polynomial given an index i.
ordinal_type d
Total dimension of basis.
void push_back(const value_type &x)
Abstract base class for 1-D orthogonal polynomials.
virtual ordinal_type size() const
Return total size of basis.
virtual ordinal_type size() const
Return total size of basis.
Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > bases
Array of bases.
A comparison functor implementing a strict weak ordering based lexographic ordering.
virtual ordinal_type index(const MultiIndex< ordinal_type > &term) const
Get index of the multivariate polynomial given orders of each coordinate.
coeff_map_type basis_map
Basis map.
Teuchos::Array< Teuchos::Array< value_type > > basis_eval_tmp
Temporary array used in basis evaluation.
ordinal_type order() const
Return order of basis.
A tensor product index set.
TensorProductBasis< ordinal_type, value_type, LexographicLess< coeff_type > > tensor_product_basis_type
Predicate functor for building sparse triple products.
virtual const Teuchos::Array< value_type > & norm_squared() const
Return array storing norm-squared of each basis polynomial.
virtual void print(std::ostream &os) const
Print basis to stream os.
Teuchos::Array< tp_predicate_type > tp_preds
value_type sparse_tol
Tolerance for computing sparse Cijk.