mir-lapack — LAPACK Bindings for D
mir-lapack provides LAPACK (Linear Algebra PACKage) bindings for D with ndslice integration — eigenvalues, SVD, LU factorization, Cholesky, and linear system solvers.
📖 Full API reference → mir-lapack.libmir.org — every module and symbol of
mir-lapack, regenerated from current source.
mir-lapack provides D bindings to LAPACK routines with ndslice integration. Use it for decompositions (LU, QR, Cholesky, SVD), eigenvalue problems, and linear system solvers.
GitHub: libmir/mir-lapack
Install
// dub.sdl
dependency "mir-lapack" version="~>1.0"
dependency "mir-blas" version="~>1.0"
dependency "mir-algorithm" version="~>3.0"Requires a LAPACK implementation (OpenBLAS, MKL, or system LAPACK):
sudo apt-get install libopenblas-dev # includes LAPACKLU factorization and linear solve
import mir.lapack;
import mir.ndslice;
// Solve A * x = b
auto A = slice!double(3, 3);
auto b = slice!double(3);
// Fill A and b ...
// LU factorization (in-place)
auto ipiv = slice!int(3);
int info = getrf(A, ipiv); // A is now LU-factored in-place
// Solve using factored A
getrs('N', A, ipiv, b); // b is now the solution xCholesky factorization
For symmetric positive-definite matrices:
// Cholesky: A = L * L^T
int info = potrf('L', A); // A lower triangle holds L
// Solve A * x = b using Cholesky factor
potrs('L', A, b);Eigenvalues (symmetric matrix)
// All eigenvalues of symmetric A
auto w = slice!double(n); // output eigenvalues
auto work = slice!double(3 * n);
int info = dsyev('N', 'U', A, w, work);
// w now contains eigenvalues in ascending orderSVD — Singular Value Decomposition
auto A = slice!double(m, n);
auto s = slice!double(min(m, n)); // singular values
auto U = slice!double(m, m);
auto Vt = slice!double(n, n);
auto work = slice!double(max(1, 5 * min(m, n)));
int info = dgesv('A', 'A', A, s, U, Vt, work);Relationship to lubeck
mir-lapack is the low-level binding layer. lubeck wraps it with a simpler API:
| Task | mir-lapack (low-level) | lubeck (high-level) |
|---|---|---|
| Solve Ax=b | getrf + getrs | solve(A, b) |
| Eigenvalues | dsyev | eigvals(A) |
| SVD | dgesv | svd(A) |
| Inverse | getrf + getri | inv(A) |
| Least squares | dgels | mldivide(A, b) |
For most use cases, lubeck is the better entry point. Use mir-lapack directly when you need workspace control, specific storage layouts, or routines not exposed by lubeck.
Related guides
mir-blas — BLAS Bindings for D
mir-blas provides BLAS (Basic Linear Algebra Subprograms) bindings for D that accept ndslice directly, enabling high-performance matrix and vector operations without manual pointer management.
dcompute — GPU Computing for D
dcompute lets you write GPU compute kernels in D that compile to OpenCL and CUDA targets. Archive page — the library is no longer actively maintained.