C++ library

The source code of the quadraturerules C library can be downloaded from the latest release on GitHub. It can be built by running:

wget https://github.com/quadraturerules/quadraturerules/releases/download/0.7.3/quadraturerules-c-0.7.3.tar.gz
mkdir src
tar -xvf quadraturerules-c-0.7.3.tar.gz -C src
cd src
gcc -c -Wall -Werror -fpic quadraturerules.c
gcc -shared -o libquadraturerules.so quadraturerules.o

Once the library is build, you can run the tests by running:

cd src/test
gcc -L.. -Wall -o test test.c -lquadraturerules
./test

Usage

The library's function single_integral_quadrature can be used to write the points and weights of quadrature rules for a single integral into memory. The functions single_integral_quadrature_points_size and single_integral_quadrature_weights_size can be used to compute how large the arrays of doubles for the points and weights need to be. For example the following snippet will create an order 3 Xiao–Gimbutas rule on a triangle:

#include "quadraturerules.h"

int pts_size = single_integral_quadrature_points_size(QR_GaussLegendre, QR_Interval, 3);
int wts_size = single_integral_quadrature_weights_size(QR_GaussLegendre, QR_Interval, 3);

double pts[pts_size];
double wts[wts_size];

single_integral_quadrature(QR_XiaoGimbutas, QR_Triangle, 3, pts, wts);

Note that the points returned by the library are represented using barycentric coordinates.