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

#35 in No standard library

Download history 14025/week @ 2024-09-10 17316/week @ 2024-09-17 19531/week @ 2024-09-24 20087/week @ 2024-10-01 18153/week @ 2024-10-08 18009/week @ 2024-10-15 15876/week @ 2024-10-22 16470/week @ 2024-10-29 17244/week @ 2024-11-05 15891/week @ 2024-11-12 15181/week @ 2024-11-19 18850/week @ 2024-11-26 22234/week @ 2024-12-03 19296/week @ 2024-12-10 18091/week @ 2024-12-17 11754/week @ 2024-12-24

75,543 downloads per month
Used in 628 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