| Crates.io | calculo |
| lib.rs | calculo |
| version | 0.1.0 |
| created_at | 2026-01-13 14:46:26.232404+00 |
| updated_at | 2026-01-13 14:46:26.232404+00 |
| description | Numeric types and operations for high-performance scientific computing. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2040346 |
| size | 83,687 |
Pluggable numeric traits for exact and approximate arithmetic. Built for algorithms that need to swap between fast floats and arbitrary-precision rationals without changing application code.
Num trait: Unified interface for f64, arbitrary-precision rationals, and floats.Int trait: Exact integer ops for fraction-free (Bareiss) pivoting and product comparisons.Rat trait: Those Nums which conveniently decompose into numerator/denominator pairs.f64, rug::Rational, or dashu::RBig.| Feature | Types | Notes |
|---|---|---|
- / simd |
f64 |
Native floats / optional SIMD-acceleration via pulp |
rug |
RugRat, RugFloat<P: usize> |
GMP-backed arbitrary precision |
dashu |
DashuRat, DashuFloat<P: usize> |
Pure-Rust arbitrary precision |
use calculo::num::{Num, Epsilon};
fn normalize<N: Num>(v: &mut [N]) {
let scale = v.iter().map(|x| x.abs()).fold(N::zero(), |a, b| if b > a { b } else { a });
N::div_slice_assign(v, &scale);
}
Switch precision by changing the type parameter---no algorithm changes required.
Licensed under AGPL-3.0-only. See LICENSE for details.