Struct rgsl::types::integration::IntegrationWorkspace
source · [−]pub struct IntegrationWorkspace { /* private fields */ }
Expand description
The QAG algorithm is a simple adaptive integration procedure. The integration region is divided into subintervals, and on each iteration the subinterval with the largest estimated error is bisected. This reduces the overall error rapidly, as the subintervals become concentrated around local difficulties in the integrand. These subintervals are managed by a gsl_integration_workspace struct, which handles the memory for the subinterval ranges, results and error estimates.
Implementations
sourceimpl IntegrationWorkspace
impl IntegrationWorkspace
sourcepub fn new(n: usize) -> Option<IntegrationWorkspace>
pub fn new(n: usize) -> Option<IntegrationWorkspace>
This function allocates a workspace sufficient to hold n double precision intervals, their integration results and error estimates. One workspace may be used multiple times as all necessary reinitialization is performed automatically by the integration routines.
pub fn limit(&self) -> usize
pub fn size(&self) -> usize
pub fn nrmax(&self) -> usize
pub fn i(&self) -> usize
pub fn maximum_level(&self) -> usize
sourcepub fn qag<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize,
key: GaussKronrodRule
) -> (Value, f64, f64)
pub fn qag<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize,
key: GaussKronrodRule
) -> (Value, f64, f64)
This function applies an integration rule adaptively until an estimate of the integral of f over (a,b) is achieved within the desired absolute and relative error limits, epsabs and epsrel. The function returns the final approximation, result, and an estimate of the absolute error, abserr. The integration rule is determined by the value of key, which should be chosen from the following symbolic names,
GSL_INTEG_GAUSS15 (key = 1)
GSL_INTEG_GAUSS21 (key = 2)
GSL_INTEG_GAUSS31 (key = 3)
GSL_INTEG_GAUSS41 (key = 4)
GSL_INTEG_GAUSS51 (key = 5)
GSL_INTEG_GAUSS61 (key = 6)
corresponding to the 15f64, 21f64, 31f64, 41f64, 51 and 61 point Gauss-Kronrod rules. The higher-order rules give better accuracy for smooth functions, while lower-order rules save time when the function contains local difficulties, such as discontinuities.
On each iteration the adaptive integration strategy bisects the interval with the largest error estimate. The subintervals and their results are stored in the memory provided by workspace. The maximum number of subintervals is given by limit, which may not exceed the allocated size of the workspace.
Returns (result, abs_err)
.
sourcepub fn qags<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qags<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function applies the Gauss-Kronrod 21-point integration rule adaptively until an estimate of the integral of f over (a,b) is achieved within the desired absolute and relative error limits, epsabs and epsrel. The results are extrapolated using the epsilon-algorithm, which accelerates the convergence of the integral in the presence of discontinuities and integrable singularities. The function returns the final approximation from the extrapolation, result, and an estimate of the absolute error, abserr. The subintervals and their results are stored in the memory provided by workspace. The maximum number of subintervals is given by limit, which may not exceed the allocated size of the workspace.
Returns (result, abs_err)
.
sourcepub fn qagp<F: Fn(f64) -> f64>(
&mut self,
f: F,
pts: &mut [f64],
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qagp<F: Fn(f64) -> f64>(
&mut self,
f: F,
pts: &mut [f64],
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function applies the adaptive integration algorithm QAGS taking account of the user-supplied locations of singular points. The array pts of length npts should contain the endpoints of the integration ranges defined by the integration region and locations of the singularities.
For example, to integrate over the region (a,b) with break-points at x_1, x_2, x_3 (where a < x_1 < x_2 < x_3 < b) the following pts array should be used
pts[0] = a
pts[1] = x_1
pts[2] = x_2
pts[3] = x_3
pts[4] = b
with npts = 5.
If you know the locations of the singular points in the integration region then this routine will be faster than QAGS.
Returns (result, abs_err)
.
sourcepub fn qagi<F: Fn(f64) -> f64>(
&mut self,
f: F,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qagi<F: Fn(f64) -> f64>(
&mut self,
f: F,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function computes the integral of the function f over the infinite interval
(-\infty,+\infty)
. The integral is mapped onto the semi-open interval (0,1]
using the
transformation:
x = (1-t)/t,
\int_{-\infty}^{+\infty} dx f(x) =
\int_0^1 dt (f((1-t)/t) + f((-1+t)/t))/t^2.
It is then integrated using the QAGS algorithm. The normal 21-point Gauss-Kronrod rule of QAGS is replaced by a 15-point rule, because the transformation can generate an integrable singularity at the origin. In this case a lower-order rule is more efficient.
Returns (result, abs_err)
.
sourcepub fn qagiu<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qagiu<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function computes the integral of the function f over the semi-infinite interval
(a,+\infty)
. The integral is mapped onto the semi-open interval (0,1]
using the
transformation:
x = a + (1-t)/t,
\int_{a}^{+\infty} dx f(x) =
\int_0^1 dt f(a + (1-t)/t)/t^2
and then integrated using the QAGS algorithm.
Returns (result, abs_err)
.
sourcepub fn qagil<F: Fn(f64) -> f64>(
&mut self,
f: F,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qagil<F: Fn(f64) -> f64>(
&mut self,
f: F,
b: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function computes the integral of the function f over the semi-infinite interval
(-\infty,b)
. The integral is mapped onto the semi-open interval (0,1]
using the
transformation:
x = b - (1-t)/t,
\int_{-\infty}^{b} dx f(x) =
\int_0^1 dt f(b - (1-t)/t)/t^2
and then integrated using the QAGS algorithm.
Returns (result, abs_err)
.
sourcepub fn qawc<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
c: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
pub fn qawc<F: Fn(f64) -> f64>(
&mut self,
f: F,
a: f64,
b: f64,
c: f64,
epsabs: f64,
epsrel: f64,
limit: usize
) -> (Value, f64, f64)
This function computes the Cauchy principal value of the integral of f over (a,b)
, with a
singularity at c,
I = \int_a^b dx f(x) / (x - c)
The adaptive bisection algorithm of QAG is used, with modifications to ensure that subdivisions do not occur at the singular point x = c.
When a subinterval contains the point x = c or is close to it then a special 25-point modified Clenshaw-Curtis rule is used to control the singularity. Further away from the singularity the algorithm uses an ordinary 15-point Gauss-Kronrod integration rule.
Returns (result, abs_err)
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for IntegrationWorkspace
impl !Send for IntegrationWorkspace
impl !Sync for IntegrationWorkspace
impl Unpin for IntegrationWorkspace
impl UnwindSafe for IntegrationWorkspace
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more