Skip to main content

vectorize_nd

Function vectorize_nd 

Source
pub fn vectorize_nd<T, U, F, D>(
    f: F,
) -> impl Fn(&Array<T, D>) -> FerrayResult<Array<U, D>>
where T: Element + Copy, U: Element, D: Dimension, F: Fn(T) -> U,
Expand description

Wrap a scalar function to operate elementwise on arrays of any dimension.

Like vectorize, but works with any dimension type D.

§Example

let square = vectorize_nd(|x: f64| x * x);
let result = square(&input_2d_array)?;