transposed

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

  1. auto transposed(Slice!(Iterator, N, kind) _slice)
    template transposed(Dimensions...)
    @optmath
    static if(allSatisfy!(isSize_t, Dimensions))
    @optmath
    transposed
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) _slice
    )
    if (
    Dimensions.length
    )
  2. alias transposed = .transposed!(staticMap!(toSize_t, Dimensions))
  3. auto transposed(Slice!(Iterator, N, kind) _slice, size_t[M] dimensions)
  4. Slice!(Iterator, 2, Universal) transposed(Slice!(Iterator, 2, kind) slice)

Members

Aliases

transposed
alias transposed = .transposed!(staticMap!(toSize_t, Dimensions))
Undocumented in source.

Functions

transposed
auto transposed(Slice!(Iterator, N, kind) _slice)

Parameters

Dimensions

indices of dimensions to be brought to the first position

Return Value

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