mir-algorithm 0.7.0-alpha8

Multidimensional arrays (ndslice), ranges, iterators, and algorithms for Dlang


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Bountysource Gitter codecov.io Circle CI

Dub downloads Dub downloads License Latest version

Mir Algorithm

Dlang core library for math, finance and a home for Dlang multidimensional array package - ndslice.

Blogs
Example (3 sec)
import mir.ndslice;

auto matrix = slice!double(3, 4);
matrix[] = 0;
matrix.diagonal[] = 1;

auto row = matrix[2];
row[3] = 6;
assert(matrix[2, 3] == 6); // D & C index order
Example (30 sec)
import mir.ndslice;
import std.stdio: writefln;

enum fmt = "%(%(%.2f %)\n%)\n";

// Magic sqaure. 
// `a` is lazy, each element is computed on-demand.
auto a = magic(5).as!float;
writefln(fmt, a);

// 5x5 grid on sqaure [1, 2] x [0, 1] with values x * x + y. 
// `b` is lazy, each element is computed on-demand.
auto b = linspace!float([5, 5], [1f, 2f], [0f, 1f]).map!"a * a + b";
writefln(fmt, b);

// allocate a 5 x 5 contiguous matrix
auto c = slice!float(5, 5);

c[] = transposed(a + b / 2); // no memory allocations here
    // 1. b / 2 - lazy element-wise operation with scalars
    // 2. a + (...) - lazy element-wise operation with other slices
        // Both slices must be `contiguous` or one-dimensional.
    // 3. transposed(...) - trasposes matrix view. The result is `universal` (numpy-like) matrix.
    // 5. c[] = (...) -- performs element-wise assignment.
writefln(fmt, c);

Our sponsors

<img src="https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/symmetry.png" height="80" />         <img src="https://raw.githubusercontent.com/libmir/mir-algorithm/master/images/kaleidic.jpeg" height="80" />

Authors:
Ilya Yaroshenko, Andrei Alexandrescu, Walter Bright, Phobos developers (see information per file)
Dependencies:
none
Versions:
0.7.0-alpha8 2017-Oct-31
0.7.0-alpha7 2017-Oct-30
0.7.0-alpha6 2017-Oct-28
0.7.0-alpha5 2017-Oct-27
0.7.0-alpha4 2017-Oct-27
Show all 104 versions
Download Stats:
  • 12 downloads today

  • 269 downloads this week

  • 2129 downloads this month

  • 9782 downloads total