The OpenD Programming Language

mir_slice._stride

Multidimensional stride property.

struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
@safe @property scope const
sizediff_t
_stride
(
size_t dimension = 0
)
()
if (
dimension < N
)
if (
0 < N_ &&
N_ < 255
&&
!(
kind_ == Canonical &&
N_ == 1
)
&&
Labels_.length <= N_
&&
isIterator!Iterator_
)

Return Value

stride of the corresponding dimension

Examples

Regular slice

import mir.ndslice.topology : iota;
auto slice = iota(3, 4, 5);
assert(slice._stride   == 20);
assert(slice._stride!0 == 20);
assert(slice._stride!1 == 5);
assert(slice._stride!2 == 1);

Modified regular slice

import mir.ndslice.dynamic : reversed, strided, swapped;
import mir.ndslice.topology : universal, iota;
assert(iota(3, 4, 50)
    .universal
    .reversed!2      //makes stride negative
    .strided!2(6)    //multiplies stride by 6 and changes the corresponding length
    .swapped!(1, 2)  //swaps dimensions `1` and `2`
    ._stride!1 == -6);

See Also

Meta