Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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
52
53namespace 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>
74 const Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_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
113 Teuchos::RCP< Stokhos::Sparse3Tensor<ordinal_type, value_type> >
115
117 virtual
118 Teuchos::RCP< Stokhos::Sparse3Tensor<ordinal_type, value_type> >
120
122 virtual value_type evaluateZero(ordinal_type i) const;
123
125
129 virtual void evaluateBases(
130 const Teuchos::ArrayView<const value_type>& point,
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
163 Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_type,
164 value_type> > >
165 getCoordinateBases() const;
166
169
171
173 typedef TensorProductBasis<ordinal_type,value_type,
176
178 ordinal_type getNumSmolyakTerms() const { return tp_bases.size(); }
179
181 Teuchos::RCP<const tensor_product_basis_type>
182 getTensorProductBasis(ordinal_type i) const { return tp_bases[i]; }
183
185 ordinal_type getSmolyakCoefficient(ordinal_type i) const {
186 return smolyak_coeffs[i];
187 }
188
189 private:
190
191 // Prohibit copying
193
194 // Prohibit Assignment
196
197 protected:
198
199 typedef std::map<coeff_type,ordinal_type,coeff_compare_type> coeff_set_type;
200 typedef Teuchos::Array<coeff_type> coeff_map_type;
202
204 std::string name;
205
207 ordinal_type p;
208
210 ordinal_type d;
211
213 ordinal_type sz;
214
216 Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_type, value_type> > > bases;
217
219 value_type sparse_tol;
220
223
226
229
231 Teuchos::Array<ordinal_type> smolyak_coeffs;
232
234 Teuchos::Array<value_type> norms;
235
237 mutable Teuchos::Array< Teuchos::Array<value_type> > basis_eval_tmp;
238
240 Teuchos::Array< Teuchos::RCP< tensor_product_basis_type > > tp_bases;
241
243 template <typename tp_predicate_type>
245 Teuchos::Array<tp_predicate_type> tp_preds;
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
A comparison functor implementing a strict weak ordering based lexographic ordering.
A multidimensional index.
Abstract base class for 1-D orthogonal polynomials.
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
Multivariate orthogonal polynomial basis generated from a Smolyak sparse grid.
Teuchos::Array< Teuchos::RCP< tensor_product_basis_type > > tp_bases
Tensor product bases comprising Smolyak set.
virtual void evaluateBases(const Teuchos::ArrayView< const value_type > &point, Teuchos::Array< value_type > &basis_vals) const
Evaluate basis polynomials at given point point.
virtual const Teuchos::Array< value_type > & norm_squared() const
Return array storing norm-squared of each basis polynomial.
ordinal_type dimension() const
Return dimension of basis.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeLinearTripleProductTensor() const
Compute linear triple product tensor where k = 0,1,..,d.
Teuchos::Array< coeff_type > coeff_map_type
virtual ordinal_type index(const MultiIndex< ordinal_type > &term) const
Get index of the multivariate polynomial given orders of each coordinate.
Teuchos::Array< Teuchos::Array< value_type > > basis_eval_tmp
Temporary array used in basis evaluation.
Teuchos::Array< ordinal_type > smolyak_coeffs
Smolyak coefficients.
TensorProductBasis< ordinal_type, value_type, LexographicLess< coeff_type > > tensor_product_basis_type
std::map< coeff_type, ordinal_type, coeff_compare_type > coeff_set_type
std::string name
Name of basis.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
ordinal_type d
Total dimension of basis.
ordinal_type order() const
Return order of basis.
coeff_map_type basis_map
Basis map.
MultiIndex< ordinal_type > coeff_type
virtual ordinal_type size() const
Return total size of basis.
coeff_type max_orders
Maximum orders for each dimension.
Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > bases
Array of bases.
ordinal_type sz
Total size of basis.
value_type sparse_tol
Tolerance for computing sparse Cijk.
SmolyakBasis(const SmolyakBasis &)
Teuchos::RCP< const tensor_product_basis_type > getTensorProductBasis(ordinal_type i) const
Return ith tensor product basis.
coeff_set_type basis_set
Basis set.
virtual const std::string & getName() const
Return string name of basis.
Teuchos::Array< value_type > norms
Norms.
virtual MultiIndex< ordinal_type > getMaxOrders() const
Return maximum order allowable for each coordinate basis.
SmolyakPredicate< TensorProductPredicate< ordinal_type > > sm_pred
Predicate for building sparse triple products.
ordinal_type getNumSmolyakTerms() const
Return number of terms in Smolyak formula.
MultiIndex< ordinal_type > multiindex_type
Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > getCoordinateBases() const
Return coordinate bases.
SmolyakBasis & operator=(const SmolyakBasis &b)
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.
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const
Get orders of each coordinate polynomial given an index i.
virtual void print(std::ostream &os) const
Print basis to stream os.
virtual ~SmolyakBasis()
Destructor.
ordinal_type p
Total order of basis.
ordinal_type getSmolyakCoefficient(ordinal_type i) const
Return ith smolyak coefficient.
virtual value_type evaluateZero(ordinal_type i) const
Evaluate basis polynomial i at zero.
Multivariate orthogonal polynomial basis generated from a tensor product of univariate polynomials.
Top-level namespace for Stokhos classes and functions.
Predicate functor for building sparse triple products.
bool operator()(const coeff_type &term) const
Teuchos::Array< tp_predicate_type > tp_preds