14 template <
typename ordinal_type,
typename value_type>
20 bool use_pce_quad_points_,
22 bool project_integrals_,
27 pce_weights(quad->getQuadWeights()),
28 basis_values(quad->getBasisAtQuadPoints()),
31 use_pce_quad_points(use_pce_quad_points_),
32 fromStieltjesMat(p+1,pce->size()),
33 project_integrals(project_integrals_),
42 template <
typename ordinal_type,
typename value_type>
48 template <
typename ordinal_type,
typename value_type>
56 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
61 if (use_pce_quad_points) {
62 quad_points = pce_vals;
63 quad_weights = pce_weights;
64 quad_values = phi_vals;
74 if (quad_order > 2*this->p)
75 quad_order = 2*this->p;
82 if (quad_weights.
size() < num_points) {
84 quad_weights.
resize(num_points);
85 quad_points.
resize(num_points);
86 quad_values.resize(num_points);
89 quad_points[i] = quad_points[0];
90 quad_values[i].
resize(this->p+1);
91 this->evaluateBases(quad_points[i], quad_values[i]);
96 template <
typename ordinal_type,
typename value_type>
110 stieltjes(0, n, pce_weights, pce_vals, alpha, beta, nrm, vals);
123 template <
typename ordinal_type,
typename value_type>
130 quad->getQuadPoints();
132 pce_vals.resize(nqp);
133 phi_vals.resize(nqp);
135 pce_vals[i] = pce->evaluate(quad_points[i], basis_values[i]);
136 phi_vals[i].resize(this->p+1);
139 if (project_integrals)
140 phi_pce_coeffs.resize(basis->size());
145 fromStieltjesMat.putScalar(0.0);
149 fromStieltjesMat(i,
j) +=
150 pce_weights[k]*phi_vals[k][i]*basis_values[k][
j];
151 fromStieltjesMat(i,
j) /= basis->norm_squared(
j);
156 template <
typename ordinal_type,
typename value_type>
168 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
175 if (project_integrals)
176 integrateBasisSquaredProj(0, a, b, weights, points, phi_vals, val1, val2);
178 integrateBasisSquared(0, a, b, weights, points, phi_vals, val1, val2);
185 if (project_integrals)
186 integrateBasisSquaredProj(i, a, b, weights, points, phi_vals, val1, val2);
188 integrateBasisSquared(i, a, b, weights, points, phi_vals, val1, val2);
192 "Stokhos::StieltjesPCEBasis::stieltjes(): "
193 <<
" Polynomial " << i <<
" out of " << nfinish
194 <<
" has norm " << val1
195 <<
"! Try increasing number of quadrature points");
198 b[i] = nrm[i]/nrm[i-1];
205 template <
typename ordinal_type,
typename value_type>
216 evaluateRecurrence(k, a, b, points, phi_vals);
221 val1 += weights[i]*phi_vals[i][k]*phi_vals[i][k];
222 val2 += weights[i]*phi_vals[i][k]*phi_vals[i][k]*points[i];
226 template <
typename ordinal_type,
typename value_type>
241 values[i][k] = points[i] - a[k-1];
245 (points[i] - a[k-1])*values[i][k-1] - b[k-1]*values[i][k-2];
248 template <
typename ordinal_type,
typename value_type>
265 evaluateRecurrence(k, a, b, points, phi_vals);
269 c += weights[i]*phi_vals[i][k]*basis_values[i][
j];
271 phi_pce_coeffs[
j] = c;
277 val1 += phi_pce_coeffs[
j]*phi_pce_coeffs[
j]*norms[
j];
282 k_it != Cijk->k_end(); ++k_it) {
285 j_it != Cijk->j_end(k_it); ++j_it) {
288 i_it != Cijk->i_end(j_it); ++i_it) {
291 val2 += phi_pce_coeffs[i]*phi_pce_coeffs[
j]*(*pce)[l]*c;
297 template <
typename ordinal_type,
typename value_type>
304 fromStieltjesMat.numCols(), 1.0, fromStieltjesMat.values(),
305 fromStieltjesMat.numRows(), in, 1, 0.0, out, 1);
308 template <
typename ordinal_type,
typename value_type>
316 template <
typename ordinal_type,
typename value_type>
322 pce_weights(quad->getQuadWeights()),
323 basis_values(quad->getBasisAtQuadPoints()),
324 pce_vals(sbasis.pce_vals),
326 use_pce_quad_points(sbasis.use_pce_quad_points),
327 fromStieltjesMat(p+1,pce->size()),
328 project_integrals(sbasis.project_integrals),
virtual Teuchos::RCP< OneDOrthogPolyBasis< ordinal_type, value_type > > cloneWithOrder(ordinal_type p) const
Clone this object with the option of building a higher order basis.
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
Implementation of OneDOrthogPolyBasis based on the general three-term recurrence relationship: for ...
void integrateBasisSquaredProj(ordinal_type k, const Teuchos::Array< value_type > &a, const Teuchos::Array< value_type > &b, const Teuchos::Array< value_type > &weights, const Teuchos::Array< value_type > &points, Teuchos::Array< Teuchos::Array< value_type > > &phi_vals, value_type &val1, value_type &val2) const
Compute and by projecting onto original PCE basis.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
void GEMV(ETransp trans, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, const x_type *x, const OrdinalType &incx, const beta_type beta, ScalarType *y, const OrdinalType &incy) const
virtual void getQuadPoints(ordinal_type quad_order, Teuchos::Array< value_type > &points, Teuchos::Array< value_type > &weights, Teuchos::Array< Teuchos::Array< value_type > > &values) const
Compute quadrature points, weights, and values of basis polynomials at given set of points points...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
StieltjesPCEBasis(ordinal_type p, const Teuchos::RCP< const Stokhos::OrthogPolyApprox< ordinal_type, value_type > > &pce, const Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > &quad, bool use_pce_quad_points, bool normalize=false, bool project_integrals=false, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk=Teuchos::null)
Constructor.
Bi-directional iterator for traversing a sparse array.
Generates three-term recurrence using the Discretized Stieltjes procedure applied to a polynomial cha...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Abstract base class for quadrature methods.
KOKKOS_INLINE_FUNCTION PCE< Storage > ceil(const PCE< Storage > &a)
~StieltjesPCEBasis()
Destructor.
void resize(size_type new_size, const value_type &x=value_type())
void evaluateRecurrence(ordinal_type k, const Teuchos::Array< value_type > &a, const Teuchos::Array< value_type > &b, const Teuchos::Array< value_type > &points, Teuchos::Array< Teuchos::Array< value_type > > &values) const
Evaluate polynomials via 3-term recurrence.
virtual void setup()
Setup basis after computing recurrence coefficients.
virtual bool computeRecurrenceCoefficients(ordinal_type n, Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const
Compute recurrence coefficients.
virtual void getQuadPoints(ordinal_type quad_order, Teuchos::Array< value_type > &points, Teuchos::Array< value_type > &weights, Teuchos::Array< Teuchos::Array< value_type > > &values) const
Get Gauss quadrature points, weights, and values of basis at points.
virtual void setup()
Setup basis after computing recurrence coefficients.
void transformCoeffsFromStieltjes(const value_type *in, value_type *out) const
Map expansion coefficients from this basis to original.
void integrateBasisSquared(ordinal_type k, const Teuchos::Array< value_type > &a, const Teuchos::Array< value_type > &b, const Teuchos::Array< value_type > &weights, const Teuchos::Array< value_type > &points, Teuchos::Array< Teuchos::Array< value_type > > &phi_vals, value_type &val1, value_type &val2) const
Compute and .
void stieltjes(ordinal_type nstart, ordinal_type nfinish, const Teuchos::Array< value_type > &weights, const Teuchos::Array< value_type > &points, Teuchos::Array< value_type > &a, Teuchos::Array< value_type > &b, Teuchos::Array< value_type > &nrm, Teuchos::Array< Teuchos::Array< value_type > > &phi_vals) const
Compute 3-term recurrence using Stieljtes procedure.