@justinelliottcobb/amari-wasm 0.12.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.closure41_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_511(arg0, arg1, arg2, arg3) {
436
+ wasm.closure34_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));
@@ -3423,6 +3362,194 @@ export class WasmFourVelocity {
3423
3362
  }
3424
3363
  }
3425
3364
 
3365
+ const WasmGaussianMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
3366
+ ? { register: () => {}, unregister: () => {} }
3367
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgaussianmultivector_free(ptr >>> 0, 1));
3368
+ /**
3369
+ * WASM wrapper for Gaussian distribution on Cl(3,0,0) multivector space
3370
+ *
3371
+ * A Gaussian distribution over 8-dimensional multivector space with
3372
+ * configurable mean and per-component standard deviation.
3373
+ */
3374
+ export class WasmGaussianMultivector {
3375
+
3376
+ static __wrap(ptr) {
3377
+ ptr = ptr >>> 0;
3378
+ const obj = Object.create(WasmGaussianMultivector.prototype);
3379
+ obj.__wbg_ptr = ptr;
3380
+ WasmGaussianMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
3381
+ return obj;
3382
+ }
3383
+
3384
+ __destroy_into_raw() {
3385
+ const ptr = this.__wbg_ptr;
3386
+ this.__wbg_ptr = 0;
3387
+ WasmGaussianMultivectorFinalization.unregister(this);
3388
+ return ptr;
3389
+ }
3390
+
3391
+ free() {
3392
+ const ptr = this.__destroy_into_raw();
3393
+ wasm.__wbg_wasmgaussianmultivector_free(ptr, 0);
3394
+ }
3395
+ /**
3396
+ * Get the standard deviations
3397
+ *
3398
+ * Returns 8 values
3399
+ * @returns {Float64Array}
3400
+ */
3401
+ getStdDevs() {
3402
+ const ret = wasm.wasmgaussianmultivector_getStdDevs(this.__wbg_ptr);
3403
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3404
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3405
+ return v1;
3406
+ }
3407
+ /**
3408
+ * Get the variance (square of std devs)
3409
+ *
3410
+ * Returns 8 values
3411
+ * @returns {Float64Array}
3412
+ */
3413
+ getVariance() {
3414
+ const ret = wasm.wasmgaussianmultivector_getVariance(this.__wbg_ptr);
3415
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3416
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3417
+ return v1;
3418
+ }
3419
+ /**
3420
+ * Draw multiple samples from this distribution
3421
+ *
3422
+ * Returns flat array of coefficients: num_samples * 8
3423
+ * @param {number} num_samples
3424
+ * @returns {Float64Array}
3425
+ */
3426
+ sampleBatch(num_samples) {
3427
+ const ret = wasm.wasmgaussianmultivector_sampleBatch(this.__wbg_ptr, num_samples);
3428
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3429
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3430
+ return v1;
3431
+ }
3432
+ /**
3433
+ * Get the full covariance matrix (flattened, row-major)
3434
+ *
3435
+ * Returns 64 values (8x8 matrix)
3436
+ * @returns {Float64Array}
3437
+ */
3438
+ getCovariance() {
3439
+ const ret = wasm.wasmgaussianmultivector_getCovariance(this.__wbg_ptr);
3440
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3441
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3442
+ return v1;
3443
+ }
3444
+ /**
3445
+ * Create a Gaussian with specified mean and standard deviation
3446
+ *
3447
+ * # Arguments
3448
+ * * `mean` - 8 coefficients for the mean multivector
3449
+ * * `std_dev` - 8 coefficients for per-coefficient standard deviation
3450
+ * @param {Float64Array} mean
3451
+ * @param {Float64Array} std_dev
3452
+ * @returns {WasmGaussianMultivector}
3453
+ */
3454
+ static withParameters(mean, std_dev) {
3455
+ const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
3456
+ const len0 = WASM_VECTOR_LEN;
3457
+ const ptr1 = passArrayF64ToWasm0(std_dev, wasm.__wbindgen_malloc);
3458
+ const len1 = WASM_VECTOR_LEN;
3459
+ const ret = wasm.wasmgaussianmultivector_withParameters(ptr0, len0, ptr1, len1);
3460
+ if (ret[2]) {
3461
+ throw takeFromExternrefTable0(ret[1]);
3462
+ }
3463
+ return WasmGaussianMultivector.__wrap(ret[0]);
3464
+ }
3465
+ /**
3466
+ * Create a Gaussian concentrated on a specific grade
3467
+ *
3468
+ * # Arguments
3469
+ * * `grade` - The grade to concentrate on (0=scalar, 1=vectors, 2=bivectors, 3=pseudoscalar)
3470
+ * * `variance` - Variance for coefficients of that grade
3471
+ * @param {number} grade
3472
+ * @param {number} variance
3473
+ * @returns {WasmGaussianMultivector}
3474
+ */
3475
+ static gradeConcentrated(grade, variance) {
3476
+ const ret = wasm.wasmgaussianmultivector_gradeConcentrated(grade, variance);
3477
+ if (ret[2]) {
3478
+ throw takeFromExternrefTable0(ret[1]);
3479
+ }
3480
+ return WasmGaussianMultivector.__wrap(ret[0]);
3481
+ }
3482
+ /**
3483
+ * Create a standard Gaussian (zero mean, unit variance per coefficient)
3484
+ */
3485
+ constructor() {
3486
+ const ret = wasm.wasmgaussianmultivector_new();
3487
+ this.__wbg_ptr = ret >>> 0;
3488
+ WasmGaussianMultivectorFinalization.register(this, this.__wbg_ptr, this);
3489
+ return this;
3490
+ }
3491
+ /**
3492
+ * Draw a sample from this distribution
3493
+ *
3494
+ * Returns 8 coefficients for the sampled multivector
3495
+ * @returns {Float64Array}
3496
+ */
3497
+ sample() {
3498
+ const ret = wasm.wasmgaussianmultivector_sample(this.__wbg_ptr);
3499
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3500
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3501
+ return v1;
3502
+ }
3503
+ /**
3504
+ * Get the mean of this distribution
3505
+ *
3506
+ * Returns 8 coefficients
3507
+ * @returns {Float64Array}
3508
+ */
3509
+ getMean() {
3510
+ const ret = wasm.wasmgaussianmultivector_getMean(this.__wbg_ptr);
3511
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3512
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3513
+ return v1;
3514
+ }
3515
+ /**
3516
+ * Compute log probability of a multivector
3517
+ *
3518
+ * # Arguments
3519
+ * * `coefficients` - 8 coefficients of the multivector
3520
+ * @param {Float64Array} coefficients
3521
+ * @returns {number}
3522
+ */
3523
+ logProb(coefficients) {
3524
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
3525
+ const len0 = WASM_VECTOR_LEN;
3526
+ const ret = wasm.wasmgaussianmultivector_logProb(this.__wbg_ptr, ptr0, len0);
3527
+ if (ret[2]) {
3528
+ throw takeFromExternrefTable0(ret[1]);
3529
+ }
3530
+ return ret[0];
3531
+ }
3532
+ /**
3533
+ * Create an isotropic Gaussian with given mean and variance
3534
+ *
3535
+ * # Arguments
3536
+ * * `mean` - 8 coefficients for the mean multivector
3537
+ * * `variance` - Variance (same for all components)
3538
+ * @param {Float64Array} mean
3539
+ * @param {number} variance
3540
+ * @returns {WasmGaussianMultivector}
3541
+ */
3542
+ static isotropic(mean, variance) {
3543
+ const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
3544
+ const len0 = WASM_VECTOR_LEN;
3545
+ const ret = wasm.wasmgaussianmultivector_isotropic(ptr0, len0, variance);
3546
+ if (ret[2]) {
3547
+ throw takeFromExternrefTable0(ret[1]);
3548
+ }
3549
+ return WasmGaussianMultivector.__wrap(ret[0]);
3550
+ }
3551
+ }
3552
+
3426
3553
  const WasmGeodesicIntegratorFinalization = (typeof FinalizationRegistry === 'undefined')
3427
3554
  ? { register: () => {}, unregister: () => {} }
3428
3555
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmgeodesicintegrator_free(ptr >>> 0, 1));
@@ -4113,7 +4240,7 @@ const WasmHolographicMemoryFinalization = (typeof FinalizationRegistry === 'unde
4113
4240
  ? { register: () => {}, unregister: () => {} }
4114
4241
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmholographicmemory_free(ptr >>> 0, 1));
4115
4242
  /**
4116
- * WASM wrapper for HolographicMemory
4243
+ * WASM wrapper for HolographicMemory using ProductClifford algebra
4117
4244
  */
4118
4245
  export class WasmHolographicMemory {
4119
4246
 
@@ -4144,21 +4271,6 @@ export class WasmHolographicMemory {
4144
4271
  const ret = wasm.wasmholographicmemory_itemCount(this.__wbg_ptr);
4145
4272
  return ret >>> 0;
4146
4273
  }
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
4274
  /**
4163
4275
  * Get the estimated SNR (signal-to-noise ratio)
4164
4276
  * @returns {number}
@@ -4168,21 +4280,22 @@ export class WasmHolographicMemory {
4168
4280
  return ret;
4169
4281
  }
4170
4282
  /**
4171
- * Check if memory is near capacity
4172
- * @returns {boolean}
4283
+ * Generate a random versor (for use as key/value)
4284
+ * @param {number} num_factors
4285
+ * @returns {Float64Array}
4173
4286
  */
4174
- isNearCapacity() {
4175
- const ret = wasm.wasmholographicmemory_isNearCapacity(this.__wbg_ptr);
4176
- return ret !== 0;
4287
+ static randomVersor(num_factors) {
4288
+ const ret = wasm.wasmholographicmemory_randomVersor(num_factors);
4289
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4290
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4291
+ return v1;
4177
4292
  }
4178
4293
  /**
4179
- * Check if memory probably contains a key
4180
- * @param {WasmTropicalDualClifford} key
4294
+ * Check if memory is near capacity
4181
4295
  * @returns {boolean}
4182
4296
  */
4183
- probablyContains(key) {
4184
- _assertClass(key, WasmTropicalDualClifford);
4185
- const ret = wasm.wasmholographicmemory_probablyContains(this.__wbg_ptr, key.__wbg_ptr);
4297
+ isNearCapacity() {
4298
+ const ret = wasm.wasmholographicmemory_isNearCapacity(this.__wbg_ptr);
4186
4299
  return ret !== 0;
4187
4300
  }
4188
4301
  /**
@@ -4194,32 +4307,26 @@ export class WasmHolographicMemory {
4194
4307
  return WasmHolographicMemory.__wrap(ret);
4195
4308
  }
4196
4309
  /**
4197
- * Get the theoretical capacity
4310
+ * Get retrieval confidence for a key
4311
+ * @param {Float64Array} key
4198
4312
  * @returns {number}
4199
4313
  */
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);
4314
+ retrieveConfidence(key) {
4315
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4316
+ const len0 = WASM_VECTOR_LEN;
4317
+ const ret = wasm.wasmholographicmemory_retrieveConfidence(this.__wbg_ptr, ptr0, len0);
4318
+ if (ret[2]) {
4319
+ throw takeFromExternrefTable0(ret[1]);
4320
+ }
4321
+ return ret[0];
4214
4322
  }
4215
4323
  /**
4216
- * Create with custom bundle temperature
4217
- * @param {number} beta
4218
- * @returns {WasmHolographicMemory}
4324
+ * Get capacity information
4325
+ * @returns {number}
4219
4326
  */
4220
- static withBundleTemperature(beta) {
4221
- const ret = wasm.wasmholographicmemory_withBundleTemperature(beta);
4222
- return WasmHolographicMemory.__wrap(ret);
4327
+ theoreticalCapacity() {
4328
+ const ret = wasm.wasmholographicmemory_theoreticalCapacity(this.__wbg_ptr);
4329
+ return ret >>> 0;
4223
4330
  }
4224
4331
  /**
4225
4332
  * Create a new holographic memory with default settings
@@ -4237,32 +4344,39 @@ export class WasmHolographicMemory {
4237
4344
  wasm.wasmholographicmemory_clear(this.__wbg_ptr);
4238
4345
  }
4239
4346
  /**
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
4347
+ * Store a key-value pair in memory (using flat coefficient arrays)
4348
+ *
4349
+ * Each array should have 256 coefficients for ProductCl3x32.
4350
+ * @param {Float64Array} key
4351
+ * @param {Float64Array} value
4251
4352
  */
4252
4353
  store(key, value) {
4253
- _assertClass(key, WasmTropicalDualClifford);
4254
- _assertClass(value, WasmTropicalDualClifford);
4255
- wasm.wasmholographicmemory_store(this.__wbg_ptr, key.__wbg_ptr, value.__wbg_ptr);
4354
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4355
+ const len0 = WASM_VECTOR_LEN;
4356
+ const ptr1 = passArrayF64ToWasm0(value, wasm.__wbindgen_malloc);
4357
+ const len1 = WASM_VECTOR_LEN;
4358
+ const ret = wasm.wasmholographicmemory_store(this.__wbg_ptr, ptr0, len0, ptr1, len1);
4359
+ if (ret[1]) {
4360
+ throw takeFromExternrefTable0(ret[0]);
4361
+ }
4256
4362
  }
4257
4363
  /**
4258
4364
  * Retrieve a value by key
4259
- * @param {WasmTropicalDualClifford} key
4260
- * @returns {WasmRetrievalResult}
4365
+ *
4366
+ * Returns the retrieved coefficients as a Float64Array.
4367
+ * @param {Float64Array} key
4368
+ * @returns {Float64Array}
4261
4369
  */
4262
4370
  retrieve(key) {
4263
- _assertClass(key, WasmTropicalDualClifford);
4264
- const ret = wasm.wasmholographicmemory_retrieve(this.__wbg_ptr, key.__wbg_ptr);
4265
- return WasmRetrievalResult.__wrap(ret);
4371
+ const ptr0 = passArrayF64ToWasm0(key, wasm.__wbindgen_malloc);
4372
+ const len0 = WASM_VECTOR_LEN;
4373
+ const ret = wasm.wasmholographicmemory_retrieve(this.__wbg_ptr, ptr0, len0);
4374
+ if (ret[3]) {
4375
+ throw takeFromExternrefTable0(ret[2]);
4376
+ }
4377
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4378
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4379
+ return v2;
4266
4380
  }
4267
4381
  }
4268
4382
 
@@ -4502,6 +4616,110 @@ export class WasmModuliSpace {
4502
4616
  }
4503
4617
  }
4504
4618
 
4619
+ const WasmMonteCarloEstimatorFinalization = (typeof FinalizationRegistry === 'undefined')
4620
+ ? { register: () => {}, unregister: () => {} }
4621
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmontecarloestimator_free(ptr >>> 0, 1));
4622
+ /**
4623
+ * Monte Carlo estimation utilities
4624
+ */
4625
+ export class WasmMonteCarloEstimator {
4626
+
4627
+ __destroy_into_raw() {
4628
+ const ptr = this.__wbg_ptr;
4629
+ this.__wbg_ptr = 0;
4630
+ WasmMonteCarloEstimatorFinalization.unregister(this);
4631
+ return ptr;
4632
+ }
4633
+
4634
+ free() {
4635
+ const ptr = this.__destroy_into_raw();
4636
+ wasm.__wbg_wasmmontecarloestimator_free(ptr, 0);
4637
+ }
4638
+ /**
4639
+ * Compute sample mean from batch samples
4640
+ *
4641
+ * # Arguments
4642
+ * * `samples` - Flat array of samples (num_samples * 8)
4643
+ *
4644
+ * # Returns
4645
+ * 8 coefficients for the mean
4646
+ * @param {Float64Array} samples
4647
+ * @returns {Float64Array}
4648
+ */
4649
+ static sampleMean(samples) {
4650
+ const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
4651
+ const len0 = WASM_VECTOR_LEN;
4652
+ const ret = wasm.wasmmontecarloestimator_sampleMean(ptr0, len0);
4653
+ if (ret[3]) {
4654
+ throw takeFromExternrefTable0(ret[2]);
4655
+ }
4656
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4657
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4658
+ return v2;
4659
+ }
4660
+ /**
4661
+ * Compute sample variance from batch samples
4662
+ *
4663
+ * # Arguments
4664
+ * * `samples` - Flat array of samples (num_samples * 8)
4665
+ *
4666
+ * # Returns
4667
+ * 8 values for per-coefficient variance
4668
+ * @param {Float64Array} samples
4669
+ * @returns {Float64Array}
4670
+ */
4671
+ static sampleVariance(samples) {
4672
+ const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
4673
+ const len0 = WASM_VECTOR_LEN;
4674
+ const ret = wasm.wasmmontecarloestimator_sampleVariance(ptr0, len0);
4675
+ if (ret[3]) {
4676
+ throw takeFromExternrefTable0(ret[2]);
4677
+ }
4678
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4679
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4680
+ return v2;
4681
+ }
4682
+ /**
4683
+ * Compute sample covariance matrix from batch samples
4684
+ *
4685
+ * # Arguments
4686
+ * * `samples` - Flat array of samples (num_samples * 8)
4687
+ *
4688
+ * # Returns
4689
+ * 64 values for 8x8 covariance matrix (row-major)
4690
+ * @param {Float64Array} samples
4691
+ * @returns {Float64Array}
4692
+ */
4693
+ static sampleCovariance(samples) {
4694
+ const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
4695
+ const len0 = WASM_VECTOR_LEN;
4696
+ const ret = wasm.wasmmontecarloestimator_sampleCovariance(ptr0, len0);
4697
+ if (ret[3]) {
4698
+ throw takeFromExternrefTable0(ret[2]);
4699
+ }
4700
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4701
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4702
+ return v2;
4703
+ }
4704
+ /**
4705
+ * Monte Carlo estimate of expectation E[f(X)] where f is the geometric product
4706
+ *
4707
+ * Estimates E[X * Y] for independent X ~ dist_x, Y ~ dist_y
4708
+ * @param {WasmGaussianMultivector} dist_x
4709
+ * @param {WasmGaussianMultivector} dist_y
4710
+ * @param {number} num_samples
4711
+ * @returns {Float64Array}
4712
+ */
4713
+ static expectationGeometricProduct(dist_x, dist_y, num_samples) {
4714
+ _assertClass(dist_x, WasmGaussianMultivector);
4715
+ _assertClass(dist_y, WasmGaussianMultivector);
4716
+ const ret = wasm.wasmmontecarloestimator_expectationGeometricProduct(dist_x.__wbg_ptr, dist_y.__wbg_ptr, num_samples);
4717
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4718
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4719
+ return v1;
4720
+ }
4721
+ }
4722
+
4505
4723
  const WasmMultiDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
4506
4724
  ? { register: () => {}, unregister: () => {} }
4507
4725
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultidualnumber_free(ptr >>> 0, 1));
@@ -5716,18 +5934,10 @@ const WasmResonatorFinalization = (typeof FinalizationRegistry === 'undefined')
5716
5934
  ? { register: () => {}, unregister: () => {} }
5717
5935
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmresonator_free(ptr >>> 0, 1));
5718
5936
  /**
5719
- * WASM wrapper for Resonator (iterative cleanup)
5937
+ * WASM wrapper for Resonator using ProductClifford algebra
5720
5938
  */
5721
5939
  export class WasmResonator {
5722
5940
 
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
5941
  __destroy_into_raw() {
5732
5942
  const ptr = this.__wbg_ptr;
5733
5943
  this.__wbg_ptr = 0;
@@ -5739,22 +5949,6 @@ export class WasmResonator {
5739
5949
  const ptr = this.__destroy_into_raw();
5740
5950
  wasm.__wbg_wasmresonator_free(ptr, 0);
5741
5951
  }
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
5952
  /**
5759
5953
  * Get the codebook size
5760
5954
  * @returns {number}
@@ -5764,7 +5958,23 @@ export class WasmResonator {
5764
5958
  return ret >>> 0;
5765
5959
  }
5766
5960
  /**
5767
- * Create a resonator from a codebook of TDC vectors
5961
+ * Get cleanup result with metadata
5962
+ * @param {Float64Array} input
5963
+ * @returns {any}
5964
+ */
5965
+ cleanupWithInfo(input) {
5966
+ const ptr0 = passArrayF64ToWasm0(input, wasm.__wbindgen_malloc);
5967
+ const len0 = WASM_VECTOR_LEN;
5968
+ const ret = wasm.wasmresonator_cleanupWithInfo(this.__wbg_ptr, ptr0, len0);
5969
+ if (ret[2]) {
5970
+ throw takeFromExternrefTable0(ret[1]);
5971
+ }
5972
+ return takeFromExternrefTable0(ret[0]);
5973
+ }
5974
+ /**
5975
+ * Create a resonator from a flat codebook array
5976
+ *
5977
+ * Each item should have 256 coefficients for ProductCl3x32.
5768
5978
  * @param {Float64Array} codebook_flat
5769
5979
  */
5770
5980
  constructor(codebook_flat) {
@@ -5780,69 +5990,19 @@ export class WasmResonator {
5780
5990
  }
5781
5991
  /**
5782
5992
  * Clean up a noisy input to find the closest codebook item
5783
- * @param {WasmTropicalDualClifford} input
5784
- * @returns {WasmCleanupResult}
5993
+ * @param {Float64Array} input
5994
+ * @returns {Float64Array}
5785
5995
  */
5786
5996
  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]);
5997
+ const ptr0 = passArrayF64ToWasm0(input, wasm.__wbindgen_malloc);
5998
+ const len0 = WASM_VECTOR_LEN;
5999
+ const ret = wasm.wasmresonator_cleanup(this.__wbg_ptr, ptr0, len0);
6000
+ if (ret[3]) {
6001
+ throw takeFromExternrefTable0(ret[2]);
5836
6002
  }
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);
6003
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
6004
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
6005
+ return v2;
5846
6006
  }
5847
6007
  }
5848
6008
 
@@ -7242,6 +7402,164 @@ export class WasmTropicalViterbi {
7242
7402
  }
7243
7403
  }
7244
7404
 
7405
+ const WasmUniformMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
7406
+ ? { register: () => {}, unregister: () => {} }
7407
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmuniformmultivector_free(ptr >>> 0, 1));
7408
+ /**
7409
+ * WASM wrapper for Uniform distribution on Cl(3,0,0) multivector space
7410
+ *
7411
+ * A uniform distribution over a hyperrectangle in 8-dimensional multivector space.
7412
+ */
7413
+ export class WasmUniformMultivector {
7414
+
7415
+ static __wrap(ptr) {
7416
+ ptr = ptr >>> 0;
7417
+ const obj = Object.create(WasmUniformMultivector.prototype);
7418
+ obj.__wbg_ptr = ptr;
7419
+ WasmUniformMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
7420
+ return obj;
7421
+ }
7422
+
7423
+ __destroy_into_raw() {
7424
+ const ptr = this.__wbg_ptr;
7425
+ this.__wbg_ptr = 0;
7426
+ WasmUniformMultivectorFinalization.unregister(this);
7427
+ return ptr;
7428
+ }
7429
+
7430
+ free() {
7431
+ const ptr = this.__destroy_into_raw();
7432
+ wasm.__wbg_wasmuniformmultivector_free(ptr, 0);
7433
+ }
7434
+ /**
7435
+ * Create a uniform distribution with specified bounds
7436
+ *
7437
+ * # Arguments
7438
+ * * `lower` - 8 coefficients for lower bounds
7439
+ * * `upper` - 8 coefficients for upper bounds
7440
+ * @param {Float64Array} lower
7441
+ * @param {Float64Array} upper
7442
+ * @returns {WasmUniformMultivector}
7443
+ */
7444
+ static withBounds(lower, upper) {
7445
+ const ptr0 = passArrayF64ToWasm0(lower, wasm.__wbindgen_malloc);
7446
+ const len0 = WASM_VECTOR_LEN;
7447
+ const ptr1 = passArrayF64ToWasm0(upper, wasm.__wbindgen_malloc);
7448
+ const len1 = WASM_VECTOR_LEN;
7449
+ const ret = wasm.wasmuniformmultivector_withBounds(ptr0, len0, ptr1, len1);
7450
+ if (ret[2]) {
7451
+ throw takeFromExternrefTable0(ret[1]);
7452
+ }
7453
+ return WasmUniformMultivector.__wrap(ret[0]);
7454
+ }
7455
+ /**
7456
+ * Get the variance of this distribution
7457
+ * @returns {Float64Array}
7458
+ */
7459
+ getVariance() {
7460
+ const ret = wasm.wasmuniformmultivector_getVariance(this.__wbg_ptr);
7461
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7462
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7463
+ return v1;
7464
+ }
7465
+ /**
7466
+ * Draw multiple samples from this distribution
7467
+ *
7468
+ * Returns flat array of coefficients: num_samples * 8
7469
+ * @param {number} num_samples
7470
+ * @returns {Float64Array}
7471
+ */
7472
+ sampleBatch(num_samples) {
7473
+ const ret = wasm.wasmuniformmultivector_sampleBatch(this.__wbg_ptr, num_samples);
7474
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7475
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7476
+ return v1;
7477
+ }
7478
+ /**
7479
+ * Create a standard uniform distribution on [-1, 1]^8
7480
+ */
7481
+ constructor() {
7482
+ const ret = wasm.wasmuniformmultivector_new();
7483
+ if (ret[2]) {
7484
+ throw takeFromExternrefTable0(ret[1]);
7485
+ }
7486
+ this.__wbg_ptr = ret[0] >>> 0;
7487
+ WasmUniformMultivectorFinalization.register(this, this.__wbg_ptr, this);
7488
+ return this;
7489
+ }
7490
+ /**
7491
+ * Draw a sample from this distribution
7492
+ *
7493
+ * Returns 8 coefficients for the sampled multivector
7494
+ * @returns {Float64Array}
7495
+ */
7496
+ sample() {
7497
+ const ret = wasm.wasmuniformmultivector_sample(this.__wbg_ptr);
7498
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7499
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7500
+ return v1;
7501
+ }
7502
+ /**
7503
+ * Get the mean of this distribution
7504
+ * @returns {Float64Array}
7505
+ */
7506
+ getMean() {
7507
+ const ret = wasm.wasmuniformmultivector_getMean(this.__wbg_ptr);
7508
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7509
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7510
+ return v1;
7511
+ }
7512
+ /**
7513
+ * Compute log probability of a multivector
7514
+ *
7515
+ * Returns log(1/volume) if inside bounds, error otherwise
7516
+ * @param {Float64Array} coefficients
7517
+ * @returns {number}
7518
+ */
7519
+ logProb(coefficients) {
7520
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
7521
+ const len0 = WASM_VECTOR_LEN;
7522
+ const ret = wasm.wasmuniformmultivector_logProb(this.__wbg_ptr, ptr0, len0);
7523
+ if (ret[2]) {
7524
+ throw takeFromExternrefTable0(ret[1]);
7525
+ }
7526
+ return ret[0];
7527
+ }
7528
+ /**
7529
+ * Get the lower bounds
7530
+ * @returns {Float64Array}
7531
+ */
7532
+ getLower() {
7533
+ const ret = wasm.wasmuniformmultivector_getLower(this.__wbg_ptr);
7534
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7535
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7536
+ return v1;
7537
+ }
7538
+ /**
7539
+ * Get the upper bounds
7540
+ * @returns {Float64Array}
7541
+ */
7542
+ getUpper() {
7543
+ const ret = wasm.wasmuniformmultivector_getUpper(this.__wbg_ptr);
7544
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
7545
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
7546
+ return v1;
7547
+ }
7548
+ /**
7549
+ * Create a uniform distribution on a hypercube [min, max]^8
7550
+ * @param {number} min
7551
+ * @param {number} max
7552
+ * @returns {WasmUniformMultivector}
7553
+ */
7554
+ static hypercube(min, max) {
7555
+ const ret = wasm.wasmuniformmultivector_hypercube(min, max);
7556
+ if (ret[2]) {
7557
+ throw takeFromExternrefTable0(ret[1]);
7558
+ }
7559
+ return WasmUniformMultivector.__wrap(ret[0]);
7560
+ }
7561
+ }
7562
+
7245
7563
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
7246
7564
 
7247
7565
  async function __wbg_load(module, imports) {
@@ -7323,7 +7641,7 @@ function __wbg_get_imports() {
7323
7641
  const ret = arg0.length;
7324
7642
  return ret;
7325
7643
  };
7326
- imports.wbg.__wbg_log_bf345a94df4f1349 = function(arg0, arg1) {
7644
+ imports.wbg.__wbg_log_7696259bf4d9d36d = function(arg0, arg1) {
7327
7645
  console.log(getStringFromWasm0(arg0, arg1));
7328
7646
  };
7329
7647
  imports.wbg.__wbg_log_ea240990d83e374e = function(arg0) {
@@ -7348,7 +7666,7 @@ function __wbg_get_imports() {
7348
7666
  const a = state0.a;
7349
7667
  state0.a = 0;
7350
7668
  try {
7351
- return __wbg_adapter_496(a, state0.b, arg0, arg1);
7669
+ return __wbg_adapter_511(a, state0.b, arg0, arg1);
7352
7670
  } finally {
7353
7671
  state0.a = a;
7354
7672
  }
@@ -7359,6 +7677,10 @@ function __wbg_get_imports() {
7359
7677
  state0.a = state0.b = 0;
7360
7678
  }
7361
7679
  };
7680
+ imports.wbg.__wbg_newfromslice_bcd6b1e87ab624a5 = function(arg0, arg1) {
7681
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
7682
+ return ret;
7683
+ };
7362
7684
  imports.wbg.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
7363
7685
  const ret = new Function(getStringFromWasm0(arg0, arg1));
7364
7686
  return ret;
@@ -7444,8 +7766,8 @@ function __wbg_get_imports() {
7444
7766
  const ret = false;
7445
7767
  return ret;
7446
7768
  };
7447
- imports.wbg.__wbindgen_closure_wrapper1715 = function(arg0, arg1, arg2) {
7448
- const ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_28);
7769
+ imports.wbg.__wbindgen_closure_wrapper1647 = function(arg0, arg1, arg2) {
7770
+ const ret = makeMutClosure(arg0, arg1, 40, __wbg_adapter_28);
7449
7771
  return ret;
7450
7772
  };
7451
7773
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {