import mir.ndslice.allocation : slice; auto a = slice!int(2, 3); a[0..$, 0..$-1] += [[1, 2], [3, 4]]; assert(a == [[1, 2, 0], [3, 4, 0]]); a[0..$, 0..$-1] += [1, 2]; assert(a == [[2, 4, 0], [4, 6, 0]]); a[1, 0..$-1] += [3, 4]; assert(a[1] == [7, 10, 0]); a[1, 0..$-1][] += [1, 2]; assert(a[1] == [8, 12, 0]);
Packed slices
import mir.ndslice.allocation : slice; import mir.ndslice.topology : blocks; auto a = slice!int(4, 4); a.blocks(2, 2)[] += [[0, 1], [2, 3]]; assert(a == [[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]);
Op Assignment op= of a regular multidimensional array to a fully defined slice.