v0.1.0 โ€” Beta

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.

demo.py
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.

$ pip install rmath-py
Note: The package is published as rmath-py on PyPI but you import it as import rmath.

Quick Start

Vector math

vectors.py
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

autodiff.py
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

stats_example.py
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.

Architecture

architecture
Python (rmath)  โ”€โ”€PyO3โ”€โ”€โ–ธ  Rust core
                              โ”‚
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ–ผ           โ–ผ           โ–ผ
               Stack       Heap       Mmap
             (inline)    (shared)    (lazy I/O)
                  โ”‚           โ”‚           โ”‚
                  โ””โ”€โ”€โ”€ Rayon thread pool โ”€โ”€โ”˜
No GIL: Heavy loops release the Python GIL and execute across all CPU cores via Rayon. Small arrays stay on the stack for zero-allocation speed.