pub enum QuadratureRule {
Trapezoid {
panels: usize,
},
Simpson {
panels: usize,
},
GaussLegendre {
order: GaussOrder,
panels: usize,
},
}Expand description
Which fixed rule quadrature_batch applies to every lane.
All three are composite rules over equal subintervals of each lane’s own interval, and all three cost a fixed, data-independent number of integrand evaluations per lane — which is what makes them branch-free, and the only part of this module that would map cleanly onto a GPU.
A panels count of 0 is treated as 1; there is no error path for it,
because it is a compile-time-shaped parameter rather than data.
| Variant | Evaluations per lane | Error order | Exact for |
|---|---|---|---|
Trapezoid | panels + 1 | O(h^2) | linear integrands |
Simpson | 2 * panels + 1 | O(h^4) | cubics |
GaussLegendre | panels * order | O(h^(2n)) | degree 2n - 1 |
§Relationship to the workspace’s other Simpson
outram-park-fork-dwsim-libs’s simpson_integrate is a faithful port of
OPEM’s rule including its documented flaw: it applies the 1, 4, 2, ..., 4, 1 weights without requiring an odd sample count, which silently degrades the
order to O(h) for an even one. Simpson here counts
panels of two subintervals each, so the sample count is odd by
construction and that failure cannot occur. The composite-over-equal-
subintervals convention is shared; the sample-slice interface and the bug are
not.
§Units
Dimensionless — a mode selector plus a count.
Variants§
Trapezoid
Composite trapezoid over panels equal subintervals.
The cheapest rule and the only one worth using when the integrand is sampled rather than smooth. Second-order accurate.
Simpson
Composite Simpson over panels panels, each spanning two equal
subintervals, so 2 * panels subintervals in total.
Fourth-order accurate and exact for cubics. Counting panels rather than samples is what makes the even-sample-count error impossible.
GaussLegendre
Composite Gauss-Legendre: panels equal subintervals, each integrated by
an order-point rule.
The best accuracy per evaluation for a smooth integrand, and the rule to
reach for by default. Gauss rules never evaluate the interval endpoints,
so an integrand that is unbounded but integrable at a or b is handled
without special-casing — the same property raffles relies on for
quantile-function moments.
Fields
order: GaussOrderNodes per subinterval.
Implementations§
Source§impl QuadratureRule
impl QuadratureRule
Sourcepub const fn evaluations(self) -> usize
pub const fn evaluations(self) -> usize
Integrand evaluations this rule performs per lane, dimensionless.
Fixed and data-independent — that is the defining property of this enum.
§Example
use outram_foam_basic_lib::ode::parallel::{GaussOrder, QuadratureRule};
assert_eq!(QuadratureRule::Trapezoid { panels: 4 }.evaluations(), 5);
assert_eq!(QuadratureRule::Simpson { panels: 4 }.evaluations(), 9);
assert_eq!(
QuadratureRule::GaussLegendre { order: GaussOrder::G5, panels: 4 }.evaluations(),
20
);