calculo

Crates.iocalculo
lib.rscalculo
version0.1.0
created_at2026-01-13 14:46:26.232404+00
updated_at2026-01-13 14:46:26.232404+00
descriptionNumeric types and operations for high-performance scientific computing.
homepage
repository
max_upload_size
id2040346
size83,687
Keeley Hoek (khoek)

documentation

README

calculo

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.

Features

  • 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.
  • Backend-agnostic: Write once, run with f64, rug::Rational, or dashu::RBig.

Backends

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

Example

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.

License

Licensed under AGPL-3.0-only. See LICENSE for details.

Commit count: 0

cargo fmt