digitalmars.D.announce - Mir Algorithm v0.5.16: safe ndslice; shortcuts; topology.pairwise
### 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 to `refTuple` - `isSorted` and `isStrictlyMonotonic` are deprecated. Use `pairwise` and `all` 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. ```d 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 for `topology.slide`. - `Slice.field` - returns underlying array for contiguous ndslices - Definition shortcuts for Slice - `UniversalVector` - `ContiguousMatrix` - `CanonicalMatrix` - `UniversalMatrix` - `ContiguousTensor` - `CanonicalTensor` - `UniversalTensor`
jmh530 <john.michael.hall gmail.com> writes:
On Saturday, 13 May 2017 at 08:10:20 UTC, 9il wrote:
On Sunday, 14 May 2017 at 17:29:44 UTC, jmh530 wrote:On Saturday, 13 May 2017 at 08:10:20 UTC, 9il wrote:Thanks, fixed.I didn't really realize these were in there. How does it compare to std.typecons.Tuple? I was thinking about doing some work with std.typecons.Tuple's that hold mir.slices and not sure if I should use RefTuple instead.1. RefTuple can hold pointers instead of values. For example Mir's zip, cartesian use RefTuples. This makes zip faster and more flexible, because it is partially mutable compared with Tuple. 2. Ndslice composed of RefTuples has special syntax with Map, for example "a + b" instead of "a + a" . 3. RefTuple does not ha ` ` syntax or other names then `a`, `b`, `c`. 4. RefTuple is faster to compile, though Example: auto s = zip(mask, b, c).map!"a ? b : c"; Loads either a or b.