Class GaussQuadrature

Class Documentation

class GaussQuadrature

A class that performs Gauss quadrature on a given function.

This class facilitates the evaluation of numerical integrals using Gauss quadrature methods. It allows the user to specify the type of quadrature, the order, and the integration bounds.

Public Types

enum IntegrationType

Specifies different types of integration.

Values:

enumerator Legendre

Support: (a, b) — Weight: 1.

enumerator ChebyshevType1

Support: (a, b) — Weight: [(b − x)(x − a)]^(-1/2)

enumerator Gegenbauer

Support: (a, b) — Weight: [(b − x)(x − a)]^α

enumerator Jacobi

Support: (a, b) — Weight: (b − x)^α · (x − a)^β

enumerator GeneralizedLaguerre

Support: (a, ∞) — Weight: (x − a)^α · exp(−b(x − a))

enumerator GeneralizedHermite

Support: (−∞, ∞) — Weight: |x − a|^α · exp(−b(x − a)^2)

enumerator Exponential

Support: (a, b) — Weight: |x − (a + b)/2|^α

enumerator Rational

Support: (a, ∞) — Weight: (x − a)^α · (x + b)^β

enumerator ChebyshevType2

Support: (a, b) — Weight: [(b − x)(x − a)]^(+1/2)

Public Functions

GaussQuadrature(unsigned int order, IntegrationType kind, double a, double b, double alpha, double beta)

Constructs a GaussQuadrature object with specified parameters.

Parameters:
  • order – The order (number of quadrature points).

  • kind – The type of quadrature (e.g., Legendre, Chebyshev).

  • a – The lower bound of the integration.

  • b – The upper bound of the integration.

  • alpha – The alpha parameter (if applicable).

  • beta – The beta parameter (if applicable).

template<typename T, typename F>
inline void integrate(F &&f, T &out, double scaler = 1, double shift = 0)

Integrates a function using the Gauss quadrature method.

Parameters:
  • f – The function to be integrated.

  • out – The output value for the integration result.

  • scaler – An optional scaling factor for the integration.

  • shift – An optional shift value for the integration.

inline void get_abscissas_and_weights(unsigned int order, double *w, double *x)

Retrieves the abscissas and weights for the quadrature.

Parameters:
  • order – The number of quadrature points.

  • w – The array to store the weights.

  • x – The array to store the abscissas.

virtual ~GaussQuadrature()

Destructor for GaussQuadrature class.

Protected Attributes

unsigned int _order

The number of quadrature points (order).

int _kind

The type of quadrature to be used.

double *_w

The array of weights for the quadrature.

double *_x

The array of abscissas for the quadrature.

double _a

The lower bound of the integration.

double _b

The upper bound of the integration.

double _alpha

The alpha parameter for certain quadrature types.

double _beta

The beta parameter for certain quadrature types.