swapped

Swaps two dimensions.

  1. template swapped(size_t dimensionA, size_t dimensionB)
  2. auto swapped(Slice!(Iterator, N, kind) _slice, size_t dimensionA, size_t dimensionB)
  3. Slice!(Iterator, 2, Universal) swapped(Slice!(Iterator, 2, kind) slice)
    @optmath
    Slice!(Iterator, 2, Universal)
    swapped
    (
    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)
    .swapped!(2, 1)
    .shape == cast(size_t[4])[3, 5, 4, 6]);

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

Function

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

assert(iota(3, 4, 5, 6)
    .swapped(1, 2)
    .shape == cast(size_t[4])[3, 5, 4, 6]);

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

2D

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

See Also

Meta