BasisPolynomial Class Reference

Base class for the basis polynomial class hierarchy. More...

Inheritance diagram for BasisPolynomial:

LagrangeInterpPolynomial OrthogonalPolynomial GenLaguerreOrthogPolynomial HermiteOrthogPolynomial JacobiOrthogPolynomial LaguerreOrthogPolynomial LegendreOrthogPolynomial List of all members.

Public Member Functions

 BasisPolynomial ()
 default constructor
 BasisPolynomial (short poly_type)
 alternate constructor
 BasisPolynomial (const BasisPolynomial &polynomial)
 copy constructor
virtual ~BasisPolynomial ()
 destructor
BasisPolynomial operator= (const BasisPolynomial &polynomial)
 assignment operator
virtual const Real & get_value (const Real &x, unsigned short n)
 retrieve the basis polynomial value for a given parameter value
virtual const Real & get_gradient (const Real &x, unsigned short n)
 retrieve the basis polynomial gradient for a given parameter value
virtual const Real & norm_squared (unsigned short n)
 inner product <Poly_n, Poly_n> = ||Poly_n||^2
virtual const RealVectorgauss_points (unsigned short n)
 return the gaussPoints corresponding to orthogonal polynomial order n.
virtual const RealVectorgauss_weights (unsigned short n)
 return the gaussWeights corresponding to orthogonal polynomial order n.
virtual void reset_gauss ()
 destroy history of Gauss pts/wts (due to change in alpha/beta stats)
virtual void alpha_stat (const Real &alpha)
 set {Jacobi,GenLaguerre}OrthogPolynomial::alphaPoly from alpha_stat
virtual void beta_stat (const Real &beta)
 set JacobiOrthogPolynomial::betaPoly from beta_stat
virtual void interpolation_points (const RealVector &interpolation_pts)
 set LagrangeInterpPolynomial::interpolationPts
BasisPolynomialpolynomial_rep () const
 that are not mapped to the top BasisPolynomial level

Static Public Member Functions

static Real factorial (unsigned short n)
 compute n!
static Real factorial_ratio (unsigned short num, unsigned short den)
 compute num!/den!
static Real n_choose_k (unsigned short n, unsigned short k)
 compute n!/(k!(n-k)!)
static Real pochhammer (const Real &m, unsigned short n)
 compute the Pochhammer symbol (m)_n = m*(m+1)...*(m+n-1)

Protected Member Functions

 BasisPolynomial (BaseConstructor)
 derived class constructors - Coplien, p. 139)

Protected Attributes

Real basisPolyValue
 value of the 1-D basis polynomial; returned by get_value()
Real basisPolyGradient
 one parameter; returned by get_gradient()

Private Member Functions

BasisPolynomialget_polynomial (short poly_type)
 appropriate derived type.

Private Attributes

BasisPolynomialpolyRep
 pointer to the letter (initialized only for the envelope)
int referenceCount
 number of objects sharing polyRep

Detailed Description

Base class for the basis polynomial class hierarchy.

The BasisPolynomial class is the base class for the univariate basis polynomial class hierarchy in DAKOTA. One instance of an BasisPolynomial is created for each variable within a multidimensional polynomial basis function (a vector of BasisPolynomials is contained in BasisPolyApproximation, which may be mixed and matched in, e.g., the Wiener-Askey scheme for polynomial chaos). For memory efficiency and enhanced polymorphism, the basis polynomial hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (BasisPolynomial) serves as the envelope and one of the derived classes (selected in BasisPolynomial::get_polynomial()) serves as the letter.


Constructor & Destructor Documentation

BasisPolynomial (  ) 

default constructor

The default constructor is used in Array<BasisPolynomial> instantiations and by the alternate envelope constructor. polyRep is NULL in this case (problem_db is needed to build a meaningful instance). This makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.

BasisPolynomial ( short  poly_type  ) 

alternate constructor

Envelope constructor which does not require access to problem_db. This constructor executes get_polynomial(type), which invokes the default constructor of the derived letter class, which in turn invokes the BaseConstructor of the base class.

BasisPolynomial ( const BasisPolynomial polynomial  ) 

copy constructor

Copy constructor manages sharing of polyRep and incrementing of referenceCount.

~BasisPolynomial (  )  [virtual]

destructor

Destructor decrements referenceCount and only deletes polyRep when referenceCount reaches zero.

BasisPolynomial ( BaseConstructor   )  [protected]

derived class constructors - Coplien, p. 139)

This constructor is the one which must build the base class data for all derived classes. get_polynomial() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid recursion in the base class constructor calling get_polynomial() again). Since the letter IS the representation, its rep pointer is set to NULL (an uninitialized pointer causes problems in ~BasisPolynomial).


Member Function Documentation

BasisPolynomial operator= ( const BasisPolynomial polynomial  ) 

assignment operator

Assignment operator decrements referenceCount for old polyRep, assigns new polyRep, and increments referenceCount for new polyRep.

const Real & get_value ( const Real &  x,
unsigned short  n 
) [virtual]

retrieve the basis polynomial value for a given parameter value

For orthogonal polynomials, n specifies the order of the polynomial, whereas for interpolation polynomials, it identifies the interpolant for the n-th point.

Reimplemented in GenLaguerreOrthogPolynomial, HermiteOrthogPolynomial, JacobiOrthogPolynomial, LagrangeInterpPolynomial, LaguerreOrthogPolynomial, and LegendreOrthogPolynomial.

const Real & get_gradient ( const Real &  x,
unsigned short  n 
) [virtual]

retrieve the basis polynomial gradient for a given parameter value

For orthogonal polynomials, n specifies the order of the polynomial, whereas for interpolation polynomials, it identifies the interpolant for the n-th point.

Reimplemented in GenLaguerreOrthogPolynomial, HermiteOrthogPolynomial, JacobiOrthogPolynomial, LagrangeInterpPolynomial, LaguerreOrthogPolynomial, and LegendreOrthogPolynomial.

const Real & norm_squared ( unsigned short  n  )  [virtual]

inner product <Poly_n, Poly_n> = ||Poly_n||^2

This is defined only for orthogonal polynomials.

Reimplemented in GenLaguerreOrthogPolynomial, HermiteOrthogPolynomial, JacobiOrthogPolynomial, LaguerreOrthogPolynomial, and LegendreOrthogPolynomial.

const RealVector & gauss_points ( unsigned short  n  )  [virtual]

return the gaussPoints corresponding to orthogonal polynomial order n.

This is defined only for orthogonal polynomials.

Reimplemented in GenLaguerreOrthogPolynomial, HermiteOrthogPolynomial, JacobiOrthogPolynomial, LaguerreOrthogPolynomial, and LegendreOrthogPolynomial.

const RealVector & gauss_weights ( unsigned short  n  )  [virtual]

return the gaussWeights corresponding to orthogonal polynomial order n.

This is defined only for orthogonal polynomials.

Reimplemented in GenLaguerreOrthogPolynomial, HermiteOrthogPolynomial, JacobiOrthogPolynomial, LaguerreOrthogPolynomial, and LegendreOrthogPolynomial.

void reset_gauss (  )  [virtual]

destroy history of Gauss pts/wts (due to change in alpha/beta stats)

This is defined only for orthogonal polynomials.

Reimplemented in OrthogonalPolynomial.

void alpha_stat ( const Real &  alpha  )  [virtual]

set {Jacobi,GenLaguerre}OrthogPolynomial::alphaPoly from alpha_stat

This is defined only for parameterized orthogonal polynomials.

Reimplemented in GenLaguerreOrthogPolynomial, and JacobiOrthogPolynomial.

void beta_stat ( const Real &  beta  )  [virtual]

set JacobiOrthogPolynomial::betaPoly from beta_stat

This is defined only for parameterized orthogonal polynomials.

Reimplemented in JacobiOrthogPolynomial.

void interpolation_points ( const RealVector interpolation_pts  )  [virtual]

set LagrangeInterpPolynomial::interpolationPts

This is defined only for interpolation polynomials.

Reimplemented in LagrangeInterpPolynomial.

Real factorial ( unsigned short  n  )  [inline, static]

compute n!

This implementation is unprotected from overflow, but this should be fine for the polynomial orders that we would expect to encounter. Whenever possible, orthogonal polynomial implementations should use factorial_ratio() or n_choose_k() instead of factorial() to avoid size_t overflow.

Real factorial_ratio ( unsigned short  num,
unsigned short  den 
) [inline, static]

compute num!/den!

This implementation sequences products in order to minimize the chances of overflow, and its use should be preferred to factorial() whenever possible.

Real n_choose_k ( unsigned short  n,
unsigned short  k 
) [inline, static]

compute n!/(k!(n-k)!)

This implementation sequences products in order to minimize the chances of overflow, and its use should be preferred to factorial() whenever possible.

Real pochhammer ( const Real &  m,
unsigned short  n 
) [inline, static]

compute the Pochhammer symbol (m)_n = m*(m+1)...*(m+n-1)

This is the rising/upper factorial formulation of the Pochhammer symbol (m)_n.

BasisPolynomial * get_polynomial ( short  poly_type  )  [private]

appropriate derived type.

Used only by the envelope constructor to initialize polyRep to the appropriate derived type.


The documentation for this class was generated from the following files:
Generated on Wed Nov 5 19:54:06 2008 for DAKOTA by  doxygen 1.5.1