Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SmolyakBasis.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef STOKHOS_SMOLYAK_BASIS_HPP
11 #define STOKHOS_SMOLYAK_BASIS_HPP
12 
13 #include <map>
14 
15 #include "Teuchos_RCP.hpp"
16 
17 #include "Stokhos_ProductBasis.hpp"
20 
21 namespace Stokhos {
22 
27  template <typename ordinal_type, typename value_type,
28  typename coeff_compare_type =
29  TotalOrderLess<MultiIndex<ordinal_type> > >
30  class SmolyakBasis :
31  public ProductBasis<ordinal_type,value_type> {
32  public:
33 
35 
40  template <typename index_set_type>
43  value_type> > >& bases,
44  const index_set_type& index_set,
45  const value_type& sparse_tol = 1.0e-12,
46  const coeff_compare_type& coeff_compare = coeff_compare_type());
47 
49  virtual ~SmolyakBasis();
50 
52 
53 
55  ordinal_type order() const;
56 
58  ordinal_type dimension() const;
59 
61  virtual ordinal_type size() const;
62 
64 
68  virtual const Teuchos::Array<value_type>& norm_squared() const;
69 
71  virtual const value_type& norm_squared(ordinal_type i) const;
72 
74 
80  virtual
83 
85  virtual
88 
90  virtual value_type evaluateZero(ordinal_type i) const;
91 
93 
97  virtual void evaluateBases(
99  Teuchos::Array<value_type>& basis_vals) const;
100 
102  virtual void print(std::ostream& os) const;
103 
105  virtual const std::string& getName() const;
106 
108 
110 
111 
113 
118  virtual const MultiIndex<ordinal_type>& term(ordinal_type i) const;
119 
121 
125  virtual ordinal_type index(const MultiIndex<ordinal_type>& term) const;
126 
128 
132  value_type> > >
133  getCoordinateBases() const;
134 
136  virtual MultiIndex<ordinal_type> getMaxOrders() const;
137 
139 
144 
146  ordinal_type getNumSmolyakTerms() const { return tp_bases.size(); }
147 
151 
154  return smolyak_coeffs[i];
155  }
156 
157  private:
158 
159  // Prohibit copying
160  SmolyakBasis(const SmolyakBasis&);
161 
162  // Prohibit Assignment
164 
165  protected:
166 
167  typedef std::map<coeff_type,ordinal_type,coeff_compare_type> coeff_set_type;
170 
172  std::string name;
173 
176 
179 
182 
185 
188 
191 
194 
197 
200 
203 
206 
209 
211  template <typename tp_predicate_type>
214 
215  // Predicate is true if any tensor-product predicate is true
216  bool operator() (const coeff_type& term) const {
217  for (ordinal_type i=0; i<tp_preds.size(); ++i)
218  if (tp_preds[i](term))
219  return true;
220  return false;
221  }
222 
223  };
224 
227 
228  }; // class SmolyakBasis
229 
230 } // Namespace Stokhos
231 
232 // Include template definitions
234 
235 #endif
std::map< coeff_type, ordinal_type, coeff_compare_type > coeff_set_type
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
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.
coeff_set_type basis_set
Basis set.
ordinal_type getNumSmolyakTerms() const
Return number of terms in Smolyak formula.
ordinal_type getSmolyakCoefficient(ordinal_type i) const
Return ith smolyak coefficient.
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.
std::string name
Name of basis.
SmolyakBasis & operator=(const SmolyakBasis &b)
Teuchos::Array< value_type > norms
Norms.
Teuchos::Array< coeff_type > coeff_map_type
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::Array< Teuchos::RCP< tensor_product_basis_type > > tp_bases
Tensor product bases comprising Smolyak set.
virtual ~SmolyakBasis()
Destructor.
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
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.
MultiIndex< ordinal_type > multiindex_type
virtual const std::string & getName() const
Return string name of basis.
Predicate functor for building sparse triple products.
Multivariate orthogonal polynomial basis generated from a Smolyak sparse grid.
ordinal_type dimension() const
Return dimension of basis.
Multivariate orthogonal polynomial basis generated from a tensor product of univariate polynomials...
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.
bool operator()(const coeff_type &term) const
Abstract base class for 1-D orthogonal polynomials.
virtual ordinal_type size() const
Return total size of basis.
size_type size() const
MultiIndex< ordinal_type > coeff_type
Teuchos::RCP< const tensor_product_basis_type > getTensorProductBasis(ordinal_type i) const
Return ith tensor product 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.
TensorProductBasis< ordinal_type, value_type, LexographicLess< coeff_type > > tensor_product_basis_type
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.