The OpenD Programming Language

sumSlices

Sum slices with a naive algorithm.

template sumSlices()
sumSlices
(
Iterator
SliceKind kind
)
(
Slice!(Iterator, 1, kind) sliceOfSlices
)
if (
isSlice!(DeepElementType!(Slice!(Iterator, 1, kind)))
)

Members

Functions

sumSlices
auto sumSlices(Slice!(Iterator, 1, kind) sliceOfSlices)

Examples

import mir.ndslice.topology: map, byDim;
import mir.ndslice.slice: sliced;

auto ar = [[1, 2, 3], [10, 20, 30]];
assert(ar.map!sliced.sumSlices == [11, 22, 33]);

import mir.ndslice.fuse: fuse;
auto a = [[[1.2], [2.1]], [[4.1], [5.2]]].fuse;
auto s = a.byDim!0.sumSlices;
assert(s == [[5.3], [7.300000000000001]]);

Meta