1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use ;
use crate*;
use cratesum;
/// Integrate a curve with the midpoint rule.
///
/// # Description
///
/// Approximates the definite integral using the midpoint rule
/// with pre-computed x-values:
///
/// ```text
/// ∫f(x) dx ≈ Δx * [f(x₁) + f(x₂) + ... + f(xₙ)]
/// ```
///
/// # Arguments
///
/// * `x`: The n-dimensional array to integrate.
/// * `delta_x`: The width between data points. If `None`, then `delta_x = 1.0`.
/// * `threads`: The requested number of threads to use for parallel execution.
/// If `None` or `Some(1)` sequential execution is used. If `Some(0)`, then
/// the maximum available parallelism is used. Thread counts are clamped to
/// the systems maximum.
///
/// # Returns
///
/// * `f64`: The computed integral.