Struct gauss_quad::hermite::GaussHermite
source · pub struct GaussHermite {
pub nodes: Vec<f64>,
pub weights: Vec<f64>,
}
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::init(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);
Fields§
§nodes: Vec<f64>
§weights: Vec<f64>
Implementations§
source§impl GaussHermite
impl GaussHermite
sourcepub fn init(deg: usize) -> GaussHermite
pub fn init(deg: usize) -> GaussHermite
Initializes Gauss-Hermite quadrature rule of the given degree by computing the needed nodes and weights.
sourcepub fn nodes_and_weights(deg: usize) -> (Vec<f64>, Vec<f64>)
pub fn nodes_and_weights(deg: usize) -> (Vec<f64>, Vec<f64>)
Apply Golub-Welsch algorithm to determine Gauss-Hermite nodes & weights construct 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
Trait Implementations§
source§impl Clone for GaussHermite
impl Clone for GaussHermite
source§fn clone(&self) -> GaussHermite
fn clone(&self) -> GaussHermite
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for GaussHermite
impl Debug for GaussHermite
source§impl PartialEq for GaussHermite
impl PartialEq for GaussHermite
source§fn eq(&self, other: &GaussHermite) -> bool
fn eq(&self, other: &GaussHermite) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for GaussHermite
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more
§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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.