pub struct Rule<T> { /* private fields */ }Expand description
Quadrature rule for numerical integration.
Represents an approximation of an integral by a weighted sum over discrete points.
The rule contains quadrature points x, weights w, and auxiliary arrays
x_forward and x_backward for efficient computation.
Implementations§
Source§impl<T> Rule<T>where
T: Copy,
impl<T> Rule<T>where
T: Copy,
Sourcepub fn x_backward(&self) -> &[T]
pub fn x_backward(&self) -> &[T]
Distance of each point from the right endpoint: b - x
Source§impl<T> Rule<T>where
T: CustomNumeric,
impl<T> Rule<T>where
T: CustomNumeric,
Sourcepub fn new(x: Vec<T>, w: Vec<T>, a: T, b: T) -> Result<Rule<T>, Error>
pub fn new(x: Vec<T>, w: Vec<T>, a: T, b: T) -> Result<Rule<T>, Error>
Create a new quadrature rule from points and weights.
§Arguments
x- Quadrature pointsw- Quadrature weightsa- Left endpoint (default: -1.0)b- Right endpoint (default: 1.0)
The points are not checked for order or for lying in [a, b];
Self::validate does that.
§Errors
Error::InvalidParameter if x and w have different lengths.
Sourcepub fn reseat(&self, a: T, b: T) -> Rule<T>
pub fn reseat(&self, a: T, b: T) -> Rule<T>
Reseat the rule to a new interval [a, b].
Scales and translates the quadrature points and weights to the new interval.
Sourcepub fn piecewise(&self, edges: &[T]) -> Result<Rule<T>, Error>
pub fn piecewise(&self, edges: &[T]) -> Result<Rule<T>, Error>
Create a piecewise rule over multiple segments.
§Arguments
edges- Segment boundaries: at least 2, finite and strictly increasing, with finite segment lengths and a finite sum of the ends of each segment (the midpoint of the segment is computed from it)
§Errors
Error::InvalidParameter if edges does not meet these conditions
Source§impl<T> Rule<T>where
T: CustomNumeric,
CustomNumeric-based implementation for f64 and Df64 support
impl<T> Rule<T>where
T: CustomNumeric,
CustomNumeric-based implementation for f64 and Df64 support
Sourcepub fn new_custom(x: Vec<T>, w: Vec<T>, a: T, b: T) -> Result<Rule<T>, Error>
pub fn new_custom(x: Vec<T>, w: Vec<T>, a: T, b: T) -> Result<Rule<T>, Error>
Create a new quadrature rule from points and weights (CustomNumeric version).
§Errors
Error::InvalidParameter if x and w have different lengths.
Sourcepub fn from_vectors_custom(
x: Vec<T>,
w: Vec<T>,
a: T,
b: T,
) -> Result<Rule<T>, Error>
pub fn from_vectors_custom( x: Vec<T>, w: Vec<T>, a: T, b: T, ) -> Result<Rule<T>, Error>
Create a new quadrature rule from vectors (CustomNumeric version).
§Errors
The errors of Self::new_custom.
Sourcepub fn reseat_custom(&self, a: T, b: T) -> Rule<T>
pub fn reseat_custom(&self, a: T, b: T) -> Rule<T>
Reseat the rule to a new interval [a, b] (CustomNumeric version).
Sourcepub fn scale_custom(&self, factor: T) -> Rule<T>
pub fn scale_custom(&self, factor: T) -> Rule<T>
Scale the weights by a factor (CustomNumeric version).
Sourcepub fn validate_custom(&self) -> bool
pub fn validate_custom(&self) -> bool
Validate the rule for consistency (CustomNumeric version).
Source§impl Rule<Compensated<f64, f64>>
Df64-specific implementation without ScalarOperand requirement
impl Rule<Compensated<f64, f64>>
Df64-specific implementation without ScalarOperand requirement
Sourcepub fn new_twofloat(
x: Vec<Compensated<f64, f64>>,
w: Vec<Compensated<f64, f64>>,
a: Compensated<f64, f64>,
b: Compensated<f64, f64>,
) -> Result<Rule<Compensated<f64, f64>>, Error>
pub fn new_twofloat( x: Vec<Compensated<f64, f64>>, w: Vec<Compensated<f64, f64>>, a: Compensated<f64, f64>, b: Compensated<f64, f64>, ) -> Result<Rule<Compensated<f64, f64>>, Error>
Create a new quadrature rule from points and weights (Df64 version).
§Errors
Error::InvalidParameter if x and w have different lengths.
Sourcepub fn from_vectors_twofloat(
x: Vec<Compensated<f64, f64>>,
w: Vec<Compensated<f64, f64>>,
a: Compensated<f64, f64>,
b: Compensated<f64, f64>,
) -> Result<Rule<Compensated<f64, f64>>, Error>
pub fn from_vectors_twofloat( x: Vec<Compensated<f64, f64>>, w: Vec<Compensated<f64, f64>>, a: Compensated<f64, f64>, b: Compensated<f64, f64>, ) -> Result<Rule<Compensated<f64, f64>>, Error>
Sourcepub fn reseat_twofloat(
&self,
a: Compensated<f64, f64>,
b: Compensated<f64, f64>,
) -> Rule<Compensated<f64, f64>>
pub fn reseat_twofloat( &self, a: Compensated<f64, f64>, b: Compensated<f64, f64>, ) -> Rule<Compensated<f64, f64>>
Reseat the rule to a new interval [a, b] (Df64 version).
Sourcepub fn scale_twofloat(
&self,
factor: Compensated<f64, f64>,
) -> Rule<Compensated<f64, f64>>
pub fn scale_twofloat( &self, factor: Compensated<f64, f64>, ) -> Rule<Compensated<f64, f64>>
Scale the weights by a factor (Df64 version).
Sourcepub fn validate_twofloat(&self) -> bool
pub fn validate_twofloat(&self) -> bool
Validate the rule for consistency (Df64 version).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Rule<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rule<T>where
T: RefUnwindSafe,
impl<T> Send for Rule<T>where
T: Send,
impl<T> Sync for Rule<T>where
T: Sync,
impl<T> Unpin for Rule<T>where
T: Unpin,
impl<T> UnsafeUnpin for Rule<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Rule<T>where
T: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
impl<T, U> Imply<T> for U
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 moreimpl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSendSync for T
impl<T> MaybeSync for Twhere
T: Sync,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.