import mir.ndslice.allocation; auto a = slice!int(2, 3); auto b = [1, 2, 3, 4].sliced(2, 2); a[0..$, 0..$-1] += b; assert(a == [[1, 2, 0], [3, 4, 0]]); a[0..$, 0..$-1] += b[0]; assert(a == [[2, 4, 0], [4, 6, 0]]); a[1, 0..$-1] += b[1]; assert(a[1] == [7, 10, 0]); a[1, 0..$-1][] += b[0]; assert(a[1] == [8, 12, 0]);
Left slice is packed
import mir.ndslice.allocation : slice; import mir.ndslice.topology : blocks, iota; auto a = slice!size_t(4, 4); a.blocks(2, 2)[] += iota(2, 2); assert(a == [[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]);
Both slices are packed
import mir.ndslice.allocation : slice; import mir.ndslice.topology : blocks, iota, pack; auto a = slice!size_t(4, 4); a.blocks(2, 2)[] += iota(2, 2, 2).pack!1; assert(a == [[0, 1, 2, 3], [0, 1, 2, 3], [4, 5, 6, 7], [4, 5, 6, 7]]);
Op Assignment op= of a value of Slice type to a fully defined slice.