#algebra #container #bit-fields

no-std bit-matrix

Library for bit matrices and vectors

13 releases (breaking)

0.9.0 Jul 7, 2025
0.8.1 Nov 17, 2024
0.8.0 Jun 26, 2024
0.6.1 Dec 31, 2021
0.0.1 Sep 7, 2015

#1074 in Algorithms

Download history 273/week @ 2026-02-13 189/week @ 2026-02-20 273/week @ 2026-02-27 455/week @ 2026-03-06 261/week @ 2026-03-13 252/week @ 2026-03-20 216/week @ 2026-03-27 980/week @ 2026-04-03 749/week @ 2026-04-10 1448/week @ 2026-04-17 1230/week @ 2026-04-24 735/week @ 2026-05-01 1115/week @ 2026-05-08 1010/week @ 2026-05-15 866/week @ 2026-05-22 1228/week @ 2026-05-29

4,283 downloads per month
Used in 22 crates (10 directly)

MIT/Apache

23KB
431 lines

bit-matrix

A compact matrix of bits.

crates.io Documentation Rust CI MSRV

Dependency Status Download Status

Rust library that implements bit matrices. You can check the documentation here.

Built on top of contain-rs/bit-vec.

Examples

This simple example calculates the transitive closure of 4x4 bit matrix.

use bit_matrix::BitMatrix;

fn main() {
    let mut matrix = BitMatrix::new(4, 4);
    let points = &[
        (0, 0),
        (0, 1),
        (0, 3),
        (1, 0),
        (1, 2),
        (2, 0),
        (2, 1),
        (3, 1),
        (3, 3),
    ];
    for &(i, j) in points {
        matrix.set(i, j, true);
    }
    matrix.transitive_closure();

    let mut expected_matrix = BitMatrix::new(4, 4);
    for i in 0..4 {
        for j in 0..4 {
            expected_matrix.set(i, j, true);
        }
    }

    assert_eq!(matrix, expected_matrix);
}

License

Dual-licensed for compatibility with the Rust project.

Licensed under the Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0, or the MIT license: http://opensource.org/licenses/MIT, at your option.

Dependencies

~100–280KB