41#include "Teuchos_TimeMonitor.hpp"
42#include "Teuchos_TestForException.hpp"
44template <
typename ordinal_type,
typename value_type,
typename ordering_type>
47 const Teuchos::Array< Teuchos::RCP<
const OneDOrthogPolyBasis<ordinal_type, value_type> > >& bases_,
48 const value_type& sparse_tol_,
49 const ordering_type& coeff_compare) :
54 sparse_tol(sparse_tol_),
56 basis_set(coeff_compare),
61 for (ordinal_type i=0; i<d; i++) {
62 max_orders[i] = bases[i]->order();
63 if (max_orders[i] > p)
68 MultiIndex<ordinal_type> orders(d);
69 for (ordinal_type i=0; i<d; ++i)
70 orders[i] = bases[i]->order();
71 AnisotropicTotalOrderIndexSet<ordinal_type> index_set(p, orders);
72 ProductBasisUtils::buildProductBasis(index_set, basis_set, basis_map);
73 sz = basis_map.size();
78 for (ordinal_type k=0; k<sz; k++) {
80 for (ordinal_type i=0; i<d; i++)
81 nrm = nrm * bases[i]->norm_squared(basis_map[k][i]);
86 name =
"Tensor product basis (";
87 for (ordinal_type i=0; i<d-1; i++)
88 name += bases[i]->getName() +
", ";
89 name += bases[d-1]->getName() +
")";
92 basis_eval_tmp.resize(d);
93 for (ordinal_type
j=0;
j<d;
j++)
94 basis_eval_tmp[
j].resize(max_orders[
j]+1);
97template <
typename ordinal_type,
typename value_type,
typename ordering_type>
103template <
typename ordinal_type,
typename value_type,
typename ordering_type>
111template <
typename ordinal_type,
typename value_type,
typename ordering_type>
119template <
typename ordinal_type,
typename value_type,
typename ordering_type>
127template <
typename ordinal_type,
typename value_type,
typename ordering_type>
128const Teuchos::Array<value_type>&
135template <
typename ordinal_type,
typename value_type,
typename ordering_type>
143template <
typename ordinal_type,
typename value_type,
typename ordering_type>
144Teuchos::RCP< Stokhos::Sparse3Tensor<ordinal_type, value_type> >
148#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
149 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos: Total Triple-Product Tensor Fill Time");
154 return ProductBasisUtils::computeTripleProductTensor(
155 bases, basis_set, basis_map, predicate, predicate, sparse_tol);
158template <
typename ordinal_type,
typename value_type,
typename ordering_type>
159Teuchos::RCP< Stokhos::Sparse3Tensor<ordinal_type, value_type> >
163#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
164 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos: Total Triple-Product Tensor Fill Time");
170 return ProductBasisUtils::computeTripleProductTensor(
171 bases, basis_set, basis_map, predicate, k_predicate, sparse_tol);
174template <
typename ordinal_type,
typename value_type,
typename ordering_type>
181 value_type z = value_type(1.0);
182 for (ordinal_type
j=0;
j<d;
j++)
183 z = z * bases[
j]->evaluate(value_type(0.0), basis_map[i][
j]);
188template <
typename ordinal_type,
typename value_type,
typename ordering_type>
191evaluateBases(
const Teuchos::ArrayView<const value_type>& point,
192 Teuchos::Array<value_type>& basis_vals)
const
194 for (ordinal_type
j=0;
j<d;
j++)
195 bases[
j]->evaluateBases(point[
j], basis_eval_tmp[
j]);
198 for (ordinal_type i=0; i<sz; i++) {
199 value_type t = value_type(1.0);
200 for (ordinal_type
j=0;
j<d;
j++)
201 t *= basis_eval_tmp[
j][basis_map[i][
j]];
206template <
typename ordinal_type,
typename value_type,
typename ordering_type>
209print(std::ostream& os)
const
211 os <<
"Tensor product basis of order " << p <<
", dimension " << d
212 <<
", and size " << sz <<
". Component bases:\n";
213 for (ordinal_type i=0; i<d; i++)
215 os <<
"Basis vector norms (squared):\n\t";
216 for (ordinal_type i=0; i<static_cast<ordinal_type>(norms.size()); i++)
217 os << norms[i] <<
" ";
221template <
typename ordinal_type,
typename value_type,
typename ordering_type>
224term(ordinal_type i)
const
229template <
typename ordinal_type,
typename value_type,
typename ordering_type>
234 typename coeff_set_type::const_iterator it = basis_set.find(term);
235 TEUCHOS_TEST_FOR_EXCEPTION(it == basis_set.end(), std::logic_error,
236 "Invalid term " << term);
240template <
typename ordinal_type,
typename value_type,
typename ordering_type>
248template <
typename ordinal_type,
typename value_type,
typename ordering_type>
249Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<ordinal_type, value_type> > >
256template <
typename ordinal_type,
typename value_type,
typename ordering_type>
A multidimensional index.
virtual ~TotalOrderBasis()
Destructor.
virtual ordinal_type index(const MultiIndex< ordinal_type > &term) const
Get index of the multivariate polynomial given orders of each coordinate.
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.
Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > getCoordinateBases() const
Return coordinate bases.
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const
Get orders of each coordinate polynomial given an index i.
virtual value_type evaluateZero(ordinal_type i) const
Evaluate basis polynomial i at zero.
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 MultiIndex< ordinal_type > getMaxOrders() const
Return maximum order allowable for each coordinate basis.
TotalOrderBasis(const Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > &bases, const value_type &sparse_tol=1.0e-12, const coeff_compare_type &coeff_compare=coeff_compare_type())
Constructor.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeLinearTripleProductTensor() const
Compute linear triple product tensor where k = 0,1,..,d.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
virtual void print(std::ostream &os) const
Print basis to stream os.
ordinal_type order() const
Return order of basis.
virtual const std::string & getName() const
Return string name of basis.
virtual ordinal_type size() const
Return total size of basis.
Predicate functor for building sparse triple products based on total order.