GaussLegendre2d: 2d quadrature transformation (1d histogram)

Description

Computes the sample points and weights needed to integrate 2d function into a 1d histogram. The histogram is binned along \(x\) axis while the \(y\) axis is integrated for a single interval. The integration is done in combination with GaussLegendre2dHist transformation.

Arguments

For a case of \(N\) bins.

  • Case A, using std::vector:

    1. edges — bin edges for \(x\) (N+1 doubles).

    2. orders — integration order for each \(x\) bin (N of size_t).

    3. ymin — lower limit for \(y\) (double).

    4. ymax — upper limit for \(y\) (double).

    5. yorder — integration order for \(y\) (size_t).

  • Case B, using double pointer:

    1. edges — bin edges for \(x\) (N+1 doubles).

    2. orders — integration order for each \(x\) bin (N of size_t).

    3. bins — number of bins (size_t).

    4. ymin — lower limit for \(y\) (double).

    5. ymax — upper limit for \(y\) (double).

    6. yorder — integration order for \(y\) (size_t).

  • Case C, using std::vector (same order):

    1. edges — bin edges for \(x\) (N+1 doubles).

    2. orders — integration order for all bins (size_t).

    3. bins — number of bins (size_t).

    4. ymin — lower limit for \(y\) (double).

    5. ymax — upper limit for \(y\) (double).

    6. yorder — integration order for \(y\) (size_t).

Outputs

  1. points.x — array of sample points \(x_i\).

  2. points.y — array of sample points \(y_i\).

  3. points.xedges — bin edges.

Implementation

According to Gauss-Legendre approximation the finite integral of order \(M (L)\) is approximated by:

\[H = \int\limits_{y_1}^{y_2}dy\int\limits_{a}^{b} f(x,y) dx \approx \sum_{k=1}^{L} \omega_k \sum_{j=1}^{M} \omega_j f(x_j, y_k).\]

In case of a histogram for each \(x\) bin \(i\) with limits \((x_i, x_{i+1})\) the integral is given by:

\[H_i = \int\limits_{y_1}^{y_2}dy\int\limits_{x_i}^{x_{i+1}} f(x, y) dx \approx \sum_{k=1}^{L} \omega_k \sum_{j_i=1}^{M_i} \omega_{ij} f(x_{ij}, y_k),\]

where \(M_i\) is integration order for each \(x\) bin \(i\) and \(L\) is integration order for \(y\).

For a given set of bin edges and orders the transformation computes sample points (output) and weights (internal). Given the array of all sample points \(x\) of size \(M\) and an array of \(y\) sample points of size \(L\) the function of interest should be computed on each \((x,y)\) pair with an output of shape \([M\times L]\). The resulting matrix should be passed to GaussLegendre2dHist instance.

For more information on Gauss-Legendre quadrature see https://en.wikipedia.org/wiki/Gaussian_quadrature.