@justinelliottcobb/amari-wasm 0.18.1 → 0.19.1

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
@@ -1,4 +1,4 @@
1
- # @justinelliottcobb/amari-wasm v0.18.1
1
+ # @justinelliottcobb/amari-wasm v0.19.1
2
2
 
3
3
  **Unified Mathematical Computing Library with High-Precision WebAssembly Support**
4
4
 
@@ -10,32 +10,31 @@ Amari is a comprehensive mathematical computing library that brings advanced alg
10
10
 
11
11
  ## Features
12
12
 
13
- ### Core Mathematical Systems
14
-
15
- - **Geometric Algebra (Clifford Algebra)**: Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
16
- - **Tropical Algebra**: Max-plus semiring operations for optimization and neural network applications
17
- - **Automatic Differentiation**: Forward-mode AD with dual numbers for exact derivatives
18
- - **Measure Theory** *(v0.10.0)*: Lebesgue integration, probability measures, and measure-theoretic foundations
19
- - **Holographic Memory** *(v0.12.3)*: Vector Symbolic Architecture for associative memory with binding and bundling operations
20
- - **Functional Analysis** *(v0.15.0)*: Hilbert spaces, linear operators, spectral decomposition, and Sobolev spaces
21
- - **Optical Field Operations** *(v0.15.1)*: GA-native Lee hologram encoding for DMD displays and VSA-based optical processing
22
- - **Computational Topology** *(v0.16.0)*: Simplicial complexes, homology computation, persistent homology, and Morse theory
23
- - **Dynamical Systems** *(v0.18.1)*: ODE solvers, stability analysis, bifurcation diagrams, Lyapunov exponents, and phase portraits
24
- - **Enumerative Geometry** *(v0.18.1)*: WDVV curve counting, equivariant localization, matroids, CSM classes, operadic composition, and stability conditions
25
- - **Probability Theory** *(v0.13.0)*: Distributions on multivector spaces, MCMC sampling, and Monte Carlo estimation
26
- - **Relativistic Physics**: Spacetime algebra (Cl(1,3)) with WebAssembly-compatible precision
27
- - **Spacecraft Orbital Mechanics**: Full-precision trajectory calculations in browsers
28
- - **Cellular Automata**: Geometric cellular automata with multivector states
29
- - **WebGPU Acceleration**: Optional GPU acceleration for large-scale operations
30
- - **Pure Rust Implementation**: Memory-safe, high-performance core with WASM bindings
31
- - **TypeScript Support**: Full TypeScript definitions included
13
+ | Module | Crate | Since | Description |
14
+ |--------|-------|-------|-------------|
15
+ | [Geometric Algebra](docs/geometric-algebra.md) | amari-core | v0.1 | Multivectors, rotors, geometric products for 3D rotations and spatial transformations |
16
+ | [Tropical Algebra](docs/tropical-algebra.md) | amari-tropical | v0.9.3 | Max-plus semiring operations for optimization and neural network applications |
17
+ | [Automatic Differentiation](docs/automatic-differentiation.md) | amari-dual | v0.9.3 | Forward-mode AD with dual numbers for exact derivatives |
18
+ | [Cellular Automata](docs/cellular-automata.md) | amari-automata | v0.9.4 | Geometric cellular automata with multivector states |
19
+ | [Holographic Memory](docs/holographic-memory.md) | amari-fusion | v0.12.3 | Vector Symbolic Architecture for associative memory with binding and bundling |
20
+ | [Measure Theory](docs/measure-theory.md) | amari-measure | v0.10.0 | Lebesgue integration, probability measures, and measure-theoretic foundations |
21
+ | [Probability](docs/probability.md) | amari-probabilistic | v0.13.0 | Distributions on multivector spaces, MCMC sampling, Monte Carlo estimation |
22
+ | [Functional Analysis](docs/functional-analysis.md) | amari-functional | v0.15.0 | Hilbert spaces, linear operators, spectral decomposition, Sobolev spaces |
23
+ | [Optical Fields](docs/optical-fields.md) | amari-holographic | v0.15.1 | GA-native Lee hologram encoding for DMD displays and VSA-based optical processing |
24
+ | [Computational Topology](docs/topology.md) | amari-topology | v0.16.0 | Simplicial complexes, homology, persistent homology, Morse theory |
25
+ | [Dynamical Systems](docs/dynamics.md) | amari-calculus | v0.19.1 | ODE solvers, stability analysis, bifurcation diagrams, Lyapunov exponents |
26
+ | [Enumerative Geometry](docs/enumerative-geometry.md) | amari-enumerative | v0.19.1 | WDVV curve counting, matroids, CSM classes, stability conditions |
27
+ | [Probabilistic Contracts](docs/probabilistic-contracts.md) | amari-flynn | v0.19.1 | SMT-LIB2 proof obligations, Monte Carlo verification, rare event tracking |
28
+ | [GF(2) Algebra](docs/gf2-algebra.md) | amari-core, amari-enumerative | v0.19.1 | GF(2) linear algebra, binary Clifford algebra, coding theory, matroid representability, Kazhdan-Lusztig polynomials |
29
+ | [Orbital Mechanics](docs/orbital-mechanics.md) | amari-relativistic | v0.9.4 | Spacetime algebra (Cl(1,3)) with high-precision trajectory calculations |
30
+
31
+ 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).
32
32
 
33
33
  ### High-Precision Arithmetic
34
34
 
35
35
  - **Pure Rust Backend**: dashu-powered arithmetic with no native dependencies
36
36
  - **Universal Deployment**: Same precision guarantees across desktop, web, and edge environments
37
37
  - **Orbital-Grade Tolerance**: Configurable precision for critical trajectory calculations
38
- - **WebAssembly 3.0 Ready**: Leverages latest WASM features for enhanced mathematical computing
39
38
 
40
39
  ## Installation
41
40
 
@@ -55,7 +54,6 @@ yarn add @justinelliottcobb/amari-wasm
55
54
  import init, { WasmMultivector, WasmRotor } from '@justinelliottcobb/amari-wasm';
56
55
 
57
56
  async function main() {
58
- // Initialize the WASM module
59
57
  await init();
60
58
 
61
59
  // Create basis vectors
@@ -68,7 +66,7 @@ async function main() {
68
66
 
69
67
  // Create a rotor for 90-degree rotation
70
68
  const rotor = WasmRotor.from_axis_angle(
71
- WasmMultivector.basis_vector(2), // z-axis
69
+ WasmMultivector.basis_vector(2),
72
70
  Math.PI / 2
73
71
  );
74
72
 
@@ -79,995 +77,14 @@ async function main() {
79
77
  const rotated = rotor.rotate_vector(vector);
80
78
 
81
79
  // Clean up WASM memory
82
- e1.free();
83
- e2.free();
84
- product.free();
85
- rotor.free();
86
- vector.free();
87
- rotated.free();
80
+ e1.free(); e2.free(); product.free();
81
+ rotor.free(); vector.free(); rotated.free();
88
82
  }
89
83
 
90
84
  main();
91
85
  ```
92
86
 
93
- ## High-Precision Orbital Mechanics
94
-
95
- ```typescript
96
- import init, {
97
- WasmSpacetimeVector,
98
- WasmFourVelocity,
99
- WasmRelativisticParticle,
100
- WasmSchwarzschildMetric
101
- } from '@justinelliottcobb/amari-wasm';
102
-
103
- async function spacecraftSimulation() {
104
- await init();
105
-
106
- // Create Earth's gravitational field
107
- const earth = WasmSchwarzschildMetric.earth();
108
-
109
- // Spacecraft at 400km altitude (ISS orbit)
110
- const altitude = 400e3; // 400 km
111
- const earthRadius = 6.371e6; // Earth radius in meters
112
- const position = new Float64Array([earthRadius + altitude, 0.0, 0.0]);
113
- const velocity = new Float64Array([0.0, 7.67e3, 0.0]); // ~7.67 km/s orbital velocity
114
-
115
- // Create spacecraft with high-precision arithmetic
116
- const spacecraft = WasmRelativisticParticle.new(
117
- position,
118
- velocity,
119
- 0.0, // No charge
120
- 1000.0, // 1000 kg spacecraft
121
- 0.0 // No magnetic charge
122
- );
123
-
124
- // Propagate orbit for one complete period with high precision
125
- const orbitalPeriod = 5580.0; // ~93 minutes
126
- const timeStep = 60.0; // 1-minute time steps
127
-
128
- // High-precision geodesic integration using dashu backend
129
- const trajectory = spacecraft.propagate_trajectory(
130
- earth,
131
- orbitalPeriod,
132
- timeStep
133
- );
134
-
135
- console.log(`Orbital trajectory computed with ${trajectory.length} points`);
136
- console.log(`Final position deviation: ${spacecraft.position_error()} meters`);
137
-
138
- // WebAssembly precision matches native accuracy
139
-
140
- // Clean up WASM memory
141
- earth.free();
142
- spacecraft.free();
143
- trajectory.forEach(point => point.free());
144
- }
145
-
146
- spacecraftSimulation();
147
- ```
148
-
149
- ## Core Concepts
150
-
151
- ### Geometric Algebra
152
-
153
- Geometric algebra extends linear algebra with the geometric product, enabling intuitive representation of rotations, reflections, and other transformations:
154
-
155
- ```typescript
156
- // Multivector operations
157
- const v1 = WasmMultivector.from_coefficients(coeffs);
158
- const v2 = WasmMultivector.random();
159
-
160
- const sum = v1.add(v2);
161
- const product = v1.geometric_product(v2);
162
- const wedge = v1.wedge_product(v2);
163
- const inner = v1.inner_product(v2);
164
- ```
165
-
166
- ### Tropical Algebra
167
-
168
- Tropical algebra replaces addition with max and multiplication with addition, useful for optimization:
169
-
170
- ```typescript
171
- import { tropical_add, tropical_multiply } from '@justinelliottcobb/amari-wasm';
172
-
173
- // Tropical operations: add = max, multiply = add
174
- const a = 5.0, b = 3.0;
175
- const trop_sum = tropical_add(a, b); // max(5, 3) = 5
176
- const trop_prod = tropical_multiply(a, b); // 5 + 3 = 8
177
- ```
178
-
179
- ### Cellular Automata
180
-
181
- Create and evolve cellular automata with geometric algebra states:
182
-
183
- ```typescript
184
- const ca = WasmGeometricCA.new(100, 100);
185
-
186
- // Set initial configuration
187
- ca.set_cell(50, 50, WasmMultivector.basis_vector(0));
188
-
189
- // Evolve the system
190
- for (let i = 0; i < 100; i++) {
191
- ca.step();
192
- }
193
-
194
- console.log(`Generation: ${ca.generation()}`);
195
- ```
196
-
197
- ### Measure Theory and Integration *(v0.10.0)*
198
-
199
- Perform numerical integration and work with probability measures:
200
-
201
- ```typescript
202
- import { WasmLebesgueMeasure, WasmProbabilityMeasure, integrate } from '@justinelliottcobb/amari-wasm';
203
-
204
- // Lebesgue measure - compute volumes
205
- const measure = new WasmLebesgueMeasure(3); // 3D space
206
- const volume = measure.measureBox([2.0, 3.0, 4.0]); // 2×3×4 box = 24
207
-
208
- // Numerical integration
209
- const f = (x) => x * x; // Function to integrate
210
- const result = integrate(f, 0, 2, 1000, WasmIntegrationMethod.Riemann);
211
- console.log(`∫₀² x² dx ≈ ${result}`); // ≈ 2.667
212
-
213
- // Probability measures
214
- const prob = WasmProbabilityMeasure.uniform(0, 1);
215
- const p = prob.probabilityInterval(0.25, 0.75, 0, 1); // P(0.25 ≤ X ≤ 0.75) = 0.5
216
- ```
217
-
218
- ### Holographic Memory *(v0.12.2)*
219
-
220
- Store and retrieve key-value associations using Vector Symbolic Architecture:
221
-
222
- ```typescript
223
- import init, {
224
- WasmTropicalDualClifford,
225
- WasmHolographicMemory,
226
- WasmResonator
227
- } from '@justinelliottcobb/amari-wasm';
228
-
229
- async function holographicDemo() {
230
- await init();
231
-
232
- // Create random vectors for keys and values
233
- const key1 = WasmTropicalDualClifford.randomVector();
234
- const value1 = WasmTropicalDualClifford.randomVector();
235
- const key2 = WasmTropicalDualClifford.randomVector();
236
- const value2 = WasmTropicalDualClifford.randomVector();
237
-
238
- // Create holographic memory
239
- const memory = new WasmHolographicMemory();
240
-
241
- // Store associations
242
- memory.store(key1, value1);
243
- memory.store(key2, value2);
244
-
245
- // Retrieve with a key
246
- const result = memory.retrieve(key1);
247
- console.log(`Confidence: ${result.confidence()}`);
248
- console.log(`Similarity to original: ${result.value().similarity(value1)}`);
249
-
250
- // Check capacity
251
- const info = memory.capacityInfo();
252
- console.log(`Items stored: ${info.itemCount}`);
253
- console.log(`Estimated SNR: ${info.estimatedSnr}`);
254
-
255
- // Binding operations (key ⊛ value)
256
- const bound = key1.bind(value1);
257
- const unbound = bound.unbind(key1); // Recovers value1
258
-
259
- // Similarity computation
260
- const sim = key1.similarity(key2);
261
- console.log(`Key similarity: ${sim}`);
262
-
263
- // Resonator cleanup for noisy inputs
264
- const codebook = [key1, key2, value1, value2];
265
- const resonator = WasmResonator.new(codebook);
266
- const noisyInput = key1; // Add noise in practice
267
- const cleaned = resonator.cleanup(noisyInput);
268
- console.log(`Best match index: ${cleaned.bestMatchIndex()}`);
269
-
270
- // Clean up WASM memory
271
- key1.free();
272
- value1.free();
273
- key2.free();
274
- value2.free();
275
- memory.free();
276
- bound.free();
277
- unbound.free();
278
- resonator.free();
279
- }
280
-
281
- holographicDemo();
282
- ```
283
-
284
- ### Probability on Geometric Algebra *(v0.13.0)*
285
-
286
- Sample from distributions on multivector spaces and perform Monte Carlo estimation:
287
-
288
- ```typescript
289
- import init, {
290
- WasmGaussianMultivector,
291
- WasmUniformMultivector,
292
- WasmMonteCarloEstimator
293
- } from '@justinelliottcobb/amari-wasm';
294
-
295
- async function probabilisticDemo() {
296
- await init();
297
-
298
- // Create a standard Gaussian distribution on Cl(3,0,0)
299
- const gaussian = WasmGaussianMultivector.standard();
300
-
301
- // Draw samples
302
- const samples = [];
303
- for (let i = 0; i < 1000; i++) {
304
- samples.push(gaussian.sample());
305
- }
306
- console.log(`Drew ${samples.length} Gaussian samples`);
307
-
308
- // Compute log probability
309
- const sample = gaussian.sample();
310
- const logProb = gaussian.logProb(sample);
311
- console.log(`Log probability: ${logProb}`);
312
-
313
- // Grade-concentrated distribution (e.g., only on bivectors)
314
- const bivectorDist = WasmGaussianMultivector.gradeConcentrated(2, 1.0);
315
- const bivectorSample = bivectorDist.sample();
316
-
317
- // Uniform distribution on unit multivectors
318
- const uniform = WasmUniformMultivector.unitSphere();
319
- const unitSample = uniform.sample();
320
-
321
- // Monte Carlo estimation
322
- const estimator = new WasmMonteCarloEstimator();
323
-
324
- // Estimate expectation of a function
325
- const estimate = estimator.estimate((mv) => mv.norm(), gaussian, 10000);
326
- console.log(`Expected norm: ${estimate.mean} ± ${estimate.stdError}`);
327
-
328
- // Clean up WASM memory
329
- gaussian.free();
330
- bivectorDist.free();
331
- uniform.free();
332
- sample.free();
333
- bivectorSample.free();
334
- unitSample.free();
335
- estimator.free();
336
- samples.forEach(s => s.free());
337
- }
338
-
339
- probabilisticDemo();
340
- ```
341
-
342
- ### Functional Analysis *(v0.15.0)*
343
-
344
- Work with Hilbert spaces, linear operators, and spectral decomposition on multivector spaces:
345
-
346
- ```typescript
347
- import init, {
348
- WasmHilbertSpace,
349
- WasmMatrixOperator,
350
- WasmSpectralDecomposition,
351
- WasmSobolevSpace,
352
- powerMethod,
353
- computeEigenvalues
354
- } from '@justinelliottcobb/amari-wasm';
355
-
356
- async function functionalDemo() {
357
- await init();
358
-
359
- // Create a Hilbert space Cl(2,0,0) ≅ ℝ⁴
360
- const hilbert = new WasmHilbertSpace();
361
- console.log(`Dimension: ${hilbert.dimension()}`); // 4
362
- console.log(`Signature: ${hilbert.signature()}`); // [2, 0, 0]
363
-
364
- // Create multivectors from coefficients [scalar, e1, e2, e12]
365
- const x = hilbert.fromCoefficients([1.0, 2.0, 3.0, 4.0]);
366
- const y = hilbert.fromCoefficients([0.5, 1.5, 2.5, 3.5]);
367
-
368
- // Inner product and norm
369
- const inner = hilbert.innerProduct(x, y);
370
- console.log(`⟨x, y⟩ = ${inner}`);
371
-
372
- const norm = hilbert.norm(x);
373
- console.log(`‖x‖ = ${norm}`);
374
-
375
- // Orthogonal projection
376
- const proj = hilbert.project(x, y);
377
- console.log(`proj_y(x) = ${proj}`);
378
-
379
- // Create a matrix operator (4x4 matrix in row-major order)
380
- const A = new WasmMatrixOperator([
381
- 4, 1, 0, 0,
382
- 1, 3, 1, 0,
383
- 0, 1, 2, 1,
384
- 0, 0, 1, 1
385
- ]);
386
-
387
- // Apply operator to a vector
388
- const Ax = A.apply(x);
389
- console.log(`Ax = ${Ax}`);
390
-
391
- // Operator properties
392
- console.log(`‖A‖ = ${A.operatorNorm()}`);
393
- console.log(`tr(A) = ${A.trace()}`);
394
- console.log(`Symmetric: ${A.isSymmetric(1e-10)}`);
395
-
396
- // Spectral decomposition for symmetric matrices
397
- const decomp = WasmSpectralDecomposition.compute(A, 100, 1e-10);
398
- const eigenvalues = decomp.eigenvalues();
399
- console.log(`Eigenvalues: ${eigenvalues}`);
400
- console.log(`Spectral radius: ${decomp.spectralRadius()}`);
401
- console.log(`Condition number: ${decomp.conditionNumber()}`);
402
-
403
- // Functional calculus: apply f(A) = exp(A)
404
- const expAx = decomp.applyFunction((lambda) => Math.exp(lambda), x);
405
- console.log(`exp(A)x = ${expAx}`);
406
-
407
- // Power method for dominant eigenvalue
408
- const dominant = powerMethod(A, null, 100, 1e-10);
409
- console.log(`Dominant eigenvalue: ${dominant[0]}`);
410
-
411
- // Sobolev spaces for PDE analysis
412
- const h1 = new WasmSobolevSpace(1, 0.0, 1.0); // H^1([0,1])
413
- console.log(`Poincaré constant: ${h1.poincareConstant()}`);
414
-
415
- // Compute H^1 norm of sin(πx)
416
- const f = (x: number) => Math.sin(Math.PI * x);
417
- const df = (x: number) => Math.PI * Math.cos(Math.PI * x);
418
- const h1Norm = h1.h1Norm(f, df);
419
- console.log(`‖sin(πx)‖_{H^1} = ${h1Norm}`);
420
-
421
- // Clean up WASM memory
422
- hilbert.free();
423
- A.free();
424
- decomp.free();
425
- h1.free();
426
- }
427
-
428
- functionalDemo();
429
- ```
430
-
431
- #### Functional Analysis API
432
-
433
- **WasmHilbertSpace:**
434
- - `new()`: Create Hilbert space Cl(2,0,0) ≅ ℝ⁴
435
- - `dimension()`: Get space dimension
436
- - `signature()`: Get Clifford algebra signature [p, q, r]
437
- - `fromCoefficients(coeffs)`: Create multivector from coefficients
438
- - `innerProduct(x, y)`: Compute ⟨x, y⟩
439
- - `norm(x)`: Compute ‖x‖
440
- - `distance(x, y)`: Compute d(x, y) = ‖x - y‖
441
- - `normalize(x)`: Normalize to unit length
442
- - `project(x, y)`: Orthogonal projection of x onto y
443
- - `isOrthogonal(x, y, tol)`: Check orthogonality
444
-
445
- **WasmMatrixOperator:**
446
- - `new(entries)`: Create from 16 entries (4×4 row-major)
447
- - `identity()`: Create identity operator
448
- - `zero()`: Create zero operator
449
- - `diagonal(entries)`: Create diagonal matrix
450
- - `scaling(lambda)`: Create λI
451
- - `apply(x)`: Apply operator T(x)
452
- - `operatorNorm()`: Compute ‖T‖
453
- - `isSymmetric(tol)`: Check symmetry
454
- - `add(other)`: Add operators
455
- - `compose(other)`: Compose operators (matrix multiply)
456
- - `scale(lambda)`: Scale by scalar
457
- - `transpose()`: Compute transpose
458
- - `trace()`: Compute trace
459
-
460
- **WasmSpectralDecomposition:**
461
- - `compute(matrix, maxIter, tol)`: Compute eigenvalue decomposition
462
- - `eigenvalues()`: Get eigenvalues
463
- - `eigenvectors()`: Get eigenvectors (flattened)
464
- - `isComplete()`: Check if decomposition is complete
465
- - `spectralRadius()`: Get largest |eigenvalue|
466
- - `conditionNumber()`: Get condition number
467
- - `isPositiveDefinite()`: Check positive definiteness
468
- - `apply(x)`: Apply reconstructed operator
469
- - `applyFunction(f, x)`: Functional calculus f(T)x
470
-
471
- **WasmSobolevSpace:**
472
- - `new(order, lower, upper)`: Create H^k([a,b])
473
- - `h1UnitInterval()`: Create H^1([0,1])
474
- - `h2UnitInterval()`: Create H^2([0,1])
475
- - `poincareConstant()`: Get Poincaré constant
476
- - `h1Norm(f, df)`: Compute H^1 norm
477
- - `h1Seminorm(df)`: Compute H^1 seminorm |f|_{H^1}
478
- - `l2Norm(f)`: Compute L^2 norm
479
- - `l2InnerProduct(f, g)`: Compute L^2 inner product
480
-
481
- **Standalone Functions:**
482
- - `powerMethod(matrix, initial, maxIter, tol)`: Dominant eigenvalue
483
- - `inverseIteration(matrix, shift, initial, maxIter, tol)`: Eigenvalue near shift
484
- - `computeEigenvalues(matrix, maxIter, tol)`: All eigenvalues
485
-
486
- ### Optical Field Operations *(v0.15.1)*
487
-
488
- Encode optical fields as binary holograms for DMD displays using geometric algebra:
489
-
490
- ```typescript
491
- import init, {
492
- WasmOpticalRotorField,
493
- WasmBinaryHologram,
494
- WasmGeometricLeeEncoder,
495
- WasmOpticalFieldAlgebra,
496
- WasmOpticalCodebook,
497
- WasmTropicalOpticalAlgebra
498
- } from '@justinelliottcobb/amari-wasm';
499
-
500
- async function opticalDemo() {
501
- await init();
502
-
503
- // Create optical rotor fields (phase + amplitude on a grid)
504
- const field1 = WasmOpticalRotorField.random(256, 256, 12345n);
505
- const field2 = WasmOpticalRotorField.random(256, 256, 67890n);
506
- const uniform = WasmOpticalRotorField.uniform(0.0, 0.5, 256, 256);
507
-
508
- console.log(`Field dimensions: ${field1.width} x ${field1.height}`);
509
- console.log(`Total energy: ${field1.totalEnergy()}`);
510
-
511
- // Lee hologram encoding for DMD display
512
- const encoder = WasmGeometricLeeEncoder.withFrequency(256, 256, 0.25);
513
- const hologram = encoder.encode(uniform);
514
-
515
- console.log(`Hologram fill factor: ${hologram.fillFactor()}`);
516
- console.log(`Theoretical efficiency: ${encoder.theoreticalEfficiency(uniform)}`);
517
-
518
- // Get binary data for hardware interface
519
- const binaryData = hologram.asBytes();
520
- console.log(`Packed binary size: ${binaryData.length} bytes`);
521
-
522
- // VSA operations on optical fields
523
- const algebra = new WasmOpticalFieldAlgebra(256, 256);
524
-
525
- // Bind two fields (rotor multiplication = phase addition)
526
- const bound = algebra.bind(field1, field2);
527
-
528
- // Compute similarity between fields
529
- const similarity = algebra.similarity(field1, field1); // Self-similarity = 1.0
530
- console.log(`Self-similarity: ${similarity}`);
531
-
532
- // Unbind to retrieve original field
533
- const retrieved = algebra.unbind(field1, bound);
534
- const retrievalSim = algebra.similarity(retrieved, field2);
535
- console.log(`Retrieval similarity: ${retrievalSim}`);
536
-
537
- // Seed-based symbol codebook for VSA
538
- const codebook = new WasmOpticalCodebook(64, 64, 42n);
539
- codebook.register("AGENT");
540
- codebook.register("ACTION");
541
- codebook.register("TARGET");
542
-
543
- const agentField = codebook.get("AGENT");
544
- const actionField = codebook.get("ACTION");
545
- console.log(`Registered symbols: ${codebook.symbols()}`);
546
-
547
- // Tropical operations for attractor dynamics
548
- const tropical = new WasmTropicalOpticalAlgebra(64, 64);
549
-
550
- // Tropical add: pointwise minimum of phase magnitudes
551
- const tropicalSum = tropical.tropicalAdd(field1, field2);
552
-
553
- // Soft tropical add with temperature parameter
554
- const softSum = tropical.softTropicalAdd(field1, field2, 10.0);
555
-
556
- // Phase distance between fields
557
- const distance = tropical.phaseDistance(field1, field2);
558
- console.log(`Phase distance: ${distance}`);
559
-
560
- // Clean up WASM memory
561
- field1.free();
562
- field2.free();
563
- uniform.free();
564
- hologram.free();
565
- bound.free();
566
- retrieved.free();
567
- agentField.free();
568
- actionField.free();
569
- tropicalSum.free();
570
- softSum.free();
571
- }
572
-
573
- opticalDemo();
574
- ```
575
-
576
- ### Computational Topology *(v0.16.0)*
577
-
578
- Compute homology groups, persistent homology, and analyze topological features of data:
579
-
580
- ```typescript
581
- import init, {
582
- WasmSimplex,
583
- WasmSimplicialComplex,
584
- WasmFiltration,
585
- WasmPersistentHomology,
586
- ripsFromDistances,
587
- findCriticalPoints2D,
588
- WasmMorseComplex
589
- } from '@justinelliottcobb/amari-wasm';
590
-
591
- async function topologyDemo() {
592
- await init();
593
-
594
- // ========================================
595
- // Simplicial Complexes and Homology
596
- // ========================================
597
-
598
- // Create a triangle (2-simplex with all faces)
599
- const complex = new WasmSimplicialComplex();
600
- complex.addSimplex([0, 1, 2]); // Triangle
601
-
602
- // Closure property: edges and vertices automatically added
603
- console.log(`Vertices: ${complex.vertexCount()}`); // 3
604
- console.log(`Edges: ${complex.edgeCount()}`); // 3
605
- console.log(`Triangles: ${complex.simplexCount(2)}`); // 1
606
-
607
- // Compute Betti numbers (topological invariants)
608
- const betti = complex.bettiNumbers();
609
- console.log(`β₀ = ${betti[0]}`); // 1 (one connected component)
610
- console.log(`β₁ = ${betti[1]}`); // 0 (no holes - filled triangle)
611
-
612
- // Euler characteristic: χ = V - E + F
613
- console.log(`χ = ${complex.eulerCharacteristic()}`); // 1
614
-
615
- // ========================================
616
- // Circle (unfilled triangle boundary)
617
- // ========================================
618
-
619
- const circle = new WasmSimplicialComplex();
620
- circle.addSimplex([0, 1]); // Edge 0-1
621
- circle.addSimplex([1, 2]); // Edge 1-2
622
- circle.addSimplex([2, 0]); // Edge 2-0
623
-
624
- const circleBetti = circle.bettiNumbers();
625
- console.log(`Circle β₀ = ${circleBetti[0]}`); // 1 (connected)
626
- console.log(`Circle β₁ = ${circleBetti[1]}`); // 1 (one hole!)
627
-
628
- // ========================================
629
- // Persistent Homology
630
- // ========================================
631
-
632
- // Build a filtration (simplices appearing over time)
633
- const filt = new WasmFiltration();
634
- filt.add(0.0, [0]); // Point 0 at t=0
635
- filt.add(0.0, [1]); // Point 1 at t=0
636
- filt.add(0.0, [2]); // Point 2 at t=0
637
- filt.add(1.0, [0, 1]); // Edge 0-1 at t=1
638
- filt.add(2.0, [1, 2]); // Edge 1-2 at t=2
639
- filt.add(3.0, [0, 2]); // Edge 0-2 at t=3 (creates loop)
640
-
641
- // Compute persistent homology
642
- const ph = WasmPersistentHomology.compute(filt);
643
-
644
- // Get persistence diagram as [dim, birth, death] triples
645
- const diagram = ph.getDiagram();
646
- for (let i = 0; i < diagram.length; i += 3) {
647
- const dim = diagram[i];
648
- const birth = diagram[i + 1];
649
- const death = diagram[i + 2];
650
- console.log(`H${dim}: born at ${birth}, dies at ${death === Infinity ? '∞' : death}`);
651
- }
652
-
653
- // Betti numbers at different times
654
- console.log(`Betti at t=0.5: ${ph.bettiAt(0.5)}`); // [3, 0] - 3 components
655
- console.log(`Betti at t=3.5: ${ph.bettiAt(3.5)}`); // [1, 1] - 1 component, 1 loop
656
-
657
- // ========================================
658
- // Vietoris-Rips Filtration from Point Cloud
659
- // ========================================
660
-
661
- // 3 points forming an equilateral triangle
662
- // Distances: d(0,1)=1, d(1,2)=1, d(0,2)=1
663
- const numPoints = 3;
664
- const maxDim = 2;
665
- // Upper triangular pairwise distances: [d(0,1), d(0,2), d(1,2)]
666
- const distances = [1.0, 1.0, 1.0];
667
-
668
- const ripsFilt = ripsFromDistances(numPoints, maxDim, distances);
669
- const ripsPH = WasmPersistentHomology.compute(ripsFilt);
670
- console.log(`Rips intervals in H0: ${ripsPH.intervalCount(0)}`);
671
- console.log(`Rips intervals in H1: ${ripsPH.intervalCount(1)}`);
672
-
673
- // ========================================
674
- // Morse Theory (Critical Points)
675
- // ========================================
676
-
677
- // Precompute f(x,y) = x² + y² on a grid
678
- const resolution = 20;
679
- const values = [];
680
- for (let i = 0; i <= resolution; i++) {
681
- const x = -1.0 + (2.0 * i) / resolution;
682
- for (let j = 0; j <= resolution; j++) {
683
- const y = -1.0 + (2.0 * j) / resolution;
684
- values.push(x * x + y * y);
685
- }
686
- }
687
-
688
- const criticalPoints = findCriticalPoints2D(
689
- resolution,
690
- -1.0, 1.0, // x range
691
- -1.0, 1.0, // y range
692
- 0.1, // tolerance
693
- values
694
- );
695
-
696
- console.log(`Found ${criticalPoints.length} critical points`);
697
- for (const cp of criticalPoints) {
698
- console.log(` ${cp.criticalType} at (${cp.position[0].toFixed(2)}, ${cp.position[1].toFixed(2)}), value=${cp.value.toFixed(2)}`);
699
- }
700
-
701
- // Morse complex analysis
702
- const morse = new WasmMorseComplex(criticalPoints);
703
- const counts = morse.countsByIndex();
704
- console.log(`Critical points by index: ${counts}`);
705
-
706
- // Verify Morse inequalities: c_k >= β_k
707
- const complexBetti = complex.bettiNumbers();
708
- console.log(`Weak Morse inequalities hold: ${morse.checkWeakMorseInequalities(complexBetti)}`);
709
-
710
- // Clean up WASM memory
711
- complex.free();
712
- circle.free();
713
- filt.free();
714
- ph.free();
715
- ripsFilt.free();
716
- ripsPH.free();
717
- morse.free();
718
- criticalPoints.forEach(cp => cp.free());
719
- }
720
-
721
- topologyDemo();
722
- ```
723
-
724
- ### Dynamical Systems *(v0.18.1)*
725
-
726
- Analyze chaotic systems, compute bifurcation diagrams, and explore phase space:
727
-
728
- ```typescript
729
- import init, {
730
- WasmLorenzSystem,
731
- WasmVanDerPolOscillator,
732
- WasmDuffingOscillator,
733
- WasmRungeKutta4,
734
- WasmLyapunovSpectrum,
735
- WasmBifurcationDiagram,
736
- WasmPhasePortrait,
737
- WasmStabilityAnalysis,
738
- computeLyapunovExponents,
739
- findFixedPoints
740
- } from '@justinelliottcobb/amari-wasm';
741
-
742
- async function dynamicsDemo() {
743
- await init();
744
-
745
- // ========================================
746
- // Lorenz Attractor
747
- // ========================================
748
-
749
- // Create classic Lorenz system (sigma=10, rho=28, beta=8/3)
750
- const lorenz = WasmLorenzSystem.classic();
751
- console.log(`Lorenz parameters: σ=${lorenz.sigma}, ρ=${lorenz.rho}, β=${lorenz.beta}`);
752
-
753
- // Create RK4 solver
754
- const solver = new WasmRungeKutta4();
755
-
756
- // Integrate trajectory from initial condition
757
- const initial = [1.0, 1.0, 1.0];
758
- const trajectory = solver.solve(lorenz, initial, 0.0, 50.0, 5000);
759
-
760
- console.log(`Trajectory has ${trajectory.length} points`);
761
-
762
- // Get final state
763
- const finalState = trajectory[trajectory.length - 1];
764
- console.log(`Final state: (${finalState[0].toFixed(3)}, ${finalState[1].toFixed(3)}, ${finalState[2].toFixed(3)})`);
765
-
766
- // ========================================
767
- // Van der Pol Limit Cycle
768
- // ========================================
769
-
770
- // Create Van der Pol oscillator with mu = 1.0
771
- const vdp = WasmVanDerPolOscillator.new(1.0);
772
-
773
- // Small initial displacement
774
- const vdpTrajectory = solver.solve(vdp, [0.1, 0.0], 0.0, 50.0, 5000);
775
-
776
- // Check limit cycle amplitude
777
- const vdpFinal = vdpTrajectory[vdpTrajectory.length - 1];
778
- console.log(`Van der Pol final amplitude: ${Math.abs(vdpFinal[0]).toFixed(3)}`);
779
-
780
- // ========================================
781
- // Lyapunov Exponents
782
- // ========================================
783
-
784
- // Compute Lyapunov spectrum for Lorenz system
785
- const lyapunov = computeLyapunovExponents(lorenz, initial, 10000, 0.01);
786
-
787
- console.log(`Lyapunov exponents: [${lyapunov.exponents.map(e => e.toFixed(4)).join(', ')}]`);
788
- console.log(`Sum: ${lyapunov.sum().toFixed(4)} (negative = dissipative)`);
789
-
790
- if (lyapunov.exponents[0] > 0) {
791
- console.log('System is chaotic!');
792
- }
793
-
794
- // Kaplan-Yorke dimension
795
- console.log(`Kaplan-Yorke dimension: ${lyapunov.kaplanYorkeDimension().toFixed(3)}`);
796
-
797
- // ========================================
798
- // Bifurcation Diagram
799
- // ========================================
800
-
801
- // Compute bifurcation diagram for logistic map
802
- const bifurcation = WasmBifurcationDiagram.compute(
803
- 'logistic',
804
- 2.5, // r_min
805
- 4.0, // r_max
806
- 1000, // num_parameters
807
- 500, // transient iterations
808
- 100 // sample points per parameter
809
- );
810
-
811
- console.log(`Bifurcation diagram: ${bifurcation.parameterCount()} parameter values`);
812
-
813
- // Get attractor points at specific parameter
814
- const attractorAt3_5 = bifurcation.attractorPoints(3.5);
815
- console.log(`Attractor at r=3.5: ${attractorAt3_5.length} points`);
816
-
817
- // ========================================
818
- // Stability Analysis
819
- // ========================================
820
-
821
- // Find fixed points of Van der Pol oscillator
822
- const fixedPoints = findFixedPoints(vdp, [[0.0, 0.0]], 1e-10);
823
-
824
- for (const fp of fixedPoints) {
825
- console.log(`Fixed point: (${fp.point[0].toFixed(6)}, ${fp.point[1].toFixed(6)})`);
826
-
827
- // Analyze stability
828
- const stability = WasmStabilityAnalysis.analyze(vdp, fp.point);
829
- console.log(` Stability: ${stability.stabilityType}`);
830
- console.log(` Eigenvalues: ${stability.eigenvalues.map(e => `${e.real.toFixed(4)}+${e.imag.toFixed(4)}i`).join(', ')}`);
831
- }
832
-
833
- // ========================================
834
- // Phase Portrait
835
- // ========================================
836
-
837
- // Generate phase portrait for Duffing oscillator
838
- const duffing = WasmDuffingOscillator.new(1.0, -1.0, 0.2, 0.3, 1.2);
839
- const portrait = WasmPhasePortrait.generate(
840
- duffing,
841
- [-2.0, 2.0], // x range
842
- [-2.0, 2.0], // y range
843
- 20, // grid resolution
844
- 5.0, // integration time
845
- 0.01 // dt
846
- );
847
-
848
- console.log(`Phase portrait: ${portrait.trajectoryCount()} trajectories`);
849
-
850
- // Get nullclines
851
- const nullclines = portrait.nullclines();
852
- console.log(`x-nullcline: ${nullclines.x.length} points`);
853
- console.log(`y-nullcline: ${nullclines.y.length} points`);
854
-
855
- // Clean up WASM memory
856
- lorenz.free();
857
- vdp.free();
858
- duffing.free();
859
- solver.free();
860
- bifurcation.free();
861
- portrait.free();
862
- fixedPoints.forEach(fp => fp.free());
863
- }
864
-
865
- dynamicsDemo();
866
- ```
867
-
868
- #### Dynamics API
869
-
870
- **WasmLorenzSystem:**
871
- - `classic()`: Create with σ=10, ρ=28, β=8/3
872
- - `new(sigma, rho, beta)`: Create with custom parameters
873
- - `sigma`, `rho`, `beta`: Parameter getters
874
- - `vectorField(state)`: Evaluate dx/dt at state
875
-
876
- **WasmVanDerPolOscillator:**
877
- - `new(mu)`: Create with damping parameter μ
878
- - `mu`: Parameter getter
879
- - `vectorField(state)`: Evaluate dx/dt at state
880
-
881
- **WasmDuffingOscillator:**
882
- - `new(alpha, beta, delta, gamma, omega)`: Create driven Duffing oscillator
883
- - `vectorField(state, t)`: Evaluate dx/dt at state and time t
884
-
885
- **WasmRosslerSystem:**
886
- - `new(a, b, c)`: Create Rossler attractor
887
- - `classic()`: Create with a=0.2, b=0.2, c=5.7
888
-
889
- **WasmHenonMap:**
890
- - `new(a, b)`: Create Henon map
891
- - `classic()`: Create with a=1.4, b=0.3
892
- - `iterate(state)`: Apply one map iteration
893
-
894
- **WasmRungeKutta4:**
895
- - `new()`: Create RK4 solver
896
- - `solve(system, initial, t0, t1, steps)`: Integrate trajectory
897
- - `step(system, state, t, dt)`: Single integration step
898
-
899
- **WasmAdaptiveSolver:**
900
- - `rkf45()`: Create RKF45 adaptive solver
901
- - `dormandPrince()`: Create Dormand-Prince solver
902
- - `solve(system, initial, t0, t1, tolerance)`: Adaptive integration
903
-
904
- **Lyapunov Functions:**
905
- - `computeLyapunovExponents(system, initial, steps, dt)`: Compute spectrum
906
- - Returns: `{ exponents, sum(), kaplanYorkeDimension(), isChaotic() }`
907
-
908
- **WasmBifurcationDiagram:**
909
- - `compute(systemType, paramMin, paramMax, numParams, transient, samples)`: Generate diagram
910
- - `parameterCount()`: Number of parameter values
911
- - `attractorPoints(param)`: Get attractor at specific parameter
912
- - `branches()`: Get all (parameter, points) pairs
913
-
914
- **WasmStabilityAnalysis:**
915
- - `analyze(system, point)`: Analyze stability at point
916
- - `stabilityType`: 'stable_node', 'stable_spiral', 'unstable_node', 'unstable_spiral', 'saddle', 'center'
917
- - `eigenvalues`: Array of {real, imag} pairs
918
- - `isStable()`: True if asymptotically stable
919
-
920
- **findFixedPoints:**
921
- - `findFixedPoints(system, initialGuesses, tolerance)`: Find fixed points via Newton's method
922
- - Returns array of `{ point, converged, iterations }`
923
-
924
- **WasmPhasePortrait:**
925
- - `generate(system, xRange, yRange, resolution, tMax, dt)`: Generate portrait
926
- - `trajectoryCount()`: Number of trajectories
927
- - `trajectories()`: Get all trajectory arrays
928
- - `nullclines()`: Get {x, y} nullcline point arrays
929
-
930
- #### Topology API
931
-
932
- **WasmSimplex:**
933
- - `new(vertices)`: Create simplex from vertex indices
934
- - `dimension()`: Get dimension (vertices - 1)
935
- - `getVertices()`: Get sorted vertex array
936
- - `orientation()`: Get orientation sign (+1 or -1)
937
- - `containsVertex(v)`: Check if vertex is in simplex
938
- - `faces(k)`: Get all k-dimensional faces
939
- - `boundaryFaces()`: Get boundary faces with signs
940
-
941
- **WasmSimplicialComplex:**
942
- - `new()`: Create empty complex
943
- - `addSimplex(vertices)`: Add simplex and all its faces
944
- - `contains(vertices)`: Check if simplex exists
945
- - `dimension()`: Get maximum simplex dimension
946
- - `simplexCount(dim)`: Count simplices in dimension
947
- - `totalSimplexCount()`: Total simplex count
948
- - `vertexCount()`: Count 0-simplices
949
- - `edgeCount()`: Count 1-simplices
950
- - `bettiNumbers()`: Compute [β₀, β₁, β₂, ...]
951
- - `eulerCharacteristic()`: Compute χ = Σ(-1)^k f_k
952
- - `fVector()`: Get face counts [f₀, f₁, f₂, ...]
953
- - `isConnected()`: Check if complex is connected
954
- - `connectedComponents()`: Count components
955
-
956
- **WasmFiltration:**
957
- - `new()`: Create empty filtration
958
- - `add(time, vertices)`: Add simplex at filtration time
959
- - `isEmpty()`: Check if filtration is empty
960
- - `complexAt(time)`: Get complex at given time
961
- - `bettiAt(time)`: Get Betti numbers at time
962
-
963
- **WasmPersistentHomology:**
964
- - `compute(filtration)`: Compute persistent homology
965
- - `getDiagram()`: Get [dim, birth, death, ...] triples
966
- - `bettiAt(time)`: Get Betti numbers at time
967
- - `intervalCount(dim)`: Count intervals in dimension
968
-
969
- **Standalone Functions:**
970
- - `ripsFromDistances(numPoints, maxDim, distances)`: Create Rips filtration
971
- - `findCriticalPoints2D(resolution, xMin, xMax, yMin, yMax, tolerance, values)`: Find critical points
972
-
973
- **WasmMorseComplex:**
974
- - `new(criticalPoints)`: Create from critical points
975
- - `countsByIndex()`: Get counts by Morse index
976
- - `checkWeakMorseInequalities(betti)`: Verify c_k >= β_k
977
-
978
- #### Optical Field API
979
-
980
- **WasmOpticalRotorField:**
981
- - `random(width, height, seed)`: Create random phase field
982
- - `uniform(phase, amplitude, width, height)`: Uniform field
983
- - `identity(width, height)`: Identity field (phase = 0)
984
- - `fromPhase(phases, width, height)`: Create from phase array
985
- - `phaseAt(x, y)`: Get phase at point (radians)
986
- - `amplitudeAt(x, y)`: Get amplitude at point
987
- - `totalEnergy()`: Sum of squared amplitudes
988
- - `normalized()`: Normalized copy (energy = 1)
989
-
990
- **WasmGeometricLeeEncoder:**
991
- - `withFrequency(width, height, frequency)`: Create horizontal carrier encoder
992
- - `new(width, height, frequency, angle)`: Create with angled carrier
993
- - `encode(field)`: Encode to binary hologram
994
- - `modulate(field)`: Get modulated field before thresholding
995
- - `theoreticalEfficiency(field)`: Compute diffraction efficiency
996
-
997
- **WasmBinaryHologram:**
998
- - `get(x, y)`: Get pixel value
999
- - `set(x, y, value)`: Set pixel value
1000
- - `fillFactor()`: Fraction of "on" pixels
1001
- - `hammingDistance(other)`: Compute Hamming distance
1002
- - `asBytes()`: Get packed binary data
1003
- - `inverted()`: Create inverted copy
1004
-
1005
- **WasmOpticalFieldAlgebra:**
1006
- - `bind(a, b)`: Rotor multiplication (phase addition)
1007
- - `unbind(key, bound)`: Retrieve associated field
1008
- - `bundle(fields, weights)`: Weighted superposition
1009
- - `bundleUniform(fields)`: Equal-weight bundle
1010
- - `similarity(a, b)`: Normalized inner product
1011
- - `inverse(field)`: Phase negation
1012
- - `scale(field, factor)`: Amplitude scaling
1013
- - `addPhase(field, phase)`: Add constant phase
1014
-
1015
- **WasmOpticalCodebook:**
1016
- - `new(width, height, baseSeed)`: Create codebook
1017
- - `register(symbol)`: Register symbol with auto-seed
1018
- - `get(symbol)`: Get or generate field for symbol
1019
- - `contains(symbol)`: Check if symbol is registered
1020
- - `symbols()`: Get all registered symbol names
1021
-
1022
- **WasmTropicalOpticalAlgebra:**
1023
- - `tropicalAdd(a, b)`: Pointwise minimum phase magnitude
1024
- - `tropicalMax(a, b)`: Pointwise maximum phase magnitude
1025
- - `tropicalMul(a, b)`: Binding (phase addition)
1026
- - `softTropicalAdd(a, b, beta)`: Soft minimum with temperature
1027
- - `phaseDistance(a, b)`: Sum of absolute phase differences
1028
- - `attractorConverge(initial, attractors, maxIter, tol)`: Attractor dynamics
1029
-
1030
- #### Probability API
1031
-
1032
- **WasmGaussianMultivector:**
1033
- - `standard()`: Create standard Gaussian on full multivector space
1034
- - `new(mean, covariance)`: Create with specified mean and covariance
1035
- - `gradeConcentrated(grade, scale)`: Gaussian concentrated on specific grade
1036
- - `sample()`: Draw a random sample
1037
- - `logProb(sample)`: Compute log probability density
1038
-
1039
- **WasmUniformMultivector:**
1040
- - `unitSphere()`: Uniform distribution on unit multivectors
1041
- - `gradeSimplex(grade)`: Uniform on grade components summing to 1
1042
- - `sample()`: Draw a random sample
1043
-
1044
- **WasmMonteCarloEstimator:**
1045
- - `estimate(fn, distribution, nSamples)`: Estimate expectation
1046
- - `estimateVariance(fn, distribution, nSamples)`: Estimate variance
1047
-
1048
- #### Holographic Memory API
1049
-
1050
- **TropicalDualClifford Operations:**
1051
- - `bind(other)`: Binding operation using geometric product
1052
- - `unbind(other)`: Inverse binding for retrieval
1053
- - `bundle(other, beta)`: Bundling operation for superposition
1054
- - `similarity(other)`: Compute normalized similarity
1055
- - `bindingIdentity()`: Get the identity element for binding
1056
- - `bindingInverse()`: Compute approximate inverse
1057
- - `randomVector()`: Create a random unit vector
1058
- - `normalizeToUnit()`: Normalize to unit magnitude
1059
-
1060
- **HolographicMemory:**
1061
- - `store(key, value)`: Store a key-value association
1062
- - `storeBatch(pairs)`: Store multiple associations efficiently
1063
- - `retrieve(key)`: Retrieve value associated with key
1064
- - `capacityInfo()`: Get storage statistics (item count, SNR, capacity)
1065
- - `clear()`: Clear all stored associations
1066
-
1067
- **Resonator:**
1068
- - `new(codebook)`: Create resonator with clean reference vectors
1069
- - `cleanup(input)`: Clean up noisy input to nearest codebook entry
1070
- - `cleanupWithIterations(input, maxIter)`: Iterative cleanup
87
+ See the [docs/](docs/) directory for detailed guides and API references for each module.
1071
88
 
1072
89
  ## Use Cases
1073
90
 
@@ -1076,175 +93,16 @@ dynamicsDemo();
1076
93
  - **Machine Learning**: Tropical neural networks and automatic differentiation
1077
94
  - **Optimization**: Tropical algebra for shortest path and scheduling problems
1078
95
  - **Scientific Computing**: High-performance mathematical operations with orbital-grade precision
1079
- - **Probability & Statistics**: Measure theory and numerical integration for statistical computations
1080
- - **Bayesian Inference**: Probabilistic modeling on geometric algebra spaces
1081
- - **Uncertainty Quantification**: Monte Carlo methods for error propagation
1082
- - **Game Development**: Efficient spatial transformations and physics
1083
- - **Spacecraft Trajectory Planning**: High-precision orbital mechanics in web applications
96
+ - **Probability & Statistics**: Measure theory, numerical integration, and probabilistic modeling
97
+ - **Formal Verification**: SMT-LIB2 proof obligation generation for browser-based verification workflows
1084
98
  - **Symbolic AI**: Holographic memory for associative reasoning and concept binding
1085
- - **Cognitive Architectures**: Brain-inspired memory systems for AI agents
1086
- - **Embedding Retrieval**: Content-addressable semantic search in vector databases
1087
99
  - **Holographic Displays**: Lee hologram encoding for DMD and SLM devices
1088
- - **Optical Computing**: Phase-encoded VSA operations for optical neural networks
1089
100
  - **Topological Data Analysis**: Persistent homology for shape and feature detection
1090
- - **Computational Biology**: Protein structure analysis via simplicial complexes
1091
- - **Sensor Networks**: Coverage analysis using homology
1092
101
  - **Chaos Theory**: Lorenz attractors, bifurcation diagrams, Lyapunov exponents
1093
- - **Control Systems**: Stability analysis and phase portraits for dynamical systems
1094
- - **Climate Modeling**: Sensitivity analysis via Lyapunov spectrum computation
1095
102
  - **Algebraic Geometry**: Rational curve counting, Schubert calculus, Gromov-Witten invariants
1096
- - **Combinatorics**: Matroid operations, Littlewood-Richardson coefficients
1097
- - **Access Control**: Geometric namespace/capability systems for secure multi-agent coordination
1098
-
1099
- ## API Reference
1100
-
1101
- ### Multivector Operations
1102
-
1103
- - `WasmMultivector.basis_vector(index)`: Create a basis vector
1104
- - `WasmMultivector.scalar(value)`: Create a scalar multivector
1105
- - `WasmMultivector.from_coefficients(array)`: Create from coefficients
1106
- - `geometric_product(a, b)`: Compute geometric product
1107
- - `wedge_product(a, b)`: Compute wedge (outer) product
1108
- - `inner_product(a, b)`: Compute inner product
1109
-
1110
- ### Rotor Operations
1111
-
1112
- - `WasmRotor.from_axis_angle(axis, angle)`: Create rotation rotor
1113
- - `WasmRotor.from_bivector(bivector, angle)`: Create from bivector
1114
- - `rotate_vector(vector)`: Apply rotation to vector
1115
- - `compose(other)`: Compose rotations
1116
-
1117
- ### Tropical Operations
1118
-
1119
- - `tropical_add(a, b)`: Tropical addition (max)
1120
- - `tropical_multiply(a, b)`: Tropical multiplication (addition)
1121
- - `tropical_power(base, exp)`: Tropical exponentiation
1122
-
1123
- ### Holographic Memory Operations
1124
-
1125
- - `WasmTropicalDualClifford.bind(other)`: Binding via geometric product
1126
- - `WasmTropicalDualClifford.unbind(other)`: Inverse binding
1127
- - `WasmTropicalDualClifford.bundle(other, beta)`: Superposition bundling
1128
- - `WasmTropicalDualClifford.similarity(other)`: Normalized similarity
1129
- - `WasmTropicalDualClifford.randomVector()`: Create random unit vector
1130
- - `WasmHolographicMemory.store(key, value)`: Store association
1131
- - `WasmHolographicMemory.retrieve(key)`: Retrieve by key
1132
- - `WasmResonator.cleanup(input)`: Clean up noisy input
1133
-
1134
- ### Probabilistic Operations
1135
-
1136
- - `WasmGaussianMultivector.standard()`: Standard Gaussian distribution
1137
- - `WasmGaussianMultivector.gradeConcentrated(grade, scale)`: Grade-specific Gaussian
1138
- - `WasmGaussianMultivector.sample()`: Draw random sample
1139
- - `WasmGaussianMultivector.logProb(sample)`: Log probability density
1140
- - `WasmUniformMultivector.unitSphere()`: Uniform on unit sphere
1141
- - `WasmUniformMultivector.sample()`: Draw random sample
1142
- - `WasmMonteCarloEstimator.estimate(fn, dist, n)`: Monte Carlo expectation
1143
-
1144
- ### Functional Analysis Operations
1145
-
1146
- - `WasmHilbertSpace.new()`: Create Hilbert space Cl(2,0,0)
1147
- - `WasmHilbertSpace.innerProduct(x, y)`: Compute inner product
1148
- - `WasmHilbertSpace.norm(x)`: Compute norm
1149
- - `WasmHilbertSpace.project(x, y)`: Orthogonal projection
1150
- - `WasmMatrixOperator.new(entries)`: Create matrix operator
1151
- - `WasmMatrixOperator.apply(x)`: Apply operator to vector
1152
- - `WasmMatrixOperator.operatorNorm()`: Compute operator norm
1153
- - `WasmSpectralDecomposition.compute(matrix, maxIter, tol)`: Eigenvalue decomposition
1154
- - `WasmSpectralDecomposition.eigenvalues()`: Get eigenvalues
1155
- - `WasmSpectralDecomposition.applyFunction(f, x)`: Functional calculus
1156
- - `WasmSobolevSpace.new(order, lower, upper)`: Create Sobolev space
1157
- - `WasmSobolevSpace.h1Norm(f, df)`: Compute H^1 norm
1158
- - `powerMethod(matrix, initial, maxIter, tol)`: Dominant eigenvalue
1159
- - `computeEigenvalues(matrix, maxIter, tol)`: All eigenvalues
1160
-
1161
- ### Optical Field Operations
1162
-
1163
- - `WasmOpticalRotorField.random(width, height, seed)`: Create random phase field
1164
- - `WasmOpticalRotorField.uniform(phase, amplitude, width, height)`: Uniform field
1165
- - `WasmGeometricLeeEncoder.withFrequency(width, height, freq)`: Create Lee encoder
1166
- - `WasmGeometricLeeEncoder.encode(field)`: Encode to binary hologram
1167
- - `WasmBinaryHologram.fillFactor()`: Fraction of "on" pixels
1168
- - `WasmBinaryHologram.asBytes()`: Get packed binary data for hardware
1169
- - `WasmOpticalFieldAlgebra.bind(a, b)`: Rotor product (phase addition)
1170
- - `WasmOpticalFieldAlgebra.unbind(key, bound)`: Retrieve associated field
1171
- - `WasmOpticalFieldAlgebra.similarity(a, b)`: Normalized inner product
1172
- - `WasmOpticalCodebook.register(symbol)`: Register symbol with auto-seed
1173
- - `WasmOpticalCodebook.get(symbol)`: Get field for symbol
1174
- - `WasmTropicalOpticalAlgebra.tropicalAdd(a, b)`: Pointwise minimum phase
1175
-
1176
- ### Topology Operations
1177
-
1178
- - `WasmSimplex.new(vertices)`: Create simplex from vertex array
1179
- - `WasmSimplex.dimension()`: Get simplex dimension
1180
- - `WasmSimplex.faces(k)`: Get k-dimensional faces
1181
- - `WasmSimplicialComplex.new()`: Create empty complex
1182
- - `WasmSimplicialComplex.addSimplex(vertices)`: Add simplex with closure
1183
- - `WasmSimplicialComplex.bettiNumbers()`: Compute Betti numbers
1184
- - `WasmSimplicialComplex.eulerCharacteristic()`: Compute Euler characteristic
1185
- - `WasmFiltration.add(time, vertices)`: Add simplex at filtration time
1186
- - `WasmPersistentHomology.compute(filtration)`: Compute persistence
1187
- - `WasmPersistentHomology.getDiagram()`: Get persistence diagram
1188
- - `ripsFromDistances(n, dim, distances)`: Build Rips filtration
1189
- - `findCriticalPoints2D(...)`: Find Morse critical points
1190
-
1191
- ### Dynamics Operations
1192
-
1193
- - `WasmLorenzSystem.classic()`: Create classic Lorenz attractor
1194
- - `WasmVanDerPolOscillator.new(mu)`: Create Van der Pol oscillator
1195
- - `WasmDuffingOscillator.new(alpha, beta, delta, gamma, omega)`: Create Duffing oscillator
1196
- - `WasmRosslerSystem.classic()`: Create Rossler attractor
1197
- - `WasmHenonMap.classic()`: Create Henon map
1198
- - `WasmRungeKutta4.solve(system, initial, t0, t1, steps)`: Integrate trajectory
1199
- - `WasmAdaptiveSolver.rkf45()`: Create adaptive RKF45 solver
1200
- - `computeLyapunovExponents(system, initial, steps, dt)`: Compute Lyapunov spectrum
1201
- - `WasmBifurcationDiagram.compute(type, paramMin, paramMax, n, transient, samples)`: Generate bifurcation diagram
1202
- - `WasmStabilityAnalysis.analyze(system, point)`: Analyze fixed point stability
1203
- - `findFixedPoints(system, guesses, tolerance)`: Find fixed points
1204
- - `WasmPhasePortrait.generate(system, xRange, yRange, res, tMax, dt)`: Generate phase portrait
1205
-
1206
- ### Enumerative Geometry Operations
1207
-
1208
- - `WasmWDVVEngine.new()`: Create WDVV engine for rational curve counting
1209
- - `WasmWDVVEngine.rationalCurveCount(degree)`: Compute N_d (rational curves through 3d-1 points)
1210
- - `WasmWDVVEngine.requiredPointCount(degree, genus)`: Required point count (3d+g-1)
1211
- - `WasmWDVVEngine.getTable()`: Get table of computed curve counts
1212
- - `WasmWDVVEngine.p1xp1Count(a, b)`: Rational curves on P^1 x P^1 of bidegree (a,b)
1213
- - `WasmWDVVEngine.p3Count(degree)`: Rational curves in P^3
1214
- - `WasmEquivariantLocalizer.new(k, n)`: Create localizer for Gr(k,n)
1215
- - `WasmEquivariantLocalizer.fixedPointCount()`: Count T-fixed points (= C(n,k))
1216
- - `WasmEquivariantLocalizer.localizedIntersection(classes)`: Intersection via localization
1217
- - `WasmMatroid.uniform(k, n)`: Create uniform matroid U_{k,n}
1218
- - `WasmMatroid.getRank()`: Get matroid rank
1219
- - `WasmMatroid.getNumBases()`: Get number of bases
1220
- - `WasmMatroid.dual()`: Compute dual matroid
1221
- - `WasmMatroid.deleteElement(e)`: Delete element
1222
- - `WasmMatroid.contractElement(e)`: Contract element
1223
- - `WasmCSMClass.ofSchubertCell(partition, k, n)`: CSM class of Schubert cell
1224
- - `WasmCSMClass.ofSchubertVariety(partition, k, n)`: CSM class of Schubert variety
1225
- - `WasmCSMClass.eulerCharacteristic()`: Get Euler characteristic
1226
- - `WasmStabilityCondition.new(k, n, trust)`: Create stability condition
1227
- - `WasmStabilityCondition.phase(class)`: Compute phase of a class
1228
- - `WasmStabilityCondition.stableCount(namespace)`: Count stable objects
1229
- - `WasmWallCrossingEngine.new(k, n)`: Create wall-crossing engine
1230
- - `WasmWallCrossingEngine.computeWalls(namespace)`: Find walls
1231
- - `WasmWallCrossingEngine.stableCountAt(namespace, trust)`: Stable count at trust level
1232
- - `WasmWallCrossingEngine.phaseDiagram(namespace)`: Generate phase diagram
1233
- - `WasmComposableNamespace.new(namespace)`: Create composable namespace
1234
- - `WasmComposableNamespace.markOutput(capId)`: Mark output interface
1235
- - `WasmComposableNamespace.markInput(capId)`: Mark input interface
1236
- - `composeNamespaces(outer, inner)`: Compose along matching interfaces
1237
- - `compositionMultiplicity(outer, inner)`: Intersection number of interfaces
1238
- - `interfacesCompatible(outer, inner)`: Check interface compatibility
1239
-
1240
- ## Examples
1241
-
1242
- Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tree/master/examples) for more detailed usage:
1243
-
1244
- - [Basic Geometric Algebra](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/geometric.ts)
1245
- - [3D Rotations with Rotors](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/rotations.ts)
1246
- - [Tropical Neural Networks](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/tropical.ts)
1247
- - [Cellular Automata](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/cellular.ts)
103
+ - **Error-Correcting Codes**: Binary linear codes (Hamming, Reed-Muller, Golay) for communication systems
104
+ - **Finite Field Combinatorics**: Grassmannian point counting, matroid representability, Kazhdan-Lusztig polynomials
105
+ - **Spacecraft Trajectory Planning**: High-precision orbital mechanics in web applications
1248
106
 
1249
107
  ## Building from Source
1250
108