Skip to main content

gradient_1d

Function gradient_1d 

Source
pub fn gradient_1d(ys: &[f64], dx: f64) -> Vec<f64>
Expand description

Numerical gradient of uniformly-spaced 1D data.

Given array ys of length n and uniform spacing dx, returns n gradient values using:

  • forward difference at the first point
  • central difference at interior points
  • backward difference at the last point

This matches NumPy’s np.gradient behaviour for 1D uniform grids.