Generic Numerical Library for Science and Machine Learning.
mir.ndslice
Multidimensional Random Access Ranges and Arraysmir.sparse
Sparse TensorsSparse
- DOK format- Different ranges for COO format
CompressedTensor
- CSR/CSC formatsmir.sparse.blas
- Sparse BLAS forCompressedTensor
mir.model.lda.hoffman
- Online variational Bayes for latent Dirichlet allocation (Online VB LDA) for sparse documents. LDA is used for topic modeling.mir.combinatorics
Combinations, combinations with repeats, cartesian power, permutations.mir.las.sum
Functions and Output Ranges for Summation Algorithms. Works with user-defined types.- Precise algorithm: improved analog of Python's
fsum
- Pairwise algorithm: fast version for Input Ranges
- Kahan, KBN, and KB2 algorithms
mir.blas
- this is slow snail, it is for experiments with BLAS API. Don't use for now.
mir.random
- non-uniform RNGs.mir.blas
- BLAS in D.
Alpha version of API is available here.
Linux | Mac OS X | Windows | |
---|---|---|---|
DMD 64 | |||
DMD 32 | OS X >= 10.7 is x86-64 only | ||
LDC 64 | #120 | ||
LDC 32 | OS X >= 10.7 is x86-64 only | #120 |
- DMD (reference D compiler) >=
2.068
- LDC (LLVM D Compiler)
0.17.0
+.
Dub is the D's package manager. You can create a new project with:
dub init --format=json <project-name>
Now you need to edit the dub.json
add mir
as dependency and set its targetType to executable
.
{
...
"dependencies": {
"mir": "~><current-version>"
},
"targetType": "executable"
}
Now you can create a main file in the source
and run your code with:
dub
You can use a different compile with dub --compiler ldc
.
For a performance boost, add -b release
to let the compiler perform additional
optimizations, inlining, removal of bound checking and assert
statements.
The easiest way to execute your code is with rdmd
.
rdmd -Isource examples/means_of_columns.d
rdmd
is a companion to the dmd
compiler that simplifies the typical edit-compile-link-run or edit-make-run cycle to a rapid edit-run cycle. Like make and other tools, rdmd
uses the relative dates of the files involved to minimize the amount of work necessary. Unlike make, rdmd
tracks dependencies and freshness without requiring additional information from the user.
You can find more information here.
The easiest way is to specify mir's sources during compilation:
ldc -Isource examples/means_of_columns.d
If you copy mir
's sources to /usr/include/dlang/ldc/mir
you don't even need the -Isource
include.
You might want to have a look at dynamic linking with dmd below - it works with ldc
too.
For an additional performance boost, you can pass -release -inline
to ldc
.
Warning: Manually using dmd
is a bit more complicated and if you are new
to DLang, we advise you to use either rdmd
, dub
or ldc
.
dmd -c -Isource examples/means_of_columns.d
If you do this more often, you probably want to install a Mir package or put the mir sources to /usr/include/dlang/dmd
.
Now you can either use static linking (will copy everything into the binary) or dynamic linking (will load binary on run) to create an executable.
Static linking will result in copying all library routines in your binary. While this might require more disk space, it is faster and more portable.
The only downside is that it requires recompilation if mir
is updated.
You need to create a static library of mir
once:
dmd -lib -oflibmir.a $(find source -name '*.d')
If you have dub
available, you can also use dub -c static-lib
.
dmd means_of_columns.o libmir.a
With dynamic linking the OS will bind the binary and it's required external shared libraries at runtime.
You need to create a shared, dynamic library of mir
once:
dmd -shared -oflibmir.so -defaultlib=libphobos2.so -fPIC $(find source -name '*.d')
We need to specify:
-defaultlib=libphobos2.so
as Phobos is statically linked by default.fPIC
to create Position Independent Code (it creates a global offset table)
If you have dub
available, you can also use dub -c dynamic-lib
.
dmd means_of_columns.o -Llibmir.so -L-rpath=.
You can inspect the dynamic linking with ldd means_of_columns
.
Putting mir
in /usr/include/dlang/dmd
, avoids the need for -Isource
.
So you can execute your code with rdmd <your-file.d>
Type | Name | Version |
---|---|---|
Stable | libmir |
|
Latest | libmir-git |
See our TODO List. Mir is very young and we are open for contributing to source code, documentation, examples and benchmarks.
mir.ndslice
is a development version of thestd.experimental.ndslice
package.