|
Mundy: Multibody Nonlocal Dynamics Version of the Day
|
Gauss-Legendre quadrature, with the number of points fixed at compile time or chosen at run time. More...
Classes | |
| class | mundy::GaussLegendre< Scalar, N > |
| The N-point Gauss-Legendre rule on [-1, 1], exact for polynomials of degree at most 2N - 1. More... | |
Namespaces | |
| namespace | mundy |
Functions | |
| template<class Scalar> | |
| void | mundy::gauss_legendre_rule (unsigned n, std::vector< Scalar > &nodes, std::vector< Scalar > &weights) |
| The n-point Gauss-Legendre rule on [-1, 1] for a run-time n, into std::vectors. | |
| template<class NodesView, class WeightsView> | |
| void | mundy::gauss_legendre_rule (unsigned n, NodesView &nodes, WeightsView &weights) |
| The n-point Gauss-Legendre rule on [-1, 1] for a run-time n, into rank-1 Kokkos views. | |
GaussLegendre<Scalar, N> follows boost::math::quadrature::gauss<Real, N>, with one difference: Boost hard-codes its tables for a few N, while here the compiler builds the table for whichever N is used. The resulting table is constexpr and usable on the host or device.
GaussLegendre uses compile-time work that grows like N^2. At the time of writing, GCC 13.3.0 compiles for N <= 204 whereas clang 18.1.8 compiles for N <= 62. Larger N need -fconstexpr-ops-limit (GCC) or -fconstexpr-steps (clang).
gauss_legendre_rule(n, nodes, weights) builds the same rule, bit for bit, for a run-time n. It has no limit on n and costs O(n^2) work at run time instead of compile time.