5 releases

0.1.4 Mar 15, 2024
0.1.3 May 1, 2023
0.1.2 Apr 13, 2023
0.1.1 Apr 8, 2023
0.1.0 Feb 18, 2023

#40 in No standard library

Download history 16942/week @ 2024-03-17 15563/week @ 2024-03-24 16176/week @ 2024-03-31 13954/week @ 2024-04-07 16065/week @ 2024-04-14 15271/week @ 2024-04-21 13367/week @ 2024-04-28 12393/week @ 2024-05-05 12113/week @ 2024-05-12 11855/week @ 2024-05-19 14243/week @ 2024-05-26 14934/week @ 2024-06-02 12783/week @ 2024-06-09 13777/week @ 2024-06-16 12216/week @ 2024-06-23 6557/week @ 2024-06-30

47,074 downloads per month
Used in 496 crates (via hexasphere)

MIT/Apache

82KB
2K SLoC

Const Linear Algebra

Crates.io

Do your math ahead of time and embed the result in the binary. Floating-point code is from compiler_builtins and libm via the const_soft_float crate. Uses const generics to check shape of inputs, and is no_std.

Please file an issue or make a test PR if your use case is not supported.

const START: CMatrix<2, 2> = CMatrix::new([
    [4.0, 1.0], 
    [2.0, 3.0]
]);

const ADD: CMatrix<2, 2> = CMatrix::new([
    [0.0, 6.0], 
    [0.0, 3.0]]
);

const EXPECTED: [[f64; 2]; 2] = [
    [0.6, -0.7], 
    [-0.2, 0.4]
];

const RESULT: [[f64; 2]; 2] = START
    .add(ADD)
    .pinv(f64::EPSILON)
    .finish();

for i in 0..2 {
    for j in 0..2 {
        assert!(float_equal(RESULT[i][j], EXPECTED[i][j], 1e-5));
    }
}

Dependencies

~165KB