pub struct GaussJacobi { /* private fields */ }
Expand description
A Gauss-Jacobi quadrature scheme.
This rule can integrate expressions of the form (1 - x)^alpha * (1 + x)^beta * f(x), where f(x) is a smooth function on a finite domain, alpha > -1 and beta > -1, and where f(x) is transformed from the domain [a, b] to the domain [-1, 1]. This enables the approximation of integrals with singularities at the end points of the domain.
§Examples
// initialize the quadrature rule.
let quad = GaussJacobi::new(10, -0.5, 0.0)?;
let integral = quad.integrate(0.0, 2.0, |x| (-x).exp());
assert_abs_diff_eq!(integral, 0.9050798148074449, epsilon = 1e-14);
Implementations§
Source§impl GaussJacobi
impl GaussJacobi
Sourcepub fn new(deg: usize, alpha: f64, beta: f64) -> Result<Self, GaussJacobiError>
pub fn new(deg: usize, alpha: f64, beta: f64) -> Result<Self, GaussJacobiError>
Initializes Gauss-Jacobi quadrature rule of the given degree by computing the nodes and weights
needed for the given parameters. alpha
is the exponent of the (1 - x) factor and beta
is the
exponent of the (1 + x) factor.
A rule of degree n can integrate polynomials of degree 2n-1 exactly.
Applies the Golub-Welsch algorithm to determine Gauss-Jacobi nodes & weights. See Gil, Segura, Temme - Numerical Methods for Special Functions
§Errors
Returns an error if deg
is smaller than 2, and/or if alpha
and/or beta
are smaller than or equal to -1.
Sourcepub fn integrate<F>(&self, a: f64, b: f64, integrand: F) -> f64
pub fn integrate<F>(&self, a: f64, b: f64, integrand: F) -> f64
Perform quadrature of integrand from a
to b
. This will integrate
(1 - x)^alpha
* (1 + x)^beta
* integrand
(x)
where alpha
and beta
were given in the call to new
, and the integrand is transformed from the domain [a, b] to the domain [-1, 1].
Source§impl GaussJacobi
impl GaussJacobi
Sourcepub fn nodes(&self) -> GaussJacobiNodes<'_> ⓘ
pub fn nodes(&self) -> GaussJacobiNodes<'_> ⓘ
Returns an iterator over the nodes of the quadrature rule.
Sourcepub fn weights(&self) -> GaussJacobiWeights<'_> ⓘ
pub fn weights(&self) -> GaussJacobiWeights<'_> ⓘ
Returns an iterator over the weights of the quadrature rule.
Sourcepub fn iter(&self) -> GaussJacobiIter<'_> ⓘ
pub fn iter(&self) -> GaussJacobiIter<'_> ⓘ
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 GaussJacobi
impl Clone for GaussJacobi
Source§fn clone(&self) -> GaussJacobi
fn clone(&self) -> GaussJacobi
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GaussJacobi
impl Debug for GaussJacobi
Source§impl<'de> Deserialize<'de> for GaussJacobi
impl<'de> Deserialize<'de> for GaussJacobi
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 From<GaussChebyshevFirstKind> for GaussJacobi
Gauss-Chebyshev quadrature of the first kind is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= -0.5.
impl From<GaussChebyshevFirstKind> for GaussJacobi
Gauss-Chebyshev quadrature of the first kind is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= -0.5.
Source§fn from(value: GaussChebyshevFirstKind) -> Self
fn from(value: GaussChebyshevFirstKind) -> Self
Source§impl From<GaussChebyshevSecondKind> for GaussJacobi
Gauss-Chebyshev quadrature of the second kind is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= 0.5.
impl From<GaussChebyshevSecondKind> for GaussJacobi
Gauss-Chebyshev quadrature of the second kind is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= 0.5.
Source§fn from(value: GaussChebyshevSecondKind) -> Self
fn from(value: GaussChebyshevSecondKind) -> Self
Source§impl From<GaussLegendre> for GaussJacobi
Gauss-Legendre quadrature is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= 0.
impl From<GaussLegendre> for GaussJacobi
Gauss-Legendre quadrature is equivalent to Gauss-Jacobi quadrature with alpha
= beta
= 0.
Source§fn from(value: GaussLegendre) -> Self
fn from(value: GaussLegendre) -> Self
Source§impl<'a> IntoIterator for &'a GaussJacobi
impl<'a> IntoIterator for &'a GaussJacobi
Source§impl IntoIterator for GaussJacobi
impl IntoIterator for GaussJacobi
Source§impl PartialEq for GaussJacobi
impl PartialEq for GaussJacobi
Source§impl Serialize for GaussJacobi
impl Serialize for GaussJacobi
impl StructuralPartialEq for GaussJacobi
Auto Trait Implementations§
impl Freeze for GaussJacobi
impl RefUnwindSafe for GaussJacobi
impl Send for GaussJacobi
impl Sync for GaussJacobi
impl Unpin for GaussJacobi
impl UnwindSafe for GaussJacobi
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.