The OpenD Programming Language

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)
  3. Slice!(Iterator, 2, Universal) transposed(Slice!(Iterator, 2, kind) slice)
    Slice!(Iterator, 2, Universal)
    transposed
    (
    Iterator
    SliceKind kind
    )
    (
    Slice!(Iterator, 2, kind) slice
    )

Parameters

slice Slice!(Iterator, 2, kind)

input slice

Return Value

Type: Slice!(Iterator, 2, Universal)

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