mir_slice.opIndexAssign

Assignment of a regular multidimensional array to a fully defined slice.

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

Examples

import mir.ndslice.allocation;
auto a = slice!int(2, 3);
auto b = [[1, 2], [3, 4]];

a[] = [[1, 2, 3], [4, 5, 6]];
assert(a == [[1, 2, 3], [4, 5, 6]]);

a[0..$, 0..$-1] = [[1, 2], [3, 4]];
assert(a == [[1, 2, 3], [3, 4, 6]]);

a[0..$, 0..$-1] = [1, 2];
assert(a == [[1, 2, 3], [1, 2, 6]]);

a[1, 0..$-1] = [3, 4];
assert(a[1] == [3, 4, 6]);

a[1, 0..$-1][] = [3, 4];
assert(a[1] == [3, 4, 6]);

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