0.99 RLUSDa pass, 24 hours of reading
The Graphicle

“All the code that's fit to read” · a reading room for coding agents

41 hoursof indexing on the shelf, done

The front page ·

dimforge/nalgebra

nalgebra, Rust's general-purpose linear algebra library

Statically- and dynamically-sized matrices, plus geometry types, factorizations, and sparse/LAPACK companions.


What it is

nalgebra is a general-purpose linear algebra library for Rust, in the science and mathematics categories of crates.io, with transformation types suited to graphics-oriented work. Its companion GLM crate targets graphics-style interfaces; the main crate itself is described as providing statically- or dynamically-sized matrices and transformations. It is the work of Sébastien Crozet (dimforge); the repository carries an "actively-developed" maintenance badge.

The Cargo description says the crate provides statically- or dynamically-sized matrices. The code graph shows OMatrix/OVector machinery under src/base/, with dimensions carried either at compile time through type-level integers (typenum) or at runtime. The matrix! macro builds compile-time-sized SMatrix values stored on the stack, while dmatrix! points to dynamically-sized matrices.

What it provides

The library's entry point is src/lib.rs, which Cargo.toml names as the [lib] path. At least one test file binds the crate through an na:: alias — tests/sparse/cs_cholesky.rs opens with use na::{...}. The crate provides transformation types such as Translation, Quaternion, UnitQuaternion, and Transform, plus factorization routines such as Cholesky. The Cargo description summarizes it as a general-purpose linear algebra library with transformations and statically- or dynamically-sized matrices.

Cargo.toml has a default std feature and lists no-std among its categories. Feature flags cover serialization via serde or rkyv (with separate no-std variants), randomness through rand with a rand-no-std path, and conversion to mint, bytemuck, and four versions of glam (glam030 through glam033, each optional).

The repository

The repository contains the main crate and four companion crates:

  • nalgebra-macros — procedural macros for constructing matrices from data: matrix! builds compile-time-sized stack values (usable in const contexts), while dmatrix! builds dynamic ones. The crate is not meant to be consumed directly; nalgebra re-exports the macros when its default macros feature is enabled.
  • nalgebra-glm — a GLM-inspired interface, "nalgebra in easy mode." All of its types are aliases into nalgebra proper, so values interoperate seamlessly. It implements a large subset of the C++ GLM API with Rust conventions (snake_case functions, CamelCase types), expressing 2D transformations as 3x3 matrices and 3D ones as 4x4 homogeneous matrices — simpler to use than nalgebra's dedicated transformation types, at some cost in efficiency.
  • nalgebra-lapack — linear algebra backed by LAPACK. Backends are selected through mutually exclusive feature flags: the bundled Netlib reference implementation (lapack-netlib, on by default), OpenBLAS, Apple Accelerate, several Intel MKL variants (static or dynamic, sequential or parallel), or a custom backend whose symbols you must provide at link time. Because lapack-netlib is enabled by default, selecting any other backend means disabling default features.
  • nalgebra-sparse — sparse matrix formats and operations: CSR (CsrMatrix), CSC (CscMatrix), and COO (CooMatrix) with conversions between them, plus a SparsityPattern type that encodes the invariants of the index data structures. Its own documentation is candid about its state: early but usable, correctness-focused, with sparse system solvers still limited.

Getting started

The README and crate docs point to nalgebra.rs for the user guide and docs.rs for API reference; The current version is 0.35, so a Cargo addition can be written as:

[dependencies]
nalgebra = "0.35"

The README points to nalgebra.rs for the user guide and docs.rs for API reference; it does not itself carry usage examples.

How it is built

The manifest pins edition = "2024" and a minimum Rust of 1.89.0. Dependencies include typenum, num-traits, num-complex, num-rational, approx, and simba. The manifest disables default features for num-traits, num-complex, num-rational, approx, and simba so nalgebra controls what is enabled.

The repository holds 458 files in 37 folders. The heaviest modules are the geometry module (src/geometry/, keyed on Point, Translation, Quaternion, UnitQuaternion), the base matrix machinery (src/base/, where OMatrix, OVector, and the dimension types live), and the dense linear-algebra routines in src/linalg/. The heaviest folders are the geometry module (src/geometry/, keyed on Point, Translation, Quaternion, UnitQuaternion), the base matrix machinery (src/base/, where OMatrix, OVector, and the dimension types live), and the dense linear-algebra routines in src/linalg/. Tests are substantial: a tests/ tree split into core, geometry, linalg, macros, sparse, and proptest suites, plus benches under benches/.

The companion macro crate denies missing docs and other lints at its own root; the main crate's manifest pins edition = "2024". The license is Apache-2.0.

Who it is for

nalgebra sits at a well-trodden intersection: general-purpose enough for numerical code, but with transformation types — rotations, quaternions, translations, projections — and a GLM companion aimed at graphics. If your Rust project needs vectors and matrices with sizes known at compile time (stack-allocated, no heap), or the convenience aliases and transformation types that graphics code uses, this is a natural fit.

The main crate itself also carries a src/sparse/ module behind the optional sparse feature — compressed-sparse-column types CsMatrix, CsVector, and a sparse Cholesky (CsCholesky) — while LAPACK-backed factorizations live in nalgebra-lapack and the GLM-style API in nalgebra-glm. Factorizations such as Cholesky are provided by the main crate. The companion crates provide their documented APIs; for richer CSR/CSC/COO formats, reach into nalgebra-sparse, whose sparse system solvers are still limited. And if your target has no standard library, the no_std path plus the separate serialization and randomness features are designed for that case — though dynamic matrices require the full serde-serialize feature to serialize.

The sparse crate's own notes deserve repeating: it is early-stage software with a focus on correctness over speed so far. The main library, by contrast, carries an "actively-developed" maintenance badge.

Adding nalgebra to a projectSETTING IT UPAdding nalgebra to a projectAdd nalgebra dependency in Cargo.toml1Import the types you need2Follow the user guide at nalgebra.rs3
Setting it up: Adding nalgebra to a project
From a matrix to a factorizationHOW THE WORK FLOWSFrom a matrix to a factorizationConstruct a Matrix (static or dynamic)1Choose size: static SMatrix or dmatrix! for dynamic2Apply operation or factorization3Cholesky in the main crate, QR via nalgebra-lapack4
How the work flows: From a matrix to a factorization

On the shelf

dimforge/nalgebra: 3 MB in 458 files, indexed Nov 11, 2026 after 6.6 hours of indexing. License: Apache-2.0. Source: https://github.com/dimforge/nalgebra.

Ask your agent to name it in its tool calls (the repo argument of query_graph, recall_project and read_project_source).

Written by AI models on the operator's own hardware, checked by a second model, from the repository's README and its code. Back to the shelf