shape

Shape of a common n-dimensional array.

@optmath
shape
(
T
)
(
T[] array
,
ref int err
)

Parameters

array T[]

common n-dimensional array

err int

error flag passed by reference

Return Value

Type: auto

static array of dimensions type of size_t[n]

Examples

int err;
size_t[2] shape = [[1, 2, 3], [4, 5, 6]].shape(err);
assert(err == 0);
assert(shape == [2, 3]);

[[1, 2], [4, 5, 6]].shape(err);
assert(err == 1);

Slice from ndarray

import mir.ndslice.allocation: slice, shape;
int err;
auto array = [[1, 2, 3], [4, 5, 6]];
auto s = array.shape(err).slice!int;
s[] = [[1, 2, 3], [4, 5, 6]];
assert(s == array);

Meta