4 releases

0.1.3 May 1, 2023
0.1.2 Apr 13, 2023
0.1.1 Apr 8, 2023
0.1.0 Feb 18, 2023

#66 in No standard library

Download history 2556/week @ 2023-06-09 3273/week @ 2023-06-16 2796/week @ 2023-06-23 2306/week @ 2023-06-30 6823/week @ 2023-07-07 8032/week @ 2023-07-14 8076/week @ 2023-07-21 6733/week @ 2023-07-28 6207/week @ 2023-08-04 8216/week @ 2023-08-11 7291/week @ 2023-08-18 7556/week @ 2023-08-25 6089/week @ 2023-09-01 7623/week @ 2023-09-08 9059/week @ 2023-09-15 6969/week @ 2023-09-22

30,755 downloads per month
Used in 188 crates (via hexasphere)

MIT/Apache

78KB
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