pub fn trapezoid<F: Float>(
y: &Array<F>,
spacing: impl Into<Spacing>,
axis: isize,
) -> Array<F>Expand description
Integrate with the trapezoidal rule along axis, like np.trapezoid(y, x_or_dx, axis=axis).
spacing is a constant dx or the sample coordinates x (length y.shape()[axis]). The
result has axis removed (a 0-d array for 1-d y; use .item()). Fewer than 2 samples gives 0.
use rustnum as np;
let y = np::array![1.0, 2.0, 3.0];
assert_eq!(np::trapezoid(&y, 1.0, -1).item(), 4.0);
assert_eq!(np::trapezoid(&y, vec![0.0, 1.0, 3.0], -1).item(), 6.5);