#bit #container #algebra #bit-field

no-std bit-matrix

Library for bit matrices and vectors

12 releases (breaking)

0.8.1 Nov 17, 2024
0.8.0 Jun 26, 2024
0.7.1 May 9, 2024
0.6.1 Dec 31, 2021
0.0.1 Sep 7, 2015

#193 in Algorithms

Download history 786/week @ 2025-02-02 944/week @ 2025-02-09 878/week @ 2025-02-16 716/week @ 2025-02-23 466/week @ 2025-03-02 1718/week @ 2025-03-09 2051/week @ 2025-03-16 1497/week @ 2025-03-23 2550/week @ 2025-03-30 5868/week @ 2025-04-06 5563/week @ 2025-04-13 3203/week @ 2025-04-20 1926/week @ 2025-04-27 1528/week @ 2025-05-04 1676/week @ 2025-05-11 887/week @ 2025-05-18

6,087 downloads per month
Used in 19 crates (9 directly)

MIT/Apache

23KB
433 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

~98–295KB