pub fn vectorize<T, U, F, D>(
f: F,
) -> impl Fn(&Array<T, D>) -> FerrayResult<Array<U, D>>Expand description
Wrap a scalar function to operate elementwise on arrays of any dimension.
Returns a closure that accepts &Array<T, D> and returns
FerrayResult<Array<U, D>>, applying f to every element.
This is NumPy’s np.vectorize — in Rust it is essentially .mapv()
wrapped as a reusable callable.
Works with any dimension type: Ix1, Ix2, IxDyn, etc.
§Example
ⓘ
let square = vectorize(|x: f64| x * x);
let result = square(&input_array)?;