repeat

Returns a slice with identical elements. RepeatSlice stores only single value.

  1. Slice!(FieldIterator!(RepeatField!T), M, Universal) repeat(T value, size_t[M] lengths)
  2. Slice!(SliceIterator!(Iterator, N, kind), M, Universal) repeat(Slice!(Iterator, N, kind) slice, size_t[M] lengths)
    @optmath
    Slice!(SliceIterator!(Iterator, N, kind), M, Universal)
    repeat
    (
    SliceKind kind
    size_t N
    Iterator
    size_t M
    )
    (
    Slice!(Iterator, N, kind) slice
    ,
    size_t[M] lengths...
    )
    if (
    M
    )

Parameters

lengths size_t[M]

list of dimension lengths

Return Value

Type: Slice!(SliceIterator!(Iterator, N, kind), M, Universal)

n-dimensional slice composed of identical values, where n is dimension count.

Examples

auto sl = iota(3).repeat(4);
assert(sl == [[0, 1, 2],
              [0, 1, 2],
              [0, 1, 2],
              [0, 1, 2]]);
import mir.ndslice.dynamic : transposed;

auto sl = iota(3)
    .repeat(4)
    .unpack
    .universal
    .transposed;

assert(sl == [[0, 0, 0, 0],
              [1, 1, 1, 1],
              [2, 2, 2, 2]]);
import mir.ndslice.allocation;

auto sl = iota([3], 6).slice;
auto slC = sl.repeat(2, 3);
sl[1] = 4;
assert(slC == [[[6, 4, 8],
                [6, 4, 8],
                [6, 4, 8]],
               [[6, 4, 8],
                [6, 4, 8],
                [6, 4, 8]]]);
import mir.primitives: DeepElementType;

auto sl = repeat(4.0, 2, 3);
assert(sl == [[4.0, 4.0, 4.0],
              [4.0, 4.0, 4.0]]);

static assert(is(DeepElementType!(typeof(sl)) == double));

sl[1, 1] = 3;
assert(sl == [[3.0, 3.0, 3.0],
              [3.0, 3.0, 3.0]]);

Meta