CMP++: Uncertainty Quantification & Bayesian Calibration
Loading...
Searching...
No Matches
cmp::Quadrature1D< BasisType > Class Template Reference

One-dimensional quadrature rule generator and integrator. More...

#include <integrator.h>

Public Member Functions

 Quadrature1D (int numPoints)
 
double integrate (std::function< double(double)> f) const
 

Public Attributes

Eigen::VectorXd nodes
 Vector containing the quadrature node points.
 
Eigen::VectorXd weights
 Vector containing the corresponding quadrature weights.
 

Detailed Description

template<typename BasisType>
class cmp::Quadrature1D< BasisType >

One-dimensional quadrature rule generator and integrator.

Mathematical Formulation: A 1D quadrature rule approximates the integral of a function $f(x)$ over an interval $[a, b]$ with a weight function $w(x)$ as:

\[ \int_{a}^{b} w(x) f(x) \, dx \approx \sum_{i=0}^{N-1} w_i f(x_i) \]

where $x_i$ are the quadrature nodes (roots of the $N$-th order orthogonal polynomial associated with $w(x)$) and $w_i$ are the corresponding quadrature weights. Using the Golub-Welsch algorithm, the nodes $x_i$ and weights $w_i$ are computed from the symmetric tridiagonal Jacobi matrix $J$ for the orthogonal polynomial sequence:

\[ J = \begin{pmatrix} a_0 & b_1 & 0 & \cdots & 0 \\ b_1 & a_1 & b_2 & \cdots & 0 \\ 0 & b_2 & a_2 & \ddots & \vdots \\ \vdots & \vdots & \ddots & \ddots & b_{N-1} \\ 0 & 0 & \cdots & b_{N-1} & a_{N-1} \end{pmatrix} \]

The nodes $x_i$ are the eigenvalues of $J$. The weights $w_i$ are computed as:

\[ w_i = \mu_0 v_{i,0}^2 \]

where $v_{i,0}$ is the first component of the normalized $i$-th eigenvector of $J$, and $\mu_0 = \int_{a}^{b} w(x) \, dx$ is the total mass/zeroth moment of the weight function.

Implementation Algorithm:

  1. Checks if the requested number of points $N$ is less than 1 (throwing std::invalid_argument).
  2. If $N == 1$, sets node $x_0 = 0.0$ and weight $w_0 = 1.0$.
  3. Otherwise, requests the Jacobi matrix $J$ of size $N \times N$ from BasisType::getJacobiMatrix(numPoints).
  4. Computes the spectral decomposition of $J$ using Eigen::SelfAdjointEigenSolver.
  5. Assigns the resulting eigenvalues directly to nodes.
  6. Computes the weights weights(i) by squaring the first component of the $i$-th eigenvector (solver.eigenvectors()(0, i)).
  7. Provides integrate(f) which evaluates $\sum_i w_i f(x_i)$.

Constructor & Destructor Documentation

◆ Quadrature1D()

template<typename BasisType >
cmp::Quadrature1D< BasisType >::Quadrature1D ( int  numPoints)
inline

Member Function Documentation

◆ integrate()

template<typename BasisType >
double cmp::Quadrature1D< BasisType >::integrate ( std::function< double(double)>  f) const
inline

Member Data Documentation

◆ nodes

template<typename BasisType >
Eigen::VectorXd cmp::Quadrature1D< BasisType >::nodes

Vector containing the quadrature node points.

◆ weights

template<typename BasisType >
Eigen::VectorXd cmp::Quadrature1D< BasisType >::weights

Vector containing the corresponding quadrature weights.


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