pub fn deriv(data: &FdMatrix, domain: DerivDomain<'_>) -> DerivResultExpand description
Compute numerical derivatives of functional data (parallelized over rows).
A single dispatcher over the DerivDomain grid enum: OneD routes to 1D differentiation,
TwoD routes to 2D partial differentiation. Numeric output is identical to the former
suffixed 1D/2D differentiation functions.
§Arguments
data- Functional data matrixdomain- Grid specification (1D or 2D) with dimension-specific parameters
§Returns
A DerivResult: OneD(FdMatrix) for 1D, TwoD(Deriv2DResult) for valid 2D input, or
None for the 2D bad-dimension guard case.
§Examples
use fdars_core::matrix::FdMatrix;
use fdars_core::fdata::{deriv, DerivDomain, DerivResult};
// Linear function f(t) = t on [0, 1], derivative should be ~1
let argvals: Vec<f64> = (0..20).map(|i| i as f64 / 19.0).collect();
let data = FdMatrix::from_column_major(argvals.clone(), 1, 20).unwrap();
let DerivResult::OneD(d) = deriv(&data, DerivDomain::OneD { argvals: &argvals, nderiv: 1 })
else {
panic!("expected 1D result");
};
assert_eq!(d.shape(), (1, 20));
// Interior points should have derivative close to 1.0
assert!((d[(0, 10)] - 1.0).abs() < 0.1);