rustmatrix.quadrature#

Gaussian quadrature points/weights for arbitrary weighting functions.

Direct port of pytmatrix.quadrature.quadrature — used by rustmatrix.orientation.orient_averaged_fixed() to build an integration rule for the orientation PDF in beta.

Pure Python on top of numpy/scipy; no Rust involvement.

rustmatrix.quadrature.discrete_gautschi(z, w, n_iter)[source]#

Discrete Gautschi / Stieltjes procedure.

Builds three-term recurrence coefficients (a, b) for the orthogonal polynomials with respect to the discrete inner product defined by abscissas z and weights w.

Parameters:
  • z (ndarray, shape (n,)) – Abscissas sampling the underlying interval.

  • w (ndarray, shape (n,)) – Weights at each abscissa (including the integration differential).

  • n_iter (int) – Number of recurrence levels to compute.

Returns:

  • a (ndarray, shape (n_iter,)) – Diagonal coefficients.

  • b (ndarray, shape (n_iter - 1,)) – Subdiagonal coefficients.

rustmatrix.quadrature.get_points_and_weights(w_func=None, left=-1.0, right=1.0, num_points=5, n=4096)[source]#

Quadrature points and weights for a custom weighting function.

Approximates \(\int_{left}^{right} f(x)\,w(x)\,dx \approx \sum_i w_i f(x_i)\) by building the orthogonal-polynomial recurrence for w from a dense midpoint sample, diagonalising the resulting tridiagonal Jacobi matrix, and reading off the points and weights.

Parameters:
  • w_func (callable, optional) – Weighting function w(x). Defaults to the constant 1 (i.e. ordinary Gauss-Legendre on [left, right]).

  • left (float) – Integration interval.

  • right (float) – Integration interval.

  • num_points (int) – Number of quadrature points to return.

  • n (int) – Resolution of the midpoint sample used to approximate w.

Returns:

points, weights – Quadrature nodes and their weights, sorted by node.

Return type:

ndarray, shape (num_points,)

Notes

Used by orientation.orient_averaged_fixed() to build a rule that integrates over the orientation PDF in β.