9 releases (5 breaking)

0.18.0 Nov 6, 2025
0.17.0 Jan 29, 2025
0.16.0 Oct 4, 2022
0.15.0 Aug 30, 2022
0.1.0 Feb 13, 2021

#1544 in Algorithms

Download history 9941/week @ 2025-10-27 14196/week @ 2025-11-03 43846/week @ 2025-11-10 34063/week @ 2025-11-17 11619/week @ 2025-11-24 14234/week @ 2025-12-01 19984/week @ 2025-12-08 16764/week @ 2025-12-15 8369/week @ 2025-12-22 5951/week @ 2025-12-29 14274/week @ 2026-01-05 14444/week @ 2026-01-12 13848/week @ 2026-01-19 11440/week @ 2026-01-26 14962/week @ 2026-02-02 14246/week @ 2026-02-09

55,141 downloads per month
Used in 133 crates (7 directly)

MIT/Apache

175KB
4K SLoC

Safe Rust wrapper for LAPACK without external dependency.

[Lapack] trait

This crates provides LAPACK wrapper as a traits. For example, LU decomposition of general matrices is provided like:

pub trait Lapack {
    fn lu(l: MatrixLayout, a: &mut [Self]) -> Result<Pivot>;
}

see [Lapack] for detail. This trait is implemented for [f32], [f64], [c32] which is an alias to num::Complex<f32>, and [c64] which is an alias to num::Complex<f64>. You can use it like f64::lu:

use lax::{Lapack, layout::MatrixLayout, Transpose};

let mut a = vec![
  1.0, 2.0,
  3.0, 4.0
];
let mut b = vec![1.0, 2.0];
let layout = MatrixLayout::C { row: 2, lda: 2 };
let pivot = f64::lu(layout, &mut a).unwrap();
f64::solve(layout, Transpose::No, &a, &pivot, &mut b).unwrap();

When you want to write generic algorithm for real and complex matrices, this trait can be used as a trait bound:

use lax::{Lapack, layout::MatrixLayout, Transpose};

fn solve_at_once<T: Lapack>(layout: MatrixLayout, a: &mut [T], b: &mut [T]) -> Result<(), lax::error::Error> {
  let pivot = T::lu(layout, a)?;
  T::solve(layout, Transpose::No, a, &pivot, b)?;
  Ok(())
}

There are several similar traits as described below to keep development easy. They are merged into a single trait, [Lapack].

Linear equation, Inverse matrix, Condition number

According to the property input metrix, several types of triangular decomposition are used:

  • [solve] module provides methods for LU-decomposition for general matrix.
  • [solveh] module provides methods for Bunch-Kaufman diagonal pivoting method for symmetric/Hermitian indefinite matrix.
  • [cholesky] module provides methods for Cholesky decomposition for symmetric/Hermitian positive dinite matrix.

Eigenvalue Problem

According to the property input metrix, there are several types of eigenvalue problem API

  • [eig] module for eigenvalue problem for general matrix.
  • [eig_generalized] module for generalized eigenvalue problem for general matrix.
  • [eigh] module for eigenvalue problem for symmetric/Hermitian matrix.
  • [eigh_generalized] module for generalized eigenvalue problem for symmetric/Hermitian matrix.

Singular Value Decomposition

  • [svd] module for singular value decomposition (SVD) for general matrix
  • [svddc] module for singular value decomposition (SVD) with divided-and-conquer algorithm for general matrix
  • [least_squares] module for solving least square problem using SVD

Linear Algebra eXtension (LAX)

crates.io docs.rs

ndarray-free safe Rust wrapper for LAPACK FFI for implementing ndarray-linalg crate. This crate responsibles for

  • Linking to LAPACK shared/static libraries
  • Dispatching to LAPACK routines based on scalar types by using Lapack trait

Dependencies

~73MB
~1M SLoC