The OpenD Programming Language

assumeContiguous

Converts a slice to contiguous kind (unsafe).

Slice!(Iterator, N, Contiguous, Labels)
assumeContiguous
(
Iterator
size_t N
SliceKind kind
Labels...
)
(
Slice!(Iterator, N, kind, Labels) slice
)

Parameters

slice Slice!(Iterator, N, kind, Labels)

a slice

Return Value

Type: Slice!(Iterator, N, Contiguous, Labels)

canonical slice

Examples

auto slice = iota(2, 3).universal.assumeContiguous;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
static assert(slice._strides.length == 0);
import mir.ndslice.slice;
import mir.ndslice.allocation: slice;

auto dataframe = slice!(double, int, string)(2, 3);
dataframe.label[] = [1, 2];
dataframe.label!1[] = ["Label1", "Label2", "Label3"];

auto assmcontdf = dataframe.canonical.assumeContiguous;
assert(assmcontdf._lengths == [2, 3]);
static assert(assmcontdf._strides.length == 0);

assert(is(typeof(assmcontdf) ==
    Slice!(double*, 2, Contiguous, int*, string*)));
assert(assmcontdf.label!0[0] == 1);
assert(assmcontdf.label!1[1] == "Label2");

See Also

Meta