The OpenD Programming Language

slice

GC-Allocates an n-dimensional slice.

Return Value

Type: auto

initialzed n-dimensional slice

Examples

auto tensor = slice([2, 3], 5);
assert(tensor.elementCount == 2 * 3);
assert(tensor[1, 1] == 5);

// creates duplicate using `slice`
auto dup = tensor.slice;
assert(dup == tensor);
import mir.ndslice.slice: Slice;
import mir.ndslice.topology : iota;
import mir.ndslice.concatenation;
auto tensor = concatenation([2, 3].iota, [3].iota(6)).slice;
assert(tensor == [3, 3].iota);

static assert(is(typeof(tensor) == Slice!(ptrdiff_t*, 2)));

Meta