This package calculates integrations points and weights for numerical
quadrature (i.e. integrating a function) over an n-dimensional
simplex. It supports arbitrary (odd) degrees of accuracy, and supports
arbitrary floating-point types.
julia> using GrundmannMoeller
julia> # Obtain quadrature scheme (2 dimensions, degree 5; degree must be odd)
julia> scheme = grundmann_moeller(Float64, Val(2), 5);
julia> length(scheme.weights)
10
julia> # Apply scheme
julia> vertices = [[0,0], [1,0], [0,1]];
julia> f(x) = x[1]*x[2]
f (generic function with 1 method)
julia> q = integrate(f, scheme, vertices)
0.04166666666666668
julia> q ≈ 1/24
true grundmann_moeller(::Type{T}, ::Val{D}, degree::Int)T: desired floating point typeD: dimensiondegree: desired polynomial degree of accuracy (must be odd)
integrate(fun, scheme, vertices::AbstractVector)
integrate(fun, scheme, vertices::AbstractMatrix)fun: integrand, should accept anSVectoras argumentscheme: quadrature schemevertices: vertices of the simplex
The vertices need to be passed either as a vector-of-vectors or as a
matrix. In the first case, there need to be D+1 points with D
coordinates each. In the second case, the matrix needs to have size
D×D+1.
This package is a Julia translation of one of the algorithms of the
Python quadpy package by Nico
Schlömer.
The algorithm itself was published by
- A. Grundmann, H. M. Möller, "Invariant integration formulas for the
n-simplex by combinatorial methods", SIAM J. Numer. Anal. 15, 282-290 (1978), DOI 10.1137/0715019.
See SimplexQuad.jl for
a simplex quadrature package that uses a different algorithm.