The OpenD Programming Language

strided

Multiplies the stride of the selected dimension by a factor.

  1. auto strided(Slice!(Iterator, N, kind) _slice, Repeat!(Dimensions.length, ptrdiff_t) factors)
    template strided(Dimensions...)
    static if(allSatisfy!(isSize_t, Dimensions))
    strided
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) _slice
    ,
    Repeat!(Dimensions.length, ptrdiff_t) factors
    )
    if (
    Dimensions.length
    )
  2. auto strided(Slice!(Iterator, N, kind) slice, ptrdiff_t factor)
  3. Slice!(Iterator, N, Universal) strided(Slice!(Iterator, N, kind) _slice, size_t dimension, ptrdiff_t factor)

Members

Functions

strided
auto strided(Slice!(Iterator, N, kind) _slice, Repeat!(Dimensions.length, ptrdiff_t) factors)

Parameters

Dimensions

indices of dimensions to be strided

Return Value

n-dimensional slice

Examples

import mir.ndslice.topology: iota;
// 0  1   2  3
// 4  5   6  7
// 8  9  10 11
assert(iota(3, 4).strided(2) == [[0, 2], [8, 10]]);
import mir.ndslice.topology: iota;
auto slice = iota(3, 4);

assert(slice
    == [[0,1,2,3], [4,5,6,7], [8,9,10,11]]);

// Template
assert(slice.strided!0(2)
    == [[0,1,2,3],            [8,9,10,11]]);

assert(slice.strided!1(3)
    == [[0,    3], [4,    7], [8,     11]]);

assert(slice.strided!(0, 1)(2, 3)
    == [[0,    3],            [8,     11]]);

// Function
assert(slice.strided(0, 2)
    == [[0,1,2,3],            [8,9,10,11]]);

assert(slice.strided(1, 3)
    == [[0,    3], [4,    7], [8,     11]]);

assert(slice.strided(0, 2).strided(1, 3)
    == [[0,    3],            [8,     11]]);
import mir.ndslice.topology: iota, universal;
static assert(iota(13, 40).universal.strided!(0, 1)(2, 5).shape == [7, 8]);
static assert(iota(93).universal.strided!(0, 0)(7, 3).shape == [5]);
import mir.ndslice.topology: iota, canonical;
auto slice = iota(3, 4).canonical;

assert(slice
    == [[0,1,2,3], [4,5,6,7], [8,9,10,11]]);

// Template
assert(slice.strided!0(2)
    == [[0,1,2,3],            [8,9,10,11]]);

// Function
assert(slice.strided(0, 2)
    == [[0,1,2,3],            [8,9,10,11]]);

Meta