#linear-algebra #ndarray #matrix


Linear Algebra package with rust-ndarray interface

13 releases (5 breaking)

0.6.0 Apr 17, 2017
0.5.2 Apr 7, 2017
0.5.1 Mar 15, 2017
0.4.2 Nov 29, 2016
0.1.6 Nov 3, 2016

#76 in Math

Download history 16/week @ 2018-12-14 40/week @ 2018-12-21 10/week @ 2018-12-28 29/week @ 2019-01-04 18/week @ 2019-01-11 13/week @ 2019-01-18 13/week @ 2019-01-25 6/week @ 2019-02-01 2/week @ 2019-02-08 2/week @ 2019-02-15 16/week @ 2019-02-22 29/week @ 2019-03-01 3/week @ 2019-03-08 20/week @ 2019-03-15 75/week @ 2019-03-22

77 downloads per month

MIT license

2.5K SLoC



Crate Version Build Status Documentation


linxal is a linear algebra package for rust. linxal uses LAPACK as a backend, (specifically with the lapack package) to execute linear algebra routines with rust-ndarray as inputs and outputs.

Installation / Usage

linxal is available on crates.io and can be installed via cargo. In your Cargo.toml file, you can use.

linxal = "0.5"


linxal exposes features to choose the underlying LAPACK / BLAS source. By default, linxal enables the openblas feature, which compiles LAPACK and BLAS from the OpenBLAS distribution via openblas-src. You can use netlib LAPACK instead, via:

version = "0.5"
default-features = false
features = ["netlib"]

Other possible features are openblas-system and netlib-system. These are similar to openblas and netlib, execpt that they use the installed shared libraries on your system instead of compiling them from source.


Documentation can be found at https://github.masonium.io/rustdoc/linxal/.


extern crate linxal;
extern crate ndarray;

use linxal::types::{c32, LinxalMatrix};
use ndarray::{arr1, arr2};

fn main() {
	let m = arr2(&[[1.0f32, 2.0],
				   [-2.0, 1.0]]);

	let r = m.eigenvalues(false, false);

	let r = r.unwrap();
	let true_evs = arr1(&[c32::new(1.0, 2.0), c32::new(1.0, -2.0)]);
	assert_eq_within_tol!(true_evs, r.values, 0.01);

	let b = arr1(&[-1.0, 1.0]);
	let x = m.solve_linear(&b).unwrap();
	let true_x = arr1(&[-0.6, -0.2]);
	assert_eq_within_tol!(x, true_x, 0.0001);


  • Correctness: linxal will strive for correctness in all cases. Any function returning a non-Err result should return a correct result.

  • Ease of Use: linxal will provide a consistent interface and should require minimal setup. Most routine should be high-level and should require no knowledge of the underlying LAPACK routines.

    linxal will minimize surprising behaviour.

  • Documentation: linxal will strive to provide documentation for all functionality. Undocumented public features are a bug.

  • Ergonomics: linxal will try to minimize boilerplate whenever appropriate.

  • Speed


  • Low-dimension arithmetic: linxal is not specifically designed or optimized for {2,3,4}-D problems, as you would encounter in computer graphics, physics, or other domains. There are libraries such as nalgebra and cgmath that specialize in low-dimensional algorithms.

  • Representation flexibility: ndarray is the only for standard matrices, and future representations of specialized formats (packed triangular, banded, tridiagonal, etc.) will probably not allow for user-defined formats.


  • Major linear algebra routines
    • Eigenvalues
    • Singular Value
    • Linear Solvers
    • Linear Least-Squares
    • Matrix Factorizations (QR, LU, etc.)
      • QR
      • LU
      • Cholesky
      • Schur
    • Inversion
    • Generalized Eigenvalues
    • Generalized Singular Value Decomposition
  • Multiple matrix formats
    • General (direct via ndarray)
    • Symmetric / Hermitian
    • Banded (Packed)
  • Random matrix generation
    • General
    • Symmetric / Hermitian
    • Positive
    • Unitary


Pull requests of all kinds (code, documentation, formatting, spell-checks) are welcome!


~654K SLoC