46 template <
typename ordinal_type,
typename value_type,
typename storage_type>
65 template <
typename ordinal_type,
typename value_type,
typename storage_type>
73 template <
typename ordinal_type,
typename value_type,
typename storage_type>
79 template <
typename ordinal_type,
typename value_type,
typename storage_type>
92 template <
typename ordinal_type,
typename value_type,
typename storage_type>
103 template <
typename ordinal_type,
typename value_type,
typename storage_type>
111 template <
typename ordinal_type,
typename value_type,
typename storage_type>
119 template <
typename ordinal_type,
typename value_type,
typename storage_type>
127 template <
typename ordinal_type,
typename value_type,
typename storage_type>
135 template <
typename ordinal_type,
typename value_type,
typename storage_type>
144 resize(basis_->size());
149 template <
typename ordinal_type,
typename value_type,
typename storage_type>
157 template <
typename ordinal_type,
typename value_type,
typename storage_type>
162 return coeff_.size();
165 template <
typename ordinal_type,
typename value_type,
typename storage_type>
172 "Stokhos::OrthogPolyApprox::coeff(): " <<
173 "Coefficient array is empty!");
175 return coeff_.coeff();
178 template <
typename ordinal_type,
typename value_type,
typename storage_type>
185 "Stokhos::OrthogPolyApprox::coeff(): " <<
186 "Coefficient array is empty!");
188 return coeff_.coeff();
191 template <
typename ordinal_type,
typename value_type,
typename storage_type>
199 template <
typename ordinal_type,
typename value_type,
typename storage_type>
207 template <
typename ordinal_type,
typename value_type,
typename storage_type>
216 theTerm[dimension] = theOrder;
218 return coeff_[index];
221 template <
typename ordinal_type,
typename value_type,
typename storage_type>
230 theTerm[dimension] = theOrder;
232 return coeff_[index];
235 template <
typename ordinal_type,
typename value_type,
typename storage_type>
242 return product_basis->term(theTerm);
245 template <
typename ordinal_type,
typename value_type,
typename storage_type>
251 basis_->evaluateBases(point, basis_vals);
252 return evaluate(point, basis_vals);
255 template <
typename ordinal_type,
typename value_type,
typename storage_type>
262 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
263 val += coeff_[i]*basis_vals[i];
268 template <
typename ordinal_type,
typename value_type,
typename storage_type>
276 template <
typename ordinal_type,
typename value_type,
typename storage_type>
282 for (
ordinal_type i=1; i<static_cast<ordinal_type>(coeff_.size()); i++) {
283 std_dev += coeff_[i]*coeff_[i]*basis_->norm_squared(i);
289 template <
typename ordinal_type,
typename value_type,
typename storage_type>
294 return std::sqrt(this->two_norm_squared());
297 template <
typename ordinal_type,
typename value_type,
typename storage_type>
305 coeff_.size() != 1, std::logic_error,
306 "basis_ == null && coeff_.size() > 1");
307 nrm = coeff_[0]*coeff_[0];
310 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
311 nrm += coeff_[i]*coeff_[i]*basis_->norm_squared(i);
316 template <
typename ordinal_type,
typename value_type,
typename storage_type>
323 basis_ ==
Teuchos::null && coeff_.size() != 1, std::logic_error,
324 "basis_ == null && coeff_.size() > 1");
327 "b.basis_ == null && b.coeff_.size() > 1");
330 coeff_.size() != 1 && b.
coeff_.
size() != 1, std::logic_error,
331 "Coefficient array sizes do not match");
334 if (coeff_.size() == 1 || b.
coeff_.
size() == 1)
335 v = coeff_[0]*b.
coeff_[0];
337 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
338 v += coeff_[i]*b.
coeff_[i]*basis_->norm_squared(i);
343 template <
typename ordinal_type,
typename value_type,
typename storage_type>
348 os <<
"Stokhos::OrthogPolyApprox of size " << coeff_.size() <<
" in basis "
349 <<
"\n\t" << basis_->getName() <<
":" << std::endl;
355 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++) {
359 os << trm[
j] <<
", ";
360 os << trm[trm.
size()-1] <<
") = " << coeff_[i] << std::endl;
366 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++) {
367 os << coeff_[i] <<
" ";
376 template <
typename ordinal_type,
typename value_type,
typename storage_type>
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
value_type two_norm_squared() const
Compute the squared two-norm of expansion.
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved)
value_type evaluate(const Teuchos::Array< value_type > &point) const
Evaluate polynomial approximation at a point.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis_
Basis expansion is relative to.
OrthogPolyApprox & operator=(const OrthogPolyApprox &x)
Assignment operator (deep copy)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ordinal_type size() const
Size.
void init(const value_type &v)
Initialize coefficients to value.
OrthogPolyApprox(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &basis=Teuchos::null, ordinal_type sz=0, const value_type *vals=NULL)
Constructor with supplied size sz.
~OrthogPolyApprox()
Destructor.
pointer coeff()
Return coefficient array.
value_type two_norm() const
Compute the two-norm of expansion.
value_type inner_product(const OrthogPolyApprox &b) const
Compute the L2 inner product of 2 PCEs.
value_type standard_deviation() const
Compute standard deviation of expansion.
Abstract base class for multivariate orthogonal polynomials.
reference operator[](ordinal_type i)
Array access.
storage_type::reference reference
std::ostream & operator<<(std::ostream &os, const ProductContainer< coeff_type > &vec)
storage_type coeff_
OrthogPolyApprox coefficients.
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, ordinal_type sz=0)
Reset to a new basis.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis() const
Return basis.
storage_type::pointer pointer
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
void load(value_type *v)
Load coefficients to an array of values.
value_type mean() const
Compute mean of expansion.
storage_type::const_reference const_reference
storage_type::const_pointer const_pointer
Class to store coefficients of a projection onto an orthogonal polynomial basis.
void init(const_reference v)
Initialize values to a constant value.
std::ostream & print(std::ostream &os) const
Print approximation in basis.
ordinal_type size() const
Return size.
void resize(const ordinal_type &sz)
Resize to new size (values are preserved)
const MultiIndex< ordinal_type > & order(ordinal_type term) const
Get orders for a given term.
ordinal_type size() const
Return size.
reference term(ordinal_type dimension, ordinal_type order)
Get coefficient term for given dimension and order.