pub struct GaussHermite { /* private fields */ }
Expand description
A Gauss-Hermite quadrature scheme.
These rules can integrate integrands of the form e^(-x^2) * f(x) over the domain (-∞, ∞).
§Example
Integrate e^(-x^2) * cos(x)
// initialize a Gauss-Hermite rule with 20 nodes
let quad = GaussHermite::new(20)?;
// numerically integrate a function over (-∞, ∞) using the Gauss-Hermite rule
let integral = quad.integrate(|x| x.cos());
assert_abs_diff_eq!(integral, PI.sqrt() / E.powf(0.25), epsilon = 1e-14);
Implementations§
Source§impl GaussHermite
impl GaussHermite
Sourcepub fn new(deg: usize) -> Result<Self, GaussHermiteError>
pub fn new(deg: usize) -> Result<Self, GaussHermiteError>
Initializes Gauss-Hermite quadrature rule of the given degree by computing the needed nodes and weights.
A rule of degree n can integrate polynomials of degree 2n-1 exactly.
Applies the Golub-Welsch algorithm to determine Gauss-Hermite nodes & weights. Constructs the companion matrix A for the Hermite Polynomial using the relation: 1/2 H_{n+1} + n H_{n-1} = x H_n A similar matrix that is symmetrized is constructed by D A D^{-1} Resulting in a symmetric tridiagonal matrix with 0 on the diagonal & sqrt(n/2) on the off-diagonal root & weight finding are equivalent to eigenvalue problem see Gil, Segura, Temme - Numerical Methods for Special Functions
§Errors
Returns an error if deg
is smaller than 2.
Source§impl GaussHermite
impl GaussHermite
Sourcepub fn nodes(&self) -> GaussHermiteNodes<'_> ⓘ
pub fn nodes(&self) -> GaussHermiteNodes<'_> ⓘ
Returns an iterator over the nodes of the quadrature rule.
Sourcepub fn weights(&self) -> GaussHermiteWeights<'_> ⓘ
pub fn weights(&self) -> GaussHermiteWeights<'_> ⓘ
Returns an iterator over the weights of the quadrature rule.
Sourcepub fn iter(&self) -> GaussHermiteIter<'_> ⓘ
pub fn iter(&self) -> GaussHermiteIter<'_> ⓘ
Returns an iterator over the node-weight pairs of the quadrature rule.
Sourcepub fn as_node_weight_pairs(&self) -> &[(Node, Weight)]
pub fn as_node_weight_pairs(&self) -> &[(Node, Weight)]
Returns a slice of all the node-weight pairs of the quadrature rule.
Sourcepub fn into_node_weight_pairs(self) -> Vec<(Node, Weight)>
pub fn into_node_weight_pairs(self) -> Vec<(Node, Weight)>
Converts the quadrature rule into a vector of node-weight pairs.
This function just returns the underlying vector without any computation or cloning.
Trait Implementations§
Source§impl Clone for GaussHermite
impl Clone for GaussHermite
Source§fn clone(&self) -> GaussHermite
fn clone(&self) -> GaussHermite
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GaussHermite
impl Debug for GaussHermite
Source§impl<'de> Deserialize<'de> for GaussHermite
impl<'de> Deserialize<'de> for GaussHermite
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> IntoIterator for &'a GaussHermite
impl<'a> IntoIterator for &'a GaussHermite
Source§impl IntoIterator for GaussHermite
impl IntoIterator for GaussHermite
Source§impl PartialEq for GaussHermite
impl PartialEq for GaussHermite
Source§impl Serialize for GaussHermite
impl Serialize for GaussHermite
impl StructuralPartialEq for GaussHermite
Auto Trait Implementations§
impl Freeze for GaussHermite
impl RefUnwindSafe for GaussHermite
impl Send for GaussHermite
impl Sync for GaussHermite
impl Unpin for GaussHermite
impl UnwindSafe for GaussHermite
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.