new slice with new length
TODO: support n-dimensional new shape
import mir.ndslice.fuse : fuse; import mir.ndslice.slice : sliced; assert([1,2].sliced.resize(3) == [1, 2, 0]); assert([1,2].sliced.resize(2) == [1, 2]); assert([1,2].sliced.resize(1) == [1]); assert([[1,2],[3,4]].fuse.resize(3) == [[1,2], [3,4], [0,0]]); assert([[1,2],[3,4]].fuse.resize(2) == [[1,2], [3,4]]); assert([[1,2],[3,4]].fuse.resize(1) == [[1,2]]); assert([1,2].sliced.resize(0) == [].sliced!int); assert([].sliced!int.resize(3) == [0,0,0]);
Returns a resized n-dimensional slice s with new size. When new size is larger, new slice is padded with 0. When new size is smaller, new slice is just a subslice of s.