zip

Groups slices into a slice of refTuples. The slices must have identical strides or be 1-dimensional.

template zip(bool sameStrides = false)
@optmath
@optmath
zip
(
Slices...
)
(
Slices slices
)
if (
Slices.length > 1 &&
allSatisfy!(isConvertibleToSlice, Slices)
)

Members

Functions

zip
auto zip(Slices slices)

Groups slices into a slice of refTuples. The slices must have identical strides or be 1-dimensional.

Parameters

sameStrides

if true assumes that all slices has the same strides.

slices

list of slices

Return Value

n-dimensional slice of elements refTuple

Examples

import mir.ndslice.allocation : slice;
import mir.ndslice.topology : flattened, iota;

auto alpha = iota!int(4, 3);
auto beta = slice!int(4, 3).universal;

auto m = zip!true(alpha, beta);
foreach (r; m)
    foreach (e; r)
        e.b = e.a;
assert(alpha == beta);

beta[] = 0;
foreach (e; m.flattened)
    e.b = cast(int)e.a;
assert(alpha == beta);

See Also

Meta