rma/
lib.rs

1#![doc = r#"
2# R-Math Algorithms
3
4A Rust crate for rare, high-performance mathematical algorithms not commonly found in mainstream libraries aimed for practical use.
5
6## Features
7- Tonelli-Shanks: Modular square roots (r^2 ≡ n mod p) over prime moduli (constant-time version)
8- Cuthill-McKee & Reverse Cuthill-McKee: Bandwidth reduction for sparse symmetric matrices (adjacency list, CSR, and CSC formats)
9    - Supports conversion from `sprs` sparse matrix types
10- Freivalds' Algorithm: Fast probabilistic verification of matrix multiplication (scalar, modular, and SIMD-accelerated variants)
11
12- Well-documented, tested, and benchmarked implementations
13- SIMD acceleration for Freivalds' algorithm (nightly Rust required, `simd` feature)
14- `no_std` compatible (except for benchmarks and RNG)
15
16## Usage
17
18Add to your `Cargo.toml`:
19```toml
20[dependencies]
21rma = "0.1"
22```
23
24Enable SIMD features (nightly Rust required):
25```toml
26[dependencies]
27rma = { version = "0.1", features = ["simd"] }
28```
29
30## SIMD Feature
31- The `simd` feature enables SIMD-accelerated Freivalds' algorithm. Requires nightly Rust and the `portable_simd` feature.
32- On stable Rust, only scalar and modular versions are available.
33
34## Examples
35
36See the documentation for each algorithm.
37
38## License
39Licensed under either of
40- Apache License, Version 2.0
41- MIT license
42
43"#]
44#![cfg_attr(feature = "simd", feature(portable_simd))]
45
46pub mod freivalds;
47
48pub use freivalds::freivalds_verify_scalar;
49pub use freivalds::freivalds_verify_scalar_mod;
50#[cfg(feature = "simd")]
51pub use freivalds::freivalds_verify_simd;
52
53pub mod cuthill_mckee;
54pub use cuthill_mckee::{
55    CscMatrix, CsrMatrix, cuthill_mckee, cuthill_mckee_csc, cuthill_mckee_csr,
56    reverse_cuthill_mckee, reverse_cuthill_mckee_csc, reverse_cuthill_mckee_csr,
57};
58
59pub mod tonelli_shanks;
60pub use tonelli_shanks::{TonelliShanksError, tonelli_shanks_ct};
61
62pub mod berlekamp;