Skip to main content

QuadratureRule

Enum QuadratureRule 

Source
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.

VariantEvaluations per laneError orderExact for
Trapezoidpanels + 1O(h^2)linear integrands
Simpson2 * panels + 1O(h^4)cubics
GaussLegendrepanels * orderO(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.

Fields

§panels: usize

Number of equal subintervals, >= 1 (0 is treated as 1).

§

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.

Fields

§panels: usize

Number of two-subinterval Simpson panels, >= 1 (0 is treated as 1).

§

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: GaussOrder

Nodes per subinterval.

§panels: usize

Number of equal subintervals, >= 1 (0 is treated as 1).

Implementations§

Source§

impl QuadratureRule

Source

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
);
Source

pub const fn label(self) -> &'static str

A short human-readable label, for benchmark tables and log lines.

Trait Implementations§

Source§

impl Clone for QuadratureRule

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for QuadratureRule

Source§

impl Debug for QuadratureRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for QuadratureRule

Source§

impl Hash for QuadratureRule

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for QuadratureRule

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for QuadratureRule

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.