48 template <
typename ordinal_type,
typename value_type>
55 name(
"Monomial Proj Gram Schmidt PCE Basis"),
57 pce_basis(pce[0].basis()),
58 pce_sz(pce_basis->size()),
61 verbose(params.get(
"Verbose", false)),
62 rank_threshold(params.get(
"Rank Threshold", 1.0e-12)),
63 orthogonalization_method(params.get(
"Orthogonalization Method",
70 if (pce[i].standard_deviation() > 1.0e-15)
73 d = non_const_pce.
size();
91 if (quad_params.
isParameter(
"Reduced Quadrature Method") &&
92 quad_params.
get<std::string>(
"Reduced Quadrature Method") ==
"Q2") {
95 value_type rank_threshold2 = quad_params.
get(
"Q2 Rank Threshold",
110 bases[i] = prod_basis->getCoordinateBases()[i]->cloneWithOrder(2*max_p);
114 std::cout <<
"built new basis of dimension " << basis2->dimension()
115 <<
" and order " << basis2->order()
116 <<
" with total size " << basis2->size() << std::endl;
124 std::cout <<
"built new quadrature with total size " << quad2->size()
129 pce2[i].reset(basis2);
136 buildQ(2*max_p, rank_threshold2, pce2, quad2, terms2, num_terms2,
143 quad->getQuadPoints();
149 SDM AA(nqp, pce_sz2);
152 basis2->evaluateBases(points[i], basis_vals);
154 AA(i,
j) = basis_vals[
j];
178 template <
typename ordinal_type,
typename value_type>
196 quad->getQuadPoints();
198 quad->getBasisAtQuadPoints();
206 A_(i,
j) = basis_values[i][
j];
212 pce_norms[
j] += (pce[
j])[i]*(pce[
j])[i]*pce_basis_->norm_squared(i);
226 F_(i,
j) = pce[
j].evaluate(points[i], basis_values[i]);
231 CPBUtils::compute_terms(max_p, d, max_sz, terms_, num_terms_);
249 SDM Bp(pce_sz_, max_sz);
251 pce_basis_->norm_squared();
256 Bp(i,
j) += weights[k]*B(k,
j)*A_(k,i);
257 Bp(i,
j) /= basis_norms[i];
265 nrm += Bp(i,
j)*Bp(i,
j)*basis_norms[i];
277 for (
int i=0; i<d+1; i++)
281 orthogonalization_method, threshold, verbose, Bp, w, Qp_, R, piv);
286 template <
typename ordinal_type,
typename value_type>
292 template <
typename ordinal_type,
typename value_type>
300 template <
typename ordinal_type,
typename value_type>
308 template <
typename ordinal_type,
typename value_type>
316 template <
typename ordinal_type,
typename value_type>
324 template <
typename ordinal_type,
typename value_type>
332 template <
typename ordinal_type,
typename value_type>
341 template <
typename ordinal_type,
typename value_type>
350 template <
typename ordinal_type,
typename value_type>
358 template <
typename ordinal_type,
typename value_type>
367 template <
typename ordinal_type,
typename value_type>
375 template <
typename ordinal_type,
typename value_type>
380 os <<
"Gram-Schmidt basis of order " << p <<
", dimension " << d
381 <<
", and size " << sz <<
". Matrix coefficients:\n";
383 os <<
"Basis vector norms (squared):\n\t";
385 os << norms[i] <<
" ";
389 template <
typename ordinal_type,
typename value_type>
411 template <
typename ordinal_type,
typename value_type>
433 template <
typename ordinal_type,
typename value_type>
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
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 Teuchos::RCP< const Stokhos::UserDefinedQuadrature< ordinal_type, value_type > > createReducedQuadrature(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Q, const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Q2, const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &F, const Teuchos::Array< value_type > &weights) const
Get reduced quadrature object.
virtual const std::string & getName() const
Return string name of basis.
Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > reduced_quad
Reduced quadrature object.
virtual Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > getReducedQuadrature() const
Get reduced quadrature object.
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
MonomialProjGramSchmidtPCEBasis2(ordinal_type p, const Teuchos::Array< Stokhos::OrthogPolyApprox< ordinal_type, value_type > > &pce, const Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > &quad, const Teuchos::ParameterList ¶ms=Teuchos::ParameterList())
Constructor.
ordinal_type d
Total dimension of basis.
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
T & get(ParameterList &l, const std::string &name)
int multiply(ETransp transa, ETransp transb, ScalarType alpha, const SerialDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &B, ScalarType beta)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ordinal_type buildQ(ordinal_type max_p, value_type threshold, const Teuchos::Array< Stokhos::OrthogPolyApprox< ordinal_type, value_type > > &pce, const Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > &quad, Teuchos::Array< Stokhos::MultiIndex< ordinal_type > > &terms_, Teuchos::Array< ordinal_type > &num_terms_, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Qp_, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &A_, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &F_)
Build the reduced basis, parameterized by total order max_p.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
int quad2(const Epetra_Map &map, bool verbose)
bool isParameter(const std::string &name) const
SDM Q
Values of transformed basis at quadrature points.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
value_type rank_threshold
Rank threshold.
virtual value_type evaluateZero(ordinal_type i) const
Evaluate basis polynomial i at zero.
Abstract base class for quadrature methods.
ordinal_type order() const
Return order of basis.
virtual void transformToOriginalBasis(const value_type *in, value_type *out, ordinal_type ncol=1, bool transpose=false) const
Transform coefficients to original basis from this basis.
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
void resize(size_type new_size, const value_type &x=value_type())
Multivariate orthogonal polynomial basis generated from a total-order complete-polynomial tensor prod...
Generate a basis from a given set of PCE expansions that is orthogonal with respect to the product me...
ordinal_type sz
Total size of basis.
void push_back(const value_type &x)
Teuchos::ParameterList params
Algorithm parameters.
virtual ~MonomialProjGramSchmidtPCEBasis2()
Destructor.
int reshape(OrdinalType numRows, OrdinalType numCols)
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.
SDM Qp
Coefficients of transformed basis in original basis.
virtual ordinal_type size() const
Return total size of basis.
Teuchos::Array< value_type > norms
Norms.
Teuchos::Array< Stokhos::MultiIndex< ordinal_type > > terms
2-D array of basis terms
#define TEUCHOS_ASSERT(assertion_test)
virtual void transformFromOriginalBasis(const value_type *in, value_type *out, ordinal_type ncol=1, bool transpose=false) const
Transform coefficients from original basis to this basis.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeLinearTripleProductTensor() const
Compute linear triple product tensor where k = 0,1,..,d.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > pce_basis
Original pce basis.
virtual void print(std::ostream &os) const
Print basis to stream os.
Teuchos::Array< ordinal_type > num_terms
Number of terms up to each order.
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...
OrdinalType numRows() const
Encapsulate various orthogonalization (ie QR) methods.