-
Notifications
You must be signed in to change notification settings - Fork 360
Closed
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!
Description
In engineering tasks there is often a need for diff function (calculate the n-th discrete difference along the given axis). numpy contains the function that works with n-d arrays.
I have implemented such function (for n1 difference case and nd-arrays) in my experimental code:
fn diff<'a, T: 'a, D, V>(data: V, axis: Option<Axis>) -> Array<T, D>
where T: NumOps + ScalarOperand, D: Dimension, V: AsArray<'a, T, D>
{
let data_view = data.into();
let axis = axis.unwrap_or(Axis(data_view.ndim() - 1));
let head = data_view.slice_axis(axis, Slice::from(..-1));
let tail = data_view.slice_axis(axis, Slice::from(1..));
&tail - &head
}It would be nice to have such universal function out of the box (perhaps with n/prepend/append parameters also).
nbro and besselfunctbluss, Dimev, Marcel-G, decahedron1, besselfunct and 1 more
Metadata
Metadata
Assignees
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!