Releases: libmir/mir-algorithm
Releases · libmir/mir-algorithm
v0.8.0
New modules
New API
mir.series(formermir.timeseries) was enhanced with map like primitives andmergefunction.eachUpperandeachLowerwas added tomir.ndslice.algorithmby @jmh530antidiagonalwas added tomir.ndslice.topology- ndslice overloaded operators was improved. [???]-like operators was added fo const and immutable ndslices.
Acknowledgments
- John Hall
- Sebastian Wilzbach
- Shigeki Karita
Part of this work has been sponsored by Symmetry Investments and Kaleidic Associates.
ndslice.fuse, qualifier propagation rework
add mir.ndslice.fuse and a a huge work on qualifier propagation (#127) * add mir.qualifier * ditto * add mir.qualifier * ditto * fix few bugs * update join * prepare docs * fix bugs * fix optmath * add import * fix makefile * ditto * ditto * fix docs * add fuse instead of join, improve API with fused slices, optimize ndslice.algorithm, fix few minor bugs * Update spline.d * Update spline.d * Update pchip.d
v0.7.0
New Modules since v0.6.21
- Reworked interpolation API, now found in
mir.interpolate,mir.interpolate.linear,mir.interpolate.pchip. - New module
mir.interpolate.splinefor cubic interpolation. Warning: multivariate cubic spline with derivatives is still experimental. - New module
mir.interpolate.constantfor constant interpolation. Warning: multivariate constant interpolant is still experimental.
API Changes since v0.6.21
- Added in
mir.math.commonfunction attributes@optmathand@fmamath. They only have effect when compiling with LDC but can be used with all compilers. (This now also applies to@fastmath.)@optmathis similar to@fastmathbut does not allow unsafe-fp-math. Does not force LDC to replace division with multiplication by reciprocal. - New
mir.utility.extMulextended unsigned multiplication that makes available the high bits of the result - New
mir.functional.aliasCall - New
mir.ndslice.algorithm.maxLengthreturns max length across all dimensions. - New
mir.ndslice.slice.IteratorOf!(T : Slice)extracts iterator type from a Slice - New
mir.ndslice.slice.ndassignassignment utility template that works both with scalars and with ndslices. - In
mir.ndslice.slice.Slice:iteratoris nowinout;opUnarynow works with-and+;opIndexAssignnow returns refthisinstead ofvoid. mir.ndslice.field.MagicFieldsupportslengthandshape.
Removed Modules
mir.interpolation,mir.interpolation.linear,mir.interpolation.Migrate to replacements.
Other Changes since v0.6.21
- Uses of
@fastmathin the Mir codebase have been replaced by@optmath, exceptingmir.math.sumSummation.fast. - In
mir.ndslice.topologyunder-the-hood improvements inslide,diff,pairwise - In
mir.ndslice.slice.SliceopBinaryandopBinaryRightnow internally usemir.ndslice.topology.vmapinstead ofmir.ndslice.topology.indexed.
Fixed since v0.7.0-alpha10
- Fix in
mir.ndslice.topology.mapfor compilation failing in cases where chained map calls couldn't be coalesced due to capturing multiple contexts (seemingly a compiler bug in some cases) #111
Fixed since v0.6.21
- Made
mir.ndslice.topology.flattenedbackwards compatible with LDC 1.2.0 for those who haven't upgraded - Added workaround in
mir.ndslice.algorithm.reducefor DMD inlining bug for non-Windows x86-64 (LDC unaffected) mir.primitives.shapenow takes its argument by reference
v0.7.0-alpha7
Non-LDC simd and asm fixes; fix some memory utils on Windows
Add stdcSlice, stdcUninitSlice
v0.6.11 Merge branch 'master' of https://github.com/libmir/mir-algorithm
add index operator [] support for const and immutable ndslices
struct Foo
{
ContiguousSlice!(1, int) bar;
int get(size_t i) immutable
{
return bar[i];
}
int get(size_t i) const
{
return bar[i];
}
}
@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
tuplewas renamed torefTupleisSortedandisStrictlyMonotonicare deprecated. Usepairwiseandallinstead.
[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
UniversalVectorContiguousMatrixCanonicalMatrixUniversalMatrixContiguousTensorCanonicalTensorUniversalTensor
Interpolation , Time-seres and more
New modules
mir.interpolationmir.interpolation.linearmir.interpolation.pchipmir.timeseriesmir.ndslice.mutationfortransposeInPlace
New functions for existing modules
mir.ndslice.topology: diffmir.ndslice.topology: slidemir.ndslice.algorithm: findIndexmir.ndslice.algorithm: minPos, maxPosmir.ndslice.algorithm: minIndex, maxIndexmir.ndslice.algorithm: minmaxPosmir.ndslice.algorithm: minmaxIndex
New features
- Syntax sugar for
indexedandcartesianv0.5.1 - Syntax sugar for map + RefTuple combination v0.5.0
- Specialisation for
map!"a".
Bug fixes
front!1/back!1was wrong for Canonical and Contiguous slices.
Syntax sugar for `indexed` and `cartesian`
import mir.ndslice.allocation: slice;
auto sli = slice!int(4, 3);
auto idx = slice!(size_t[2])(3);
idx[] = [
cast(size_t[2])[0, 2],
cast(size_t[2])[3, 1],
cast(size_t[2])[2, 0]];
// equivalent to:
// import mir.ndslice.topology: indexed;
// sli.indexed(indx)[] = 1;
sli[idx][] = 1;
assert(sli == [
[0, 0, 1],
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
]);
foreach (row; sli[[1, 3].sliced])
row[] += 2;
assert(sli == [
[0, 0, 1],
[2, 2, 2], // <-- += 2
[1, 0, 0],
[2, 3, 2], // <-- += 2
]);import mir.ndslice.topology: iota;
import mir.ndslice.allocation: slice;
auto sli = slice!int(5, 6);
// equivalent to
// import mir.ndslice.topology: indexed, cartesian;
// auto a = [0, sli.length!0 / 2, sli.length!0 - 1].sliced;
// auto b = [0, sli.length!1 / 2, sli.length!1 - 1].sliced;
// auto c = cartesian(a, b);
// auto minor = sli.indexed(c);
auto minor = sli[[0, $ / 2, $ - 1].sliced, [0, $ / 2, $ - 1].sliced];
minor[] = iota([3, 3], 1);
assert(sli == [
// ↓ ↓ ↓︎
[1, 0, 0, 2, 0, 3], // <---
[0, 0, 0, 0, 0, 0],
[4, 0, 0, 5, 0, 6], // <---
[0, 0, 0, 0, 0, 0],
[7, 0, 0, 8, 0, 9], // <---
]);Syntax sugar for map + RefTuple combination
map on top of ndslice composed of RefTuples recognises it and passes list of args instead of single tuple.
Old:
auto c = cartesian(a, b)
.map!"a.a + a.b";New:
auto c = cartesian(a, b)
.map!"a + b";