input slice
n-dimensional slice
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]);
Swaps two dimensions.