@justinelliottcobb/amari-wasm 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,6 +32,30 @@ Amari is a comprehensive mathematical computing library that brings advanced alg
32
32
 
33
33
  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).
34
34
 
35
+ ### v0.23.0 Arbitrary-Signature GA (new in development)
36
+
37
+ The `0.23.0` release introduces generic runtime-signature multivector support:
38
+
39
+ - `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.
40
+ - `WasmGenericRotor` — rotors for any signature, created from bivectors via the exponential map.
41
+ - **Match-table dispatch** for all 84 signatures with total dimension ≤ 6 (compile-time optimized).
42
+ - **Cayley-table fallback** for larger dimensions with thread-local caching.
43
+
44
+ 8 fast-path aliases provide pre-configured wrappers for the most common signatures:
45
+
46
+ | Alias | Signature | Use case |
47
+ |-------|-----------|----------|
48
+ | `WasmMultivector300` / `GA` | Cl(3,0,0) | 3D Euclidean rotations, graphics |
49
+ | `WasmMultivector210` / `ST` | Cl(2,1,0) | 2+1 spacetime physics |
50
+ | `WasmMultivector310` / `MINK` | Cl(3,1,0) | 3+1 Minkowski relativity |
51
+ | `WasmMultivector200` / `PL` | Cl(2,0,0) | 2D planar / complex numbers |
52
+ | `WasmMultivector030` / `QUAT` | Cl(0,3,0) | Pure quaternion algebra |
53
+ | `WasmMultivector410` / `CGA` | Cl(4,1,0) | Conformal GA (translations as rotors) |
54
+ | `WasmMultivector500` / `P5D` | Cl(5,0,0) | 5D Euclidean / projective GA |
55
+ | `WasmMultivector110` / `S2D` | Cl(1,1,0) | Split-complex / 1+1 spacetime |
56
+
57
+ Backward compatibility: `WasmMultivector` and `WasmRotor` remain as aliases for `WasmMultivector300` and `WasmRotor300`.
58
+
35
59
  ### v0.22.0 CGT / Surreal WASM Surface
36
60
 
37
61
  The `0.22.0` release exposes the new short-game and short-surreal Rust APIs to JavaScript/TypeScript:
@@ -74,39 +98,47 @@ yarn add @justinelliottcobb/amari-wasm
74
98
  ## Quick Start
75
99
 
76
100
  ```typescript
77
- import init, { WasmMultivector, WasmRotor } from '@justinelliottcobb/amari-wasm';
101
+ import init, {
102
+ WasmGenericMultivector,
103
+ WasmGenericRotor,
104
+ WasmMultivector, // alias for WasmMultivector300 (Cl 3,0,0)
105
+ WasmRotor,
106
+ } from '@justinelliottcobb/amari-wasm';
78
107
 
79
108
  async function main() {
80
109
  await init();
81
110
 
82
- // Create basis vectors
83
- const e1 = WasmMultivector.basis_vector(0);
84
- const e2 = WasmMultivector.basis_vector(1);
85
-
86
- // Compute geometric product
87
- const product = e1.geometric_product(e2);
88
- console.log(product.to_string()); // e12 (bivector)
89
-
90
- // Create a rotor for 90-degree rotation
91
- const rotor = WasmRotor.from_axis_angle(
92
- WasmMultivector.basis_vector(2),
93
- Math.PI / 2
94
- );
95
-
96
- // Rotate a vector
97
- const vector = WasmMultivector.from_coefficients(
98
- new Float64Array([1, 0, 0, 0, 0, 0, 0, 0])
99
- );
100
- const rotated = rotor.rotate_vector(vector);
101
-
102
- // Clean up WASM memory
103
- e1.free(); e2.free(); product.free();
104
- rotor.free(); vector.free(); rotated.free();
111
+ // ── Generic API: any signature at runtime ──
112
+
113
+ // Cl(2,1,0) 2+1 spacetime
114
+ const e1 = WasmGenericMultivector.basisVector(2, 1, 0, 0);
115
+ const e3 = WasmGenericMultivector.basisVector(2, 1, 0, 2);
116
+
117
+ // e3 squares to -1 in Cl(2,1,0) (negative metric signature)
118
+ const e3Sq = e3.geometric_product(e3);
119
+ console.log(e3Sq.getCoefficient(0)); // -1
120
+
121
+ // ── Fast-path alias: Cl(3,0,0) Euclidean ──
122
+
123
+ const a = WasmMultivector.basisVector(0); // e1
124
+ const b = WasmMultivector.basisVector(1); // e2
125
+ const product = a.geometric_product(b);
126
+ console.log(product.getCoefficients()); // [0, 0, 0, 1, 0, 0, 0, 0] = e12
127
+
128
+ // ── Rotor in Cl(3,0,0) ──
129
+
130
+ const bivector = a.outer_product(b); // e12 bivector plane
131
+ const rotor = WasmGenericRotor.fromBivector(bivector, Math.PI / 2);
132
+ const rotated = rotor.apply(a);
133
+ // 90° rotation in e12 plane: e1 → e2
134
+ console.log(Math.abs(rotated.getCoefficient(2))); // ≈ 1.0
105
135
  }
106
136
 
107
137
  main();
108
138
  ```
109
139
 
140
+ **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`).
141
+
110
142
  See the [docs/](docs/) directory for detailed guides and API references for each module.
111
143
 
112
144
  ## Use Cases