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

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

#5 in Math

Download history 162736/week @ 2024-08-01 188557/week @ 2024-08-08 183506/week @ 2024-08-15 184565/week @ 2024-08-22 186946/week @ 2024-08-29 199552/week @ 2024-09-05 202617/week @ 2024-09-12 193047/week @ 2024-09-19 208562/week @ 2024-09-26 197609/week @ 2024-10-03 202192/week @ 2024-10-10 204816/week @ 2024-10-17 213035/week @ 2024-10-24 203847/week @ 2024-10-31 189078/week @ 2024-11-07 164382/week @ 2024-11-14

807,779 downloads per month
Used in 2,507 crates (951 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

~0.8–4.5MB
~101K SLoC