Amari v0.16.0
Comprehensive Mathematical Computing Platform with Geometric Algebra, Differential Calculus, Measure Theory, Probability Theory, Functional Analysis, Algebraic Topology, and Vector Symbolic Architectures
A unified mathematical computing library featuring geometric algebra, differential calculus, measure theory, probability theory on geometric spaces, functional analysis (Hilbert spaces, operators, spectral theory), algebraic topology (homology, persistent homology, Morse theory), relativistic physics, tropical algebra, automatic differentiation, holographic associative memory (Vector Symbolic Architectures), optical field operations for holographic displays, and information geometry. The library provides multi-GPU infrastructure with intelligent workload distribution and complete WebAssembly support for browser deployment.
Live Examples Suite | API Documentation
Features
Core Mathematical Systems
- Geometric Algebra (Clifford Algebra): Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
- Differential Calculus: Unified geometric calculus with scalar/vector fields, gradients, divergence, curl, and Lie derivatives
- Measure Theory: Sigma-algebras, measurable functions, integration on geometric spaces, and probability measures
- Probability Theory: Distributions on multivector spaces, stochastic processes, MCMC sampling, and Bayesian inference
- Functional Analysis: Hilbert spaces, bounded operators, spectral decomposition, eigenvalue algorithms, and Sobolev spaces
- Algebraic Topology: Simplicial complexes, homology computation, persistent homology (TDA), Morse theory, and fiber bundles
- Vector Symbolic Architectures: Holographic Reduced Representations (HRR), binding algebras, and associative memory
- Optical Field Operations: GA-native Lee hologram encoding for DMD displays, rotor field algebra, and VSA on optical wavefronts
- Relativistic Physics: Complete spacetime algebra (Cl(1,3)) with Minkowski signature for relativistic calculations
- Tropical Algebra: Max-plus semiring operations for optimization and neural network applications
- Automatic Differentiation: Forward-mode AD with dual numbers for exact derivatives
- Fusion Systems: Tropical-dual-Clifford fusion combining three algebraic systems
- Information Geometry: Statistical manifolds, KL/JS divergences, and Fisher information
- Optimization: Gradient-based optimization with geometric constraints
- Network Analysis: Geometric network analysis and graph neural networks
- Cellular Automata: Geometric automata with configurable rules
- Enumerative Geometry: Algebraic curves and enumerative computations
Multi-GPU Infrastructure
- Multi-GPU Architecture: Infrastructure supporting up to 8 GPUs with intelligent workload distribution
- Advanced Load Balancing: Five strategies including Balanced, CapabilityAware, MemoryAware, LatencyOptimized, and Adaptive
- Performance Profiling: Timeline analysis with microsecond precision and automatic bottleneck detection
- Comprehensive Benchmarking: Production-ready validation across all mathematical domains
- Graceful Degradation: Automatic fallback to single GPU or CPU when multi-GPU unavailable
Platform Support
- Native Rust: High-performance execution with rug (GMP/MPFR) backend for high-precision arithmetic
- WebAssembly: Full-featured WASM bindings with dashu backend for browser compatibility
- GPU Acceleration: WebGPU support for large-scale parallel computations
- TypeScript Support: Complete TypeScript definitions included
- Cross-Platform: Linux, macOS, Windows, browsers, Node.js, and edge computing environments
Installation
Rust Crates
Add to your Cargo.toml:
[]
# Complete library with all features
= "0.16.0"
# Or individual crates:
# Core geometric algebra and mathematical foundations
= "0.16.0"
# Differential calculus with geometric algebra
= "0.16.0"
# Measure theory and integration
= "0.16.0"
# Probability theory on geometric algebra spaces
= "0.16.0"
# Functional analysis: Hilbert spaces, operators, spectral theory
= "0.16.0"
# Algebraic topology: homology, persistent homology, Morse theory
= "0.16.0"
# Vector Symbolic Architectures, holographic memory, and optical fields
= "0.16.0"
# High-precision relativistic physics
= { = "0.16.0", = ["high-precision"] }
# GPU acceleration (includes optical field GPU operations)
= "0.16.0"
# Optimization algorithms
= "0.16.0"
# Additional mathematical systems
= "0.16.0"
= "0.16.0"
= "0.16.0"
= "0.16.0"
= "0.16.0"
= "0.16.0"
= "0.16.0"
JavaScript/TypeScript (WebAssembly)
Or with yarn:
Quick Start
Rust: Geometric Algebra
use ;
// 3D Euclidean Clifford algebra Cl(3,0,0)
type Cl3 = ;
// Create basis vectors
let e1: Cl3 = e1;
let e2: Cl3 = e2;
// Geometric product: e1 * e2 = e1 ∧ e2 (bivector)
let e12 = e1.geometric_product;
// Create rotor for 90° rotation in xy-plane
let rotor = from_bivector;
// Apply rotation: e1 → e2
let rotated = rotor.apply;
Rust: Differential Calculus
use ;
use Multivector;
// Define a scalar field f(x,y,z) = x² + y² + z²
let field = new;
// Compute gradient at a point
let point = ;
let gradient = field.gradient;
// Define a vector field
let vector_field = new;
// Compute divergence and curl
let derivative = new;
let div = derivative.divergence;
let curl = derivative.curl;
Rust: Tropical Algebra
use TropicalNumber;
// Create tropical numbers using the constructor
let a = new;
let b = new;
// Tropical operations
let sum = a.tropical_add; // max(3, 5) = 5
let product = a.tropical_mul; // 3 + 5 = 8
// Access values
println!;
println!;
// Tropical identities
let zero = tropical_zero; // -∞ (additive identity)
let one = tropical_one; // 0 (multiplicative identity)
Rust: Automatic Differentiation
use DualNumber;
// Create dual number for differentiation
// f(x) = x² at x = 3, with seed derivative 1
let x = new;
// Compute f(x) = x²
let result = x * x;
// Extract value and derivative
println!; // 9.0
println!; // 6.0
// For constants (derivative = 0)
let c = constant;
let scaled = x * c; // 2x, derivative = 2
Rust: Tropical-Dual-Clifford Fusion
use TropicalDualClifford;
// Create from logits (common in ML applications)
let logits = vec!;
let tdc = from_logits;
// Evaluate using all three algebras simultaneously
let other = from_logits;
let evaluation = tdc.evaluate;
// Extract features from each algebra
let tropical_features = tdc.extract_tropical_features; // Fast path-finding
let dual_features = tdc.extract_dual_features; // Automatic gradients
// Perform sensitivity analysis
let sensitivity = tdc.sensitivity_analysis;
let most_sensitive = sensitivity.most_sensitive;
println!;
println!;
Rust: Vector Symbolic Architectures (Holographic Memory)
use ;
// Create holographic memory with 256-dimensional vectors
let mut memory: = new;
// Generate random keys and values
let key1 = random;
let value1 = random;
// Store key-value associations via superposition
memory.store;
let key2 = random;
let value2 = random;
memory.store;
// Retrieve with a query key
let retrieved = memory.retrieve;
println!;
// Binding operations for role-filler structures
let bound = key1.bind; // key ⊛ value
let recovered = bound.unbind; // Approximately recovers value1
println!;
// Resonator network for cleanup/factorization
use Resonator;
let codebook = vec!;
let resonator = new;
let noisy = retrieved.clone; // Noisy retrieval
let cleaned = resonator.cleanup; // 10 iterations
Rust: Optical Field Operations (Lee Hologram Encoding)
use ;
// Create optical rotor fields (phase + amplitude on a 2D grid)
let field_a = random;
let field_b = random;
let uniform = uniform;
println!;
println!;
// Lee hologram encoding for DMD display
let config = new; // carrier frequency = 0.25
let encoder = new;
let hologram = encoder.encode;
println!;
// Get binary data for hardware interface (bit-packed)
let binary_data = hologram.as_bytes;
println!;
// VSA operations on optical fields
let algebra = new;
// Bind two fields (rotor multiplication = phase addition)
let bound = algebra.bind;
// Compute similarity between fields
let similarity = algebra.similarity; // Self-similarity ≈ 1.0
println!;
// Unbind to retrieve original field
let retrieved = algebra.unbind;
let retrieval_sim = algebra.similarity;
println!;
// Seed-based symbol codebook for reproducible VSA
let mut codebook = new;
codebook.register;
codebook.register;
codebook.register;
let agent_field = codebook.get;
let action_field = codebook.get;
println!;
// Tropical operations for attractor dynamics
let tropical = new;
let tropical_sum = tropical.tropical_add; // Pointwise min phase
let phase_distance = tropical.phase_distance;
println!;
Rust: Functional Analysis (Hilbert Spaces & Spectral Theory)
use ;
use MatrixOperator;
use spectral_decompose;
// Create the Hilbert space Cl(2,0,0) ≅ ℝ⁴
let space: = new;
// Create orthogonal elements
let x = space.from_coefficients.unwrap;
let y = space.from_coefficients.unwrap;
// Inner product and norm
let ip = space.inner_product; // 0.0 (orthogonal)
let norm_x = space.norm; // √5
// Create a symmetric matrix operator (Hamiltonian)
let hamiltonian = diagonal.unwrap;
// Spectral decomposition: H = Σᵢ λᵢ Pᵢ
let spectral = spectral_decompose.unwrap;
let eigenvalues = spectral.eigenvalues;
println!;
// Functional calculus: compute e^{-βH} for thermal states
let beta = 0.5;
let thermal = spectral.apply_function;
Rust: Algebraic Topology (Homology & Persistent Homology)
use ;
// Build a simplicial complex (hollow tetrahedron = 2-sphere)
let mut sphere = new;
sphere.add_simplex;
sphere.add_simplex;
sphere.add_simplex;
sphere.add_simplex;
// Compute Betti numbers
let betti = sphere.betti_numbers;
assert_eq!; // 1 connected component
assert_eq!; // No 1D holes
assert_eq!; // 1 void (sphere encloses space)
// Euler characteristic: χ = V - E + F = 4 - 6 + 4 = 2
assert_eq!;
// Persistent homology for topological data analysis
let mut filt = new;
filt.add; // Points born at t=0
filt.add;
filt.add;
filt.add; // Edge connects 0-1 at t=1
filt.add; // Edge connects 1-2 at t=2
filt.add; // Closes loop at t=3
let ph = compute.unwrap;
let betti_t3 = ph.diagram.betti_at;
// At t=3.5: 1 component (β₀=1), 1 loop (β₁=1)
Rust: Probability on Geometric Algebra
use ;
use ;
// Gaussian distribution on Cl(3,0,0) - 8-dimensional multivector space
let gaussian = standard;
// Draw samples
let mut rng = thread_rng;
let sample = gaussian.sample;
println!;
// Evaluate log-probability
let log_p = gaussian.log_prob.unwrap;
println!;
// Grade-concentrated distribution (e.g., only on bivectors)
let bivector_dist = grade_concentrated.unwrap;
// Geometric Brownian Motion on multivector space
let gbm = new; // drift=0.1, volatility=0.2
let path = gbm.sample_path.unwrap;
println!;
// MCMC sampling with Metropolis-Hastings
use MetropolisHastings;
let sampler = new; // step_size=0.5
let samples = sampler.sample_n;
println!;
JavaScript/TypeScript: Mathematical Computing
import init, { WasmMultivector, WasmTropicalNumber, WasmDualNumber } from '@justinelliottcobb/amari-wasm';
async function main() {
// Initialize the WASM module
await init();
// Geometric Algebra: Create and rotate vectors
const e1 = WasmMultivector.basisVector(0);
const e2 = WasmMultivector.basisVector(1);
const bivector = e1.geometricProduct(e2);
console.log('Geometric product:', bivector.toString());
// Tropical Algebra: Neural network operations
const trop1 = WasmTropicalNumber.new(3.0);
const trop2 = WasmTropicalNumber.new(5.0);
const sum = trop1.tropicalAdd(trop2); // max(3, 5) = 5
const product = trop1.tropicalMul(trop2); // 3 + 5 = 8
console.log('Tropical operations:', sum.getValue(), product.getValue());
// Automatic Differentiation: Compute derivatives
const x = WasmDualNumber.new(2.0, 1.0);
const xSquared = x.mul(x); // f(x) = x², f'(x) = 2x
console.log('f(2) =', xSquared.getValue(), "f'(2) =", xSquared.getDerivative());
// Clean up WASM memory
e1.free(); e2.free(); bivector.free();
trop1.free(); trop2.free(); sum.free(); product.free();
x.free(); xSquared.free();
}
main();
Architecture
Crate Hierarchy
Domain Crates (provide mathematical APIs):
amari-core: Core Clifford algebra types and CPU implementationsamari-measure: Measure theory, sigma-algebras, and integrationamari-calculus: Differential calculus with geometric algebraamari-probabilistic: Probability distributions on multivector spaces, stochastic processes, MCMCamari-functional: Hilbert spaces, bounded operators, spectral decomposition, Sobolev spacesamari-topology: Algebraic topology, simplicial complexes, persistent homology, Morse theoryamari-holographic: Vector Symbolic Architectures (VSA), binding algebras, holographic memory, optical field operationsamari-tropical: Tropical (max-plus) algebra for optimizationamari-dual: Dual numbers for automatic differentiationamari-fusion: Unified Tropical-Dual-Clifford systemamari-info-geom: Information geometry and statistical manifoldsamari-automata: Cellular automata with geometric algebraamari-network: Graph neural networks and network analysisamari-relativistic: Spacetime algebra and relativistic physicsamari-enumerative: Enumerative geometry and algebraic curvesamari-optimization: Gradient-based optimization algorithmsamari-flynn: Probabilistic verification contracts
Integration Crates (consume domain APIs):
amari-gpu: Multi-GPU acceleration with WebGPUamari-wasm: WebAssembly bindings for TypeScript/JavaScriptamari: Umbrella crate re-exporting all features
Key Types
// Multivector in Clifford algebra Cl(P,Q,R)
// P: positive signature, Q: negative signature, R: zero signature
// Tropical numbers (max-plus semiring)
// Use TropicalNumber::new(value)
// Dual numbers for automatic differentiation
// Use DualNumber::new(value, derivative)
// Multi-variable dual numbers
// Use MultiDualNumber::new(value, gradients)
// Tropical-Dual-Clifford unified system
// Common algebras
type Cl3 = ; // 3D Euclidean
type Spacetime = ; // Minkowski spacetime
type PGA3D = ; // Projective Geometric Algebra
Mathematical Foundation
Clifford Algebra Cl(P,Q,R)
- P: Basis vectors with e²ᵢ = +1 (positive signature)
- Q: Basis vectors with e²ᵢ = -1 (negative signature)
- R: Basis vectors with e²ᵢ = 0 (degenerate)
ab = a·b + a∧b // Geometric product = inner + outer product
Tropical Algebra (Max-Plus)
a ⊕ b = max(a, b) // Tropical addition
a ⊙ b = a + b // Tropical multiplication
Applications: Path optimization, sequence decoding, dynamic programming
Dual Numbers
a + εb where ε² = 0
(a + εb) + (c + εd) = (a + c) + ε(b + d)
(a + εb) × (c + εd) = ac + ε(ad + bc)
Applications: Automatic differentiation, gradient computation
Information Geometry
- Fisher Information Metric: Riemannian metric on statistical manifolds
- α-Connections: Generalized connections parameterized by α ∈ [-1,1]
- Dually Flat Manifolds: Manifolds with e-connection (α=+1) and m-connection (α=-1)
- Bregman Divergences: Information-geometric divergences
v0.12.0 Breaking Changes
Version 0.12.0 introduced significant API improvements for better encapsulation:
TropicalNumber
// Before (v0.11.x)
let a = TropicalNumber;
let value = a.0;
let sum = a.tropical_add;
// After (v0.12.0+)
let a = new;
let value = a.value;
let sum = a.tropical_add; // Now takes reference
DualNumber
// Before (v0.11.x)
let x = DualNumber ;
let value = x.real;
// After (v0.12.0+)
let x = new;
let value = x.value;
let deriv = x.derivative;
See MIGRATION_v0.12.0.md for complete migration guide.
Interactive Examples Suite
The Amari Examples Suite provides comprehensive interactive documentation:
-
Live Visualizations: 7 interactive visualizations demonstrating mathematical concepts
- Multivector coefficient manipulation in Cl(3,0,0)
- Tropical algebra operations with convergence animation
- Dual numbers with real-time derivative curves
- Rotor-based 3D rotations
- Fisher information on probability simplex
- MCMC sampling visualization
- Interactive geometric networks
-
Comprehensive API Reference: 77 classes with 300+ methods fully documented
- Geometric Algebra (Multivector, Rotor, Bivector)
- Tropical Algebra (TropicalNumber, TropicalMatrix)
- Automatic Differentiation (DualNumber, MultiDualNumber)
- Probability (GaussianMultivector, MCMC samplers)
- And 12 more categories
-
Interactive Playground: Write and run JavaScript code with live WASM execution
GPU Module Status (v0.16.0)
| Module | Status | Feature Flag |
|---|---|---|
| Core GA | ✅ Enabled | default |
| Info Geometry | ✅ Enabled | default |
| Relativistic | ✅ Enabled | default |
| Network | ✅ Enabled | default |
| Measure | ✅ Enabled | measure |
| Calculus | ✅ Enabled | calculus |
| Dual | ✅ Enabled | dual |
| Enumerative | ✅ Enabled | enumerative |
| Automata | ✅ Enabled | automata |
| Fusion | ✅ Enabled | fusion |
| Holographic | ✅ Enabled | holographic |
| Optical Fields | ✅ Enabled | holographic |
| Probabilistic | ✅ Enabled | probabilistic |
| Functional | ✅ Enabled | functional |
| Topology | ✅ New in v0.16.0 | topology |
| Tropical | ❌ Disabled | - |
Note: Tropical GPU module temporarily disabled due to Rust orphan impl rules. Use CPU implementations from domain crates.
v0.16.0 GPU Additions
The topology feature provides GPU-accelerated computational topology operations:
- GpuTopology: GPU context for topology operations with adaptive dispatch
- TOPOLOGY_DISTANCE_MATRIX: Parallel pairwise Euclidean distance computation (256-thread workgroups)
- TOPOLOGY_MORSE_CRITICAL: Discrete Morse theory critical point detection (8-neighbor comparison)
- TOPOLOGY_BOUNDARY_MATRIX: Sparse boundary operator construction for persistent homology
- TOPOLOGY_MATRIX_REDUCTION: Column reduction algorithm for persistence computation
- Automatic CPU fallback for < 100 points (distance matrix) or < 10,000 cells (Morse theory)
v0.15.1 GPU Additions
The holographic feature includes GPU-accelerated optical field operations:
- GpuOpticalField: GPU context for optical rotor field operations
- OPTICAL_BIND_SHADER: Parallel rotor multiplication (256-thread workgroups)
- OPTICAL_SIMILARITY_SHADER: Inner product with workgroup reduction
- LEE_ENCODE_SHADER: Binary hologram encoding with bit-packing
- Automatic CPU fallback for fields < 4096 pixels (64×64)
Building
Prerequisites
- Rust 1.75+ with
cargo - Node.js 16+ (for TypeScript bindings)
wasm-pack(for WASM builds)
Build and Test
# Run all tests
# Run with all features
# Build documentation
WebAssembly Build
Performance
The library is optimized for high-performance applications:
- SIMD: Vectorized operations where supported
- Cache Alignment: 64-byte aligned data structures
- Const Generics: Zero-cost abstractions for dimensions
- GPU Fallback: Automatic CPU/GPU dispatch based on workload size
- Batch Operations: Efficient batch processing for large datasets
Documentation
- Migration Guide: Migrating from v0.11.x to v0.12.0+
- Changelog: Version history and changes
- API Documentation: Complete API reference
Contributing
Contributions are welcome. For development setup:
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Acknowledgments
- Inspired by the geometric algebra community and research in Information Geometry
- Built with modern Rust performance idioms and WebAssembly best practices
- Named after Shun-ichi Amari's contributions to Information Geometry
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: API Docs
"Geometry is the art of correct reasoning from incorrectly drawn figures." - Henri Poincaré