#linear-algebra #matrix #vector-math #algebra #matrix-math #vector-matrix

no-std nalgebra

General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices

113 releases

0.33.2 Oct 29, 2024
0.33.0 Jun 23, 2024
0.32.5 Mar 28, 2024
0.32.3 Jul 9, 2023
0.1.0 Nov 22, 2014

#7 in Math

Download history 727358/week @ 2025-03-03 708443/week @ 2025-03-10 580630/week @ 2025-03-17 587966/week @ 2025-03-24 557094/week @ 2025-03-31 518980/week @ 2025-04-07 452588/week @ 2025-04-14 463912/week @ 2025-04-21 496603/week @ 2025-04-28 523815/week @ 2025-05-05 535616/week @ 2025-05-12 528069/week @ 2025-05-19 464940/week @ 2025-05-26 572437/week @ 2025-06-02 551268/week @ 2025-06-09 479795/week @ 2025-06-16

2,088,190 downloads per month
Used in 3,018 crates (1,122 directly)

Apache-2.0

2MB
36K SLoC

crates.io

crates.io

Users guide | Documentation


Linear algebra library for the Rust programming language.



lib.rs:

nalgebra

nalgebra is a linear algebra library written for Rust targeting:

  • General-purpose linear algebra (still lacks a lot of features…)
  • Real-time computer graphics.
  • Real-time computer physics.

Using nalgebra

You will need the last stable build of the rust compiler and the official package manager: cargo.

Simply add the following to your Cargo.toml file:

[dependencies]
// TODO: replace the * by the latest version.
nalgebra = "*"

Most useful functionalities of nalgebra are grouped in the root module nalgebra::.

However, the recommended way to use nalgebra is to import types and traits explicitly, and call free-functions using the na:: prefix:

#[macro_use]
extern crate approx; // For the macro assert_relative_eq!
extern crate nalgebra as na;
use na::{Vector3, Rotation3};

fn main() {
let axis  = Vector3::x_axis();
let angle = 1.57;
let b     = Rotation3::from_axis_angle(&axis, angle);

assert_relative_eq!(b.axis().unwrap(), axis);
assert_relative_eq!(b.angle(), angle);
}

Features

nalgebra is meant to be a general-purpose, low-dimensional, linear algebra library, with an optimized set of tools for computer graphics and physics. Those features include:

Dependencies

~1–5MB
~121K SLoC