rotated

Rotates two selected dimensions by k*90 degrees. The order of dimensions is important. If the slice has two dimensions, the default direction is counterclockwise.

  1. template rotated(size_t dimensionA, size_t dimensionB)
  2. auto rotated(Slice!(Iterator, N, kind) _slice, size_t dimensionA, size_t dimensionB, sizediff_t k)
    @optmath
    rotated
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) _slice
    ,
    size_t dimensionA
    ,
    size_t dimensionB
    ,
    sizediff_t k = 1
    )
  3. Slice!(Iterator, 2, Universal) rotated(Slice!(Iterator, 2, kind) slice, sizediff_t k)

Parameters

dimensionA size_t

first dimension

dimensionB size_t

second dimension

k sizediff_t

rotation counter, can be negative

Return Value

Type: auto

n-dimensional slice

Examples

import mir.ndslice.slice;
import mir.ndslice.topology: iota;
auto slice = iota(2, 3);

auto a = [[0, 1, 2],
          [3, 4, 5]];

auto b = [[2, 5],
          [1, 4],
          [0, 3]];

auto c = [[5, 4, 3],
          [2, 1, 0]];

auto d = [[3, 0],
          [4, 1],
          [5, 2]];

assert(slice.rotated       ( 4) == a);
assert(slice.rotated!(0, 1)(-4) == a);
assert(slice.rotated (1, 0,  8) == a);

assert(slice.rotated            == b);
assert(slice.rotated!(0, 1)(-3) == b);
assert(slice.rotated (1, 0,  3) == b);

assert(slice.rotated       ( 6) == c);
assert(slice.rotated!(0, 1)( 2) == c);
assert(slice.rotated (0, 1, -2) == c);

assert(slice.rotated       ( 7) == d);
assert(slice.rotated!(0, 1)( 3) == d);
assert(slice.rotated (1, 0,   ) == d);

Meta