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 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef STOKHOS_SMOLYAK_BASIS_HPP
43 #define STOKHOS_SMOLYAK_BASIS_HPP
44 
45 #include <map>
46 
47 #include "Teuchos_RCP.hpp"
48 
49 #include "Stokhos_ProductBasis.hpp"
52 
53 namespace Stokhos {
54 
59  template <typename ordinal_type, typename value_type,
60  typename coeff_compare_type =
61  TotalOrderLess<MultiIndex<ordinal_type> > >
62  class SmolyakBasis :
63  public ProductBasis<ordinal_type,value_type> {
64  public:
65 
67 
72  template <typename index_set_type>
75  value_type> > >& bases,
76  const index_set_type& index_set,
77  const value_type& sparse_tol = 1.0e-12,
78  const coeff_compare_type& coeff_compare = coeff_compare_type());
79 
81  virtual ~SmolyakBasis();
82 
84 
85 
87  ordinal_type order() const;
88 
90  ordinal_type dimension() const;
91 
93  virtual ordinal_type size() const;
94 
96 
100  virtual const Teuchos::Array<value_type>& norm_squared() const;
101 
103  virtual const value_type& norm_squared(ordinal_type i) const;
104 
106 
112  virtual
115 
117  virtual
120 
122  virtual value_type evaluateZero(ordinal_type i) const;
123 
125 
129  virtual void evaluateBases(
131  Teuchos::Array<value_type>& basis_vals) const;
132 
134  virtual void print(std::ostream& os) const;
135 
137  virtual const std::string& getName() const;
138 
140 
142 
143 
145 
150  virtual const MultiIndex<ordinal_type>& term(ordinal_type i) const;
151 
153 
157  virtual ordinal_type index(const MultiIndex<ordinal_type>& term) const;
158 
160 
164  value_type> > >
165  getCoordinateBases() const;
166 
168  virtual MultiIndex<ordinal_type> getMaxOrders() const;
169 
171 
176 
178  ordinal_type getNumSmolyakTerms() const { return tp_bases.size(); }
179 
183 
186  return smolyak_coeffs[i];
187  }
188 
189  private:
190 
191  // Prohibit copying
192  SmolyakBasis(const SmolyakBasis&);
193 
194  // Prohibit Assignment
196 
197  protected:
198 
199  typedef std::map<coeff_type,ordinal_type,coeff_compare_type> coeff_set_type;
202 
204  std::string name;
205 
208 
211 
214 
217 
220 
223 
226 
229 
232 
235 
238 
241 
243  template <typename tp_predicate_type>
246 
247  // Predicate is true if any tensor-product predicate is true
248  bool operator() (const coeff_type& term) const {
249  for (ordinal_type i=0; i<tp_preds.size(); ++i)
250  if (tp_preds[i](term))
251  return true;
252  return false;
253  }
254 
255  };
256 
259 
260  }; // class SmolyakBasis
261 
262 } // Namespace Stokhos
263 
264 // Include template definitions
266 
267 #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.