Skip to main content

adele_ring/
lib.rs

1//! # adele-ring — exact multi-base arithmetic engine
2//!
3//! `adele-ring` represents numbers across multiple prime channels using the
4//! Residue Number System (RNS). Because the channels are mutually independent
5//! (no carry propagation), arithmetic is embarrassingly parallel and maps onto
6//! both CPU threads (rayon) and GPU threads (wgpu).
7//!
8//! On top of the RNS substrate sits a *number tower* that keeps every value at
9//! the cheapest exact level it can:
10//!
11//! | Level | Set      | Type                         |
12//! |-------|----------|------------------------------|
13//! | 0     | ℤ        | [`rns::RnsInt`]              |
14//! | 1     | ℚ        | [`rational::RnsRational`]    |
15//! | 2     | ℚ̄        | [`algebraic::AlgebraicNumber`] |
16//! | 3     | ℝ_c      | [`computable::ComputableReal`] |
17//! | 4     | 𝒮        | [`symbolic::SymbolicExpr`]   |
18//!
19//! The crate name uses a hyphen (`adele-ring`) but the Rust path uses an
20//! underscore (`adele_ring`), per Rust's identifier rules.
21
22/// Channel-count threshold above which single-value operations parallelize over
23/// channels with rayon. Below it, sequential is faster (task overhead ~50ns vs
24/// channel op ~1ns: break-even around 8–16 channels).
25pub const RAYON_CHANNEL_THRESHOLD: usize = 16;
26
27// ── Phase 1: parallelism foundation ──────────────────────────────────────────
28pub mod backend;
29pub mod batch;
30pub mod cpu;
31pub mod gpu;
32pub mod primes;
33pub mod rns;
34
35// ── Phase 2: the number tower ────────────────────────────────────────────────
36// (enabled incrementally as each module lands)
37pub mod algebraic;
38pub mod computable;
39pub mod dispatch;
40pub mod rational;
41pub mod symbolic;
42pub mod tower;
43
44pub use algebraic::{AlgebraicNumber, Polynomial};
45pub use backend::{executor, ArithmeticBackend, Executor};
46pub use batch::RnsBatch;
47pub use computable::{Computable, ComputableReal};
48pub use dispatch::{DispatchPlan, Dispatcher};
49pub use rational::RnsRational;
50pub use rns::{garner_crt, Channels, RnsInt};
51pub use symbolic::{IdentityGraph, SymbolicExpr};
52pub use tower::{TowerLevel, TowerValue};