@safe ndslice; shortcuts; topology.pairwise instead of isSorted and isStrictlyMonotonic
Slice is safe now
User-defined iterators must care about their safety except bounds checks.
Bounds are checked in ndslice code.
Deprecations
tuple
was renamed torefTuple
isSorted
andisStrictlyMonotonic
are deprecated. Usepairwise
andall
instead.
[float.nan, 1].isSorted
is true both for Mir and Phobos, but it must be false.
*.pairwise!"a <= b".all
solves this issue explicitly.
import mir.ndslice.algorithm: all;
import mir.ndslice.slice;
import mir.ndslice.sorting: sort;
import mir.ndslice.topology: pairwise;
auto arr = [1, 1, 2].sliced;
assert(arr.pairwise!"a <= b".all);
assert(!arr.pairwise!"a < b".all);
arr = [4, 3, 2, 1].sliced;
assert(!arr.pairwise!"a <= b".all);
assert(!arr.pairwise!"a < b".all);
sort(arr);
assert(arr.pairwise!"a <= b".all);
assert(arr.pairwise!"a < b".all);
New API
pairwise
- pairwise map for vectors. It is shortcut fortopology.slide
.Slice.field
- returns underlying array for contiguous ndslices- Definition shortcuts for Slice
UniversalVector
ContiguousMatrix
CanonicalMatrix
UniversalMatrix
ContiguousTensor
CanonicalTensor
UniversalTensor