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 andmerge
function.eachUpper
andeachLower
was added tomir.ndslice.algorithm
by @jmh530antidiagonal
was 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.spline
for cubic interpolation. Warning: multivariate cubic spline with derivatives is still experimental. - New module
mir.interpolate.constant
for constant interpolation. Warning: multivariate constant interpolant is still experimental.
API Changes since v0.6.21
- Added in
mir.math.common
function attributes@optmath
and@fmamath
. They only have effect when compiling with LDC but can be used with all compilers. (This now also applies to@fastmath
.)@optmath
is similar to@fastmath
but does not allow unsafe-fp-math. Does not force LDC to replace division with multiplication by reciprocal. - New
mir.utility.extMul
extended unsigned multiplication that makes available the high bits of the result - New
mir.functional.aliasCall
- New
mir.ndslice.algorithm.maxLength
returns max length across all dimensions. - New
mir.ndslice.slice.IteratorOf!(T : Slice)
extracts iterator type from a Slice - New
mir.ndslice.slice.ndassign
assignment utility template that works both with scalars and with ndslices. - In
mir.ndslice.slice.Slice
:iterator
is nowinout
;opUnary
now works with-
and+
;opIndexAssign
now returns refthis
instead ofvoid
. mir.ndslice.field.MagicField
supportslength
andshape
.
Removed Modules
mir.interpolation
,mir.interpolation.linear
,mir.interpolation.
Migrate to replacements.
Other Changes since v0.6.21
- Uses of
@fastmath
in the Mir codebase have been replaced by@optmath
, exceptingmir.math.sum
Summation.fast
. - In
mir.ndslice.topology
under-the-hood improvements inslide
,diff
,pairwise
- In
mir.ndslice.slice.Slice
opBinary
andopBinaryRight
now internally usemir.ndslice.topology.vmap
instead ofmir.ndslice.topology.indexed
.
Fixed since v0.7.0-alpha10
- Fix in
mir.ndslice.topology.map
for 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.flattened
backwards compatible with LDC 1.2.0 for those who haven't upgraded - Added workaround in
mir.ndslice.algorithm.reduce
for DMD inlining bug for non-Windows x86-64 (LDC unaffected) mir.primitives.shape
now 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
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
Interpolation , Time-seres and more
New modules
mir.interpolation
mir.interpolation.linear
mir.interpolation.pchip
mir.timeseries
mir.ndslice.mutation
fortransposeInPlace
New functions for existing modules
mir.ndslice.topology: diff
mir.ndslice.topology: slide
mir.ndslice.algorithm: findIndex
mir.ndslice.algorithm: minPos, maxPos
mir.ndslice.algorithm: minIndex, maxIndex
mir.ndslice.algorithm: minmaxPos
mir.ndslice.algorithm: minmaxIndex
New features
- Syntax sugar for
indexed
andcartesian
v0.5.1 - Syntax sugar for map + RefTuple combination v0.5.0
- Specialisation for
map!"a"
.
Bug fixes
front!1
/back!1
was 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 RefTuple
s 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";