Numerical computing
for modern Python.
RMath runs heavy math in Rust and exposes it to Python via PyO3. All array operations, linear algebra, and statistics execute outside the GIL on a Rayon thread pool.
import rmath as rm
# Create a 1000ร1000 random matrix
data = rm.Array.randn(1000, 1000)
# Parallel stats โ runs outside the GIL
avg = data.mean()
std = data.std_dev()
# Solve a linear system
b = rm.Array.ones(1000, 1)
x = rm.linalg.solve(data, b)
Installation
Pre-built wheels are available for Windows, Linux, and macOS. No Rust toolchain required.
rmath-py on PyPI
but you import it as import rmath.
Quick Start
Vector math
import rmath.vector as rv
v = rv.Vector.linspace(0, 10, 1_000_000)
result = v.sin().exp().sum() # chained, parallel
# Operator overloading
v2 = v + 5.0
dot = v @ v2
Automatic differentiation
import rmath.calculus as rc
# f(x) = xยฒ + 3x, evaluated at x = 2
x = rc.Dual(2.0, 1.0)
y = x * x + x * 3.0
print(y.value) # 10.0
print(y.derivative) # 7.0 โ f'(x) = 2x + 3
Statistics
import rmath as rm
data = [2.4, 3.1, 2.8, 3.5, 2.9, 3.2]
report = rm.stats.describe(data)
# {'count': 6, 'mean': 2.98, 'variance': 0.14,
# 'std': 0.37, 'skewness': 0.04, 'kurtosis': -1.28}
Modules
Click any module to see the full API reference.
rmath.array
N-dimensional arrays with automatic storage tiering โ stack, heap, or memory-mapped.
rmath.vector
1-D parallel engine with 80+ operations: trig, sorting, filtering, complex numbers.
rmath.scalar
Precision f64 math โ 80+ functions that mirror and extend Python's math module.
rmath.linalg
Matrix solvers, decompositions (QR, SVD, Cholesky, Eigenvalue), rank, and pseudoinverse.
rmath.stats
Descriptive and inferential statistics โ T-tests, ANOVA, regression, distributions.
rmath.calculus
Automatic differentiation via dual numbers, numerical integration, root-finding.
rmath.geometry
Distance metrics, quaternions, cross products, convex hull, point-in-polygon.
rmath.signal
FFT, inverse FFT, convolution (full / same / valid modes), spectral analysis.
rmath.nn
Activations (GELU, Softmax), loss functions, normalization, pooling layers.
rmath.special
Gamma, log-gamma, and error functions with scalar, vector, and array dispatch.
rmath.constants
Mathematical constants (ฯ, e, ฯ) and machine-precision values (epsilon, max float).
Architecture
Python (rmath) โโPyO3โโโธ Rust core
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ
โผ โผ โผ
Stack Heap Mmap
(inline) (shared) (lazy I/O)
โ โ โ
โโโโ Rayon thread pool โโโ