46 template <
typename ordinal_type,
typename value_type,
typename storage_type>
57 else if (theBasis != Teuchos::null)
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>
128 Teuchos::RCP<const Stokhos::OrthogPolyBasis<ordinal_type, value_type> >
135 template <
typename ordinal_type,
typename value_type,
typename storage_type>
143 else if (basis_ != Teuchos::null)
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>
171 TEUCHOS_TEST_FOR_EXCEPTION(coeff_.size() == 0, std::logic_error,
172 "Stokhos::OrthogPolyApprox::coeff(): " <<
173 "Coefficient array is empty!");
175 return coeff_.coeff();
178 template <
typename ordinal_type,
typename value_type,
typename storage_type>
184 TEUCHOS_TEST_FOR_EXCEPTION(coeff_.size() == 0, std::logic_error,
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>
212 Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
213 product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(basis_,
true);
216 theTerm[dimension] = theOrder;
218 return coeff_[index];
221 template <
typename ordinal_type,
typename value_type,
typename storage_type>
226 Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
227 product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(basis_,
true);
230 theTerm[dimension] = theOrder;
232 return coeff_[index];
235 template <
typename ordinal_type,
typename value_type,
typename storage_type>
240 Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
241 product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(basis_,
true);
242 return product_basis->term(theTerm);
245 template <
typename ordinal_type,
typename value_type,
typename storage_type>
248 evaluate(
const Teuchos::Array<value_type>& point)
const
250 Teuchos::Array<value_type> basis_vals(basis_->size());
251 basis_->evaluateBases(point, basis_vals);
252 return evaluate(point, basis_vals);
255 template <
typename ordinal_type,
typename value_type,
typename storage_type>
258 evaluate(
const Teuchos::Array<value_type>& point,
259 const Teuchos::Array<value_type>& basis_vals)
const
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>
303 if (basis_ == Teuchos::null) {
304 TEUCHOS_TEST_FOR_EXCEPTION(
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>
322 TEUCHOS_TEST_FOR_EXCEPTION(
323 basis_ == Teuchos::null && coeff_.size() != 1, std::logic_error,
324 "basis_ == null && coeff_.size() > 1");
325 TEUCHOS_TEST_FOR_EXCEPTION(
327 "b.basis_ == null && b.coeff_.size() > 1");
328 TEUCHOS_TEST_FOR_EXCEPTION(
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>
346 print(std::ostream& os)
const
348 os <<
"Stokhos::OrthogPolyApprox of size " << coeff_.size() <<
" in basis "
349 <<
"\n\t" << basis_->getName() <<
":" << std::endl;
351 Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
352 product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(basis_);
354 if (product_basis != Teuchos::null) {
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>