@justinelliottcobb/amari-wasm 0.10.0 → 0.12.2
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 +115 -10
- package/amari_wasm.d.ts +651 -110
- package/amari_wasm.js +1492 -433
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ Amari is a comprehensive mathematical computing library that brings advanced alg
|
|
|
15
15
|
- **Geometric Algebra (Clifford Algebra)**: Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
|
|
16
16
|
- **Tropical Algebra**: Max-plus semiring operations for optimization and neural network applications
|
|
17
17
|
- **Automatic Differentiation**: Forward-mode AD with dual numbers for exact derivatives
|
|
18
|
-
- **Measure Theory** *(
|
|
18
|
+
- **Measure Theory** *(v0.10.0)*: Lebesgue integration, probability measures, and measure-theoretic foundations
|
|
19
|
+
- **Holographic Memory** *(v0.12.2)*: Vector Symbolic Architecture for associative memory with binding and bundling operations
|
|
19
20
|
- **Relativistic Physics**: Spacetime algebra (Cl(1,3)) with WebAssembly-compatible precision
|
|
20
21
|
- **Spacecraft Orbital Mechanics**: Full-precision trajectory calculations in browsers
|
|
21
22
|
- **Cellular Automata**: Geometric cellular automata with multivector states
|
|
@@ -187,7 +188,7 @@ for (let i = 0; i < 100; i++) {
|
|
|
187
188
|
console.log(`Generation: ${ca.generation()}`);
|
|
188
189
|
```
|
|
189
190
|
|
|
190
|
-
### Measure Theory and Integration *(
|
|
191
|
+
### Measure Theory and Integration *(v0.10.0)*
|
|
191
192
|
|
|
192
193
|
Perform numerical integration and work with probability measures:
|
|
193
194
|
|
|
@@ -208,16 +209,109 @@ const prob = WasmProbabilityMeasure.uniform(0, 1);
|
|
|
208
209
|
const p = prob.probabilityInterval(0.25, 0.75, 0, 1); // P(0.25 ≤ X ≤ 0.75) = 0.5
|
|
209
210
|
```
|
|
210
211
|
|
|
212
|
+
### Holographic Memory *(v0.12.2)*
|
|
213
|
+
|
|
214
|
+
Store and retrieve key-value associations using Vector Symbolic Architecture:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import init, {
|
|
218
|
+
WasmTropicalDualClifford,
|
|
219
|
+
WasmHolographicMemory,
|
|
220
|
+
WasmResonator
|
|
221
|
+
} from '@justinelliottcobb/amari-wasm';
|
|
222
|
+
|
|
223
|
+
async function holographicDemo() {
|
|
224
|
+
await init();
|
|
225
|
+
|
|
226
|
+
// Create random vectors for keys and values
|
|
227
|
+
const key1 = WasmTropicalDualClifford.randomVector();
|
|
228
|
+
const value1 = WasmTropicalDualClifford.randomVector();
|
|
229
|
+
const key2 = WasmTropicalDualClifford.randomVector();
|
|
230
|
+
const value2 = WasmTropicalDualClifford.randomVector();
|
|
231
|
+
|
|
232
|
+
// Create holographic memory
|
|
233
|
+
const memory = new WasmHolographicMemory();
|
|
234
|
+
|
|
235
|
+
// Store associations
|
|
236
|
+
memory.store(key1, value1);
|
|
237
|
+
memory.store(key2, value2);
|
|
238
|
+
|
|
239
|
+
// Retrieve with a key
|
|
240
|
+
const result = memory.retrieve(key1);
|
|
241
|
+
console.log(`Confidence: ${result.confidence()}`);
|
|
242
|
+
console.log(`Similarity to original: ${result.value().similarity(value1)}`);
|
|
243
|
+
|
|
244
|
+
// Check capacity
|
|
245
|
+
const info = memory.capacityInfo();
|
|
246
|
+
console.log(`Items stored: ${info.itemCount}`);
|
|
247
|
+
console.log(`Estimated SNR: ${info.estimatedSnr}`);
|
|
248
|
+
|
|
249
|
+
// Binding operations (key ⊛ value)
|
|
250
|
+
const bound = key1.bind(value1);
|
|
251
|
+
const unbound = bound.unbind(key1); // Recovers value1
|
|
252
|
+
|
|
253
|
+
// Similarity computation
|
|
254
|
+
const sim = key1.similarity(key2);
|
|
255
|
+
console.log(`Key similarity: ${sim}`);
|
|
256
|
+
|
|
257
|
+
// Resonator cleanup for noisy inputs
|
|
258
|
+
const codebook = [key1, key2, value1, value2];
|
|
259
|
+
const resonator = WasmResonator.new(codebook);
|
|
260
|
+
const noisyInput = key1; // Add noise in practice
|
|
261
|
+
const cleaned = resonator.cleanup(noisyInput);
|
|
262
|
+
console.log(`Best match index: ${cleaned.bestMatchIndex()}`);
|
|
263
|
+
|
|
264
|
+
// Clean up WASM memory
|
|
265
|
+
key1.free();
|
|
266
|
+
value1.free();
|
|
267
|
+
key2.free();
|
|
268
|
+
value2.free();
|
|
269
|
+
memory.free();
|
|
270
|
+
bound.free();
|
|
271
|
+
unbound.free();
|
|
272
|
+
resonator.free();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
holographicDemo();
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Holographic Memory API
|
|
279
|
+
|
|
280
|
+
**TropicalDualClifford Operations:**
|
|
281
|
+
- `bind(other)`: Binding operation using geometric product
|
|
282
|
+
- `unbind(other)`: Inverse binding for retrieval
|
|
283
|
+
- `bundle(other, beta)`: Bundling operation for superposition
|
|
284
|
+
- `similarity(other)`: Compute normalized similarity
|
|
285
|
+
- `bindingIdentity()`: Get the identity element for binding
|
|
286
|
+
- `bindingInverse()`: Compute approximate inverse
|
|
287
|
+
- `randomVector()`: Create a random unit vector
|
|
288
|
+
- `normalizeToUnit()`: Normalize to unit magnitude
|
|
289
|
+
|
|
290
|
+
**HolographicMemory:**
|
|
291
|
+
- `store(key, value)`: Store a key-value association
|
|
292
|
+
- `storeBatch(pairs)`: Store multiple associations efficiently
|
|
293
|
+
- `retrieve(key)`: Retrieve value associated with key
|
|
294
|
+
- `capacityInfo()`: Get storage statistics (item count, SNR, capacity)
|
|
295
|
+
- `clear()`: Clear all stored associations
|
|
296
|
+
|
|
297
|
+
**Resonator:**
|
|
298
|
+
- `new(codebook)`: Create resonator with clean reference vectors
|
|
299
|
+
- `cleanup(input)`: Clean up noisy input to nearest codebook entry
|
|
300
|
+
- `cleanupWithIterations(input, maxIter)`: Iterative cleanup
|
|
301
|
+
|
|
211
302
|
## Use Cases
|
|
212
303
|
|
|
213
|
-
- Computer Graphics
|
|
214
|
-
- Physics Simulations
|
|
215
|
-
- Machine Learning
|
|
216
|
-
- Optimization
|
|
217
|
-
- Scientific Computing
|
|
218
|
-
- Probability & Statistics
|
|
219
|
-
- Game Development
|
|
220
|
-
- Spacecraft Trajectory Planning
|
|
304
|
+
- **Computer Graphics**: 3D rotations and transformations using rotors
|
|
305
|
+
- **Physics Simulations**: Geometric algebra for electromagnetic fields and relativistic calculations
|
|
306
|
+
- **Machine Learning**: Tropical neural networks and automatic differentiation
|
|
307
|
+
- **Optimization**: Tropical algebra for shortest path and scheduling problems
|
|
308
|
+
- **Scientific Computing**: High-performance mathematical operations with orbital-grade precision
|
|
309
|
+
- **Probability & Statistics**: Measure theory and numerical integration for statistical computations
|
|
310
|
+
- **Game Development**: Efficient spatial transformations and physics
|
|
311
|
+
- **Spacecraft Trajectory Planning**: High-precision orbital mechanics in web applications
|
|
312
|
+
- **Symbolic AI**: Holographic memory for associative reasoning and concept binding
|
|
313
|
+
- **Cognitive Architectures**: Brain-inspired memory systems for AI agents
|
|
314
|
+
- **Embedding Retrieval**: Content-addressable semantic search in vector databases
|
|
221
315
|
|
|
222
316
|
## API Reference
|
|
223
317
|
|
|
@@ -243,6 +337,17 @@ const p = prob.probabilityInterval(0.25, 0.75, 0, 1); // P(0.25 ≤ X ≤ 0.75)
|
|
|
243
337
|
- `tropical_multiply(a, b)`: Tropical multiplication (addition)
|
|
244
338
|
- `tropical_power(base, exp)`: Tropical exponentiation
|
|
245
339
|
|
|
340
|
+
### Holographic Memory Operations
|
|
341
|
+
|
|
342
|
+
- `WasmTropicalDualClifford.bind(other)`: Binding via geometric product
|
|
343
|
+
- `WasmTropicalDualClifford.unbind(other)`: Inverse binding
|
|
344
|
+
- `WasmTropicalDualClifford.bundle(other, beta)`: Superposition bundling
|
|
345
|
+
- `WasmTropicalDualClifford.similarity(other)`: Normalized similarity
|
|
346
|
+
- `WasmTropicalDualClifford.randomVector()`: Create random unit vector
|
|
347
|
+
- `WasmHolographicMemory.store(key, value)`: Store association
|
|
348
|
+
- `WasmHolographicMemory.retrieve(key)`: Retrieve by key
|
|
349
|
+
- `WasmResonator.cleanup(input)`: Clean up noisy input
|
|
350
|
+
|
|
246
351
|
## Examples
|
|
247
352
|
|
|
248
353
|
Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tree/master/examples) for more detailed usage:
|