1-dimensional slice
diagonal 2-dimensional slice
import mir.ndslice.topology : iota; import mir.ndslice.slice : sliced; // ------- // | 0 1 2 | // ------- auto a = iota(3).diag; auto result = [[0, 0, 0], [0, 1, 0], [0, 0, 2]].sliced; assert(a[0] == result[0]); assert(a[1] == result[1]); assert(a[2] == result[2]);
Create a diagonal 2-dimensional slice from a 1-dimensional slice.