pub struct QuadratureRule<F> {
pub nodes: Vec<F>,
pub weights: Vec<F>,
}Expand description
A precomputed quadrature rule on the reference interval [-1, 1].
Stores nodes and weights that can be reused across many integrations. Rule construction allocates; integration with a precomputed rule does not.
Fields§
§nodes: Vec<F>Quadrature nodes on [-1, 1].
weights: Vec<F>Corresponding quadrature weights.
Implementations§
Source§impl<F: Float> QuadratureRule<F>
impl<F: Float> QuadratureRule<F>
Sourcepub fn integrate<G>(&self, a: F, b: F, f: G) -> Fwhere
G: Fn(F) -> F,
pub fn integrate<G>(&self, a: F, b: F, f: G) -> Fwhere
G: Fn(F) -> F,
Integrate f over [a, b] using this rule.
Applies an affine transform from [-1, 1] to [a, b]: x = (b - a) / 2 * t + (a + b) / 2
The result is scaled by (b - a) / 2.
§Panics
Panics if the conversion of 2.0 to F via F::from fails, which
should not occur for standard floating-point types.
Sourcepub fn integrate_composite<G>(&self, a: F, b: F, n_panels: usize, f: G) -> Fwhere
G: Fn(F) -> F,
pub fn integrate_composite<G>(&self, a: F, b: F, n_panels: usize, f: G) -> Fwhere
G: Fn(F) -> F,
Integrate f over [a, b] using a composite rule with n_panels equal subintervals.
Each panel applies this quadrature rule independently, then sums the results.
Total function evaluations = self.order() * n_panels.
§Panics
Panics if n_panels or the panel indices cannot be converted to F
via F::from, which should not occur for standard floating-point types
with reasonable panel counts.
Sourcepub fn integrate_composite_par<G>(&self, a: F, b: F, n_panels: usize, f: G) -> F
pub fn integrate_composite_par<G>(&self, a: F, b: F, n_panels: usize, f: G) -> F
Parallel composite integration over [a, b] with n_panels subintervals.
Identical to integrate_composite but evaluates
panels in parallel using rayon. Requires F: Send + Sync and f: Fn(F) -> F + Sync.
§Panics
Panics if n_panels or the panel indices cannot be converted to F
via F::from, which should not occur for standard floating-point types
with reasonable panel counts.
Trait Implementations§
Source§impl<F: Clone> Clone for QuadratureRule<F>
impl<F: Clone> Clone for QuadratureRule<F>
Source§fn clone(&self) -> QuadratureRule<F>
fn clone(&self) -> QuadratureRule<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<F> Freeze for QuadratureRule<F>
impl<F> RefUnwindSafe for QuadratureRule<F>where
F: RefUnwindSafe,
impl<F> Send for QuadratureRule<F>where
F: Send,
impl<F> Sync for QuadratureRule<F>where
F: Sync,
impl<F> Unpin for QuadratureRule<F>where
F: Unpin,
impl<F> UnsafeUnpin for QuadratureRule<F>
impl<F> UnwindSafe for QuadratureRule<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more