transposed

N-dimensional transpose operator. Brings selected dimensions to the first position.

  1. template transposed(Dimensions...)
  2. auto transposed(Slice!(Iterator, N, kind) _slice, size_t[M] dimensions)
    @optmath
    transposed
    (
    Iterator
    size_t N
    SliceKind kind
    size_t M
    )
    (
    Slice!(Iterator, N, kind) _slice
    ,
    size_t[M] dimensions...
    )
  3. Slice!(Iterator, 2, Universal) transposed(Slice!(Iterator, 2, kind) slice)

Parameters

dimensions size_t[M]

indices of dimensions to be brought to the first position

Return Value

Type: auto

n-dimensional slice

Examples

Template

import mir.ndslice.slice;
import mir.ndslice.topology: iota;

assert(iota(3, 4, 5, 6, 7)
    .transposed!(3, 1, 0)
    .shape == cast(size_t[5])[6, 4, 3, 5, 7]);

assert(iota(3, 4, 5, 6, 7)
    .transposed!(4, 1, 0)
    .shape == cast(size_t[5])[7, 4, 3, 5, 6]);

Function

import mir.ndslice.slice;
import mir.ndslice.topology: iota;

assert(iota(3, 4, 5, 6, 7)
    .transposed(3, 1, 0)
    .shape == cast(size_t[5])[6, 4, 3, 5, 7]);

assert(iota(3, 4, 5, 6, 7)
    .transposed(4, 1, 0)
    .shape == cast(size_t[5])[7, 4, 3, 5, 6]);

Single-argument function

import mir.ndslice.slice;
import mir.ndslice.topology: iota;

assert(iota(3, 4, 5, 6, 7)
    .transposed(3)
    .shape == cast(size_t[5])[6, 3, 4, 5, 7]);

assert(iota(3, 4, 5, 6, 7)
    .transposed(4)
    .shape == cast(size_t[5])[7, 3, 4, 5, 6]);

_2-dimensional transpose

import mir.ndslice.slice;
import mir.ndslice.topology: iota;
assert(iota(3, 4)
    .transposed
    .shape == cast(size_t[2])[4, 3]);

See Also

Meta