gauss_leg Interface
public interface gauss_leg
Generate tensor-product Gauss-Legendre points and weights.
Despite its name, degree is the number of quadrature points minus one.
Thus points integrate every univariate polynomial of
degree at most exactly in exact arithmetic.
Tensor products have this directional exactness separately in each
coordinate.
Original reference: C. F. Gauss, Methodus nova integralium valores per approximationem inveniendi, H. Dieterich, Gottingae, 1815. Digitized original.
Module Procedures
private pure subroutine gauss_legendre_1D(interval, degree, Xksi, Wksi)
Generate a one-dimensional Gauss-Legendre rule on an interval.
degree+1 nodes integrate polynomials through degree 2*degree+1 in
exact arithmetic. degree>=0 and size(interval)>=2 are unchecked shape
preconditions. The first two interval entries must also be finite. When
they are finite but not strictly increasing, allocated nodes and weights
are filled with NaNs.
Arguments
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in), | contiguous | :: | interval(:) |
Integration interval; the first two entries are used. |
|
| integer, | intent(in) | :: | degree |
Quadrature order minus one; must be nonnegative. |
||
| real(kind=rk), | intent(out), | allocatable | :: | Xksi(:) |
Allocated nodes and weights, each of length |
|
| real(kind=rk), | intent(out), | allocatable | :: | Wksi(:) |
Allocated nodes and weights, each of length |
private pure subroutine gauss_legendre_2D(interval1, interval2, degree, Xksi, Wksi)
Generate a tensor-product Gauss-Legendre rule on a rectangle.
Direction 1 varies fastest. Xksi has shape
[(degree(1)+1)*(degree(2)+1),2]; Wksi contains the corresponding
products of one-dimensional weights. degree must contain at least two
nonnegative entries, and both interval arrays must contain at least two
finite entries with increasing first pair; these preconditions are not
shape-validated by this wrapper.
Arguments
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in), | contiguous | :: | interval1(:) |
Strictly increasing direction-1 interval. |
|
| real(kind=rk), | intent(in), | contiguous | :: | interval2(:) |
Strictly increasing direction-2 interval. |
|
| integer, | intent(in), | contiguous | :: | degree(:) |
Quadrature orders minus one |
|
| real(kind=rk), | intent(out), | allocatable | :: | Xksi(:,:) |
Flattened parameter pairs and tensor-product weights. |
|
| real(kind=rk), | intent(out), | allocatable | :: | Wksi(:) |
Flattened parameter pairs and tensor-product weights. |
private pure subroutine gauss_legendre_3D(interval1, interval2, interval3, degree, Xksi, Wksi)
Generate a tensor-product Gauss-Legendre rule on a cuboid.
Direction 1 varies fastest, then direction 2. Xksi has three columns
and one row per tensor-product point; Wksi uses the same ordering.
degree must contain at least three nonnegative entries, and every
interval must contain at least two finite entries with increasing first
pair; these preconditions are not shape-validated by this wrapper.
Arguments
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in), | contiguous | :: | interval1(:) |
Strictly increasing direction-1 interval. |
|
| real(kind=rk), | intent(in), | contiguous | :: | interval2(:) |
Strictly increasing direction-2 interval. |
|
| real(kind=rk), | intent(in), | contiguous | :: | interval3(:) |
Strictly increasing direction-3 interval. |
|
| integer, | intent(in), | contiguous | :: | degree(:) |
Quadrature orders minus one |
|
| real(kind=rk), | intent(out), | allocatable | :: | Xksi(:,:) |
Flattened parameter triples and tensor-product weights. |
|
| real(kind=rk), | intent(out), | allocatable | :: | Wksi(:) |
Flattened parameter triples and tensor-product weights. |
private pure subroutine gauss_legendre_tensor(intervals, degree, Xksi, Wksi, ig)
Tensor Gauss rule in direction-1-fastest order, or just its one-based point ig. Column d holds the interval for axis d. An invalid selection returns an empty rule.
Arguments
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in), | contiguous | :: | intervals(:,:) | ||
| integer, | intent(in) | :: | degree(:) | |||
| real(kind=rk), | intent(out), | allocatable | :: | Xksi(:,:) | ||
| real(kind=rk), | intent(out), | allocatable | :: | Wksi(:) | ||
| integer, | intent(in), | optional | :: | ig |