The OpenD Programming Language

mir_slice.opIndexOpAssign

Op Assignment op= of a regular multidimensional array to a fully defined slice.

  1. auto ref opIndexOpAssign(T value, size_t[N] _indices)
  2. void opIndexOpAssign(Slice!(RIterator, RN, rkind) value, Slices slices)
  3. void opIndexOpAssign(T[] value, Slices slices)
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    return scope
    static if(isMutable!DeepElement)
    void
    opIndexOpAssign
    (
    string op
    T
    Slices...
    )
    (
    T[] value
    ,
    Slices slices
    )
    if (
    isFullPureSlice!Slices &&
    &&
    DynamicArrayDimensionsCount!(T[]) - DynamicArrayDimensionsCount!DeepElement <= typeof(this.opIndex(slices)).N
    )
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )
  4. void opIndexOpAssign(T value, Slices slices)
  5. void opIndexOpAssign(T concatenation, Slices slices)

Examples

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]]);

Meta