an integer indicating which lag to use
lazy differences.
import mir.ndslice.slice: sliced; assert([2, 4, 3, -1].sliced.diff == [2, -1, -4]);
N-dimensional
// 0 1 2 3 // 4 5 6 7 => // 8 9 10 11 // 1 1 1 // 1 1 1 => // 1 1 1 // 0 0 0 // 0 0 0 assert([3, 4].iota.diff == repeat(0, [2, 3]));
packed slices
// 0 1 2 3 // 4 5 6 7 // 8 9 10 11 auto s = iota(3, 4); import std.stdio; assert(iota(3, 4).byDim!0.diff == [ [4, 4, 4, 4], [4, 4, 4, 4]]); assert(iota(3, 4).byDim!1.diff == [ [1, 1, 1], [1, 1, 1], [1, 1, 1]]);
Differences between tensor elements.
The computation is performed on request, when the element is accessed.