UQTk: Uncertainty Quantification Toolkit 3.1.5
Quad Class Reference

Generates quadrature rules. More...

#include <quad.h>

Classes

struct  QuadRule
 Rule structure that stores quadrature points, weights and indices. More...
 

Public Member Functions

 Quad (char *grid_type, char *fs_type, int ndim, int param, double alpha=0.0, double betta=1.0)
 Constructor: initializes the rule type, sparseness type, dimensionality, level or ppd parameter, and two optional parameters for quadrature rule.
 
 Quad (Array1D< string > &grid_types, char *fs_type, Array1D< int > &param, Array1D< double > &alphas, Array1D< double > &bettas)
 Constructor, overloaded for dimension-unisotropy: initializes the dimension-specific rule types, sparseness type, dimension-specific ppd or level, and two optional parameters for quadrature rule per each dimension.
 
 Quad ()
 Constructor: empty.
 
 ~Quad ()
 Destructor.
 
void init ()
 Initialization function.
 
void SetAlpha (double alpha)
 Set the parameter alpha.
 
void SetBeta (double betta)
 Set the parameter beta.
 
void SetDomain (Array1D< double > &aa, Array1D< double > &bb)
 Set the domain endpoints (for compact support domains)
 
void SetDomain (Array1D< double > &aa)
 Set the domain endpoint (for semi-infinite domains)
 
void GetDomain (Array1D< double > &aa, Array1D< double > &bb) const
 Get the domain endpoints (for compact support domains)
 
void GetDomain (Array1D< double > &aa) const
 Get the domain endpoint (for semi-infinite domains)
 
void SetRule (Array2D< double > &q, Array1D< double > &w)
 Set the rule externally (only quadrature points and weights)
 
void SetRule (Array2D< double > &q, Array1D< double > &w, Array2D< int > &ind)
 Set the rule externally (quadrature points, weights and indices) Dummy function for backward compatibility.
 
void SetRule ()
 Set the rule externally (quadrature points, weights, indices, and the level)
 
void GetRule (Array2D< double > &q, Array1D< double > &w)
 Get the quadrature rule.
 
void GetRule (Array2D< double > &q, Array1D< double > &w, Array2D< int > &ind)
 Get the quadrature rule with indexing Dummy function for backward compatibility.
 
void SetQdpts (Array2D< double > &q)
 Externally set quadrature points.
 
void SetWghts (Array1D< double > &w)
 Externally set the weights.
 
void GetQdpts (Array2D< double > &q)
 Externally set the indices.
 
void GetWghts (Array1D< double > &w)
 Get the weights.
 
void SetLevel (int param)
 Get the indices.
 
void nextLevel ()
 Compute the indices of the next-level points.
 
int GetNQ ()
 Get the number of quadrature points.
 
void SetVerbosity (int verbosity)
 Set the verbosity level.
 

Private Member Functions

 Quad (const Quad &)
 Dummy copy constructor, which should not be used as it is currently not well defined.
 
void MultiplyTwoRules (QuadRule *rule1, QuadRule *rule2, QuadRule *rule_prod)
 Multiply two rules (full tensor product)
 
void MultiplyManyRules (int nrules, QuadRule *rules, QuadRule *rule_prod)
 Multiply many rules (full tensor product)
 
void MultiplyManyRules_ (int nrules, QuadRule *rules, QuadRule *rule_prod)
 
void AddTwoRules (QuadRule *rule1, QuadRule *rule2, QuadRule *rule_sum)
 Add two rules.
 
void SubtractTwoRules (QuadRule *rule1, QuadRule *rule2, QuadRule *rule_sum)
 Subtract two rules.
 
void create1DRule (string gridtype, Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Compute 1D rules.
 
void create1DRule_CC (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Clenshaw-Curtis (includes the endpoints)
 
void create1DRule_LU (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Legendre-Uniform.
 
void create1DRule_HG (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr)
 Gauss-Hermite.
 
void create1DRule_NC (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Newton-Cotes (i.e. equispaced, includes the endpoints)
 
void create1DRule_NCO (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Newton-Cotes open (i.e. excludes the endpoints)
 
void create1DRule_CCO (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Clenshaw-Curtis open (i.e. excludes the endpoints)
 
void create1DRule_JB (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Jacobi-Beta.
 
void create1DRule_LG (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr)
 Gamma-Laguerre.
 
void create1DRule_SW (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr)
 Stieltjes-Wigert.
 
void create1DRule_pdf (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Custom rule given the recursive coefficients of the corresponding orthogonal polynomials.
 
void create1DRule_GP3 (Array1D< double > &qdpts, Array1D< double > &wghts, int ngr, double a, double b)
 Gauss-Patterson starting with Legendre-Uniform 3.
 
void getMultiIndexLevel (Array2D< int > &multiIndexLevel, int level, int ndim)
 Auxilliary function: get the level of the multi-index.
 
void compressRule (QuadRule *rule)
 Compress the rule, i.e. merge repeating points.
 

Private Attributes

Array1D< double > aa_
 The left endpoints of the domain.
 
Array1D< double > bb_
 the right endpoints of the domain
 
int quadverbose_
 Verbosity level.
 
double alpha_
 The first parameter of the rule, if any.
 
double beta_
 The second parameter of the rule, if any.
 
Array1D< double > alphas_
 The first parameter of the rule, if any.
 
Array1D< double > betas_
 The second parameter of the rule, if any.
 
QuadRule rule_
 The quadrature rule structure.
 
int ndim_
 The dimensionality.
 
int nlevel_
 The current level, working variable for hierarchical construction.
 
int maxlevel_
 The level for sparse rules, or the number of grid points per dim for full product rules.
 
Array1D< int > param_
 
Array2D< int > npts_all
 Working arrays.
 
Array2D< int > npts_1_all
 
Array2D< QuadRuleqr_all
 
Array2D< QuadRuleqr_1_all
 
int growth_rule_
 Growth rule: exponential(0) or linear(1)
 
Array1D< int > growth_rules_
 Growth rules: exponential(0) or linear(1)
 
string grid_type_
 Grid type: 'CC','CCO','NC','NCO','LU', 'HG', 'JB', 'LG', 'SW', 'pdf', or 'GP3'.
 
Array1D< string > grid_types_
 Vector of grid types: 'CC','CCO','NC','NCO','LU', 'HG', 'JB', 'LG', 'SW', 'pdf', or 'GP3'.
 
string fs_type_
 Sparseness type (full or sparse)
 

Detailed Description

Generates quadrature rules.

Note
Besides quadrature rules corresponding to PC bases (i.e. LU, HG, LG, SW, JB), Clenshaw-Curtis(CC) and Newton-Cotes(NC) as well as their Open (with no endpoints) versions (CCO, NCO) are implemented. Also, Gauss-Patterson (GP3) and custom (pdf) rules are added.

Constructor & Destructor Documentation

◆ Quad() [1/4]

Quad::Quad ( char * grid_type,
char * fs_type,
int ndim,
int param,
double alpha = 0.0,
double betta = 1.0 )

Constructor: initializes the rule type, sparseness type, dimensionality, level or ppd parameter, and two optional parameters for quadrature rule.

Note
Options for the arguments are: grid_type : LU, HG, LG, SW, JB, CC, CCO, NC, NCO, GP3, pdf fs_type : full, sparse ndim : integer dimensionality param : integer points-per-dimension (if full), or level (if sparse) alpha : parameter #1 for the corresponding PC type (e.g. LG requires one parameter) betta : parameter #2 for the corresponding PC type (e.g. JB requires two parameters)

◆ Quad() [2/4]

Quad::Quad ( Array1D< string > & grid_types,
char * fs_type,
Array1D< int > & param,
Array1D< double > & alphas,
Array1D< double > & bettas )

Constructor, overloaded for dimension-unisotropy: initializes the dimension-specific rule types, sparseness type, dimension-specific ppd or level, and two optional parameters for quadrature rule per each dimension.

Note
Options for the arguments are: grid_types : array with entry options LU, HG, LG, SW, JB, CC, CCO, NC, NCO, GP3, pdf fs_type : full, sparse param : integer array for points-per-dimension (if full), or an array with first element indicating the level (if sparse) alpha : array of parameters #1 for the corresponding PC type (e.g. LG requires one parameter) bettas : array of parameters #2 for the corresponding PC type (e.g. JB requires two parameters)

◆ Quad() [3/4]

Quad::Quad ( )
inline

Constructor: empty.

◆ ~Quad()

Quad::~Quad ( )
inline

Destructor.

◆ Quad() [4/4]

Quad::Quad ( const Quad & )
inlineprivate

Dummy copy constructor, which should not be used as it is currently not well defined.

Member Function Documentation

◆ AddTwoRules()

void Quad::AddTwoRules ( QuadRule * rule1,
QuadRule * rule2,
QuadRule * rule_sum )
private

Add two rules.

◆ compressRule()

void Quad::compressRule ( QuadRule * rule)
private

Compress the rule, i.e. merge repeating points.

◆ create1DRule()

void Quad::create1DRule ( string gridtype,
Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Compute 1D rules.

◆ create1DRule_CC()

void Quad::create1DRule_CC ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Clenshaw-Curtis (includes the endpoints)

Note
Heavily adopted from http://people.sc.fsu.edu/~jburkardt/cpp_src/sparse_grid_cc/sparse_grid_cc.html (distributed under LGPL)

◆ create1DRule_CCO()

void Quad::create1DRule_CCO ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Clenshaw-Curtis open (i.e. excludes the endpoints)

Note
Heavily adopted from http://people.sc.fsu.edu/~jburkardt/cpp_src/sparse_grid_cc/sparse_grid_cc.html (distributed under LGPL)

◆ create1DRule_GP3()

void Quad::create1DRule_GP3 ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Gauss-Patterson starting with Legendre-Uniform 3.

Note
Hardwired reading of quadrature points and weights

◆ create1DRule_HG()

void Quad::create1DRule_HG ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr )
private

Gauss-Hermite.

◆ create1DRule_JB()

void Quad::create1DRule_JB ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Jacobi-Beta.

◆ create1DRule_LG()

void Quad::create1DRule_LG ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr )
private

Gamma-Laguerre.

◆ create1DRule_LU()

void Quad::create1DRule_LU ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Legendre-Uniform.

◆ create1DRule_NC()

void Quad::create1DRule_NC ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Newton-Cotes (i.e. equispaced, includes the endpoints)

◆ create1DRule_NCO()

void Quad::create1DRule_NCO ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Newton-Cotes open (i.e. excludes the endpoints)

◆ create1DRule_pdf()

void Quad::create1DRule_pdf ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr,
double a,
double b )
private

Custom rule given the recursive coefficients of the corresponding orthogonal polynomials.

Todo
Recursive coefficients are given in a file 'ab.dat'; will need to make this more friendly

◆ create1DRule_SW()

void Quad::create1DRule_SW ( Array1D< double > & qdpts,
Array1D< double > & wghts,
int ngr )
private

Stieltjes-Wigert.

◆ GetDomain() [1/2]

void Quad::GetDomain ( Array1D< double > & aa) const
inline

Get the domain endpoint (for semi-infinite domains)

◆ GetDomain() [2/2]

void Quad::GetDomain ( Array1D< double > & aa,
Array1D< double > & bb ) const
inline

Get the domain endpoints (for compact support domains)

◆ getMultiIndexLevel()

void Quad::getMultiIndexLevel ( Array2D< int > & multiIndexLevel,
int level,
int ndim )
private

Auxilliary function: get the level of the multi-index.

◆ GetNQ()

int Quad::GetNQ ( )
inline

Get the number of quadrature points.

◆ GetQdpts()

void Quad::GetQdpts ( Array2D< double > & q)
inline

Externally set the indices.

Get quadrature points

◆ GetRule() [1/2]

void Quad::GetRule ( Array2D< double > & q,
Array1D< double > & w )

Get the quadrature rule.

◆ GetRule() [2/2]

void Quad::GetRule ( Array2D< double > & q,
Array1D< double > & w,
Array2D< int > & ind )
inline

Get the quadrature rule with indexing Dummy function for backward compatibility.

◆ GetWghts()

void Quad::GetWghts ( Array1D< double > & w)
inline

Get the weights.

◆ init()

void Quad::init ( )

Initialization function.

◆ MultiplyManyRules()

void Quad::MultiplyManyRules ( int nrules,
QuadRule * rules,
QuadRule * rule_prod )
private

Multiply many rules (full tensor product)

◆ MultiplyManyRules_()

void Quad::MultiplyManyRules_ ( int nrules,
QuadRule * rules,
QuadRule * rule_prod )
private

◆ MultiplyTwoRules()

void Quad::MultiplyTwoRules ( QuadRule * rule1,
QuadRule * rule2,
QuadRule * rule_prod )
private

Multiply two rules (full tensor product)

◆ nextLevel()

void Quad::nextLevel ( )

Compute the indices of the next-level points.

◆ SetAlpha()

void Quad::SetAlpha ( double alpha)
inline

Set the parameter alpha.

◆ SetBeta()

void Quad::SetBeta ( double betta)
inline

Set the parameter beta.

◆ SetDomain() [1/2]

void Quad::SetDomain ( Array1D< double > & aa)

Set the domain endpoint (for semi-infinite domains)

◆ SetDomain() [2/2]

void Quad::SetDomain ( Array1D< double > & aa,
Array1D< double > & bb )

Set the domain endpoints (for compact support domains)

◆ SetLevel()

void Quad::SetLevel ( int param)
inline

Get the indices.

Set the level parameter

◆ SetQdpts()

void Quad::SetQdpts ( Array2D< double > & q)
inline

Externally set quadrature points.

◆ SetRule() [1/3]

void Quad::SetRule ( )

Set the rule externally (quadrature points, weights, indices, and the level)

Set the rule (the function that builds quadrature points/weights/indices)

◆ SetRule() [2/3]

void Quad::SetRule ( Array2D< double > & q,
Array1D< double > & w )

Set the rule externally (only quadrature points and weights)

◆ SetRule() [3/3]

void Quad::SetRule ( Array2D< double > & q,
Array1D< double > & w,
Array2D< int > & ind )
inline

Set the rule externally (quadrature points, weights and indices) Dummy function for backward compatibility.

◆ SetVerbosity()

void Quad::SetVerbosity ( int verbosity)
inline

Set the verbosity level.

Note
Currently, the values of 0, 1 and 2 are implemented

◆ SetWghts()

void Quad::SetWghts ( Array1D< double > & w)
inline

Externally set the weights.

◆ SubtractTwoRules()

void Quad::SubtractTwoRules ( QuadRule * rule1,
QuadRule * rule2,
QuadRule * rule_sum )
private

Subtract two rules.

Member Data Documentation

◆ aa_

Array1D<double> Quad::aa_
private

The left endpoints of the domain.

◆ alpha_

double Quad::alpha_
private

The first parameter of the rule, if any.

◆ alphas_

Array1D<double> Quad::alphas_
private

The first parameter of the rule, if any.

◆ bb_

Array1D<double> Quad::bb_
private

the right endpoints of the domain

◆ beta_

double Quad::beta_
private

The second parameter of the rule, if any.

◆ betas_

Array1D<double> Quad::betas_
private

The second parameter of the rule, if any.

◆ fs_type_

string Quad::fs_type_
private

Sparseness type (full or sparse)

◆ grid_type_

string Quad::grid_type_
private

Grid type: 'CC','CCO','NC','NCO','LU', 'HG', 'JB', 'LG', 'SW', 'pdf', or 'GP3'.

◆ grid_types_

Array1D<string> Quad::grid_types_
private

Vector of grid types: 'CC','CCO','NC','NCO','LU', 'HG', 'JB', 'LG', 'SW', 'pdf', or 'GP3'.

◆ growth_rule_

int Quad::growth_rule_
private

Growth rule: exponential(0) or linear(1)

◆ growth_rules_

Array1D<int> Quad::growth_rules_
private

Growth rules: exponential(0) or linear(1)

◆ maxlevel_

int Quad::maxlevel_
private

The level for sparse rules, or the number of grid points per dim for full product rules.

◆ ndim_

int Quad::ndim_
private

The dimensionality.

◆ nlevel_

int Quad::nlevel_
private

The current level, working variable for hierarchical construction.

◆ npts_1_all

Array2D<int> Quad::npts_1_all
private

◆ npts_all

Array2D<int> Quad::npts_all
private

Working arrays.

◆ param_

Array1D<int> Quad::param_
private

◆ qr_1_all

Array2D<QuadRule> Quad::qr_1_all
private

◆ qr_all

Array2D<QuadRule> Quad::qr_all
private

◆ quadverbose_

int Quad::quadverbose_
private

Verbosity level.

Note
Currently the values of 0, 1 or 2 are implemented.

◆ rule_

QuadRule Quad::rule_
private

The quadrature rule structure.


The documentation for this class was generated from the following files: