16 releases (6 breaking)
0.7.3 | Jan 22, 2025 |
---|---|
0.7.2 | Jan 22, 2025 |
0.6.0 | Jan 16, 2025 |
0.5.0 | Jan 16, 2025 |
0.0.3 | Jan 14, 2025 |
#128 in Math
560 downloads per month
14MB
333K
SLoC
Quadrature rules
The online encylopedia of quadrature rules is a reference website that lists a number of quadrature rules.
Quadrature rules are sets of points and weights that are used to approximate integrals. If ${p_0,\dots,p_{n-1}}\subset\mathbb{R}^d$ and ${w_0,\dots,w_{n-1}}\subset\mathbb{R}$ are the points and weights (repectively) of the quadrature rule for a single integral, then:
$$\int f(x),\mathrm{d}x \approx \sum_{i=0}^{n-1}f(p_i)w_i$$
Libraries
All of the quadrature rules included in the online encylopedia of quadrature rules are included in the quadraturerules library, which is available in the following languages:
C++ library
The source code of the quadraturerules C++ library can be downloaded from the latest release on GitHub. It can be installed by running:
wget https://github.com/quadraturerules/quadraturerules/releases/download/{{VERSION}}/quadraturerules-cpp-{{VERSION}}.tar.gz
mkdir src
tar -xvf quadraturerules-cpp-{{VERSION}}.tar.gz -C src
mkdir build
cd build
cmake ../src
make
make install
Once the library is installed, you can run the tests by running:
python src/test/run_tests.py
Or you can run individual tests:
cd src/test/{TEST_NAME}
cmake .
make .
./{TEST_NAME}
Usage
The library's function single_integral_quadrature
can be used to get the points and weights
of quadrature rules for a single integral. For example the following snippet will create an
order 3 Xiao--Gimbutas rule on a triangle:
#include <quadraturerules.h>
using quadraturerules;
auto [points, weights] = single_integral_quadrature(
QuadratureRule::XiaoGimbutas,
Domain::Triangle,
3,
);
Note that the points returned by the library are represented using barycentric coordinates.