sparse

Sparse tensors represented in Dictionary of Keys (DOK) format.

Sparse!(T, N)
sparse
(
T
size_t N
)
(
size_t[N] lengths...
)

Parameters

N

dimension count

lengths size_t[N]

list of dimension lengths

Return Value

Type: Sparse!(T, N)

N-dimensional slice composed of indeces

Examples

auto slice = sparse!double(2, 3);
slice[0][] = 1;
slice[0, 1] = 2;
--slice[0, 0];
slice[1, 2] += 4;

assert(slice == [[0, 2, 1], [0, 0, 4]]);

import std.range.primitives: isRandomAccessRange;
static assert(isRandomAccessRange!(Sparse!(double, 2)));

import mir.ndslice.slice: Slice, DeepElementType;
static assert(is(Sparse!(double, 2) : Slice!(FieldIterator!(SparseField!double), 2)));
static assert(is(DeepElementType!(Sparse!(double, 2)) == double));

See Also

Meta