@justinelliottcobb/amari-wasm
v0.23.0
Published
WebAssembly bindings for Amari mathematical computing library - geometric algebra, tropical algebra, automatic differentiation, measure theory, fusion systems, and information geometry
Maintainers
Readme
@justinelliottcobb/amari-wasm v0.22.0
Unified Mathematical Computing Library with High-Precision WebAssembly Support
Amari is a comprehensive mathematical computing library that brings advanced algebraic systems to JavaScript/TypeScript through WebAssembly. Features high-precision arithmetic for spacecraft orbital mechanics and relativistic physics calculations with pure Rust implementation and no native dependencies for universal deployment.
Features
| Module | Crate | Since | Description |
|--------|-------|-------|-------------|
| Geometric Algebra | amari-core | v0.1 | Multivectors, rotors, geometric products for 3D rotations and spatial transformations |
| Tropical Algebra | amari-tropical | v0.9.3 | Max-plus semiring operations plus 0.21.0 ordinal-weighted optimization carriers below ε₀ |
| Automatic Differentiation | amari-dual | v0.9.3 | Forward-mode AD with 0.21.0 branch policies, multi-dual seeding, and fixed-size gradient wrappers |
| Combinatorial Game Theory | amari-cgt | v0.22.0 | Short normal-play games, cuts, outcomes, comparison, nimbers, and inspection helpers |
| Short Surreal Numbers | amari-surreal | v0.22.0 | Exact dyadic short-surreal arithmetic and conversion to/from numeric CGT games |
| Cellular Automata | amari-automata | v0.9.4 | Geometric cellular automata with multivector states |
| Holographic Memory | amari-fusion | v0.12.3 | Vector Symbolic Architecture for associative memory with binding and bundling |
| Measure Theory | amari-measure | v0.10.0 | Lebesgue integration, probability measures, and measure-theoretic foundations |
| Probability | amari-probabilistic | v0.13.0 | Distributions on multivector spaces, MCMC sampling, Monte Carlo estimation |
| Functional Analysis | amari-functional | v0.15.0 | Hilbert spaces, linear operators, spectral decomposition, Sobolev spaces |
| Optical Fields | amari-holographic | v0.15.1 | GA-native Lee hologram encoding for DMD displays and VSA-based optical processing |
| Computational Topology | amari-topology | v0.16.0 | Simplicial complexes, homology, persistent homology, Morse theory |
| Dynamical Systems | amari-calculus | v0.19.1 | ODE solvers, stability analysis, bifurcation diagrams, Lyapunov exponents |
| Enumerative Geometry | amari-enumerative | v0.19.1 | WDVV curve counting, matroids, CSM classes, stability conditions |
| Probabilistic Contracts | amari-flynn | v0.19.1 | SMT-LIB2 proof obligations, Monte Carlo verification, rare event tracking |
| GF(2) Algebra | amari-core, amari-enumerative | v0.19.1 | GF(2) linear algebra, binary Clifford algebra, coding theory, matroid representability, Kazhdan-Lusztig polynomials |
| Orbital Mechanics | amari-relativistic | v0.9.4 | Spacetime algebra (Cl(1,3)) with high-precision trajectory calculations |
Also includes bindings for: amari-network (geometric network analysis), amari-optimization (gradient descent, NSGA-II), amari-info-geom (Fisher metrics, statistical manifolds), amari-calculus (differential geometry, manifolds).
v0.23.0 Arbitrary-Signature GA (new in development)
The 0.23.0 release introduces generic runtime-signature multivector support:
WasmGenericMultivector(p, q, r)— create and operate on multivectors of any Clifford algebra signature Cl(p, q, r) at runtime. Signature is chosen at construction time and all operations (geometric product, inner product, outer product, reverse, grade projection, exp, normalize, inverse) automatically use the correct metric.WasmGenericRotor— rotors for any signature, created from bivectors via the exponential map.- Match-table dispatch for all 84 signatures with total dimension ≤ 6 (compile-time optimized).
- Cayley-table fallback for larger dimensions with thread-local caching.
8 fast-path aliases provide pre-configured wrappers for the most common signatures:
| Alias | Signature | Use case |
|-------|-----------|----------|
| WasmMultivector300 / GA | Cl(3,0,0) | 3D Euclidean rotations, graphics |
| WasmMultivector210 / ST | Cl(2,1,0) | 2+1 spacetime physics |
| WasmMultivector310 / MINK | Cl(3,1,0) | 3+1 Minkowski relativity |
| WasmMultivector200 / PL | Cl(2,0,0) | 2D planar / complex numbers |
| WasmMultivector030 / QUAT | Cl(0,3,0) | Pure quaternion algebra |
| WasmMultivector410 / CGA | Cl(4,1,0) | Conformal GA (translations as rotors) |
| WasmMultivector500 / P5D | Cl(5,0,0) | 5D Euclidean / projective GA |
| WasmMultivector110 / S2D | Cl(1,1,0) | Split-complex / 1+1 spacetime |
Backward compatibility: WasmMultivector and WasmRotor remain as aliases for WasmMultivector300 and WasmRotor300.
v0.22.0 CGT / Surreal WASM Surface
The 0.22.0 release exposes the new short-game and short-surreal Rust APIs to JavaScript/TypeScript:
WasmCgtArenaandWasmGameIdfor arena-backed short games, focused one-option cuts, addition/subtraction/negation, comparison, outcomes, canonicalization, and formatting.WasmGameInspectionfor birthday, canonical form, outcome, numeric/impartial classification, and reachable-node counts.WasmDyadicfor exact dyadic arithmetic with checked division inside the short-surreal layer.WasmShortSurrealfor exact short-surreal arithmetic plus conversion from numeric CGT games and reconstruction back into aWasmCgtArena.
The scope remains intentionally short/exact: loopy games, misère play, symbolic infinite surreals, and surcomplex arithmetic are not part of the 0.22.0 WASM surface.
v0.21.0 Tropical / Dual WASM Surface
The 0.21.0 release exposes the new optimization-oriented Rust APIs to JavaScript/TypeScript:
TropicalBatch.foldOplus(...)andTropicalBatch.foldOtimes(...)for semiring folds.WasmOrdinalArena,WasmOrdinal, andWasmOrdinalWeightfor bounded ordinals below ε₀, ordinal formatting/inspection, and ordinal-weightoplus/otimeshelpers.WasmBranchPolicyplusmaxByPolicy(...)/minByPolicy(...)on dual and multi-dual numbers for explicit tie behavior.WasmMultiDualNumber.variables(...)for basis-seeded gradient setup.WasmStaticMultiDual2,WasmStaticMultiDual3, andWasmStaticMultiDual4for small fixed-size forward-mode AD loops in browser-facing workloads.
High-Precision Arithmetic
- Pure Rust Backend: dashu-powered arithmetic with no native dependencies
- Universal Deployment: Same precision guarantees across desktop, web, and edge environments
- Orbital-Grade Tolerance: Configurable precision for critical trajectory calculations
Installation
npm install @justinelliottcobb/amari-wasmOr with yarn:
yarn add @justinelliottcobb/amari-wasmQuick Start
import init, {
WasmGenericMultivector,
WasmGenericRotor,
WasmMultivector, // alias for WasmMultivector300 (Cl 3,0,0)
WasmRotor,
} from '@justinelliottcobb/amari-wasm';
async function main() {
await init();
// ── Generic API: any signature at runtime ──
// Cl(2,1,0) — 2+1 spacetime
const e1 = WasmGenericMultivector.basisVector(2, 1, 0, 0);
const e3 = WasmGenericMultivector.basisVector(2, 1, 0, 2);
// e3 squares to -1 in Cl(2,1,0) (negative metric signature)
const e3Sq = e3.geometric_product(e3);
console.log(e3Sq.getCoefficient(0)); // -1
// ── Fast-path alias: Cl(3,0,0) Euclidean ──
const a = WasmMultivector.basisVector(0); // e1
const b = WasmMultivector.basisVector(1); // e2
const product = a.geometric_product(b);
console.log(product.getCoefficients()); // [0, 0, 0, 1, 0, 0, 0, 0] = e12
// ── Rotor in Cl(3,0,0) ──
const bivector = a.outer_product(b); // e12 bivector plane
const rotor = WasmGenericRotor.fromBivector(bivector, Math.PI / 2);
const rotated = rotor.apply(a);
// 90° rotation in e12 plane: e1 → e2
console.log(Math.abs(rotated.getCoefficient(2))); // ≈ 1.0
}
main();Fast-path aliases: WasmMultivector300, WasmMultivector210 (ST), WasmMultivector310 (Minkowski), WasmMultivector200 (planar), WasmMultivector030 (quaternion), WasmMultivector410 (CGA), WasmMultivector500 (5D), WasmMultivector110 (split). Each has a matching WasmRotor* and a TypeScript convenience export (GA, ST, MINK, PL, QUAT, CGA, P5D, S2D).
See the docs/ directory for detailed guides and API references for each module.
Use Cases
- Computer Graphics: 3D rotations and transformations using rotors
- Physics Simulations: Geometric algebra for electromagnetic fields and relativistic calculations
- Machine Learning: Tropical neural networks and automatic differentiation
- Optimization: Tropical algebra for shortest path and scheduling problems
- Scientific Computing: High-performance mathematical operations with orbital-grade precision
- Probability & Statistics: Measure theory, numerical integration, and probabilistic modeling
- Formal Verification: SMT-LIB2 proof obligation generation for browser-based verification workflows
- Symbolic AI: Holographic memory for associative reasoning and concept binding
- Holographic Displays: Lee hologram encoding for DMD and SLM devices
- Topological Data Analysis: Persistent homology for shape and feature detection
- Chaos Theory: Lorenz attractors, bifurcation diagrams, Lyapunov exponents
- Algebraic Geometry: Rational curve counting, Schubert calculus, Gromov-Witten invariants
- Error-Correcting Codes: Binary linear codes (Hamming, Reed-Muller, Golay) for communication systems
- Finite Field Combinatorics: Grassmannian point counting, matroid representability, Kazhdan-Lusztig polynomials
- Spacecraft Trajectory Planning: High-precision orbital mechanics in web applications
Building from Source
# Clone the repository
git clone https://github.com/justinelliottcobb/Amari.git
cd Amari/amari-wasm
# Install dependencies
npm install
# Build WASM module
npm run build
# Run tests
npm testContributing
Contributions are welcome. Please see CONTRIBUTING.md for details.
License
MIT License - see LICENSE for details.
Acknowledgments
- Built with Rust and wasm-bindgen
- Inspired by geometric algebra libraries like GAViewer and Ganja.js
- Tropical algebra concepts from discrete mathematics
Contact
- GitHub: @justinelliottcobb
- NPM: @justinelliottcobb/amari-wasm
Made with Rust by the Amari team
