12 template <
typename ordinal_type,
typename value_type,
typename storage_type>
31 template <
typename ordinal_type,
typename value_type,
typename storage_type>
39 template <
typename ordinal_type,
typename value_type,
typename storage_type>
45 template <
typename ordinal_type,
typename value_type,
typename storage_type>
58 template <
typename ordinal_type,
typename value_type,
typename storage_type>
69 template <
typename ordinal_type,
typename value_type,
typename storage_type>
77 template <
typename ordinal_type,
typename value_type,
typename storage_type>
85 template <
typename ordinal_type,
typename value_type,
typename storage_type>
93 template <
typename ordinal_type,
typename value_type,
typename storage_type>
101 template <
typename ordinal_type,
typename value_type,
typename storage_type>
110 resize(basis_->size());
115 template <
typename ordinal_type,
typename value_type,
typename storage_type>
123 template <
typename ordinal_type,
typename value_type,
typename storage_type>
128 return coeff_.size();
131 template <
typename ordinal_type,
typename value_type,
typename storage_type>
138 "Stokhos::OrthogPolyApprox::coeff(): " <<
139 "Coefficient array is empty!");
141 return coeff_.coeff();
144 template <
typename ordinal_type,
typename value_type,
typename storage_type>
151 "Stokhos::OrthogPolyApprox::coeff(): " <<
152 "Coefficient array is empty!");
154 return coeff_.coeff();
157 template <
typename ordinal_type,
typename value_type,
typename storage_type>
165 template <
typename ordinal_type,
typename value_type,
typename storage_type>
173 template <
typename ordinal_type,
typename value_type,
typename storage_type>
182 theTerm[dimension] = theOrder;
184 return coeff_[index];
187 template <
typename ordinal_type,
typename value_type,
typename storage_type>
196 theTerm[dimension] = theOrder;
198 return coeff_[index];
201 template <
typename ordinal_type,
typename value_type,
typename storage_type>
208 return product_basis->term(theTerm);
211 template <
typename ordinal_type,
typename value_type,
typename storage_type>
217 basis_->evaluateBases(point, basis_vals);
218 return evaluate(point, basis_vals);
221 template <
typename ordinal_type,
typename value_type,
typename storage_type>
228 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
229 val += coeff_[i]*basis_vals[i];
234 template <
typename ordinal_type,
typename value_type,
typename storage_type>
242 template <
typename ordinal_type,
typename value_type,
typename storage_type>
248 for (
ordinal_type i=1; i<static_cast<ordinal_type>(coeff_.size()); i++) {
249 std_dev += coeff_[i]*coeff_[i]*basis_->norm_squared(i);
255 template <
typename ordinal_type,
typename value_type,
typename storage_type>
260 return std::sqrt(this->two_norm_squared());
263 template <
typename ordinal_type,
typename value_type,
typename storage_type>
271 coeff_.size() != 1, std::logic_error,
272 "basis_ == null && coeff_.size() > 1");
273 nrm = coeff_[0]*coeff_[0];
276 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
277 nrm += coeff_[i]*coeff_[i]*basis_->norm_squared(i);
282 template <
typename ordinal_type,
typename value_type,
typename storage_type>
289 basis_ ==
Teuchos::null && coeff_.size() != 1, std::logic_error,
290 "basis_ == null && coeff_.size() > 1");
293 "b.basis_ == null && b.coeff_.size() > 1");
296 coeff_.size() != 1 && b.
coeff_.
size() != 1, std::logic_error,
297 "Coefficient array sizes do not match");
300 if (coeff_.size() == 1 || b.
coeff_.
size() == 1)
301 v = coeff_[0]*b.
coeff_[0];
303 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++)
304 v += coeff_[i]*b.
coeff_[i]*basis_->norm_squared(i);
309 template <
typename ordinal_type,
typename value_type,
typename storage_type>
314 os <<
"Stokhos::OrthogPolyApprox of size " << coeff_.size() <<
" in basis "
315 <<
"\n\t" << basis_->getName() <<
":" << std::endl;
321 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++) {
325 os << trm[
j] <<
", ";
326 os << trm[trm.
size()-1] <<
") = " << coeff_[i] << std::endl;
332 for (
ordinal_type i=0; i<static_cast<ordinal_type>(coeff_.size()); i++) {
333 os << coeff_[i] <<
" ";
342 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.