| Crates.io | rma |
| lib.rs | rma |
| version | 0.4.0 |
| created_at | 2025-05-28 14:46:25.18237+00 |
| updated_at | 2025-07-17 01:02:59.784713+00 |
| description | Rare, high-performance mathematical algorithms for Rust. |
| homepage | https://github.com/bogwi/r-math |
| repository | https://github.com/bogwi/r-math |
| max_upload_size | |
| id | 1692860 |
| size | 251,351 |
A Rust crate for rare, high-performance mathematical algorithms not commonly found in mainstream libraries.
Chakravala method: Solves Pell's equation x² - Dy² = 1 for a given non-square integer D.
Berlekamp's Algorithm: Factorization of polynomials over finite fields (GF(p))
berlekamp_roots_dense_deg256_p64b time: [14.323 ms 14.345 ms 14.366 ms]
berlekamp_roots_sparse_deg256_p64b time: [15.582 ms 15.609 ms 15.635 ms]
Tonelli-Shanks: Modular square roots (r^2 ≡ n mod p) over prime moduli (constant-time version)
Cuthill–McKee & Reverse Cuthill–McKee: Bandwidth reduction for sparse symmetric matrices (adjacency list, CSR, and CSC formats)
sprs sparse matrix typesFast Minimum Degree Algorithm: Exact elimination ordering for sparse matrices with O(nm) complexity
Freivalds' Algorithm: Fast probabilistic verification of matrix multiplication (scalar, modular, and SIMD-accelerated variants)
Well-documented, tested, and benchmarked implementations
SIMD acceleration for Freivalds' algorithm (nightly Rust required)
Add to your Cargo.toml:
[dependencies]
rma = "0.3"
Enable SIMD features (nightly Rust required):
[dependencies]
rma = { version = "0.3", features = ["simd"] }
Benchmarks are provided using criterion in the benches/ directory.
On stable Rust:
cargo bench
cargo bench --bench freivalds_bench
On nightly Rust (to enable SIMD):
cargo bench --features simd
cargo bench --bench freivalds_bench --features simd
becnhes naming convention is filename with the _bench suffix; you check all in Cargo.toml
On stable Rust:
cargo test
On nightly Rust (to enable SIMD tests):
cargo test --features simd
#![feature(portable_simd)])This crate will be updated with new algorithms over time, focusing on rare, advanced, or otherwise unported mathematical algorithms.
Licensed under either of
r-math aims to be a home for rare, advanced, and high-performance mathematical algorithms in Rust.