Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_LegendreBasisImp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 template <typename ordinal_type, typename value_type>
12 LegendreBasis(ordinal_type p, bool normalize, Stokhos::GrowthPolicy growth) :
13  RecurrenceBasis<ordinal_type, value_type>("Legendre", p, normalize, growth)
14 {
15  this->setup();
16 
17 #ifdef HAVE_STOKHOS_DAKOTA
18  this->setSparseGridGrowthRule(webbur::level_to_order_linear_wn);
19 #endif
20 }
21 
22 template <typename ordinal_type, typename value_type>
26 {
27  // Compute coefficients in 3-term recurrsion
28  computeRecurrenceCoefficients(p+1, this->alpha, this->beta, this->delta,
29  this->gamma);
30 
31  // Setup rest of recurrence basis
32  this->setup();
33 }
34 
35 template <typename ordinal_type, typename value_type>
38 {
39 }
40 
41 template <typename ordinal_type, typename value_type>
42 bool
48  Teuchos::Array<value_type>& theGamma) const
49 {
50  // Legendre 3 term recurrence:
51  // P_0(x) = 1
52  // P_1(x) = x
53  // P_i(x) = (2*i-1)/i*x*P_{i-1}(x) - (i-1)/i*P_{i-2}(x), i=2,3,...
54  theAlpha[0] = 0.0;
55  theBeta[0] = 1.0;
56  theDelta[0] = 1.0;
57  theGamma[0] = 1.0;
58  for (ordinal_type i=1; i<n; i++) {
59  theAlpha[i] = 0.0;
60  //theBeta[i] = value_type(i*i) / value_type((2*i-1)*(2*i+1));
61  theBeta[i] = value_type(i) / value_type(i+1);
62  theDelta[i] = value_type(2*i+1) / value_type(i+1);
63  theGamma[i] = 1.0;
64  }
65 
66  return false;
67 }
68 
69 template <typename ordinal_type, typename value_type>
73 {
74  return
76 }
Teuchos::Array< value_type > delta
Recurrence coefficients.
LegendreBasis(ordinal_type p, bool normalize=false, GrowthPolicy growth=SLOW_GROWTH)
Constructor.
Implementation of OneDOrthogPolyBasis based on the general three-term recurrence relationship: for ...
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.
Teuchos::Array< value_type > beta
Recurrence coefficients.
GrowthPolicy
Enumerated type for determining Smolyak growth policies.
Teuchos::Array< value_type > alpha
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Legendre polynomial basis.
virtual void setup()
Setup basis after computing recurrence coefficients.
Teuchos::Array< value_type > gamma
Recurrence coefficients.
virtual void setSparseGridGrowthRule(LevelToOrderFnPtr ptr)
Set sparse grid rule.