47 template <
typename ordinal_type,
typename value_type>
53 normalize(normalize_),
55 quad_zero_tol(1.0e-14),
56 #ifdef HAVE_STOKHOS_DAKOTA
57 sparse_grid_growth_rule(webbur::level_to_order_linear_nn),
59 sparse_grid_growth_rule(NULL),
69 template <
typename ordinal_type,
typename value_type>
74 normalize(basis.normalize),
76 quad_zero_tol(basis.quad_zero_tol),
77 sparse_grid_growth_rule(basis.sparse_grid_growth_rule),
86 template <
typename ordinal_type,
typename value_type>
92 computeRecurrenceCoefficients(p+1, alpha, beta, delta, gamma);
93 if (normalize && !is_normalized) {
94 normalizeRecurrenceCoefficients(alpha, beta, delta, gamma);
100 norms[0] = beta[0]/(gamma[0]*gamma[0]);
102 norms[k] = (beta[k]/gamma[k])*(delta[k-1]/delta[k])*norms[k-1];
106 template <
typename ordinal_type,
typename value_type>
112 template <
typename ordinal_type,
typename value_type>
120 template <
typename ordinal_type,
typename value_type>
128 template <
typename ordinal_type,
typename value_type>
136 template <
typename ordinal_type,
typename value_type>
144 template <
typename ordinal_type,
typename value_type>
155 getQuadPoints(3*p, points, weights, values);
164 weights[l]*(values[l][i])*(values[l][
j])*(values[l][k]);
166 (*Cijk)(i,
j,k) = triple_product;
174 template <
typename ordinal_type,
typename value_type>
186 getQuadPoints(3*p, points, weights, values);
195 weights[l]*(values[l][i])*(values[l][
j])*(values[l][k]);
197 if (
std::abs(triple_product/norms[i]) > sparse_tol)
198 Cijk->add_term(i,
j,k,triple_product);
202 Cijk->fillComplete();
207 template <
typename ordinal_type,
typename value_type>
215 getQuadPoints(2*p, points, weights, values);
221 evaluateBasesAndDerivatives(points[i], values[i], derivs[i]);
228 for (
int qp=0; qp<nqp; qp++)
229 b += weights[qp]*derivs[qp][i]*values[qp][
j];
237 template <
typename ordinal_type,
typename value_type>
249 basis_pts[1] = (delta[0]*x-alpha[0])*basis_pts[0]/gamma[1];
251 basis_pts[i] = ((delta[i-1]*x-alpha[i-1])*basis_pts[i-1] -
252 beta[i-1]*basis_pts[i-2])/gamma[i];
255 template <
typename ordinal_type,
typename value_type>
262 evaluateBases(x, vals);
265 derivs[1] = delta[0]/(gamma[0]*gamma[1]);
267 derivs[i] = (delta[i-1]*vals[i-1] + (delta[i-1]*x-alpha[i-1])*derivs[i-1] -
268 beta[i-1]*derivs[i-2])/gamma[i];
271 template <
typename ordinal_type,
typename value_type>
286 value_type v1 = (x*delta[0]-alpha[0])*v0/gamma[1];
292 v2 = ((delta[i-1]*x-alpha[i-1])*v1 - beta[i-1]*v0)/gamma[i];
300 template <
typename ordinal_type,
typename value_type>
305 os << name <<
" basis of order " << p <<
"." << std::endl;
307 os <<
"Alpha recurrence coefficients:\n\t";
309 os << alpha[i] <<
" ";
312 os <<
"Beta recurrence coefficients:\n\t";
314 os << beta[i] <<
" ";
317 os <<
"Delta recurrence coefficients:\n\t";
319 os << delta[i] <<
" ";
322 os <<
"Gamma recurrence coefficients:\n\t";
324 os << gamma[i] <<
" ";
327 os <<
"Basis polynomial norms (squared):\n\t";
329 os << norms[i] <<
" ";
333 template <
typename ordinal_type,
typename value_type>
341 template <
typename ordinal_type,
typename value_type>
362 if(num_points > p+1){
363 bool is_normalized = computeRecurrenceCoefficients(num_points, a, b, c, d);
365 normalizeRecurrenceCoefficients(a, b, c, d);
375 normalizeRecurrenceCoefficients(a, b, c, d);
378 quad_points.
resize(num_points);
379 quad_weights.
resize(num_points);
381 if (num_points == 1) {
382 quad_points[0] = a[0];
383 quad_weights[0] = beta[0];
418 my_lapack.
PTEQR(
'I', num_points, &a[0], &b[1], eig_vectors.
values(),
419 num_points, &workspace[0], &info_flag);
421 "PTEQR returned info = " << info_flag);
426 quad_points[i] = a[num_points-1-i]-shift;
427 if (
std::abs(quad_points[i]) < quad_zero_tol)
428 quad_points[i] = 0.0;
429 quad_weights[i] = beta[0]*eig_vectors[num_points-1-i][0]*eig_vectors[num_points-1-i][0];
434 quad_values.resize(num_points);
436 quad_values[i].resize(p+1);
437 evaluateBases(quad_points[i], quad_values[i]);
441 template <
typename ordinal_type,
typename value_type>
449 template <
typename ordinal_type,
typename value_type>
461 template <
typename ordinal_type,
typename value_type>
477 template <
typename ordinal_type,
typename value_type>
491 template <
typename ordinal_type,
typename value_type>
506 b[k] =
std::sqrt((b[k]*g[k])/(c[k]*c[k-1]));
ScalarType * values() const
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
virtual void evaluateBases(const value_type &point, Teuchos::Array< value_type > &basis_pts) const
Evaluate each basis polynomial at given point point.
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeSparseTripleProductTensor(ordinal_type order) const
Compute triple product tensor.
virtual void getRecurrenceCoefficients(Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const
Return recurrence coefficients defined by above formula.
virtual const std::string & getName() const
Return string name of basis.
Implementation of OneDOrthogPolyBasis based on the general three-term recurrence relationship: for ...
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
virtual value_type evaluate(const value_type &point, ordinal_type order) const
Evaluate basis polynomial given by order order at given point point.
virtual ~RecurrenceBasis()
Destructor.
virtual ordinal_type pointGrowth(ordinal_type n) const
Evaluate point growth rule for Smolyak-type bases.
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)
GrowthPolicy
Enumerated type for determining Smolyak growth policies.
virtual Teuchos::RCP< Stokhos::Dense3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
void PTEQR(const char &COMPZ, const OrdinalType &n, MagnitudeType *D, MagnitudeType *E, ScalarType *Z, const OrdinalType &ldz, MagnitudeType *WORK, OrdinalType *info) const
void normalizeRecurrenceCoefficients(Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const
Normalize coefficients.
virtual void evaluateBasesAndDerivatives(const value_type &point, Teuchos::Array< value_type > &vals, Teuchos::Array< value_type > &derivs) const
Evaluate basis polynomials and their derivatives at given point point.
virtual ordinal_type quadDegreeOfExactness(ordinal_type n) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
KOKKOS_INLINE_FUNCTION PCE< Storage > ceil(const PCE< Storage > &a)
virtual Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > computeDerivDoubleProductTensor() const
Compute derivative double product tensor.
virtual ordinal_type order() const
Return order of basis (largest monomial degree ).
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
void resize(size_type new_size, const value_type &x=value_type())
virtual void print(std::ostream &os) const
Print basis to stream os.
virtual ordinal_type coefficientGrowth(ordinal_type n) const
Evaluate coefficient growth rule for Smolyak-type bases.
virtual void setup()
Setup basis after computing recurrence coefficients.
virtual ordinal_type size() const
Return total size of basis (given by order() + 1).
Data structure storing a dense 3-tensor C(i,j,k).
virtual const Teuchos::Array< value_type > & norm_squared() const
Return array storing norm-squared of each basis polynomial.
RecurrenceBasis(const std::string &name, ordinal_type p, bool normalize, GrowthPolicy growth=SLOW_GROWTH)
Constructor to be called by derived classes.
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)