13 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
14 template <
typename index_set_type>
18 const index_set_type& index_set,
20 const ordering_type& coeff_compare) :
25 sparse_tol(sparse_tol_),
27 basis_set(coeff_compare),
58 typedef std::map<multiindex_type,ordinal_type,index_compare> index_map_type;
60 alpha_set_type alpha_set(dim, 1);
61 typename alpha_set_type::iterator alpha_begin = alpha_set.begin();
62 typename alpha_set_type::iterator alpha_end = alpha_set.end();
63 typename index_set_type::iterator index_iterator = index_set.begin();
64 typename index_set_type::iterator index_end = index_set.end();
66 index_map_type index_map;
67 for (; index_iterator != index_end; ++index_iterator) {
68 for (
typename alpha_set_type::iterator alpha = alpha_begin;
69 alpha != alpha_end; ++alpha) {
70 bool valid_index =
true;
72 diff[i] = (*index_iterator)[i] - (*alpha)[i];
81 if (alpha_order % 2 == 0)
85 typename index_map_type::iterator index_map_iterator =
87 if (index_map_iterator == index_map.end())
88 index_map[diff] = val;
90 index_map_iterator->second +=
val;
96 typename index_map_type::iterator index_map_iterator = index_map.begin();
97 typename index_map_type::iterator index_map_end = index_map.end();
98 for (; index_map_iterator != index_map_end; ++index_map_iterator) {
101 if (index_map_iterator->second == 0)
107 coeff_growth_index[i] =
108 bases[i]->coefficientGrowth(index_map_iterator->first[i]);
130 for (
typename coeff_set_type::iterator i =
basis_set.begin();
168 name =
"Smolyak basis (";
179 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
185 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
193 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
201 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
209 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>
230 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
235 bases, basis_set, basis_map, sm_pred, sm_pred, sparse_tol);
238 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
243 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
248 for (
ordinal_type i=0; i<sm_pred.tp_preds.size(); ++i) {
254 bases, basis_set, basis_map, sm_pred, k_pred, sparse_tol);
257 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
266 z = z * bases[
j]->evaluate(
value_type(0.0), basis_map[i][
j]);
271 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
278 bases[
j]->evaluateBases(point[
j], basis_eval_tmp[j]);
284 t *= basis_eval_tmp[j][basis_map[i][j]];
289 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
294 os <<
"Smolyak basis of order " << p <<
", dimension " << d
295 <<
", and size " << sz <<
". Component bases:\n";
298 os <<
"Basis vector norms (squared):\n\t";
299 for (
ordinal_type i=0; i<static_cast<ordinal_type>(norms.size()); i++)
300 os << norms[i] <<
" ";
304 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
312 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
317 typename coeff_set_type::const_iterator it = basis_set.find(term);
319 "Invalid term " << term);
323 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
331 template <
typename ordinal_type,
typename value_type,
typename ordering_type>
339 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.