@justinelliottcobb/amari-wasm 0.12.2 → 0.12.3

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/amari_wasm.d.ts CHANGED
@@ -877,29 +877,6 @@ export class WasmChowClass {
877
877
  */
878
878
  multiply(other: WasmChowClass): WasmChowClass;
879
879
  }
880
- /**
881
- * WASM wrapper for cleanup results
882
- */
883
- export class WasmCleanupResult {
884
- private constructor();
885
- free(): void;
886
- /**
887
- * Get the cleaned (denoised) value
888
- */
889
- getCleaned(): WasmTropicalDualClifford;
890
- /**
891
- * Check if the cleanup converged
892
- */
893
- didConverge(): boolean;
894
- /**
895
- * Get the number of iterations used
896
- */
897
- getIterations(): number;
898
- /**
899
- * Get the index of the best matching codebook item
900
- */
901
- getBestMatchIndex(): number;
902
- }
903
880
  /**
904
881
  * WASM wrapper for community detection results
905
882
  */
@@ -1422,7 +1399,7 @@ export class WasmGrassmannian {
1422
1399
  constructor(k: number, n: number);
1423
1400
  }
1424
1401
  /**
1425
- * WASM wrapper for HolographicMemory
1402
+ * WASM wrapper for HolographicMemory using ProductClifford algebra
1426
1403
  */
1427
1404
  export class WasmHolographicMemory {
1428
1405
  free(): void;
@@ -1430,38 +1407,30 @@ export class WasmHolographicMemory {
1430
1407
  * Get the number of stored items
1431
1408
  */
1432
1409
  itemCount(): number;
1433
- /**
1434
- * Batch store multiple key-value pairs
1435
- */
1436
- storeBatch(keys: Float64Array, values: Float64Array): void;
1437
1410
  /**
1438
1411
  * Get the estimated SNR (signal-to-noise ratio)
1439
1412
  */
1440
1413
  estimatedSnr(): number;
1441
1414
  /**
1442
- * Check if memory is near capacity
1415
+ * Generate a random versor (for use as key/value)
1443
1416
  */
1444
- isNearCapacity(): boolean;
1417
+ static randomVersor(num_factors: number): Float64Array;
1445
1418
  /**
1446
- * Check if memory probably contains a key
1419
+ * Check if memory is near capacity
1447
1420
  */
1448
- probablyContains(key: WasmTropicalDualClifford): boolean;
1421
+ isNearCapacity(): boolean;
1449
1422
  /**
1450
1423
  * Create with key tracking enabled (for attribution)
1451
1424
  */
1452
1425
  static withKeyTracking(): WasmHolographicMemory;
1453
1426
  /**
1454
- * Get the theoretical capacity
1455
- */
1456
- theoreticalCapacity(): number;
1457
- /**
1458
- * Retrieve with custom temperature
1427
+ * Get retrieval confidence for a key
1459
1428
  */
1460
- retrieveAtTemperature(key: WasmTropicalDualClifford, beta: number): WasmRetrievalResult;
1429
+ retrieveConfidence(key: Float64Array): number;
1461
1430
  /**
1462
- * Create with custom bundle temperature
1431
+ * Get capacity information
1463
1432
  */
1464
- static withBundleTemperature(beta: number): WasmHolographicMemory;
1433
+ theoreticalCapacity(): number;
1465
1434
  /**
1466
1435
  * Create a new holographic memory with default settings
1467
1436
  */
@@ -1471,17 +1440,17 @@ export class WasmHolographicMemory {
1471
1440
  */
1472
1441
  clear(): void;
1473
1442
  /**
1474
- * Merge another memory into this one
1475
- */
1476
- merge(other: WasmHolographicMemory): void;
1477
- /**
1478
- * Store a key-value pair in memory
1443
+ * Store a key-value pair in memory (using flat coefficient arrays)
1444
+ *
1445
+ * Each array should have 256 coefficients for ProductCl3x32.
1479
1446
  */
1480
- store(key: WasmTropicalDualClifford, value: WasmTropicalDualClifford): void;
1447
+ store(key: Float64Array, value: Float64Array): void;
1481
1448
  /**
1482
1449
  * Retrieve a value by key
1450
+ *
1451
+ * Returns the retrieved coefficients as a Float64Array.
1483
1452
  */
1484
- retrieve(key: WasmTropicalDualClifford): WasmRetrievalResult;
1453
+ retrieve(key: Float64Array): Float64Array;
1485
1454
  }
1486
1455
  /**
1487
1456
  * WASM wrapper for Inverse CA Designer (simplified)
@@ -1987,45 +1956,28 @@ export class WasmRelativisticParticle {
1987
1956
  to_string(): string;
1988
1957
  }
1989
1958
  /**
1990
- * WASM wrapper for Resonator (iterative cleanup)
1959
+ * WASM wrapper for Resonator using ProductClifford algebra
1991
1960
  */
1992
1961
  export class WasmResonator {
1993
1962
  free(): void;
1994
- /**
1995
- * Create with custom configuration
1996
- */
1997
- static withConfig(codebook_flat: Float64Array, max_iterations: number, convergence_threshold: number): WasmResonator;
1998
1963
  /**
1999
1964
  * Get the codebook size
2000
1965
  */
2001
1966
  codebookSize(): number;
2002
1967
  /**
2003
- * Create a resonator from a codebook of TDC vectors
1968
+ * Get cleanup result with metadata
2004
1969
  */
2005
- constructor(codebook_flat: Float64Array);
1970
+ cleanupWithInfo(input: Float64Array): any;
2006
1971
  /**
2007
- * Clean up a noisy input to find the closest codebook item
2008
- */
2009
- cleanup(input: WasmTropicalDualClifford): WasmCleanupResult;
2010
- }
2011
- /**
2012
- * WASM wrapper for retrieval results
2013
- */
2014
- export class WasmRetrievalResult {
2015
- private constructor();
2016
- free(): void;
2017
- /**
2018
- * Get the retrieval confidence (0 to 1)
2019
- */
2020
- getConfidence(): number;
2021
- /**
2022
- * Get attribution as arrays of [index, weight] pairs
1972
+ * Create a resonator from a flat codebook array
1973
+ *
1974
+ * Each item should have 256 coefficients for ProductCl3x32.
2023
1975
  */
2024
- getAttribution(): any;
1976
+ constructor(codebook_flat: Float64Array);
2025
1977
  /**
2026
- * Get the retrieved value
1978
+ * Clean up a noisy input to find the closest codebook item
2027
1979
  */
2028
- getValue(): WasmTropicalDualClifford;
1980
+ cleanup(input: Float64Array): Float64Array;
2029
1981
  }
2030
1982
  /**
2031
1983
  * Rotor operations for WASM
@@ -2569,7 +2521,6 @@ export interface InitOutput {
2569
2521
  readonly __wbg_scalarfield_free: (a: number, b: number) => void;
2570
2522
  readonly __wbg_set_wasmtrajectorypoint_time: (a: number, b: number) => void;
2571
2523
  readonly __wbg_wasmchowclass_free: (a: number, b: number) => void;
2572
- readonly __wbg_wasmcleanupresult_free: (a: number, b: number) => void;
2573
2524
  readonly __wbg_wasmcommunity_free: (a: number, b: number) => void;
2574
2525
  readonly __wbg_wasmduallyflatmanifold_free: (a: number, b: number) => void;
2575
2526
  readonly __wbg_wasmevaluationresult_free: (a: number, b: number) => void;
@@ -2590,7 +2541,6 @@ export interface InitOutput {
2590
2541
  readonly __wbg_wasmpropagationanalysis_free: (a: number, b: number) => void;
2591
2542
  readonly __wbg_wasmrelativisticparticle_free: (a: number, b: number) => void;
2592
2543
  readonly __wbg_wasmresonator_free: (a: number, b: number) => void;
2593
- readonly __wbg_wasmretrievalresult_free: (a: number, b: number) => void;
2594
2544
  readonly __wbg_wasmschwarzschildmetric_free: (a: number, b: number) => void;
2595
2545
  readonly __wbg_wasmselfassembler_free: (a: number, b: number) => void;
2596
2546
  readonly __wbg_wasmsensitivitymap_free: (a: number, b: number) => void;
@@ -2705,10 +2655,6 @@ export interface InitOutput {
2705
2655
  readonly wasmchowclass_new: (a: number, b: number) => number;
2706
2656
  readonly wasmchowclass_point: () => number;
2707
2657
  readonly wasmchowclass_power: (a: number, b: number) => number;
2708
- readonly wasmcleanupresult_didConverge: (a: number) => number;
2709
- readonly wasmcleanupresult_getBestMatchIndex: (a: number) => number;
2710
- readonly wasmcleanupresult_getCleaned: (a: number) => number;
2711
- readonly wasmcleanupresult_getIterations: (a: number) => number;
2712
2658
  readonly wasmcommunity_centroid_coefficients: (a: number) => [number, number];
2713
2659
  readonly wasmcommunity_nodes: (a: number) => [number, number];
2714
2660
  readonly wasmcountingmeasure_isMeasurable: (a: number) => number;
@@ -2812,15 +2758,12 @@ export interface InitOutput {
2812
2758
  readonly wasmholographicmemory_estimatedSnr: (a: number) => number;
2813
2759
  readonly wasmholographicmemory_isNearCapacity: (a: number) => number;
2814
2760
  readonly wasmholographicmemory_itemCount: (a: number) => number;
2815
- readonly wasmholographicmemory_merge: (a: number, b: number) => void;
2816
2761
  readonly wasmholographicmemory_new: () => number;
2817
- readonly wasmholographicmemory_probablyContains: (a: number, b: number) => number;
2818
- readonly wasmholographicmemory_retrieve: (a: number, b: number) => number;
2819
- readonly wasmholographicmemory_retrieveAtTemperature: (a: number, b: number, c: number) => number;
2820
- readonly wasmholographicmemory_store: (a: number, b: number, c: number) => void;
2821
- readonly wasmholographicmemory_storeBatch: (a: number, b: number, c: number, d: number, e: number) => [number, number];
2762
+ readonly wasmholographicmemory_randomVersor: (a: number) => [number, number];
2763
+ readonly wasmholographicmemory_retrieve: (a: number, b: number, c: number) => [number, number, number, number];
2764
+ readonly wasmholographicmemory_retrieveConfidence: (a: number, b: number, c: number) => [number, number, number];
2765
+ readonly wasmholographicmemory_store: (a: number, b: number, c: number, d: number, e: number) => [number, number];
2822
2766
  readonly wasmholographicmemory_theoreticalCapacity: (a: number) => number;
2823
- readonly wasmholographicmemory_withBundleTemperature: (a: number) => number;
2824
2767
  readonly wasmholographicmemory_withKeyTracking: () => number;
2825
2768
  readonly wasminversecadesigner_evaluateFitness: (a: number, b: number, c: number) => [number, number, number];
2826
2769
  readonly wasminversecadesigner_findSeed: (a: number, b: number, c: number) => [number, number, number, number];
@@ -2910,13 +2853,10 @@ export interface InitOutput {
2910
2853
  readonly wasmrelativisticparticle_to_string: (a: number) => [number, number];
2911
2854
  readonly wasmrelativisticparticle_total_energy: (a: number) => number;
2912
2855
  readonly wasmrelativisticparticle_with_energy: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
2913
- readonly wasmresonator_cleanup: (a: number, b: number) => number;
2856
+ readonly wasmresonator_cleanup: (a: number, b: number, c: number) => [number, number, number, number];
2857
+ readonly wasmresonator_cleanupWithInfo: (a: number, b: number, c: number) => [number, number, number];
2914
2858
  readonly wasmresonator_codebookSize: (a: number) => number;
2915
2859
  readonly wasmresonator_new: (a: number, b: number) => [number, number, number];
2916
- readonly wasmresonator_withConfig: (a: number, b: number, c: number, d: number) => [number, number, number];
2917
- readonly wasmretrievalresult_getAttribution: (a: number) => [number, number, number];
2918
- readonly wasmretrievalresult_getConfidence: (a: number) => number;
2919
- readonly wasmretrievalresult_getValue: (a: number) => number;
2920
2860
  readonly wasmrotor_apply: (a: number, b: number) => number;
2921
2861
  readonly wasmrotor_compose: (a: number, b: number) => number;
2922
2862
  readonly wasmrotor_fromBivector: (a: number, b: number) => number;
@@ -3077,8 +3017,8 @@ export interface InitOutput {
3077
3017
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
3078
3018
  readonly __wbindgen_export_6: WebAssembly.Table;
3079
3019
  readonly __externref_table_dealloc: (a: number) => void;
3080
- readonly closure58_externref_shim: (a: number, b: number, c: any) => void;
3081
- readonly closure49_externref_shim: (a: number, b: number, c: any, d: any) => void;
3020
+ readonly closure40_externref_shim: (a: number, b: number, c: any) => void;
3021
+ readonly closure33_externref_shim: (a: number, b: number, c: any, d: any) => void;
3082
3022
  readonly __wbindgen_start: () => void;
3083
3023
  }
3084
3024
 
package/amari_wasm.js CHANGED
@@ -45,6 +45,20 @@ function getStringFromWasm0(ptr, len) {
45
45
  return decodeText(ptr, len);
46
46
  }
47
47
 
48
+ let cachedFloat64ArrayMemory0 = null;
49
+
50
+ function getFloat64ArrayMemory0() {
51
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
52
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
53
+ }
54
+ return cachedFloat64ArrayMemory0;
55
+ }
56
+
57
+ function getArrayF64FromWasm0(ptr, len) {
58
+ ptr = ptr >>> 0;
59
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
60
+ }
61
+
48
62
  let WASM_VECTOR_LEN = 0;
49
63
 
50
64
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -209,20 +223,6 @@ function debugString(val) {
209
223
  // TODO we could test for more things here, like `Set`s and `Map`s.
210
224
  return className;
211
225
  }
212
-
213
- let cachedFloat64ArrayMemory0 = null;
214
-
215
- function getFloat64ArrayMemory0() {
216
- if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
217
- cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
218
- }
219
- return cachedFloat64ArrayMemory0;
220
- }
221
-
222
- function getArrayF64FromWasm0(ptr, len) {
223
- ptr = ptr >>> 0;
224
- return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
225
- }
226
226
  /**
227
227
  * Initialize the WASM module
228
228
  */
@@ -429,11 +429,11 @@ function passArray32ToWasm0(arg, malloc) {
429
429
  return ptr;
430
430
  }
431
431
  function __wbg_adapter_28(arg0, arg1, arg2) {
432
- wasm.closure58_externref_shim(arg0, arg1, arg2);
432
+ wasm.closure40_externref_shim(arg0, arg1, arg2);
433
433
  }
434
434
 
435
- function __wbg_adapter_496(arg0, arg1, arg2, arg3) {
436
- wasm.closure49_externref_shim(arg0, arg1, arg2, arg3);
435
+ function __wbg_adapter_486(arg0, arg1, arg2, arg3) {
436
+ wasm.closure33_externref_shim(arg0, arg1, arg2, arg3);
437
437
  }
438
438
 
439
439
  /**
@@ -2572,67 +2572,6 @@ export class WasmChowClass {
2572
2572
  }
2573
2573
  }
2574
2574
 
2575
- const WasmCleanupResultFinalization = (typeof FinalizationRegistry === 'undefined')
2576
- ? { register: () => {}, unregister: () => {} }
2577
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmcleanupresult_free(ptr >>> 0, 1));
2578
- /**
2579
- * WASM wrapper for cleanup results
2580
- */
2581
- export class WasmCleanupResult {
2582
-
2583
- static __wrap(ptr) {
2584
- ptr = ptr >>> 0;
2585
- const obj = Object.create(WasmCleanupResult.prototype);
2586
- obj.__wbg_ptr = ptr;
2587
- WasmCleanupResultFinalization.register(obj, obj.__wbg_ptr, obj);
2588
- return obj;
2589
- }
2590
-
2591
- __destroy_into_raw() {
2592
- const ptr = this.__wbg_ptr;
2593
- this.__wbg_ptr = 0;
2594
- WasmCleanupResultFinalization.unregister(this);
2595
- return ptr;
2596
- }
2597
-
2598
- free() {
2599
- const ptr = this.__destroy_into_raw();
2600
- wasm.__wbg_wasmcleanupresult_free(ptr, 0);
2601
- }
2602
- /**
2603
- * Get the cleaned (denoised) value
2604
- * @returns {WasmTropicalDualClifford}
2605
- */
2606
- getCleaned() {
2607
- const ret = wasm.wasmcleanupresult_getCleaned(this.__wbg_ptr);
2608
- return WasmTropicalDualClifford.__wrap(ret);
2609
- }
2610
- /**
2611
- * Check if the cleanup converged
2612
- * @returns {boolean}
2613
- */
2614
- didConverge() {
2615
- const ret = wasm.wasmcleanupresult_didConverge(this.__wbg_ptr);
2616
- return ret !== 0;
2617
- }
2618
- /**
2619
- * Get the number of iterations used
2620
- * @returns {number}
2621
- */
2622
- getIterations() {
2623
- const ret = wasm.wasmcleanupresult_getIterations(this.__wbg_ptr);
2624
- return ret >>> 0;
2625
- }
2626
- /**
2627
- * Get the index of the best matching codebook item
2628
- * @returns {number}
2629
- */
2630
- getBestMatchIndex() {
2631
- const ret = wasm.wasmcleanupresult_getBestMatchIndex(this.__wbg_ptr);
2632
- return ret >>> 0;
2633
- }
2634
- }
2635
-
2636
2575
  const WasmCommunityFinalization = (typeof FinalizationRegistry === 'undefined')
2637
2576
  ? { register: () => {}, unregister: () => {} }
2638
2577
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmcommunity_free(ptr >>> 0, 1));
@@ -4113,7 +4052,7 @@ const WasmHolographicMemoryFinalization = (typeof FinalizationRegistry === 'unde
4113
4052
  ? { register: () => {}, unregister: () => {} }
4114
4053
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmholographicmemory_free(ptr >>> 0, 1));
4115
4054
  /**
4116
- * WASM wrapper for HolographicMemory
4055
+ * WASM wrapper for HolographicMemory using ProductClifford algebra
4117
4056
  */
4118
4057
  export class WasmHolographicMemory {
4119
4058
 
@@ -4144,21 +4083,6 @@ export class WasmHolographicMemory {
4144
4083
  const ret = wasm.wasmholographicmemory_itemCount(this.__wbg_ptr);
4145
4084
  return ret >>> 0;
4146
4085
  }
4147
- /**
4148
- * Batch store multiple key-value pairs
4149
- * @param {Float64Array} keys
4150
- * @param {Float64Array} values
4151
- */
4152
- storeBatch(keys, values) {
4153
- const ptr0 = passArrayF64ToWasm0(keys, wasm.__wbindgen_malloc);
4154
- const len0 = WASM_VECTOR_LEN;
4155
- const ptr1 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4156
- const len1 = WASM_VECTOR_LEN;
4157
- const ret = wasm.wasmholographicmemory_storeBatch(this.__wbg_ptr, ptr0, len0, ptr1, len1);
4158
- if (ret[1]) {
4159
- throw takeFromExternrefTable0(ret[0]);
4160
- }
4161
- }
4162
4086
  /**
4163
4087
  * Get the estimated SNR (signal-to-noise ratio)
4164
4088
  * @returns {number}
@@ -4168,21 +4092,22 @@ export class WasmHolographicMemory {
4168
4092
  return ret;
4169
4093
  }
4170
4094
  /**
4171
- * Check if memory is near capacity
4172
- * @returns {boolean}
4095
+ * Generate a random versor (for use as key/value)
4096
+ * @param {number} num_factors
4097
+ * @returns {Float64Array}
4173
4098
  */
4174
- isNearCapacity() {
4175
- const ret = wasm.wasmholographicmemory_isNearCapacity(this.__wbg_ptr);
4176
- return ret !== 0;
4099
+ static randomVersor(num_factors) {
4100
+ const ret = wasm.wasmholographicmemory_randomVersor(num_factors);
4101
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4102
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4103
+ return v1;
4177
4104
  }
4178
4105
  /**
4179
- * Check if memory probably contains a key
4180
- * @param {WasmTropicalDualClifford} key
4106
+ * Check if memory is near capacity
4181
4107
  * @returns {boolean}
4182
4108
  */
4183
- probablyContains(key) {
4184
- _assertClass(key, WasmTropicalDualClifford);
4185
- const ret = wasm.wasmholographicmemory_probablyContains(this.__wbg_ptr, key.__wbg_ptr);
4109
+ isNearCapacity() {
4110
+ const ret = wasm.wasmholographicmemory_isNearCapacity(this.__wbg_ptr);
4186
4111
  return ret !== 0;
4187
4112
  }
4188
4113
  /**
@@ -4194,32 +4119,26 @@ export class WasmHolographicMemory {
4194
4119
  return WasmHolographicMemory.__wrap(ret);
4195
4120
  }
4196
4121
  /**
4197
- * Get the theoretical capacity
4122
+ * Get retrieval confidence for a key
4123
+ * @param {Float64Array} key
4198
4124
  * @returns {number}
4199
4125
  */
4200
- theoreticalCapacity() {
4201
- const ret = wasm.wasmholographicmemory_theoreticalCapacity(this.__wbg_ptr);
4202
- return ret >>> 0;
4203
- }
4204
- /**
4205
- * Retrieve with custom temperature
4206
- * @param {WasmTropicalDualClifford} key
4207
- * @param {number} beta
4208
- * @returns {WasmRetrievalResult}
4209
- */
4210
- retrieveAtTemperature(key, beta) {
4211
- _assertClass(key, WasmTropicalDualClifford);
4212
- const ret = wasm.wasmholographicmemory_retrieveAtTemperature(this.__wbg_ptr, key.__wbg_ptr, beta);
4213
- return WasmRetrievalResult.__wrap(ret);
4126
+ retrieveConfidence(key) {
4127
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4128
+ const len0 = WASM_VECTOR_LEN;
4129
+ const ret = wasm.wasmholographicmemory_retrieveConfidence(this.__wbg_ptr, ptr0, len0);
4130
+ if (ret[2]) {
4131
+ throw takeFromExternrefTable0(ret[1]);
4132
+ }
4133
+ return ret[0];
4214
4134
  }
4215
4135
  /**
4216
- * Create with custom bundle temperature
4217
- * @param {number} beta
4218
- * @returns {WasmHolographicMemory}
4136
+ * Get capacity information
4137
+ * @returns {number}
4219
4138
  */
4220
- static withBundleTemperature(beta) {
4221
- const ret = wasm.wasmholographicmemory_withBundleTemperature(beta);
4222
- return WasmHolographicMemory.__wrap(ret);
4139
+ theoreticalCapacity() {
4140
+ const ret = wasm.wasmholographicmemory_theoreticalCapacity(this.__wbg_ptr);
4141
+ return ret >>> 0;
4223
4142
  }
4224
4143
  /**
4225
4144
  * Create a new holographic memory with default settings
@@ -4237,32 +4156,39 @@ export class WasmHolographicMemory {
4237
4156
  wasm.wasmholographicmemory_clear(this.__wbg_ptr);
4238
4157
  }
4239
4158
  /**
4240
- * Merge another memory into this one
4241
- * @param {WasmHolographicMemory} other
4242
- */
4243
- merge(other) {
4244
- _assertClass(other, WasmHolographicMemory);
4245
- wasm.wasmholographicmemory_merge(this.__wbg_ptr, other.__wbg_ptr);
4246
- }
4247
- /**
4248
- * Store a key-value pair in memory
4249
- * @param {WasmTropicalDualClifford} key
4250
- * @param {WasmTropicalDualClifford} value
4159
+ * Store a key-value pair in memory (using flat coefficient arrays)
4160
+ *
4161
+ * Each array should have 256 coefficients for ProductCl3x32.
4162
+ * @param {Float64Array} key
4163
+ * @param {Float64Array} value
4251
4164
  */
4252
4165
  store(key, value) {
4253
- _assertClass(key, WasmTropicalDualClifford);
4254
- _assertClass(value, WasmTropicalDualClifford);
4255
- wasm.wasmholographicmemory_store(this.__wbg_ptr, key.__wbg_ptr, value.__wbg_ptr);
4166
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4167
+ const len0 = WASM_VECTOR_LEN;
4168
+ const ptr1 = passArrayF64ToWasm0(value, wasm.__wbindgen_malloc);
4169
+ const len1 = WASM_VECTOR_LEN;
4170
+ const ret = wasm.wasmholographicmemory_store(this.__wbg_ptr, ptr0, len0, ptr1, len1);
4171
+ if (ret[1]) {
4172
+ throw takeFromExternrefTable0(ret[0]);
4173
+ }
4256
4174
  }
4257
4175
  /**
4258
4176
  * Retrieve a value by key
4259
- * @param {WasmTropicalDualClifford} key
4260
- * @returns {WasmRetrievalResult}
4177
+ *
4178
+ * Returns the retrieved coefficients as a Float64Array.
4179
+ * @param {Float64Array} key
4180
+ * @returns {Float64Array}
4261
4181
  */
4262
4182
  retrieve(key) {
4263
- _assertClass(key, WasmTropicalDualClifford);
4264
- const ret = wasm.wasmholographicmemory_retrieve(this.__wbg_ptr, key.__wbg_ptr);
4265
- return WasmRetrievalResult.__wrap(ret);
4183
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4184
+ const len0 = WASM_VECTOR_LEN;
4185
+ const ret = wasm.wasmholographicmemory_retrieve(this.__wbg_ptr, ptr0, len0);
4186
+ if (ret[3]) {
4187
+ throw takeFromExternrefTable0(ret[2]);
4188
+ }
4189
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4190
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4191
+ return v2;
4266
4192
  }
4267
4193
  }
4268
4194
 
@@ -5716,18 +5642,10 @@ const WasmResonatorFinalization = (typeof FinalizationRegistry === 'undefined')
5716
5642
  ? { register: () => {}, unregister: () => {} }
5717
5643
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmresonator_free(ptr >>> 0, 1));
5718
5644
  /**
5719
- * WASM wrapper for Resonator (iterative cleanup)
5645
+ * WASM wrapper for Resonator using ProductClifford algebra
5720
5646
  */
5721
5647
  export class WasmResonator {
5722
5648
 
5723
- static __wrap(ptr) {
5724
- ptr = ptr >>> 0;
5725
- const obj = Object.create(WasmResonator.prototype);
5726
- obj.__wbg_ptr = ptr;
5727
- WasmResonatorFinalization.register(obj, obj.__wbg_ptr, obj);
5728
- return obj;
5729
- }
5730
-
5731
5649
  __destroy_into_raw() {
5732
5650
  const ptr = this.__wbg_ptr;
5733
5651
  this.__wbg_ptr = 0;
@@ -5739,22 +5657,6 @@ export class WasmResonator {
5739
5657
  const ptr = this.__destroy_into_raw();
5740
5658
  wasm.__wbg_wasmresonator_free(ptr, 0);
5741
5659
  }
5742
- /**
5743
- * Create with custom configuration
5744
- * @param {Float64Array} codebook_flat
5745
- * @param {number} max_iterations
5746
- * @param {number} convergence_threshold
5747
- * @returns {WasmResonator}
5748
- */
5749
- static withConfig(codebook_flat, max_iterations, convergence_threshold) {
5750
- const ptr0 = passArrayF64ToWasm0(codebook_flat, wasm.__wbindgen_malloc);
5751
- const len0 = WASM_VECTOR_LEN;
5752
- const ret = wasm.wasmresonator_withConfig(ptr0, len0, max_iterations, convergence_threshold);
5753
- if (ret[2]) {
5754
- throw takeFromExternrefTable0(ret[1]);
5755
- }
5756
- return WasmResonator.__wrap(ret[0]);
5757
- }
5758
5660
  /**
5759
5661
  * Get the codebook size
5760
5662
  * @returns {number}
@@ -5764,7 +5666,23 @@ export class WasmResonator {
5764
5666
  return ret >>> 0;
5765
5667
  }
5766
5668
  /**
5767
- * Create a resonator from a codebook of TDC vectors
5669
+ * Get cleanup result with metadata
5670
+ * @param {Float64Array} input
5671
+ * @returns {any}
5672
+ */
5673
+ cleanupWithInfo(input) {
5674
+ const ptr0 = passArrayF64ToWasm0(input, wasm.__wbindgen_malloc);
5675
+ const len0 = WASM_VECTOR_LEN;
5676
+ const ret = wasm.wasmresonator_cleanupWithInfo(this.__wbg_ptr, ptr0, len0);
5677
+ if (ret[2]) {
5678
+ throw takeFromExternrefTable0(ret[1]);
5679
+ }
5680
+ return takeFromExternrefTable0(ret[0]);
5681
+ }
5682
+ /**
5683
+ * Create a resonator from a flat codebook array
5684
+ *
5685
+ * Each item should have 256 coefficients for ProductCl3x32.
5768
5686
  * @param {Float64Array} codebook_flat
5769
5687
  */
5770
5688
  constructor(codebook_flat) {
@@ -5780,69 +5698,19 @@ export class WasmResonator {
5780
5698
  }
5781
5699
  /**
5782
5700
  * Clean up a noisy input to find the closest codebook item
5783
- * @param {WasmTropicalDualClifford} input
5784
- * @returns {WasmCleanupResult}
5701
+ * @param {Float64Array} input
5702
+ * @returns {Float64Array}
5785
5703
  */
5786
5704
  cleanup(input) {
5787
- _assertClass(input, WasmTropicalDualClifford);
5788
- const ret = wasm.wasmresonator_cleanup(this.__wbg_ptr, input.__wbg_ptr);
5789
- return WasmCleanupResult.__wrap(ret);
5790
- }
5791
- }
5792
-
5793
- const WasmRetrievalResultFinalization = (typeof FinalizationRegistry === 'undefined')
5794
- ? { register: () => {}, unregister: () => {} }
5795
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmretrievalresult_free(ptr >>> 0, 1));
5796
- /**
5797
- * WASM wrapper for retrieval results
5798
- */
5799
- export class WasmRetrievalResult {
5800
-
5801
- static __wrap(ptr) {
5802
- ptr = ptr >>> 0;
5803
- const obj = Object.create(WasmRetrievalResult.prototype);
5804
- obj.__wbg_ptr = ptr;
5805
- WasmRetrievalResultFinalization.register(obj, obj.__wbg_ptr, obj);
5806
- return obj;
5807
- }
5808
-
5809
- __destroy_into_raw() {
5810
- const ptr = this.__wbg_ptr;
5811
- this.__wbg_ptr = 0;
5812
- WasmRetrievalResultFinalization.unregister(this);
5813
- return ptr;
5814
- }
5815
-
5816
- free() {
5817
- const ptr = this.__destroy_into_raw();
5818
- wasm.__wbg_wasmretrievalresult_free(ptr, 0);
5819
- }
5820
- /**
5821
- * Get the retrieval confidence (0 to 1)
5822
- * @returns {number}
5823
- */
5824
- getConfidence() {
5825
- const ret = wasm.wasmretrievalresult_getConfidence(this.__wbg_ptr);
5826
- return ret;
5827
- }
5828
- /**
5829
- * Get attribution as arrays of [index, weight] pairs
5830
- * @returns {any}
5831
- */
5832
- getAttribution() {
5833
- const ret = wasm.wasmretrievalresult_getAttribution(this.__wbg_ptr);
5834
- if (ret[2]) {
5835
- throw takeFromExternrefTable0(ret[1]);
5705
+ const ptr0 = passArrayF64ToWasm0(input, wasm.__wbindgen_malloc);
5706
+ const len0 = WASM_VECTOR_LEN;
5707
+ const ret = wasm.wasmresonator_cleanup(this.__wbg_ptr, ptr0, len0);
5708
+ if (ret[3]) {
5709
+ throw takeFromExternrefTable0(ret[2]);
5836
5710
  }
5837
- return takeFromExternrefTable0(ret[0]);
5838
- }
5839
- /**
5840
- * Get the retrieved value
5841
- * @returns {WasmTropicalDualClifford}
5842
- */
5843
- getValue() {
5844
- const ret = wasm.wasmretrievalresult_getValue(this.__wbg_ptr);
5845
- return WasmTropicalDualClifford.__wrap(ret);
5711
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
5712
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
5713
+ return v2;
5846
5714
  }
5847
5715
  }
5848
5716
 
@@ -7323,7 +7191,7 @@ function __wbg_get_imports() {
7323
7191
  const ret = arg0.length;
7324
7192
  return ret;
7325
7193
  };
7326
- imports.wbg.__wbg_log_bf345a94df4f1349 = function(arg0, arg1) {
7194
+ imports.wbg.__wbg_log_73e7856ded7435b4 = function(arg0, arg1) {
7327
7195
  console.log(getStringFromWasm0(arg0, arg1));
7328
7196
  };
7329
7197
  imports.wbg.__wbg_log_ea240990d83e374e = function(arg0) {
@@ -7348,7 +7216,7 @@ function __wbg_get_imports() {
7348
7216
  const a = state0.a;
7349
7217
  state0.a = 0;
7350
7218
  try {
7351
- return __wbg_adapter_496(a, state0.b, arg0, arg1);
7219
+ return __wbg_adapter_486(a, state0.b, arg0, arg1);
7352
7220
  } finally {
7353
7221
  state0.a = a;
7354
7222
  }
@@ -7359,6 +7227,10 @@ function __wbg_get_imports() {
7359
7227
  state0.a = state0.b = 0;
7360
7228
  }
7361
7229
  };
7230
+ imports.wbg.__wbg_newfromslice_bcd6b1e87ab624a5 = function(arg0, arg1) {
7231
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
7232
+ return ret;
7233
+ };
7362
7234
  imports.wbg.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
7363
7235
  const ret = new Function(getStringFromWasm0(arg0, arg1));
7364
7236
  return ret;
@@ -7444,8 +7316,8 @@ function __wbg_get_imports() {
7444
7316
  const ret = false;
7445
7317
  return ret;
7446
7318
  };
7447
- imports.wbg.__wbindgen_closure_wrapper1715 = function(arg0, arg1, arg2) {
7448
- const ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_28);
7319
+ imports.wbg.__wbindgen_closure_wrapper1599 = function(arg0, arg1, arg2) {
7320
+ const ret = makeMutClosure(arg0, arg1, 39, __wbg_adapter_28);
7449
7321
  return ret;
7450
7322
  };
7451
7323
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Amari Contributors"
6
6
  ],
7
7
  "description": "WebAssembly bindings for Amari mathematical computing library - geometric algebra, tropical algebra, automatic differentiation, measure theory, fusion systems, and information geometry",
8
- "version": "0.12.2",
8
+ "version": "0.12.3",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",