stdcUninitAlignedSlice

Allocates an uninitialized aligned array using core.stdc.stdlib.malloc and creates an n-dimensional slice over it.

@system
@optmath
stdcUninitAlignedSlice
(
T
size_t N
)
(
size_t[N] lengths
,)

Parameters

lengths size_t[N]

list of lengths for each dimension

alignment uint

memory alignment (bytes)

Return Value

Type: auto

contiguous uninitialized n-dimensional slice

Examples

import mir.ndslice.slice: Slice;
auto tensor = stdcUninitAlignedSlice!double([5, 6, 7], 64);
assert(tensor.length == 5);
assert(tensor.elementCount == 5 * 6 * 7);
assert(cast(size_t)(tensor.ptr) % 64 == 0);
static assert(is(typeof(tensor) == Slice!(double*, 3)));
stdcFreeAlignedSlice(tensor);

Meta