@justinelliottcobb/amari-wasm 0.14.0 → 0.15.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 +323 -1
- package/amari_wasm.d.ts +838 -4
- package/amari_wasm.js +1985 -101
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/amari_wasm.js
CHANGED
|
@@ -236,6 +236,98 @@ function passArrayF64ToWasm0(arg, malloc) {
|
|
|
236
236
|
WASM_VECTOR_LEN = arg.length;
|
|
237
237
|
return ptr;
|
|
238
238
|
}
|
|
239
|
+
|
|
240
|
+
function _assertClass(instance, klass) {
|
|
241
|
+
if (!(instance instanceof klass)) {
|
|
242
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function takeFromExternrefTable0(idx) {
|
|
247
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
248
|
+
wasm.__externref_table_dealloc(idx);
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Power method for computing dominant eigenvalue
|
|
253
|
+
*
|
|
254
|
+
* # Arguments
|
|
255
|
+
* * `matrix` - The matrix operator
|
|
256
|
+
* * `initial` - Initial guess (optional, uses random if not provided)
|
|
257
|
+
* * `max_iterations` - Maximum iterations
|
|
258
|
+
* * `tolerance` - Convergence tolerance
|
|
259
|
+
*
|
|
260
|
+
* # Returns
|
|
261
|
+
* [eigenvalue, eigenvector...] flattened array
|
|
262
|
+
* @param {WasmMatrixOperator} matrix
|
|
263
|
+
* @param {Float64Array | null | undefined} initial
|
|
264
|
+
* @param {number} max_iterations
|
|
265
|
+
* @param {number} tolerance
|
|
266
|
+
* @returns {Float64Array}
|
|
267
|
+
*/
|
|
268
|
+
export function powerMethod(matrix, initial, max_iterations, tolerance) {
|
|
269
|
+
_assertClass(matrix, WasmMatrixOperator);
|
|
270
|
+
var ptr0 = isLikeNone(initial) ? 0 : passArrayF64ToWasm0(initial, wasm.__wbindgen_malloc);
|
|
271
|
+
var len0 = WASM_VECTOR_LEN;
|
|
272
|
+
const ret = wasm.powerMethod(matrix.__wbg_ptr, ptr0, len0, max_iterations, tolerance);
|
|
273
|
+
if (ret[3]) {
|
|
274
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
275
|
+
}
|
|
276
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
277
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
278
|
+
return v2;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Inverse iteration for computing eigenvalue near a shift
|
|
283
|
+
*
|
|
284
|
+
* # Arguments
|
|
285
|
+
* * `matrix` - The matrix operator
|
|
286
|
+
* * `shift` - Value near the desired eigenvalue
|
|
287
|
+
* * `initial` - Initial guess (optional)
|
|
288
|
+
* * `max_iterations` - Maximum iterations
|
|
289
|
+
* * `tolerance` - Convergence tolerance
|
|
290
|
+
*
|
|
291
|
+
* # Returns
|
|
292
|
+
* [eigenvalue, eigenvector...] flattened array
|
|
293
|
+
* @param {WasmMatrixOperator} matrix
|
|
294
|
+
* @param {number} shift
|
|
295
|
+
* @param {Float64Array | null | undefined} initial
|
|
296
|
+
* @param {number} max_iterations
|
|
297
|
+
* @param {number} tolerance
|
|
298
|
+
* @returns {Float64Array}
|
|
299
|
+
*/
|
|
300
|
+
export function inverseIteration(matrix, shift, initial, max_iterations, tolerance) {
|
|
301
|
+
_assertClass(matrix, WasmMatrixOperator);
|
|
302
|
+
var ptr0 = isLikeNone(initial) ? 0 : passArrayF64ToWasm0(initial, wasm.__wbindgen_malloc);
|
|
303
|
+
var len0 = WASM_VECTOR_LEN;
|
|
304
|
+
const ret = wasm.inverseIteration(matrix.__wbg_ptr, shift, ptr0, len0, max_iterations, tolerance);
|
|
305
|
+
if (ret[3]) {
|
|
306
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
307
|
+
}
|
|
308
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
309
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
310
|
+
return v2;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Compute all eigenvalues of a symmetric matrix
|
|
315
|
+
* @param {WasmMatrixOperator} matrix
|
|
316
|
+
* @param {number} max_iterations
|
|
317
|
+
* @param {number} tolerance
|
|
318
|
+
* @returns {Float64Array}
|
|
319
|
+
*/
|
|
320
|
+
export function computeEigenvalues(matrix, max_iterations, tolerance) {
|
|
321
|
+
_assertClass(matrix, WasmMatrixOperator);
|
|
322
|
+
const ret = wasm.computeEigenvalues(matrix.__wbg_ptr, max_iterations, tolerance);
|
|
323
|
+
if (ret[3]) {
|
|
324
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
325
|
+
}
|
|
326
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
327
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
328
|
+
return v1;
|
|
329
|
+
}
|
|
330
|
+
|
|
239
331
|
/**
|
|
240
332
|
* Initialize the enumerative geometry module
|
|
241
333
|
*/
|
|
@@ -254,11 +346,6 @@ export function light_deflection_angle(impact_parameter, mass) {
|
|
|
254
346
|
return ret;
|
|
255
347
|
}
|
|
256
348
|
|
|
257
|
-
function takeFromExternrefTable0(idx) {
|
|
258
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
259
|
-
wasm.__externref_table_dealloc(idx);
|
|
260
|
-
return value;
|
|
261
|
-
}
|
|
262
349
|
/**
|
|
263
350
|
* Convert velocity to Lorentz factor
|
|
264
351
|
* @param {number} velocity_magnitude
|
|
@@ -359,11 +446,6 @@ export function expectation(f, a, b, samples) {
|
|
|
359
446
|
return ret[0];
|
|
360
447
|
}
|
|
361
448
|
|
|
362
|
-
function _assertClass(instance, klass) {
|
|
363
|
-
if (!(instance instanceof klass)) {
|
|
364
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
449
|
/**
|
|
368
450
|
* Compute KL divergence D_KL(P||Q) between two distributions
|
|
369
451
|
*
|
|
@@ -403,6 +485,32 @@ export function initAutomata() {
|
|
|
403
485
|
wasm.initAutomata();
|
|
404
486
|
}
|
|
405
487
|
|
|
488
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
489
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
490
|
+
for (let i = 0; i < array.length; i++) {
|
|
491
|
+
const add = addToExternrefTable0(array[i]);
|
|
492
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
493
|
+
}
|
|
494
|
+
WASM_VECTOR_LEN = array.length;
|
|
495
|
+
return ptr;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
499
|
+
|
|
500
|
+
function getFloat32ArrayMemory0() {
|
|
501
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
502
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
503
|
+
}
|
|
504
|
+
return cachedFloat32ArrayMemory0;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
508
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
509
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
510
|
+
WASM_VECTOR_LEN = arg.length;
|
|
511
|
+
return ptr;
|
|
512
|
+
}
|
|
513
|
+
|
|
406
514
|
function getArrayU8FromWasm0(ptr, len) {
|
|
407
515
|
ptr = ptr >>> 0;
|
|
408
516
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -428,12 +536,35 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
428
536
|
WASM_VECTOR_LEN = arg.length;
|
|
429
537
|
return ptr;
|
|
430
538
|
}
|
|
431
|
-
|
|
432
|
-
|
|
539
|
+
|
|
540
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
541
|
+
ptr = ptr >>> 0;
|
|
542
|
+
const mem = getDataViewMemory0();
|
|
543
|
+
const result = [];
|
|
544
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
545
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
546
|
+
}
|
|
547
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
548
|
+
return result;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
552
|
+
ptr = ptr >>> 0;
|
|
553
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
557
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
558
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
559
|
+
WASM_VECTOR_LEN = arg.length;
|
|
560
|
+
return ptr;
|
|
561
|
+
}
|
|
562
|
+
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
563
|
+
wasm.closure44_externref_shim(arg0, arg1, arg2);
|
|
433
564
|
}
|
|
434
565
|
|
|
435
|
-
function
|
|
436
|
-
wasm.
|
|
566
|
+
function __wbg_adapter_683(arg0, arg1, arg2, arg3) {
|
|
567
|
+
wasm.closure37_externref_shim(arg0, arg1, arg2, arg3);
|
|
437
568
|
}
|
|
438
569
|
|
|
439
570
|
/**
|
|
@@ -2463,6 +2594,199 @@ export class WasmAlphaConnection {
|
|
|
2463
2594
|
}
|
|
2464
2595
|
}
|
|
2465
2596
|
|
|
2597
|
+
const WasmBinaryHologramFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2598
|
+
? { register: () => {}, unregister: () => {} }
|
|
2599
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmbinaryhologram_free(ptr >>> 0, 1));
|
|
2600
|
+
/**
|
|
2601
|
+
* WASM wrapper for BinaryHologram.
|
|
2602
|
+
*
|
|
2603
|
+
* Bit-packed binary pattern for DMD display, the output of Lee encoding.
|
|
2604
|
+
*/
|
|
2605
|
+
export class WasmBinaryHologram {
|
|
2606
|
+
|
|
2607
|
+
static __wrap(ptr) {
|
|
2608
|
+
ptr = ptr >>> 0;
|
|
2609
|
+
const obj = Object.create(WasmBinaryHologram.prototype);
|
|
2610
|
+
obj.__wbg_ptr = ptr;
|
|
2611
|
+
WasmBinaryHologramFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2612
|
+
return obj;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
__destroy_into_raw() {
|
|
2616
|
+
const ptr = this.__wbg_ptr;
|
|
2617
|
+
this.__wbg_ptr = 0;
|
|
2618
|
+
WasmBinaryHologramFinalization.unregister(this);
|
|
2619
|
+
return ptr;
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
free() {
|
|
2623
|
+
const ptr = this.__destroy_into_raw();
|
|
2624
|
+
wasm.__wbg_wasmbinaryhologram_free(ptr, 0);
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Fill factor (fraction of "on" pixels, 0 to 1).
|
|
2628
|
+
* @returns {number}
|
|
2629
|
+
*/
|
|
2630
|
+
fillFactor() {
|
|
2631
|
+
const ret = wasm.wasmbinaryhologram_fillFactor(this.__wbg_ptr);
|
|
2632
|
+
return ret;
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Compute Hamming distance between two holograms.
|
|
2636
|
+
* @param {WasmBinaryHologram} other
|
|
2637
|
+
* @returns {number}
|
|
2638
|
+
*/
|
|
2639
|
+
hammingDistance(other) {
|
|
2640
|
+
_assertClass(other, WasmBinaryHologram);
|
|
2641
|
+
const ret = wasm.wasmbinaryhologram_hammingDistance(this.__wbg_ptr, other.__wbg_ptr);
|
|
2642
|
+
return ret >>> 0;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Compute normalized Hamming distance (0 to 1).
|
|
2646
|
+
* @param {WasmBinaryHologram} other
|
|
2647
|
+
* @returns {number}
|
|
2648
|
+
*/
|
|
2649
|
+
normalizedHammingDistance(other) {
|
|
2650
|
+
_assertClass(other, WasmBinaryHologram);
|
|
2651
|
+
const ret = wasm.wasmbinaryhologram_normalizedHammingDistance(this.__wbg_ptr, other.__wbg_ptr);
|
|
2652
|
+
return ret;
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Get pixel value at (x, y).
|
|
2656
|
+
* @param {number} x
|
|
2657
|
+
* @param {number} y
|
|
2658
|
+
* @returns {boolean}
|
|
2659
|
+
*/
|
|
2660
|
+
get(x, y) {
|
|
2661
|
+
const ret = wasm.wasmbinaryhologram_get(this.__wbg_ptr, x, y);
|
|
2662
|
+
return ret !== 0;
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Create from boolean array (as u8: 0 = false, non-zero = true).
|
|
2666
|
+
* @param {Uint8Array} pattern
|
|
2667
|
+
* @param {number} width
|
|
2668
|
+
* @param {number} height
|
|
2669
|
+
*/
|
|
2670
|
+
constructor(pattern, width, height) {
|
|
2671
|
+
const ptr0 = passArray8ToWasm0(pattern, wasm.__wbindgen_malloc);
|
|
2672
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2673
|
+
const ret = wasm.wasmbinaryhologram_new(ptr0, len0, width, height);
|
|
2674
|
+
if (ret[2]) {
|
|
2675
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2676
|
+
}
|
|
2677
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2678
|
+
WasmBinaryHologramFinalization.register(this, this.__wbg_ptr, this);
|
|
2679
|
+
return this;
|
|
2680
|
+
}
|
|
2681
|
+
/**
|
|
2682
|
+
* Set pixel value at (x, y).
|
|
2683
|
+
* @param {number} x
|
|
2684
|
+
* @param {number} y
|
|
2685
|
+
* @param {boolean} value
|
|
2686
|
+
*/
|
|
2687
|
+
set(x, y, value) {
|
|
2688
|
+
wasm.wasmbinaryhologram_set(this.__wbg_ptr, x, y, value);
|
|
2689
|
+
}
|
|
2690
|
+
/**
|
|
2691
|
+
* XOR two holograms.
|
|
2692
|
+
* @param {WasmBinaryHologram} other
|
|
2693
|
+
* @returns {WasmBinaryHologram}
|
|
2694
|
+
*/
|
|
2695
|
+
xor(other) {
|
|
2696
|
+
_assertClass(other, WasmBinaryHologram);
|
|
2697
|
+
const ret = wasm.wasmbinaryhologram_xor(this.__wbg_ptr, other.__wbg_ptr);
|
|
2698
|
+
return WasmBinaryHologram.__wrap(ret);
|
|
2699
|
+
}
|
|
2700
|
+
/**
|
|
2701
|
+
* Create an all-ones hologram.
|
|
2702
|
+
* @param {number} width
|
|
2703
|
+
* @param {number} height
|
|
2704
|
+
* @returns {WasmBinaryHologram}
|
|
2705
|
+
*/
|
|
2706
|
+
static ones(width, height) {
|
|
2707
|
+
const ret = wasm.wasmbinaryhologram_ones(width, height);
|
|
2708
|
+
return WasmBinaryHologram.__wrap(ret);
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Get grid width.
|
|
2712
|
+
* @returns {number}
|
|
2713
|
+
*/
|
|
2714
|
+
get width() {
|
|
2715
|
+
const ret = wasm.wasmbinaryhologram_width(this.__wbg_ptr);
|
|
2716
|
+
return ret >>> 0;
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Create an all-zeros hologram.
|
|
2720
|
+
* @param {number} width
|
|
2721
|
+
* @param {number} height
|
|
2722
|
+
* @returns {WasmBinaryHologram}
|
|
2723
|
+
*/
|
|
2724
|
+
static zeros(width, height) {
|
|
2725
|
+
const ret = wasm.wasmbinaryhologram_zeros(width, height);
|
|
2726
|
+
return WasmBinaryHologram.__wrap(ret);
|
|
2727
|
+
}
|
|
2728
|
+
/**
|
|
2729
|
+
* Get grid height.
|
|
2730
|
+
* @returns {number}
|
|
2731
|
+
*/
|
|
2732
|
+
get height() {
|
|
2733
|
+
const ret = wasm.wasmbinaryhologram_height(this.__wbg_ptr);
|
|
2734
|
+
return ret >>> 0;
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* Get total number of pixels.
|
|
2738
|
+
* @returns {number}
|
|
2739
|
+
*/
|
|
2740
|
+
get length() {
|
|
2741
|
+
const ret = wasm.wasmbinaryhologram_length(this.__wbg_ptr);
|
|
2742
|
+
return ret >>> 0;
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Toggle pixel at (x, y).
|
|
2746
|
+
* @param {number} x
|
|
2747
|
+
* @param {number} y
|
|
2748
|
+
*/
|
|
2749
|
+
toggle(x, y) {
|
|
2750
|
+
wasm.wasmbinaryhologram_toggle(this.__wbg_ptr, x, y);
|
|
2751
|
+
}
|
|
2752
|
+
/**
|
|
2753
|
+
* Get packed binary data (for hardware interface).
|
|
2754
|
+
* @returns {Uint8Array}
|
|
2755
|
+
*/
|
|
2756
|
+
asBytes() {
|
|
2757
|
+
const ret = wasm.wasmbinaryhologram_asBytes(this.__wbg_ptr);
|
|
2758
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2759
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2760
|
+
return v1;
|
|
2761
|
+
}
|
|
2762
|
+
/**
|
|
2763
|
+
* Create an inverted copy.
|
|
2764
|
+
* @returns {WasmBinaryHologram}
|
|
2765
|
+
*/
|
|
2766
|
+
inverted() {
|
|
2767
|
+
const ret = wasm.wasmbinaryhologram_inverted(this.__wbg_ptr);
|
|
2768
|
+
return WasmBinaryHologram.__wrap(ret);
|
|
2769
|
+
}
|
|
2770
|
+
/**
|
|
2771
|
+
* Count of "on" pixels.
|
|
2772
|
+
* @returns {number}
|
|
2773
|
+
*/
|
|
2774
|
+
popcount() {
|
|
2775
|
+
const ret = wasm.wasmbinaryhologram_popcount(this.__wbg_ptr);
|
|
2776
|
+
return ret >>> 0;
|
|
2777
|
+
}
|
|
2778
|
+
/**
|
|
2779
|
+
* Convert to boolean array (as u8: 0 = false, 1 = true).
|
|
2780
|
+
* @returns {Uint8Array}
|
|
2781
|
+
*/
|
|
2782
|
+
toBools() {
|
|
2783
|
+
const ret = wasm.wasmbinaryhologram_toBools(this.__wbg_ptr);
|
|
2784
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2785
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2786
|
+
return v1;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2466
2790
|
const WasmChowClassFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2467
2791
|
? { register: () => {}, unregister: () => {} }
|
|
2468
2792
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmchowclass_free(ptr >>> 0, 1));
|
|
@@ -3944,7 +4268,7 @@ export class WasmGeometricEdge {
|
|
|
3944
4268
|
* @returns {number}
|
|
3945
4269
|
*/
|
|
3946
4270
|
get target() {
|
|
3947
|
-
const ret = wasm.
|
|
4271
|
+
const ret = wasm.wasmbinaryhologram_height(this.__wbg_ptr);
|
|
3948
4272
|
return ret >>> 0;
|
|
3949
4273
|
}
|
|
3950
4274
|
/**
|
|
@@ -3957,6 +4281,129 @@ export class WasmGeometricEdge {
|
|
|
3957
4281
|
}
|
|
3958
4282
|
}
|
|
3959
4283
|
|
|
4284
|
+
const WasmGeometricLeeEncoderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4285
|
+
? { register: () => {}, unregister: () => {} }
|
|
4286
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricleeencoder_free(ptr >>> 0, 1));
|
|
4287
|
+
/**
|
|
4288
|
+
* WASM wrapper for GeometricLeeEncoder.
|
|
4289
|
+
*
|
|
4290
|
+
* Encodes optical rotor fields to binary holograms using Lee's method.
|
|
4291
|
+
*/
|
|
4292
|
+
export class WasmGeometricLeeEncoder {
|
|
4293
|
+
|
|
4294
|
+
static __wrap(ptr) {
|
|
4295
|
+
ptr = ptr >>> 0;
|
|
4296
|
+
const obj = Object.create(WasmGeometricLeeEncoder.prototype);
|
|
4297
|
+
obj.__wbg_ptr = ptr;
|
|
4298
|
+
WasmGeometricLeeEncoderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4299
|
+
return obj;
|
|
4300
|
+
}
|
|
4301
|
+
|
|
4302
|
+
__destroy_into_raw() {
|
|
4303
|
+
const ptr = this.__wbg_ptr;
|
|
4304
|
+
this.__wbg_ptr = 0;
|
|
4305
|
+
WasmGeometricLeeEncoderFinalization.unregister(this);
|
|
4306
|
+
return ptr;
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
free() {
|
|
4310
|
+
const ptr = this.__destroy_into_raw();
|
|
4311
|
+
wasm.__wbg_wasmgeometricleeencoder_free(ptr, 0);
|
|
4312
|
+
}
|
|
4313
|
+
/**
|
|
4314
|
+
* Get carrier angle.
|
|
4315
|
+
* @returns {number}
|
|
4316
|
+
*/
|
|
4317
|
+
get carrierAngle() {
|
|
4318
|
+
const ret = wasm.wasmgeometricleeencoder_carrierAngle(this.__wbg_ptr);
|
|
4319
|
+
return ret;
|
|
4320
|
+
}
|
|
4321
|
+
/**
|
|
4322
|
+
* Create encoder with horizontal carrier (angle = 0).
|
|
4323
|
+
* @param {number} width
|
|
4324
|
+
* @param {number} height
|
|
4325
|
+
* @param {number} carrier_frequency
|
|
4326
|
+
* @returns {WasmGeometricLeeEncoder}
|
|
4327
|
+
*/
|
|
4328
|
+
static withFrequency(width, height, carrier_frequency) {
|
|
4329
|
+
const ret = wasm.wasmgeometricleeencoder_withFrequency(width, height, carrier_frequency);
|
|
4330
|
+
return WasmGeometricLeeEncoder.__wrap(ret);
|
|
4331
|
+
}
|
|
4332
|
+
/**
|
|
4333
|
+
* Get carrier frequency.
|
|
4334
|
+
* @returns {number}
|
|
4335
|
+
*/
|
|
4336
|
+
get carrierFrequency() {
|
|
4337
|
+
const ret = wasm.wasmgeometricleeencoder_carrierFrequency(this.__wbg_ptr);
|
|
4338
|
+
return ret;
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* Theoretical diffraction efficiency for the given field.
|
|
4342
|
+
* @param {WasmOpticalRotorField} field
|
|
4343
|
+
* @returns {number}
|
|
4344
|
+
*/
|
|
4345
|
+
theoreticalEfficiency(field) {
|
|
4346
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
4347
|
+
const ret = wasm.wasmgeometricleeencoder_theoreticalEfficiency(this.__wbg_ptr, field.__wbg_ptr);
|
|
4348
|
+
return ret;
|
|
4349
|
+
}
|
|
4350
|
+
/**
|
|
4351
|
+
* Create encoder with configuration.
|
|
4352
|
+
*
|
|
4353
|
+
* # Arguments
|
|
4354
|
+
* * `width` - Grid width
|
|
4355
|
+
* * `height` - Grid height
|
|
4356
|
+
* * `carrier_frequency` - Carrier frequency in cycles per pixel
|
|
4357
|
+
* * `carrier_angle` - Carrier direction angle (radians, 0 = horizontal)
|
|
4358
|
+
* @param {number} width
|
|
4359
|
+
* @param {number} height
|
|
4360
|
+
* @param {number} carrier_frequency
|
|
4361
|
+
* @param {number} carrier_angle
|
|
4362
|
+
*/
|
|
4363
|
+
constructor(width, height, carrier_frequency, carrier_angle) {
|
|
4364
|
+
const ret = wasm.wasmgeometricleeencoder_new(width, height, carrier_frequency, carrier_angle);
|
|
4365
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4366
|
+
WasmGeometricLeeEncoderFinalization.register(this, this.__wbg_ptr, this);
|
|
4367
|
+
return this;
|
|
4368
|
+
}
|
|
4369
|
+
/**
|
|
4370
|
+
* Get encoder width.
|
|
4371
|
+
* @returns {number}
|
|
4372
|
+
*/
|
|
4373
|
+
get width() {
|
|
4374
|
+
const ret = wasm.wasmgeometricca_generation(this.__wbg_ptr);
|
|
4375
|
+
return ret >>> 0;
|
|
4376
|
+
}
|
|
4377
|
+
/**
|
|
4378
|
+
* Encode a rotor field to binary hologram.
|
|
4379
|
+
* @param {WasmOpticalRotorField} field
|
|
4380
|
+
* @returns {WasmBinaryHologram}
|
|
4381
|
+
*/
|
|
4382
|
+
encode(field) {
|
|
4383
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
4384
|
+
const ret = wasm.wasmgeometricleeencoder_encode(this.__wbg_ptr, field.__wbg_ptr);
|
|
4385
|
+
return WasmBinaryHologram.__wrap(ret);
|
|
4386
|
+
}
|
|
4387
|
+
/**
|
|
4388
|
+
* Get encoder height.
|
|
4389
|
+
* @returns {number}
|
|
4390
|
+
*/
|
|
4391
|
+
get height() {
|
|
4392
|
+
const ret = wasm.wasmgeometricleeencoder_height(this.__wbg_ptr);
|
|
4393
|
+
return ret >>> 0;
|
|
4394
|
+
}
|
|
4395
|
+
/**
|
|
4396
|
+
* Compute the modulated rotor field (before thresholding).
|
|
4397
|
+
* @param {WasmOpticalRotorField} field
|
|
4398
|
+
* @returns {WasmOpticalRotorField}
|
|
4399
|
+
*/
|
|
4400
|
+
modulate(field) {
|
|
4401
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
4402
|
+
const ret = wasm.wasmgeometricleeencoder_modulate(this.__wbg_ptr, field.__wbg_ptr);
|
|
4403
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
|
|
3960
4407
|
const WasmGeometricNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3961
4408
|
? { register: () => {}, unregister: () => {} }
|
|
3962
4409
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricnetwork_free(ptr >>> 0, 1));
|
|
@@ -4458,18 +4905,188 @@ export class WasmGrassmannian {
|
|
|
4458
4905
|
}
|
|
4459
4906
|
}
|
|
4460
4907
|
|
|
4461
|
-
const
|
|
4908
|
+
const WasmHilbertSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4462
4909
|
? { register: () => {}, unregister: () => {} }
|
|
4463
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
4910
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmhilbertspace_free(ptr >>> 0, 1));
|
|
4464
4911
|
/**
|
|
4465
|
-
* WASM wrapper for
|
|
4912
|
+
* WASM wrapper for MultivectorHilbertSpace over Cl(2,0,0)
|
|
4913
|
+
*
|
|
4914
|
+
* Provides finite-dimensional Hilbert space operations on multivectors.
|
|
4466
4915
|
*/
|
|
4467
|
-
export class
|
|
4916
|
+
export class WasmHilbertSpace {
|
|
4468
4917
|
|
|
4469
|
-
|
|
4470
|
-
ptr =
|
|
4471
|
-
|
|
4472
|
-
|
|
4918
|
+
__destroy_into_raw() {
|
|
4919
|
+
const ptr = this.__wbg_ptr;
|
|
4920
|
+
this.__wbg_ptr = 0;
|
|
4921
|
+
WasmHilbertSpaceFinalization.unregister(this);
|
|
4922
|
+
return ptr;
|
|
4923
|
+
}
|
|
4924
|
+
|
|
4925
|
+
free() {
|
|
4926
|
+
const ptr = this.__destroy_into_raw();
|
|
4927
|
+
wasm.__wbg_wasmhilbertspace_free(ptr, 0);
|
|
4928
|
+
}
|
|
4929
|
+
/**
|
|
4930
|
+
* Compute inner product <x, y>
|
|
4931
|
+
* @param {Float64Array} x
|
|
4932
|
+
* @param {Float64Array} y
|
|
4933
|
+
* @returns {number}
|
|
4934
|
+
*/
|
|
4935
|
+
innerProduct(x, y) {
|
|
4936
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
4937
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4938
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
4939
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4940
|
+
const ret = wasm.wasmhilbertspace_innerProduct(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
4941
|
+
if (ret[2]) {
|
|
4942
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4943
|
+
}
|
|
4944
|
+
return ret[0];
|
|
4945
|
+
}
|
|
4946
|
+
/**
|
|
4947
|
+
* Check if two vectors are orthogonal
|
|
4948
|
+
* @param {Float64Array} x
|
|
4949
|
+
* @param {Float64Array} y
|
|
4950
|
+
* @param {number} tolerance
|
|
4951
|
+
* @returns {boolean}
|
|
4952
|
+
*/
|
|
4953
|
+
isOrthogonal(x, y, tolerance) {
|
|
4954
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
4955
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4956
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
4957
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4958
|
+
const ret = wasm.wasmhilbertspace_isOrthogonal(this.__wbg_ptr, ptr0, len0, ptr1, len1, tolerance);
|
|
4959
|
+
if (ret[2]) {
|
|
4960
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4961
|
+
}
|
|
4962
|
+
return ret[0] !== 0;
|
|
4963
|
+
}
|
|
4964
|
+
/**
|
|
4965
|
+
* Create a multivector from coefficients
|
|
4966
|
+
*
|
|
4967
|
+
* # Arguments
|
|
4968
|
+
* * `coefficients` - Array of 4 coefficients [scalar, e1, e2, e12]
|
|
4969
|
+
* @param {Float64Array} coefficients
|
|
4970
|
+
* @returns {Float64Array}
|
|
4971
|
+
*/
|
|
4972
|
+
fromCoefficients(coefficients) {
|
|
4973
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
4974
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4975
|
+
const ret = wasm.wasmhilbertspace_fromCoefficients(this.__wbg_ptr, ptr0, len0);
|
|
4976
|
+
if (ret[3]) {
|
|
4977
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4978
|
+
}
|
|
4979
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4980
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4981
|
+
return v2;
|
|
4982
|
+
}
|
|
4983
|
+
/**
|
|
4984
|
+
* Create a new Hilbert space Cl(2,0,0) ~ R^4
|
|
4985
|
+
*/
|
|
4986
|
+
constructor() {
|
|
4987
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
4988
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4989
|
+
WasmHilbertSpaceFinalization.register(this, this.__wbg_ptr, this);
|
|
4990
|
+
return this;
|
|
4991
|
+
}
|
|
4992
|
+
/**
|
|
4993
|
+
* Compute the norm ||x||
|
|
4994
|
+
* @param {Float64Array} x
|
|
4995
|
+
* @returns {number}
|
|
4996
|
+
*/
|
|
4997
|
+
norm(x) {
|
|
4998
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
4999
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5000
|
+
const ret = wasm.wasmhilbertspace_norm(this.__wbg_ptr, ptr0, len0);
|
|
5001
|
+
if (ret[2]) {
|
|
5002
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5003
|
+
}
|
|
5004
|
+
return ret[0];
|
|
5005
|
+
}
|
|
5006
|
+
/**
|
|
5007
|
+
* Orthogonal projection of x onto y
|
|
5008
|
+
* @param {Float64Array} x
|
|
5009
|
+
* @param {Float64Array} y
|
|
5010
|
+
* @returns {Float64Array}
|
|
5011
|
+
*/
|
|
5012
|
+
project(x, y) {
|
|
5013
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
5014
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5015
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
5016
|
+
const len1 = WASM_VECTOR_LEN;
|
|
5017
|
+
const ret = wasm.wasmhilbertspace_project(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
5018
|
+
if (ret[3]) {
|
|
5019
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5020
|
+
}
|
|
5021
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5022
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5023
|
+
return v3;
|
|
5024
|
+
}
|
|
5025
|
+
/**
|
|
5026
|
+
* Compute distance d(x, y) = ||x - y||
|
|
5027
|
+
* @param {Float64Array} x
|
|
5028
|
+
* @param {Float64Array} y
|
|
5029
|
+
* @returns {number}
|
|
5030
|
+
*/
|
|
5031
|
+
distance(x, y) {
|
|
5032
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
5033
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5034
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
5035
|
+
const len1 = WASM_VECTOR_LEN;
|
|
5036
|
+
const ret = wasm.wasmhilbertspace_distance(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
5037
|
+
if (ret[2]) {
|
|
5038
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5039
|
+
}
|
|
5040
|
+
return ret[0];
|
|
5041
|
+
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Get the dimension of the space (4 for Cl(2,0,0))
|
|
5044
|
+
* @returns {number}
|
|
5045
|
+
*/
|
|
5046
|
+
dimension() {
|
|
5047
|
+
const ret = wasm.wasmhilbertspace_dimension(this.__wbg_ptr);
|
|
5048
|
+
return ret >>> 0;
|
|
5049
|
+
}
|
|
5050
|
+
/**
|
|
5051
|
+
* Normalize a vector to unit length
|
|
5052
|
+
* @param {Float64Array} x
|
|
5053
|
+
* @returns {Float64Array}
|
|
5054
|
+
*/
|
|
5055
|
+
normalize(x) {
|
|
5056
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
5057
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5058
|
+
const ret = wasm.wasmhilbertspace_normalize(this.__wbg_ptr, ptr0, len0);
|
|
5059
|
+
if (ret[3]) {
|
|
5060
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5061
|
+
}
|
|
5062
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5063
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5064
|
+
return v2;
|
|
5065
|
+
}
|
|
5066
|
+
/**
|
|
5067
|
+
* Get the Clifford algebra signature (p, q, r)
|
|
5068
|
+
* @returns {Uint32Array}
|
|
5069
|
+
*/
|
|
5070
|
+
signature() {
|
|
5071
|
+
const ret = wasm.wasmhilbertspace_signature(this.__wbg_ptr);
|
|
5072
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
5073
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
5074
|
+
return v1;
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
|
|
5078
|
+
const WasmHolographicMemoryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5079
|
+
? { register: () => {}, unregister: () => {} }
|
|
5080
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmholographicmemory_free(ptr >>> 0, 1));
|
|
5081
|
+
/**
|
|
5082
|
+
* WASM wrapper for HolographicMemory using ProductClifford algebra
|
|
5083
|
+
*/
|
|
5084
|
+
export class WasmHolographicMemory {
|
|
5085
|
+
|
|
5086
|
+
static __wrap(ptr) {
|
|
5087
|
+
ptr = ptr >>> 0;
|
|
5088
|
+
const obj = Object.create(WasmHolographicMemory.prototype);
|
|
5089
|
+
obj.__wbg_ptr = ptr;
|
|
4473
5090
|
WasmHolographicMemoryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4474
5091
|
return obj;
|
|
4475
5092
|
}
|
|
@@ -4840,6 +5457,201 @@ export class WasmMCMCDiagnostics {
|
|
|
4840
5457
|
}
|
|
4841
5458
|
}
|
|
4842
5459
|
|
|
5460
|
+
const WasmMatrixOperatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5461
|
+
? { register: () => {}, unregister: () => {} }
|
|
5462
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmatrixoperator_free(ptr >>> 0, 1));
|
|
5463
|
+
/**
|
|
5464
|
+
* WASM wrapper for matrix operators on Hilbert spaces
|
|
5465
|
+
*
|
|
5466
|
+
* Represents bounded linear operators as matrices.
|
|
5467
|
+
*/
|
|
5468
|
+
export class WasmMatrixOperator {
|
|
5469
|
+
|
|
5470
|
+
static __wrap(ptr) {
|
|
5471
|
+
ptr = ptr >>> 0;
|
|
5472
|
+
const obj = Object.create(WasmMatrixOperator.prototype);
|
|
5473
|
+
obj.__wbg_ptr = ptr;
|
|
5474
|
+
WasmMatrixOperatorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
5475
|
+
return obj;
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5478
|
+
__destroy_into_raw() {
|
|
5479
|
+
const ptr = this.__wbg_ptr;
|
|
5480
|
+
this.__wbg_ptr = 0;
|
|
5481
|
+
WasmMatrixOperatorFinalization.unregister(this);
|
|
5482
|
+
return ptr;
|
|
5483
|
+
}
|
|
5484
|
+
|
|
5485
|
+
free() {
|
|
5486
|
+
const ptr = this.__destroy_into_raw();
|
|
5487
|
+
wasm.__wbg_wasmmatrixoperator_free(ptr, 0);
|
|
5488
|
+
}
|
|
5489
|
+
/**
|
|
5490
|
+
* Get the matrix entries as a flat array (row-major)
|
|
5491
|
+
* @returns {Float64Array}
|
|
5492
|
+
*/
|
|
5493
|
+
getEntries() {
|
|
5494
|
+
const ret = wasm.wasmmatrixoperator_getEntries(this.__wbg_ptr);
|
|
5495
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5496
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5497
|
+
return v1;
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Check if the matrix is symmetric
|
|
5501
|
+
* @param {number} tolerance
|
|
5502
|
+
* @returns {boolean}
|
|
5503
|
+
*/
|
|
5504
|
+
isSymmetric(tolerance) {
|
|
5505
|
+
const ret = wasm.wasmmatrixoperator_isSymmetric(this.__wbg_ptr, tolerance);
|
|
5506
|
+
return ret !== 0;
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* Compute operator norm ||T||
|
|
5510
|
+
* @returns {number}
|
|
5511
|
+
*/
|
|
5512
|
+
operatorNorm() {
|
|
5513
|
+
const ret = wasm.wasmmatrixoperator_operatorNorm(this.__wbg_ptr);
|
|
5514
|
+
return ret;
|
|
5515
|
+
}
|
|
5516
|
+
/**
|
|
5517
|
+
* Add two operators
|
|
5518
|
+
* @param {WasmMatrixOperator} other
|
|
5519
|
+
* @returns {WasmMatrixOperator}
|
|
5520
|
+
*/
|
|
5521
|
+
add(other) {
|
|
5522
|
+
_assertClass(other, WasmMatrixOperator);
|
|
5523
|
+
const ret = wasm.wasmmatrixoperator_add(this.__wbg_ptr, other.__wbg_ptr);
|
|
5524
|
+
if (ret[2]) {
|
|
5525
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5526
|
+
}
|
|
5527
|
+
return WasmMatrixOperator.__wrap(ret[0]);
|
|
5528
|
+
}
|
|
5529
|
+
/**
|
|
5530
|
+
* Create a matrix operator from a flattened row-major matrix
|
|
5531
|
+
*
|
|
5532
|
+
* # Arguments
|
|
5533
|
+
* * `entries` - 16 entries for a 4x4 matrix in row-major order
|
|
5534
|
+
* @param {Float64Array} entries
|
|
5535
|
+
*/
|
|
5536
|
+
constructor(entries) {
|
|
5537
|
+
const ptr0 = passArrayF64ToWasm0(entries, wasm.__wbindgen_malloc);
|
|
5538
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5539
|
+
const ret = wasm.wasmmatrixoperator_new(ptr0, len0);
|
|
5540
|
+
if (ret[2]) {
|
|
5541
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5542
|
+
}
|
|
5543
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
5544
|
+
WasmMatrixOperatorFinalization.register(this, this.__wbg_ptr, this);
|
|
5545
|
+
return this;
|
|
5546
|
+
}
|
|
5547
|
+
/**
|
|
5548
|
+
* Create a zero operator
|
|
5549
|
+
* @returns {WasmMatrixOperator}
|
|
5550
|
+
*/
|
|
5551
|
+
static zero() {
|
|
5552
|
+
const ret = wasm.wasmmatrixoperator_zero();
|
|
5553
|
+
return WasmMatrixOperator.__wrap(ret);
|
|
5554
|
+
}
|
|
5555
|
+
/**
|
|
5556
|
+
* Apply the operator to a vector: T(x)
|
|
5557
|
+
* @param {Float64Array} x
|
|
5558
|
+
* @returns {Float64Array}
|
|
5559
|
+
*/
|
|
5560
|
+
apply(x) {
|
|
5561
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
5562
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5563
|
+
const ret = wasm.wasmmatrixoperator_apply(this.__wbg_ptr, ptr0, len0);
|
|
5564
|
+
if (ret[3]) {
|
|
5565
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5566
|
+
}
|
|
5567
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5568
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5569
|
+
return v2;
|
|
5570
|
+
}
|
|
5571
|
+
/**
|
|
5572
|
+
* Scale operator by scalar
|
|
5573
|
+
* @param {number} lambda
|
|
5574
|
+
* @returns {WasmMatrixOperator}
|
|
5575
|
+
*/
|
|
5576
|
+
scale(lambda) {
|
|
5577
|
+
const ret = wasm.wasmmatrixoperator_scale(this.__wbg_ptr, lambda);
|
|
5578
|
+
return WasmMatrixOperator.__wrap(ret);
|
|
5579
|
+
}
|
|
5580
|
+
/**
|
|
5581
|
+
* Compute the trace
|
|
5582
|
+
* @returns {number}
|
|
5583
|
+
*/
|
|
5584
|
+
trace() {
|
|
5585
|
+
const ret = wasm.wasmmatrixoperator_trace(this.__wbg_ptr);
|
|
5586
|
+
return ret;
|
|
5587
|
+
}
|
|
5588
|
+
/**
|
|
5589
|
+
* Compose two operators (matrix multiplication)
|
|
5590
|
+
* @param {WasmMatrixOperator} other
|
|
5591
|
+
* @returns {WasmMatrixOperator}
|
|
5592
|
+
*/
|
|
5593
|
+
compose(other) {
|
|
5594
|
+
_assertClass(other, WasmMatrixOperator);
|
|
5595
|
+
const ret = wasm.wasmmatrixoperator_compose(this.__wbg_ptr, other.__wbg_ptr);
|
|
5596
|
+
if (ret[2]) {
|
|
5597
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5598
|
+
}
|
|
5599
|
+
return WasmMatrixOperator.__wrap(ret[0]);
|
|
5600
|
+
}
|
|
5601
|
+
/**
|
|
5602
|
+
* Create a scaling operator (λI)
|
|
5603
|
+
* @param {number} lambda
|
|
5604
|
+
* @returns {WasmMatrixOperator}
|
|
5605
|
+
*/
|
|
5606
|
+
static scaling(lambda) {
|
|
5607
|
+
const ret = wasm.wasmmatrixoperator_scaling(lambda);
|
|
5608
|
+
return WasmMatrixOperator.__wrap(ret);
|
|
5609
|
+
}
|
|
5610
|
+
/**
|
|
5611
|
+
* Create a diagonal matrix from diagonal entries
|
|
5612
|
+
* @param {Float64Array} entries
|
|
5613
|
+
* @returns {WasmMatrixOperator}
|
|
5614
|
+
*/
|
|
5615
|
+
static diagonal(entries) {
|
|
5616
|
+
const ptr0 = passArrayF64ToWasm0(entries, wasm.__wbindgen_malloc);
|
|
5617
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5618
|
+
const ret = wasm.wasmmatrixoperator_diagonal(ptr0, len0);
|
|
5619
|
+
if (ret[2]) {
|
|
5620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5621
|
+
}
|
|
5622
|
+
return WasmMatrixOperator.__wrap(ret[0]);
|
|
5623
|
+
}
|
|
5624
|
+
/**
|
|
5625
|
+
* Create the identity operator
|
|
5626
|
+
* @returns {WasmMatrixOperator}
|
|
5627
|
+
*/
|
|
5628
|
+
static identity() {
|
|
5629
|
+
const ret = wasm.wasmmatrixoperator_identity();
|
|
5630
|
+
return WasmMatrixOperator.__wrap(ret);
|
|
5631
|
+
}
|
|
5632
|
+
/**
|
|
5633
|
+
* Get a single matrix entry at (i, j)
|
|
5634
|
+
* @param {number} i
|
|
5635
|
+
* @param {number} j
|
|
5636
|
+
* @returns {number}
|
|
5637
|
+
*/
|
|
5638
|
+
getEntry(i, j) {
|
|
5639
|
+
const ret = wasm.wasmmatrixoperator_getEntry(this.__wbg_ptr, i, j);
|
|
5640
|
+
if (ret[2]) {
|
|
5641
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5642
|
+
}
|
|
5643
|
+
return ret[0];
|
|
5644
|
+
}
|
|
5645
|
+
/**
|
|
5646
|
+
* Compute the transpose
|
|
5647
|
+
* @returns {WasmMatrixOperator}
|
|
5648
|
+
*/
|
|
5649
|
+
transpose() {
|
|
5650
|
+
const ret = wasm.wasmmatrixoperator_transpose(this.__wbg_ptr);
|
|
5651
|
+
return WasmMatrixOperator.__wrap(ret);
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
|
|
4843
5655
|
const WasmMetropolisHastingsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4844
5656
|
? { register: () => {}, unregister: () => {} }
|
|
4845
5657
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmetropolishastings_free(ptr >>> 0, 1));
|
|
@@ -5335,7 +6147,7 @@ export class WasmMultiObjectiveResult {
|
|
|
5335
6147
|
* @returns {number}
|
|
5336
6148
|
*/
|
|
5337
6149
|
get generations() {
|
|
5338
|
-
const ret = wasm.
|
|
6150
|
+
const ret = wasm.wasmbinaryhologram_width(this.__wbg_ptr);
|
|
5339
6151
|
return ret >>> 0;
|
|
5340
6152
|
}
|
|
5341
6153
|
/**
|
|
@@ -5682,46 +6494,624 @@ export class WasmNodeMetadata {
|
|
|
5682
6494
|
}
|
|
5683
6495
|
}
|
|
5684
6496
|
|
|
5685
|
-
const
|
|
6497
|
+
const WasmOpticalCodebookFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5686
6498
|
? { register: () => {}, unregister: () => {} }
|
|
5687
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
6499
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmopticalcodebook_free(ptr >>> 0, 1));
|
|
5688
6500
|
/**
|
|
5689
|
-
* WASM wrapper for
|
|
6501
|
+
* WASM wrapper for OpticalCodebook.
|
|
6502
|
+
*
|
|
6503
|
+
* Maps symbols to deterministically-generated rotor fields.
|
|
5690
6504
|
*/
|
|
5691
|
-
export class
|
|
5692
|
-
|
|
5693
|
-
static __wrap(ptr) {
|
|
5694
|
-
ptr = ptr >>> 0;
|
|
5695
|
-
const obj = Object.create(WasmOptimizationResult.prototype);
|
|
5696
|
-
obj.__wbg_ptr = ptr;
|
|
5697
|
-
WasmOptimizationResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
5698
|
-
return obj;
|
|
5699
|
-
}
|
|
6505
|
+
export class WasmOpticalCodebook {
|
|
5700
6506
|
|
|
5701
6507
|
__destroy_into_raw() {
|
|
5702
6508
|
const ptr = this.__wbg_ptr;
|
|
5703
6509
|
this.__wbg_ptr = 0;
|
|
5704
|
-
|
|
6510
|
+
WasmOpticalCodebookFinalization.unregister(this);
|
|
5705
6511
|
return ptr;
|
|
5706
6512
|
}
|
|
5707
6513
|
|
|
5708
6514
|
free() {
|
|
5709
6515
|
const ptr = this.__destroy_into_raw();
|
|
5710
|
-
wasm.
|
|
6516
|
+
wasm.__wbg_wasmopticalcodebook_free(ptr, 0);
|
|
5711
6517
|
}
|
|
5712
6518
|
/**
|
|
5713
|
-
*
|
|
5714
|
-
* @returns {number}
|
|
6519
|
+
* Clear the field cache (seeds retained).
|
|
5715
6520
|
*/
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
return ret >>> 0;
|
|
6521
|
+
clearCache() {
|
|
6522
|
+
wasm.wasmopticalcodebook_clearCache(this.__wbg_ptr);
|
|
5719
6523
|
}
|
|
5720
6524
|
/**
|
|
5721
|
-
*
|
|
5722
|
-
* @
|
|
6525
|
+
* Register multiple symbols at once.
|
|
6526
|
+
* @param {string[]} symbols
|
|
5723
6527
|
*/
|
|
5724
|
-
|
|
6528
|
+
registerAll(symbols) {
|
|
6529
|
+
const ptr0 = passArrayJsValueToWasm0(symbols, wasm.__wbindgen_malloc);
|
|
6530
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6531
|
+
wasm.wasmopticalcodebook_registerAll(this.__wbg_ptr, ptr0, len0);
|
|
6532
|
+
}
|
|
6533
|
+
/**
|
|
6534
|
+
* Register a symbol with specific seed.
|
|
6535
|
+
* @param {string} symbol
|
|
6536
|
+
* @param {bigint} seed
|
|
6537
|
+
*/
|
|
6538
|
+
registerWithSeed(symbol, seed) {
|
|
6539
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6541
|
+
wasm.wasmopticalcodebook_registerWithSeed(this.__wbg_ptr, ptr0, len0, seed);
|
|
6542
|
+
}
|
|
6543
|
+
/**
|
|
6544
|
+
* Get or generate field for a symbol.
|
|
6545
|
+
* @param {string} symbol
|
|
6546
|
+
* @returns {WasmOpticalRotorField | undefined}
|
|
6547
|
+
*/
|
|
6548
|
+
get(symbol) {
|
|
6549
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6550
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6551
|
+
const ret = wasm.wasmopticalcodebook_get(this.__wbg_ptr, ptr0, len0);
|
|
6552
|
+
return ret === 0 ? undefined : WasmOpticalRotorField.__wrap(ret);
|
|
6553
|
+
}
|
|
6554
|
+
/**
|
|
6555
|
+
* Create a new codebook.
|
|
6556
|
+
*
|
|
6557
|
+
* # Arguments
|
|
6558
|
+
* * `width` - Field grid width
|
|
6559
|
+
* * `height` - Field grid height
|
|
6560
|
+
* * `base_seed` - Base seed for deterministic generation
|
|
6561
|
+
* @param {number} width
|
|
6562
|
+
* @param {number} height
|
|
6563
|
+
* @param {bigint} base_seed
|
|
6564
|
+
*/
|
|
6565
|
+
constructor(width, height, base_seed) {
|
|
6566
|
+
const ret = wasm.wasmopticalcodebook_new(width, height, base_seed);
|
|
6567
|
+
this.__wbg_ptr = ret >>> 0;
|
|
6568
|
+
WasmOpticalCodebookFinalization.register(this, this.__wbg_ptr, this);
|
|
6569
|
+
return this;
|
|
6570
|
+
}
|
|
6571
|
+
/**
|
|
6572
|
+
* Number of registered symbols.
|
|
6573
|
+
* @returns {number}
|
|
6574
|
+
*/
|
|
6575
|
+
get length() {
|
|
6576
|
+
const ret = wasm.wasmopticalcodebook_length(this.__wbg_ptr);
|
|
6577
|
+
return ret >>> 0;
|
|
6578
|
+
}
|
|
6579
|
+
/**
|
|
6580
|
+
* Remove a symbol from the codebook.
|
|
6581
|
+
* @param {string} symbol
|
|
6582
|
+
* @returns {boolean}
|
|
6583
|
+
*/
|
|
6584
|
+
remove(symbol) {
|
|
6585
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6587
|
+
const ret = wasm.wasmopticalcodebook_remove(this.__wbg_ptr, ptr0, len0);
|
|
6588
|
+
return ret !== 0;
|
|
6589
|
+
}
|
|
6590
|
+
/**
|
|
6591
|
+
* Get all registered symbol names.
|
|
6592
|
+
* @returns {string[]}
|
|
6593
|
+
*/
|
|
6594
|
+
symbols() {
|
|
6595
|
+
const ret = wasm.wasmopticalcodebook_symbols(this.__wbg_ptr);
|
|
6596
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
6597
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
6598
|
+
return v1;
|
|
6599
|
+
}
|
|
6600
|
+
/**
|
|
6601
|
+
* Check if a symbol is registered.
|
|
6602
|
+
* @param {string} symbol
|
|
6603
|
+
* @returns {boolean}
|
|
6604
|
+
*/
|
|
6605
|
+
contains(symbol) {
|
|
6606
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6607
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6608
|
+
const ret = wasm.wasmopticalcodebook_contains(this.__wbg_ptr, ptr0, len0);
|
|
6609
|
+
return ret !== 0;
|
|
6610
|
+
}
|
|
6611
|
+
/**
|
|
6612
|
+
* Generate field without caching.
|
|
6613
|
+
* @param {string} symbol
|
|
6614
|
+
* @returns {WasmOpticalRotorField | undefined}
|
|
6615
|
+
*/
|
|
6616
|
+
generate(symbol) {
|
|
6617
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6618
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6619
|
+
const ret = wasm.wasmopticalcodebook_generate(this.__wbg_ptr, ptr0, len0);
|
|
6620
|
+
return ret === 0 ? undefined : WasmOpticalRotorField.__wrap(ret);
|
|
6621
|
+
}
|
|
6622
|
+
/**
|
|
6623
|
+
* Get the seed for a registered symbol.
|
|
6624
|
+
* @param {string} symbol
|
|
6625
|
+
* @returns {bigint | undefined}
|
|
6626
|
+
*/
|
|
6627
|
+
getSeed(symbol) {
|
|
6628
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6629
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6630
|
+
const ret = wasm.wasmopticalcodebook_getSeed(this.__wbg_ptr, ptr0, len0);
|
|
6631
|
+
return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
|
|
6632
|
+
}
|
|
6633
|
+
/**
|
|
6634
|
+
* Check if codebook is empty.
|
|
6635
|
+
* @returns {boolean}
|
|
6636
|
+
*/
|
|
6637
|
+
isEmpty() {
|
|
6638
|
+
const ret = wasm.wasmopticalcodebook_isEmpty(this.__wbg_ptr);
|
|
6639
|
+
return ret !== 0;
|
|
6640
|
+
}
|
|
6641
|
+
/**
|
|
6642
|
+
* Register a symbol with auto-generated seed.
|
|
6643
|
+
* @param {string} symbol
|
|
6644
|
+
*/
|
|
6645
|
+
register(symbol) {
|
|
6646
|
+
const ptr0 = passStringToWasm0(symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6648
|
+
wasm.wasmopticalcodebook_register(this.__wbg_ptr, ptr0, len0);
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6651
|
+
|
|
6652
|
+
const WasmOpticalFieldAlgebraFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6653
|
+
? { register: () => {}, unregister: () => {} }
|
|
6654
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmopticalfieldalgebra_free(ptr >>> 0, 1));
|
|
6655
|
+
/**
|
|
6656
|
+
* WASM wrapper for OpticalFieldAlgebra.
|
|
6657
|
+
*
|
|
6658
|
+
* Provides VSA operations on rotor fields: bind, bundle, similarity, inverse.
|
|
6659
|
+
*/
|
|
6660
|
+
export class WasmOpticalFieldAlgebra {
|
|
6661
|
+
|
|
6662
|
+
__destroy_into_raw() {
|
|
6663
|
+
const ptr = this.__wbg_ptr;
|
|
6664
|
+
this.__wbg_ptr = 0;
|
|
6665
|
+
WasmOpticalFieldAlgebraFinalization.unregister(this);
|
|
6666
|
+
return ptr;
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
free() {
|
|
6670
|
+
const ptr = this.__destroy_into_raw();
|
|
6671
|
+
wasm.__wbg_wasmopticalfieldalgebra_free(ptr, 0);
|
|
6672
|
+
}
|
|
6673
|
+
/**
|
|
6674
|
+
* Compute the average phase (circular mean) of a field.
|
|
6675
|
+
* @param {WasmOpticalRotorField} field
|
|
6676
|
+
* @returns {number}
|
|
6677
|
+
*/
|
|
6678
|
+
meanPhase(field) {
|
|
6679
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
6680
|
+
const ret = wasm.wasmopticalfieldalgebra_meanPhase(this.__wbg_ptr, field.__wbg_ptr);
|
|
6681
|
+
return ret;
|
|
6682
|
+
}
|
|
6683
|
+
/**
|
|
6684
|
+
* Compute similarity between two fields.
|
|
6685
|
+
*
|
|
6686
|
+
* Returns normalized inner product.
|
|
6687
|
+
* Range: [-1, 1], where 1 = identical phase.
|
|
6688
|
+
* @param {WasmOpticalRotorField} a
|
|
6689
|
+
* @param {WasmOpticalRotorField} b
|
|
6690
|
+
* @returns {number}
|
|
6691
|
+
*/
|
|
6692
|
+
similarity(a, b) {
|
|
6693
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
6694
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
6695
|
+
const ret = wasm.wasmopticalfieldalgebra_similarity(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
6696
|
+
if (ret[2]) {
|
|
6697
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6698
|
+
}
|
|
6699
|
+
return ret[0];
|
|
6700
|
+
}
|
|
6701
|
+
/**
|
|
6702
|
+
* Bundle with uniform weights (1/n).
|
|
6703
|
+
* @param {WasmOpticalRotorField[]} fields
|
|
6704
|
+
* @returns {WasmOpticalRotorField}
|
|
6705
|
+
*/
|
|
6706
|
+
bundleUniform(fields) {
|
|
6707
|
+
const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
|
|
6708
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6709
|
+
const ret = wasm.wasmopticalfieldalgebra_bundleUniform(this.__wbg_ptr, ptr0, len0);
|
|
6710
|
+
if (ret[2]) {
|
|
6711
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6712
|
+
}
|
|
6713
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
6714
|
+
}
|
|
6715
|
+
/**
|
|
6716
|
+
* Compute phase variance (circular variance) of a field.
|
|
6717
|
+
* @param {WasmOpticalRotorField} field
|
|
6718
|
+
* @returns {number}
|
|
6719
|
+
*/
|
|
6720
|
+
phaseVariance(field) {
|
|
6721
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
6722
|
+
const ret = wasm.wasmopticalfieldalgebra_phaseVariance(this.__wbg_ptr, field.__wbg_ptr);
|
|
6723
|
+
return ret;
|
|
6724
|
+
}
|
|
6725
|
+
/**
|
|
6726
|
+
* Create new algebra instance for fields of the given dimensions.
|
|
6727
|
+
* @param {number} width
|
|
6728
|
+
* @param {number} height
|
|
6729
|
+
*/
|
|
6730
|
+
constructor(width, height) {
|
|
6731
|
+
const ret = wasm.wasmopticalfieldalgebra_new(width, height);
|
|
6732
|
+
this.__wbg_ptr = ret >>> 0;
|
|
6733
|
+
WasmOpticalFieldAlgebraFinalization.register(this, this.__wbg_ptr, this);
|
|
6734
|
+
return this;
|
|
6735
|
+
}
|
|
6736
|
+
/**
|
|
6737
|
+
* Bind two fields (pointwise rotor product).
|
|
6738
|
+
*
|
|
6739
|
+
* Creates an association: bound = A ⊗ B.
|
|
6740
|
+
* Unbind with: B ≈ inverse(A) ⊗ bound.
|
|
6741
|
+
* @param {WasmOpticalRotorField} a
|
|
6742
|
+
* @param {WasmOpticalRotorField} b
|
|
6743
|
+
* @returns {WasmOpticalRotorField}
|
|
6744
|
+
*/
|
|
6745
|
+
bind(a, b) {
|
|
6746
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
6747
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
6748
|
+
const ret = wasm.wasmopticalfieldalgebra_bind(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
6749
|
+
if (ret[2]) {
|
|
6750
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6751
|
+
}
|
|
6752
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
6753
|
+
}
|
|
6754
|
+
/**
|
|
6755
|
+
* Scale a field's amplitude by a constant factor.
|
|
6756
|
+
* @param {WasmOpticalRotorField} field
|
|
6757
|
+
* @param {number} factor
|
|
6758
|
+
* @returns {WasmOpticalRotorField}
|
|
6759
|
+
*/
|
|
6760
|
+
scale(field, factor) {
|
|
6761
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
6762
|
+
const ret = wasm.wasmopticalfieldalgebra_scale(this.__wbg_ptr, field.__wbg_ptr, factor);
|
|
6763
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6764
|
+
}
|
|
6765
|
+
/**
|
|
6766
|
+
* Get algebra width.
|
|
6767
|
+
* @returns {number}
|
|
6768
|
+
*/
|
|
6769
|
+
get width() {
|
|
6770
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
6771
|
+
return ret >>> 0;
|
|
6772
|
+
}
|
|
6773
|
+
/**
|
|
6774
|
+
* Bundle multiple fields (weighted superposition).
|
|
6775
|
+
*
|
|
6776
|
+
* # Arguments
|
|
6777
|
+
* * `fields` - Flattened array of field data (scalars, bivectors, amplitudes for each field)
|
|
6778
|
+
* * `weights` - Weights for each field
|
|
6779
|
+
* * `field_count` - Number of fields
|
|
6780
|
+
* @param {WasmOpticalRotorField[]} fields
|
|
6781
|
+
* @param {Float32Array} weights
|
|
6782
|
+
* @returns {WasmOpticalRotorField}
|
|
6783
|
+
*/
|
|
6784
|
+
bundle(fields, weights) {
|
|
6785
|
+
const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
|
|
6786
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6787
|
+
const ptr1 = passArrayF32ToWasm0(weights, wasm.__wbindgen_malloc);
|
|
6788
|
+
const len1 = WASM_VECTOR_LEN;
|
|
6789
|
+
const ret = wasm.wasmopticalfieldalgebra_bundle(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
6790
|
+
if (ret[2]) {
|
|
6791
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6792
|
+
}
|
|
6793
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
6794
|
+
}
|
|
6795
|
+
/**
|
|
6796
|
+
* Get algebra height.
|
|
6797
|
+
* @returns {number}
|
|
6798
|
+
*/
|
|
6799
|
+
get height() {
|
|
6800
|
+
const ret = wasm.wasmmodulispace_getMarkedPoints(this.__wbg_ptr);
|
|
6801
|
+
return ret >>> 0;
|
|
6802
|
+
}
|
|
6803
|
+
/**
|
|
6804
|
+
* Create random field.
|
|
6805
|
+
* @param {bigint} seed
|
|
6806
|
+
* @returns {WasmOpticalRotorField}
|
|
6807
|
+
*/
|
|
6808
|
+
random(seed) {
|
|
6809
|
+
const ret = wasm.wasmopticalfieldalgebra_random(this.__wbg_ptr, seed);
|
|
6810
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6811
|
+
}
|
|
6812
|
+
/**
|
|
6813
|
+
* Unbind operation: retrieve associated value.
|
|
6814
|
+
*
|
|
6815
|
+
* Given `bound = bind(key, value)`, calling `unbind(key, bound)`
|
|
6816
|
+
* returns (approximately) `value`.
|
|
6817
|
+
* @param {WasmOpticalRotorField} key
|
|
6818
|
+
* @param {WasmOpticalRotorField} bound
|
|
6819
|
+
* @returns {WasmOpticalRotorField}
|
|
6820
|
+
*/
|
|
6821
|
+
unbind(key, bound) {
|
|
6822
|
+
_assertClass(key, WasmOpticalRotorField);
|
|
6823
|
+
_assertClass(bound, WasmOpticalRotorField);
|
|
6824
|
+
const ret = wasm.wasmopticalfieldalgebra_unbind(this.__wbg_ptr, key.__wbg_ptr, bound.__wbg_ptr);
|
|
6825
|
+
if (ret[2]) {
|
|
6826
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6827
|
+
}
|
|
6828
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
6829
|
+
}
|
|
6830
|
+
/**
|
|
6831
|
+
* Compute inverse field (rotor reverse).
|
|
6832
|
+
*
|
|
6833
|
+
* For rotors: R^(-1) = R^† = cos(φ) - sin(φ)·e₁₂
|
|
6834
|
+
* @param {WasmOpticalRotorField} field
|
|
6835
|
+
* @returns {WasmOpticalRotorField}
|
|
6836
|
+
*/
|
|
6837
|
+
inverse(field) {
|
|
6838
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
6839
|
+
const ret = wasm.wasmopticalfieldalgebra_inverse(this.__wbg_ptr, field.__wbg_ptr);
|
|
6840
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6841
|
+
}
|
|
6842
|
+
/**
|
|
6843
|
+
* Create identity field (phase = 0, amplitude = 1).
|
|
6844
|
+
* @returns {WasmOpticalRotorField}
|
|
6845
|
+
*/
|
|
6846
|
+
identity() {
|
|
6847
|
+
const ret = wasm.wasmopticalfieldalgebra_identity(this.__wbg_ptr);
|
|
6848
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6849
|
+
}
|
|
6850
|
+
/**
|
|
6851
|
+
* Add a constant phase to all pixels.
|
|
6852
|
+
* @param {WasmOpticalRotorField} field
|
|
6853
|
+
* @param {number} phase
|
|
6854
|
+
* @returns {WasmOpticalRotorField}
|
|
6855
|
+
*/
|
|
6856
|
+
addPhase(field, phase) {
|
|
6857
|
+
_assertClass(field, WasmOpticalRotorField);
|
|
6858
|
+
const ret = wasm.wasmopticalfieldalgebra_addPhase(this.__wbg_ptr, field.__wbg_ptr, phase);
|
|
6859
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6860
|
+
}
|
|
6861
|
+
}
|
|
6862
|
+
|
|
6863
|
+
const WasmOpticalRotorFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6864
|
+
? { register: () => {}, unregister: () => {} }
|
|
6865
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmopticalrotorfield_free(ptr >>> 0, 1));
|
|
6866
|
+
/**
|
|
6867
|
+
* WASM wrapper for OpticalRotorField.
|
|
6868
|
+
*
|
|
6869
|
+
* Represents an optical wavefront as a grid of rotors in Cl(2,0).
|
|
6870
|
+
* Each point has phase (rotor angle) and amplitude components.
|
|
6871
|
+
*/
|
|
6872
|
+
export class WasmOpticalRotorField {
|
|
6873
|
+
|
|
6874
|
+
static __wrap(ptr) {
|
|
6875
|
+
ptr = ptr >>> 0;
|
|
6876
|
+
const obj = Object.create(WasmOpticalRotorField.prototype);
|
|
6877
|
+
obj.__wbg_ptr = ptr;
|
|
6878
|
+
WasmOpticalRotorFieldFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
6879
|
+
return obj;
|
|
6880
|
+
}
|
|
6881
|
+
|
|
6882
|
+
static __unwrap(jsValue) {
|
|
6883
|
+
if (!(jsValue instanceof WasmOpticalRotorField)) {
|
|
6884
|
+
return 0;
|
|
6885
|
+
}
|
|
6886
|
+
return jsValue.__destroy_into_raw();
|
|
6887
|
+
}
|
|
6888
|
+
|
|
6889
|
+
__destroy_into_raw() {
|
|
6890
|
+
const ptr = this.__wbg_ptr;
|
|
6891
|
+
this.__wbg_ptr = 0;
|
|
6892
|
+
WasmOpticalRotorFieldFinalization.unregister(this);
|
|
6893
|
+
return ptr;
|
|
6894
|
+
}
|
|
6895
|
+
|
|
6896
|
+
free() {
|
|
6897
|
+
const ptr = this.__destroy_into_raw();
|
|
6898
|
+
wasm.__wbg_wasmopticalrotorfield_free(ptr, 0);
|
|
6899
|
+
}
|
|
6900
|
+
/**
|
|
6901
|
+
* Create from phase array with uniform amplitude of 1.0.
|
|
6902
|
+
* @param {Float32Array} phase
|
|
6903
|
+
* @param {number} width
|
|
6904
|
+
* @param {number} height
|
|
6905
|
+
* @returns {WasmOpticalRotorField}
|
|
6906
|
+
*/
|
|
6907
|
+
static fromPhase(phase, width, height) {
|
|
6908
|
+
const ptr0 = passArrayF32ToWasm0(phase, wasm.__wbindgen_malloc);
|
|
6909
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6910
|
+
const ret = wasm.wasmopticalrotorfield_fromPhase(ptr0, len0, width, height);
|
|
6911
|
+
if (ret[2]) {
|
|
6912
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6913
|
+
}
|
|
6914
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
6915
|
+
}
|
|
6916
|
+
/**
|
|
6917
|
+
* Create a normalized copy (total energy = 1).
|
|
6918
|
+
* @returns {WasmOpticalRotorField}
|
|
6919
|
+
*/
|
|
6920
|
+
normalized() {
|
|
6921
|
+
const ret = wasm.wasmopticalrotorfield_normalized(this.__wbg_ptr);
|
|
6922
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6923
|
+
}
|
|
6924
|
+
/**
|
|
6925
|
+
* Clone this field.
|
|
6926
|
+
* @returns {WasmOpticalRotorField}
|
|
6927
|
+
*/
|
|
6928
|
+
clone() {
|
|
6929
|
+
const ret = wasm.wasmopticalrotorfield_clone(this.__wbg_ptr);
|
|
6930
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
6931
|
+
}
|
|
6932
|
+
/**
|
|
6933
|
+
* Get all scalar (cos φ) components.
|
|
6934
|
+
* @returns {Float32Array}
|
|
6935
|
+
*/
|
|
6936
|
+
getScalars() {
|
|
6937
|
+
const ret = wasm.wasmopticalrotorfield_getScalars(this.__wbg_ptr);
|
|
6938
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
6939
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
6940
|
+
return v1;
|
|
6941
|
+
}
|
|
6942
|
+
/**
|
|
6943
|
+
* Get amplitude at a point.
|
|
6944
|
+
* @param {number} x
|
|
6945
|
+
* @param {number} y
|
|
6946
|
+
* @returns {number}
|
|
6947
|
+
*/
|
|
6948
|
+
amplitudeAt(x, y) {
|
|
6949
|
+
const ret = wasm.wasmopticalrotorfield_amplitudeAt(this.__wbg_ptr, x, y);
|
|
6950
|
+
return ret;
|
|
6951
|
+
}
|
|
6952
|
+
/**
|
|
6953
|
+
* Compute total energy (sum of squared amplitudes).
|
|
6954
|
+
* @returns {number}
|
|
6955
|
+
*/
|
|
6956
|
+
totalEnergy() {
|
|
6957
|
+
const ret = wasm.wasmopticalrotorfield_totalEnergy(this.__wbg_ptr);
|
|
6958
|
+
return ret;
|
|
6959
|
+
}
|
|
6960
|
+
/**
|
|
6961
|
+
* Get all bivector (sin φ) components.
|
|
6962
|
+
* @returns {Float32Array}
|
|
6963
|
+
*/
|
|
6964
|
+
getBivectors() {
|
|
6965
|
+
const ret = wasm.wasmopticalrotorfield_getBivectors(this.__wbg_ptr);
|
|
6966
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
6967
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
6968
|
+
return v1;
|
|
6969
|
+
}
|
|
6970
|
+
/**
|
|
6971
|
+
* Get all amplitude components.
|
|
6972
|
+
* @returns {Float32Array}
|
|
6973
|
+
*/
|
|
6974
|
+
getAmplitudes() {
|
|
6975
|
+
const ret = wasm.wasmopticalrotorfield_getAmplitudes(this.__wbg_ptr);
|
|
6976
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
6977
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
6978
|
+
return v1;
|
|
6979
|
+
}
|
|
6980
|
+
/**
|
|
6981
|
+
* Create from phase and amplitude arrays.
|
|
6982
|
+
*
|
|
6983
|
+
* # Arguments
|
|
6984
|
+
* * `phase` - Phase values in radians (length = width * height)
|
|
6985
|
+
* * `amplitude` - Amplitude values (length = width * height)
|
|
6986
|
+
* * `width` - Grid width
|
|
6987
|
+
* * `height` - Grid height
|
|
6988
|
+
* @param {Float32Array} phase
|
|
6989
|
+
* @param {Float32Array} amplitude
|
|
6990
|
+
* @param {number} width
|
|
6991
|
+
* @param {number} height
|
|
6992
|
+
*/
|
|
6993
|
+
constructor(phase, amplitude, width, height) {
|
|
6994
|
+
const ptr0 = passArrayF32ToWasm0(phase, wasm.__wbindgen_malloc);
|
|
6995
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6996
|
+
const ptr1 = passArrayF32ToWasm0(amplitude, wasm.__wbindgen_malloc);
|
|
6997
|
+
const len1 = WASM_VECTOR_LEN;
|
|
6998
|
+
const ret = wasm.wasmopticalrotorfield_new(ptr0, len0, ptr1, len1, width, height);
|
|
6999
|
+
if (ret[2]) {
|
|
7000
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7001
|
+
}
|
|
7002
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
7003
|
+
WasmOpticalRotorFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
7004
|
+
return this;
|
|
7005
|
+
}
|
|
7006
|
+
/**
|
|
7007
|
+
* Get grid width.
|
|
7008
|
+
* @returns {number}
|
|
7009
|
+
*/
|
|
7010
|
+
get width() {
|
|
7011
|
+
const ret = wasm.wasmopticalrotorfield_width(this.__wbg_ptr);
|
|
7012
|
+
return ret >>> 0;
|
|
7013
|
+
}
|
|
7014
|
+
/**
|
|
7015
|
+
* Get grid height.
|
|
7016
|
+
* @returns {number}
|
|
7017
|
+
*/
|
|
7018
|
+
get height() {
|
|
7019
|
+
const ret = wasm.wasmopticalrotorfield_height(this.__wbg_ptr);
|
|
7020
|
+
return ret >>> 0;
|
|
7021
|
+
}
|
|
7022
|
+
/**
|
|
7023
|
+
* Get total number of points.
|
|
7024
|
+
* @returns {number}
|
|
7025
|
+
*/
|
|
7026
|
+
get length() {
|
|
7027
|
+
const ret = wasm.wasmopticalrotorfield_length(this.__wbg_ptr);
|
|
7028
|
+
return ret >>> 0;
|
|
7029
|
+
}
|
|
7030
|
+
/**
|
|
7031
|
+
* Create with random phase (deterministic from seed).
|
|
7032
|
+
* @param {number} width
|
|
7033
|
+
* @param {number} height
|
|
7034
|
+
* @param {bigint} seed
|
|
7035
|
+
* @returns {WasmOpticalRotorField}
|
|
7036
|
+
*/
|
|
7037
|
+
static random(width, height, seed) {
|
|
7038
|
+
const ret = wasm.wasmopticalrotorfield_random(width, height, seed);
|
|
7039
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
7040
|
+
}
|
|
7041
|
+
/**
|
|
7042
|
+
* Create uniform field (constant phase and amplitude).
|
|
7043
|
+
* @param {number} phase
|
|
7044
|
+
* @param {number} amplitude
|
|
7045
|
+
* @param {number} width
|
|
7046
|
+
* @param {number} height
|
|
7047
|
+
* @returns {WasmOpticalRotorField}
|
|
7048
|
+
*/
|
|
7049
|
+
static uniform(phase, amplitude, width, height) {
|
|
7050
|
+
const ret = wasm.wasmopticalrotorfield_uniform(phase, amplitude, width, height);
|
|
7051
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
7052
|
+
}
|
|
7053
|
+
/**
|
|
7054
|
+
* Create identity field (phase = 0, amplitude = 1).
|
|
7055
|
+
* @param {number} width
|
|
7056
|
+
* @param {number} height
|
|
7057
|
+
* @returns {WasmOpticalRotorField}
|
|
7058
|
+
*/
|
|
7059
|
+
static identity(width, height) {
|
|
7060
|
+
const ret = wasm.wasmopticalrotorfield_identity(width, height);
|
|
7061
|
+
return WasmOpticalRotorField.__wrap(ret);
|
|
7062
|
+
}
|
|
7063
|
+
/**
|
|
7064
|
+
* Get phase at a point (in radians, range [-π, π]).
|
|
7065
|
+
* @param {number} x
|
|
7066
|
+
* @param {number} y
|
|
7067
|
+
* @returns {number}
|
|
7068
|
+
*/
|
|
7069
|
+
phaseAt(x, y) {
|
|
7070
|
+
const ret = wasm.wasmopticalrotorfield_phaseAt(this.__wbg_ptr, x, y);
|
|
7071
|
+
return ret;
|
|
7072
|
+
}
|
|
7073
|
+
}
|
|
7074
|
+
|
|
7075
|
+
const WasmOptimizationResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7076
|
+
? { register: () => {}, unregister: () => {} }
|
|
7077
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmoptimizationresult_free(ptr >>> 0, 1));
|
|
7078
|
+
/**
|
|
7079
|
+
* WASM wrapper for optimization results
|
|
7080
|
+
*/
|
|
7081
|
+
export class WasmOptimizationResult {
|
|
7082
|
+
|
|
7083
|
+
static __wrap(ptr) {
|
|
7084
|
+
ptr = ptr >>> 0;
|
|
7085
|
+
const obj = Object.create(WasmOptimizationResult.prototype);
|
|
7086
|
+
obj.__wbg_ptr = ptr;
|
|
7087
|
+
WasmOptimizationResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7088
|
+
return obj;
|
|
7089
|
+
}
|
|
7090
|
+
|
|
7091
|
+
__destroy_into_raw() {
|
|
7092
|
+
const ptr = this.__wbg_ptr;
|
|
7093
|
+
this.__wbg_ptr = 0;
|
|
7094
|
+
WasmOptimizationResultFinalization.unregister(this);
|
|
7095
|
+
return ptr;
|
|
7096
|
+
}
|
|
7097
|
+
|
|
7098
|
+
free() {
|
|
7099
|
+
const ptr = this.__destroy_into_raw();
|
|
7100
|
+
wasm.__wbg_wasmoptimizationresult_free(ptr, 0);
|
|
7101
|
+
}
|
|
7102
|
+
/**
|
|
7103
|
+
* Get number of iterations
|
|
7104
|
+
* @returns {number}
|
|
7105
|
+
*/
|
|
7106
|
+
get iterations() {
|
|
7107
|
+
const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
|
|
7108
|
+
return ret >>> 0;
|
|
7109
|
+
}
|
|
7110
|
+
/**
|
|
7111
|
+
* Get final objective value
|
|
7112
|
+
* @returns {number}
|
|
7113
|
+
*/
|
|
7114
|
+
get objective_value() {
|
|
5725
7115
|
const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
|
|
5726
7116
|
return ret;
|
|
5727
7117
|
}
|
|
@@ -6666,67 +8056,223 @@ export class WasmSensitivityMap {
|
|
|
6666
8056
|
* Get all sensitivities as JavaScript arrays
|
|
6667
8057
|
* @returns {any}
|
|
6668
8058
|
*/
|
|
6669
|
-
getAllSensitivities() {
|
|
6670
|
-
const ret = wasm.wasmsensitivitymap_getAllSensitivities(this.__wbg_ptr);
|
|
8059
|
+
getAllSensitivities() {
|
|
8060
|
+
const ret = wasm.wasmsensitivitymap_getAllSensitivities(this.__wbg_ptr);
|
|
8061
|
+
if (ret[2]) {
|
|
8062
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8063
|
+
}
|
|
8064
|
+
return takeFromExternrefTable0(ret[0]);
|
|
8065
|
+
}
|
|
8066
|
+
/**
|
|
8067
|
+
* Get total sensitivity across all components
|
|
8068
|
+
* @returns {number}
|
|
8069
|
+
*/
|
|
8070
|
+
getTotalSensitivity() {
|
|
8071
|
+
const ret = wasm.wasmsensitivitymap_getTotalSensitivity(this.__wbg_ptr);
|
|
8072
|
+
return ret;
|
|
8073
|
+
}
|
|
8074
|
+
}
|
|
8075
|
+
|
|
8076
|
+
const WasmSimpleOptimizerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
8077
|
+
? { register: () => {}, unregister: () => {} }
|
|
8078
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsimpleoptimizer_free(ptr >>> 0, 1));
|
|
8079
|
+
/**
|
|
8080
|
+
* Simple quadratic optimization problem for WASM demonstration
|
|
8081
|
+
*/
|
|
8082
|
+
export class WasmSimpleOptimizer {
|
|
8083
|
+
|
|
8084
|
+
__destroy_into_raw() {
|
|
8085
|
+
const ptr = this.__wbg_ptr;
|
|
8086
|
+
this.__wbg_ptr = 0;
|
|
8087
|
+
WasmSimpleOptimizerFinalization.unregister(this);
|
|
8088
|
+
return ptr;
|
|
8089
|
+
}
|
|
8090
|
+
|
|
8091
|
+
free() {
|
|
8092
|
+
const ptr = this.__destroy_into_raw();
|
|
8093
|
+
wasm.__wbg_wasmsimpleoptimizer_free(ptr, 0);
|
|
8094
|
+
}
|
|
8095
|
+
/**
|
|
8096
|
+
* Optimize a simple quadratic function: minimize sum(c_i * x_i^2)
|
|
8097
|
+
* @param {Float64Array} coefficients
|
|
8098
|
+
* @param {Float64Array} initial_point
|
|
8099
|
+
* @returns {WasmOptimizationResult}
|
|
8100
|
+
*/
|
|
8101
|
+
optimizeQuadratic(coefficients, initial_point) {
|
|
8102
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
8103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8104
|
+
const ptr1 = passArrayF64ToWasm0(initial_point, wasm.__wbindgen_malloc);
|
|
8105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
8106
|
+
const ret = wasm.wasmsimpleoptimizer_optimizeQuadratic(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
8107
|
+
if (ret[2]) {
|
|
8108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8109
|
+
}
|
|
8110
|
+
return WasmOptimizationResult.__wrap(ret[0]);
|
|
8111
|
+
}
|
|
8112
|
+
/**
|
|
8113
|
+
* Create a new simple optimizer
|
|
8114
|
+
*/
|
|
8115
|
+
constructor() {
|
|
8116
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
8117
|
+
this.__wbg_ptr = ret >>> 0;
|
|
8118
|
+
WasmSimpleOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
8119
|
+
return this;
|
|
8120
|
+
}
|
|
8121
|
+
}
|
|
8122
|
+
|
|
8123
|
+
const WasmSobolevSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
8124
|
+
? { register: () => {}, unregister: () => {} }
|
|
8125
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsobolevspace_free(ptr >>> 0, 1));
|
|
8126
|
+
/**
|
|
8127
|
+
* WASM wrapper for Sobolev spaces H^k
|
|
8128
|
+
*
|
|
8129
|
+
* Provides function spaces with weak derivatives.
|
|
8130
|
+
*/
|
|
8131
|
+
export class WasmSobolevSpace {
|
|
8132
|
+
|
|
8133
|
+
static __wrap(ptr) {
|
|
8134
|
+
ptr = ptr >>> 0;
|
|
8135
|
+
const obj = Object.create(WasmSobolevSpace.prototype);
|
|
8136
|
+
obj.__wbg_ptr = ptr;
|
|
8137
|
+
WasmSobolevSpaceFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8138
|
+
return obj;
|
|
8139
|
+
}
|
|
8140
|
+
|
|
8141
|
+
__destroy_into_raw() {
|
|
8142
|
+
const ptr = this.__wbg_ptr;
|
|
8143
|
+
this.__wbg_ptr = 0;
|
|
8144
|
+
WasmSobolevSpaceFinalization.unregister(this);
|
|
8145
|
+
return ptr;
|
|
8146
|
+
}
|
|
8147
|
+
|
|
8148
|
+
free() {
|
|
8149
|
+
const ptr = this.__destroy_into_raw();
|
|
8150
|
+
wasm.__wbg_wasmsobolevspace_free(ptr, 0);
|
|
8151
|
+
}
|
|
8152
|
+
/**
|
|
8153
|
+
* Compute the H^1 seminorm |f|_{H^1} = ||f'||_{L^2}
|
|
8154
|
+
* @param {Function} df
|
|
8155
|
+
* @returns {number}
|
|
8156
|
+
*/
|
|
8157
|
+
h1Seminorm(df) {
|
|
8158
|
+
const ret = wasm.wasmsobolevspace_h1Seminorm(this.__wbg_ptr, df);
|
|
8159
|
+
if (ret[2]) {
|
|
8160
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8161
|
+
}
|
|
8162
|
+
return ret[0];
|
|
8163
|
+
}
|
|
8164
|
+
/**
|
|
8165
|
+
* Create H^1 over the unit interval [0, 1]
|
|
8166
|
+
* @returns {WasmSobolevSpace}
|
|
8167
|
+
*/
|
|
8168
|
+
static h1UnitInterval() {
|
|
8169
|
+
const ret = wasm.wasmsobolevspace_h1UnitInterval();
|
|
8170
|
+
return WasmSobolevSpace.__wrap(ret);
|
|
8171
|
+
}
|
|
8172
|
+
/**
|
|
8173
|
+
* Create H^2 over the unit interval [0, 1]
|
|
8174
|
+
* @returns {WasmSobolevSpace}
|
|
8175
|
+
*/
|
|
8176
|
+
static h2UnitInterval() {
|
|
8177
|
+
const ret = wasm.wasmsobolevspace_h2UnitInterval();
|
|
8178
|
+
return WasmSobolevSpace.__wrap(ret);
|
|
8179
|
+
}
|
|
8180
|
+
/**
|
|
8181
|
+
* Compute L^2 inner product <f, g>
|
|
8182
|
+
* @param {Function} f
|
|
8183
|
+
* @param {Function} g
|
|
8184
|
+
* @returns {number}
|
|
8185
|
+
*/
|
|
8186
|
+
l2InnerProduct(f, g) {
|
|
8187
|
+
const ret = wasm.wasmsobolevspace_l2InnerProduct(this.__wbg_ptr, f, g);
|
|
8188
|
+
if (ret[2]) {
|
|
8189
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8190
|
+
}
|
|
8191
|
+
return ret[0];
|
|
8192
|
+
}
|
|
8193
|
+
/**
|
|
8194
|
+
* Compute the Poincare constant estimate for the domain
|
|
8195
|
+
*
|
|
8196
|
+
* For [a,b], this is (b-a)/π
|
|
8197
|
+
* @returns {number}
|
|
8198
|
+
*/
|
|
8199
|
+
poincareConstant() {
|
|
8200
|
+
const ret = wasm.wasmsobolevspace_poincareConstant(this.__wbg_ptr);
|
|
8201
|
+
return ret;
|
|
8202
|
+
}
|
|
8203
|
+
/**
|
|
8204
|
+
* Set the number of quadrature points
|
|
8205
|
+
* @param {number} n
|
|
8206
|
+
*/
|
|
8207
|
+
setQuadraturePoints(n) {
|
|
8208
|
+
wasm.wasmsobolevspace_setQuadraturePoints(this.__wbg_ptr, n);
|
|
8209
|
+
}
|
|
8210
|
+
/**
|
|
8211
|
+
* Create a Sobolev space H^k over an interval [a, b]
|
|
8212
|
+
*
|
|
8213
|
+
* # Arguments
|
|
8214
|
+
* * `order` - The Sobolev regularity (1 for H^1, 2 for H^2)
|
|
8215
|
+
* * `lower` - Lower bound of the interval
|
|
8216
|
+
* * `upper` - Upper bound of the interval
|
|
8217
|
+
* @param {number} order
|
|
8218
|
+
* @param {number} lower
|
|
8219
|
+
* @param {number} upper
|
|
8220
|
+
*/
|
|
8221
|
+
constructor(order, lower, upper) {
|
|
8222
|
+
const ret = wasm.wasmsobolevspace_new(order, lower, upper);
|
|
8223
|
+
if (ret[2]) {
|
|
8224
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8225
|
+
}
|
|
8226
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
8227
|
+
WasmSobolevSpaceFinalization.register(this, this.__wbg_ptr, this);
|
|
8228
|
+
return this;
|
|
8229
|
+
}
|
|
8230
|
+
/**
|
|
8231
|
+
* Get the domain bounds [lower, upper]
|
|
8232
|
+
* @returns {Float64Array}
|
|
8233
|
+
*/
|
|
8234
|
+
bounds() {
|
|
8235
|
+
const ret = wasm.wasmsobolevspace_bounds(this.__wbg_ptr);
|
|
8236
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8237
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8238
|
+
return v1;
|
|
8239
|
+
}
|
|
8240
|
+
/**
|
|
8241
|
+
* Compute the H^k norm of a function using numerical integration
|
|
8242
|
+
*
|
|
8243
|
+
* # Arguments
|
|
8244
|
+
* * `f` - JavaScript function f(x) to evaluate
|
|
8245
|
+
* * `df` - JavaScript function f'(x) (first derivative)
|
|
8246
|
+
* @param {Function} f
|
|
8247
|
+
* @param {Function} df
|
|
8248
|
+
* @returns {number}
|
|
8249
|
+
*/
|
|
8250
|
+
h1Norm(f, df) {
|
|
8251
|
+
const ret = wasm.wasmsobolevspace_h1Norm(this.__wbg_ptr, f, df);
|
|
6671
8252
|
if (ret[2]) {
|
|
6672
8253
|
throw takeFromExternrefTable0(ret[1]);
|
|
6673
8254
|
}
|
|
6674
|
-
return
|
|
8255
|
+
return ret[0];
|
|
6675
8256
|
}
|
|
6676
8257
|
/**
|
|
6677
|
-
*
|
|
8258
|
+
* Compute L^2 norm of a function
|
|
8259
|
+
* @param {Function} f
|
|
6678
8260
|
* @returns {number}
|
|
6679
8261
|
*/
|
|
6680
|
-
|
|
6681
|
-
const ret = wasm.
|
|
6682
|
-
return ret;
|
|
6683
|
-
}
|
|
6684
|
-
}
|
|
6685
|
-
|
|
6686
|
-
const WasmSimpleOptimizerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6687
|
-
? { register: () => {}, unregister: () => {} }
|
|
6688
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsimpleoptimizer_free(ptr >>> 0, 1));
|
|
6689
|
-
/**
|
|
6690
|
-
* Simple quadratic optimization problem for WASM demonstration
|
|
6691
|
-
*/
|
|
6692
|
-
export class WasmSimpleOptimizer {
|
|
6693
|
-
|
|
6694
|
-
__destroy_into_raw() {
|
|
6695
|
-
const ptr = this.__wbg_ptr;
|
|
6696
|
-
this.__wbg_ptr = 0;
|
|
6697
|
-
WasmSimpleOptimizerFinalization.unregister(this);
|
|
6698
|
-
return ptr;
|
|
6699
|
-
}
|
|
6700
|
-
|
|
6701
|
-
free() {
|
|
6702
|
-
const ptr = this.__destroy_into_raw();
|
|
6703
|
-
wasm.__wbg_wasmsimpleoptimizer_free(ptr, 0);
|
|
6704
|
-
}
|
|
6705
|
-
/**
|
|
6706
|
-
* Optimize a simple quadratic function: minimize sum(c_i * x_i^2)
|
|
6707
|
-
* @param {Float64Array} coefficients
|
|
6708
|
-
* @param {Float64Array} initial_point
|
|
6709
|
-
* @returns {WasmOptimizationResult}
|
|
6710
|
-
*/
|
|
6711
|
-
optimizeQuadratic(coefficients, initial_point) {
|
|
6712
|
-
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
6713
|
-
const len0 = WASM_VECTOR_LEN;
|
|
6714
|
-
const ptr1 = passArrayF64ToWasm0(initial_point, wasm.__wbindgen_malloc);
|
|
6715
|
-
const len1 = WASM_VECTOR_LEN;
|
|
6716
|
-
const ret = wasm.wasmsimpleoptimizer_optimizeQuadratic(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
8262
|
+
l2Norm(f) {
|
|
8263
|
+
const ret = wasm.wasmsobolevspace_l2Norm(this.__wbg_ptr, f);
|
|
6717
8264
|
if (ret[2]) {
|
|
6718
8265
|
throw takeFromExternrefTable0(ret[1]);
|
|
6719
8266
|
}
|
|
6720
|
-
return
|
|
8267
|
+
return ret[0];
|
|
6721
8268
|
}
|
|
6722
8269
|
/**
|
|
6723
|
-
*
|
|
8270
|
+
* Get the Sobolev order k
|
|
8271
|
+
* @returns {number}
|
|
6724
8272
|
*/
|
|
6725
|
-
|
|
6726
|
-
const ret = wasm.
|
|
6727
|
-
|
|
6728
|
-
WasmSimpleOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
6729
|
-
return this;
|
|
8273
|
+
order() {
|
|
8274
|
+
const ret = wasm.wasmsobolevspace_order(this.__wbg_ptr);
|
|
8275
|
+
return ret >>> 0;
|
|
6730
8276
|
}
|
|
6731
8277
|
}
|
|
6732
8278
|
|
|
@@ -6882,6 +8428,156 @@ export class WasmSpacetimeVector {
|
|
|
6882
8428
|
}
|
|
6883
8429
|
}
|
|
6884
8430
|
|
|
8431
|
+
const WasmSpectralDecompositionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
8432
|
+
? { register: () => {}, unregister: () => {} }
|
|
8433
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmspectraldecomposition_free(ptr >>> 0, 1));
|
|
8434
|
+
/**
|
|
8435
|
+
* WASM wrapper for spectral decomposition
|
|
8436
|
+
*
|
|
8437
|
+
* Provides eigenvalue decomposition for symmetric matrices.
|
|
8438
|
+
*/
|
|
8439
|
+
export class WasmSpectralDecomposition {
|
|
8440
|
+
|
|
8441
|
+
static __wrap(ptr) {
|
|
8442
|
+
ptr = ptr >>> 0;
|
|
8443
|
+
const obj = Object.create(WasmSpectralDecomposition.prototype);
|
|
8444
|
+
obj.__wbg_ptr = ptr;
|
|
8445
|
+
WasmSpectralDecompositionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8446
|
+
return obj;
|
|
8447
|
+
}
|
|
8448
|
+
|
|
8449
|
+
__destroy_into_raw() {
|
|
8450
|
+
const ptr = this.__wbg_ptr;
|
|
8451
|
+
this.__wbg_ptr = 0;
|
|
8452
|
+
WasmSpectralDecompositionFinalization.unregister(this);
|
|
8453
|
+
return ptr;
|
|
8454
|
+
}
|
|
8455
|
+
|
|
8456
|
+
free() {
|
|
8457
|
+
const ptr = this.__destroy_into_raw();
|
|
8458
|
+
wasm.__wbg_wasmspectraldecomposition_free(ptr, 0);
|
|
8459
|
+
}
|
|
8460
|
+
/**
|
|
8461
|
+
* Get the eigenvalues
|
|
8462
|
+
* @returns {Float64Array}
|
|
8463
|
+
*/
|
|
8464
|
+
eigenvalues() {
|
|
8465
|
+
const ret = wasm.wasmspectraldecomposition_eigenvalues(this.__wbg_ptr);
|
|
8466
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8467
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8468
|
+
return v1;
|
|
8469
|
+
}
|
|
8470
|
+
/**
|
|
8471
|
+
* Check if the decomposition is complete
|
|
8472
|
+
* @returns {boolean}
|
|
8473
|
+
*/
|
|
8474
|
+
isComplete() {
|
|
8475
|
+
const ret = wasm.wasmspectraldecomposition_isComplete(this.__wbg_ptr);
|
|
8476
|
+
return ret !== 0;
|
|
8477
|
+
}
|
|
8478
|
+
/**
|
|
8479
|
+
* Get the eigenvectors as a flattened array
|
|
8480
|
+
*
|
|
8481
|
+
* Returns 4 eigenvectors of 4 components each (16 total)
|
|
8482
|
+
* @returns {Float64Array}
|
|
8483
|
+
*/
|
|
8484
|
+
eigenvectors() {
|
|
8485
|
+
const ret = wasm.wasmspectraldecomposition_eigenvectors(this.__wbg_ptr);
|
|
8486
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8487
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8488
|
+
return v1;
|
|
8489
|
+
}
|
|
8490
|
+
/**
|
|
8491
|
+
* Apply f(T) = Σᵢ f(λᵢ) Pᵢ to a vector using functional calculus
|
|
8492
|
+
*
|
|
8493
|
+
* # Arguments
|
|
8494
|
+
* * `f` - JavaScript function to apply to eigenvalues
|
|
8495
|
+
* * `x` - Input vector
|
|
8496
|
+
* @param {Function} f
|
|
8497
|
+
* @param {Float64Array} x
|
|
8498
|
+
* @returns {Float64Array}
|
|
8499
|
+
*/
|
|
8500
|
+
applyFunction(f, x) {
|
|
8501
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
8502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8503
|
+
const ret = wasm.wasmspectraldecomposition_applyFunction(this.__wbg_ptr, f, ptr0, len0);
|
|
8504
|
+
if (ret[3]) {
|
|
8505
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
8506
|
+
}
|
|
8507
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8508
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8509
|
+
return v2;
|
|
8510
|
+
}
|
|
8511
|
+
/**
|
|
8512
|
+
* Get the spectral radius (largest |eigenvalue|)
|
|
8513
|
+
* @returns {number}
|
|
8514
|
+
*/
|
|
8515
|
+
spectralRadius() {
|
|
8516
|
+
const ret = wasm.wasmspectraldecomposition_spectralRadius(this.__wbg_ptr);
|
|
8517
|
+
return ret;
|
|
8518
|
+
}
|
|
8519
|
+
/**
|
|
8520
|
+
* Get the condition number
|
|
8521
|
+
* @returns {number | undefined}
|
|
8522
|
+
*/
|
|
8523
|
+
conditionNumber() {
|
|
8524
|
+
const ret = wasm.wasmspectraldecomposition_conditionNumber(this.__wbg_ptr);
|
|
8525
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
8526
|
+
}
|
|
8527
|
+
/**
|
|
8528
|
+
* Check if the operator is positive definite
|
|
8529
|
+
* @returns {boolean}
|
|
8530
|
+
*/
|
|
8531
|
+
isPositiveDefinite() {
|
|
8532
|
+
const ret = wasm.wasmspectraldecomposition_isPositiveDefinite(this.__wbg_ptr);
|
|
8533
|
+
return ret !== 0;
|
|
8534
|
+
}
|
|
8535
|
+
/**
|
|
8536
|
+
* Check if the operator is positive semi-definite
|
|
8537
|
+
* @returns {boolean}
|
|
8538
|
+
*/
|
|
8539
|
+
isPositiveSemidefinite() {
|
|
8540
|
+
const ret = wasm.wasmspectraldecomposition_isPositiveSemidefinite(this.__wbg_ptr);
|
|
8541
|
+
return ret !== 0;
|
|
8542
|
+
}
|
|
8543
|
+
/**
|
|
8544
|
+
* Apply the reconstructed operator T = Σᵢ λᵢ Pᵢ to a vector
|
|
8545
|
+
* @param {Float64Array} x
|
|
8546
|
+
* @returns {Float64Array}
|
|
8547
|
+
*/
|
|
8548
|
+
apply(x) {
|
|
8549
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
8550
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8551
|
+
const ret = wasm.wasmspectraldecomposition_apply(this.__wbg_ptr, ptr0, len0);
|
|
8552
|
+
if (ret[3]) {
|
|
8553
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
8554
|
+
}
|
|
8555
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8556
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8557
|
+
return v2;
|
|
8558
|
+
}
|
|
8559
|
+
/**
|
|
8560
|
+
* Compute spectral decomposition of a symmetric matrix
|
|
8561
|
+
*
|
|
8562
|
+
* # Arguments
|
|
8563
|
+
* * `matrix` - The symmetric matrix operator to decompose
|
|
8564
|
+
* * `max_iterations` - Maximum iterations for eigenvalue computation
|
|
8565
|
+
* * `tolerance` - Convergence tolerance
|
|
8566
|
+
* @param {WasmMatrixOperator} matrix
|
|
8567
|
+
* @param {number} max_iterations
|
|
8568
|
+
* @param {number} tolerance
|
|
8569
|
+
* @returns {WasmSpectralDecomposition}
|
|
8570
|
+
*/
|
|
8571
|
+
static compute(matrix, max_iterations, tolerance) {
|
|
8572
|
+
_assertClass(matrix, WasmMatrixOperator);
|
|
8573
|
+
const ret = wasm.wasmspectraldecomposition_compute(matrix.__wbg_ptr, max_iterations, tolerance);
|
|
8574
|
+
if (ret[2]) {
|
|
8575
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8576
|
+
}
|
|
8577
|
+
return WasmSpectralDecomposition.__wrap(ret[0]);
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
|
|
6885
8581
|
const WasmTrajectoryPointFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6886
8582
|
? { register: () => {}, unregister: () => {} }
|
|
6887
8583
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtrajectorypoint_free(ptr >>> 0, 1));
|
|
@@ -7488,7 +9184,7 @@ export class WasmTropicalNetwork {
|
|
|
7488
9184
|
* @returns {number}
|
|
7489
9185
|
*/
|
|
7490
9186
|
getSize() {
|
|
7491
|
-
const ret = wasm.
|
|
9187
|
+
const ret = wasm.wasmbinaryhologram_width(this.__wbg_ptr);
|
|
7492
9188
|
return ret >>> 0;
|
|
7493
9189
|
}
|
|
7494
9190
|
/**
|
|
@@ -7674,6 +9370,181 @@ export class WasmTropicalNumber {
|
|
|
7674
9370
|
}
|
|
7675
9371
|
}
|
|
7676
9372
|
|
|
9373
|
+
const WasmTropicalOpticalAlgebraFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
9374
|
+
? { register: () => {}, unregister: () => {} }
|
|
9375
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalopticalalgebra_free(ptr >>> 0, 1));
|
|
9376
|
+
/**
|
|
9377
|
+
* WASM wrapper for TropicalOpticalAlgebra.
|
|
9378
|
+
*
|
|
9379
|
+
* Tropical (min, +) operations on optical fields for attractor dynamics.
|
|
9380
|
+
*/
|
|
9381
|
+
export class WasmTropicalOpticalAlgebra {
|
|
9382
|
+
|
|
9383
|
+
__destroy_into_raw() {
|
|
9384
|
+
const ptr = this.__wbg_ptr;
|
|
9385
|
+
this.__wbg_ptr = 0;
|
|
9386
|
+
WasmTropicalOpticalAlgebraFinalization.unregister(this);
|
|
9387
|
+
return ptr;
|
|
9388
|
+
}
|
|
9389
|
+
|
|
9390
|
+
free() {
|
|
9391
|
+
const ptr = this.__destroy_into_raw();
|
|
9392
|
+
wasm.__wbg_wasmtropicalopticalalgebra_free(ptr, 0);
|
|
9393
|
+
}
|
|
9394
|
+
/**
|
|
9395
|
+
* Tropical addition: pointwise minimum of phase magnitudes.
|
|
9396
|
+
*
|
|
9397
|
+
* For each pixel, selects the rotor with smaller absolute phase.
|
|
9398
|
+
* @param {WasmOpticalRotorField} a
|
|
9399
|
+
* @param {WasmOpticalRotorField} b
|
|
9400
|
+
* @returns {WasmOpticalRotorField}
|
|
9401
|
+
*/
|
|
9402
|
+
tropicalAdd(a, b) {
|
|
9403
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9404
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9405
|
+
const ret = wasm.wasmtropicalopticalalgebra_tropicalAdd(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
9406
|
+
if (ret[2]) {
|
|
9407
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9408
|
+
}
|
|
9409
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
9410
|
+
}
|
|
9411
|
+
/**
|
|
9412
|
+
* Tropical maximum: pointwise maximum of phase magnitudes.
|
|
9413
|
+
* @param {WasmOpticalRotorField} a
|
|
9414
|
+
* @param {WasmOpticalRotorField} b
|
|
9415
|
+
* @returns {WasmOpticalRotorField}
|
|
9416
|
+
*/
|
|
9417
|
+
tropicalMax(a, b) {
|
|
9418
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9419
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9420
|
+
const ret = wasm.wasmtropicalopticalalgebra_tropicalMax(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
9421
|
+
if (ret[2]) {
|
|
9422
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9423
|
+
}
|
|
9424
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
9425
|
+
}
|
|
9426
|
+
/**
|
|
9427
|
+
* Tropical multiplication: binding operation (phase addition).
|
|
9428
|
+
* @param {WasmOpticalRotorField} a
|
|
9429
|
+
* @param {WasmOpticalRotorField} b
|
|
9430
|
+
* @returns {WasmOpticalRotorField}
|
|
9431
|
+
*/
|
|
9432
|
+
tropicalMul(a, b) {
|
|
9433
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9434
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9435
|
+
const ret = wasm.wasmtropicalopticalalgebra_tropicalMul(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
9436
|
+
if (ret[2]) {
|
|
9437
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9438
|
+
}
|
|
9439
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
9440
|
+
}
|
|
9441
|
+
/**
|
|
9442
|
+
* Compute phase distance between two fields.
|
|
9443
|
+
*
|
|
9444
|
+
* Returns the sum of absolute phase differences.
|
|
9445
|
+
* @param {WasmOpticalRotorField} a
|
|
9446
|
+
* @param {WasmOpticalRotorField} b
|
|
9447
|
+
* @returns {number}
|
|
9448
|
+
*/
|
|
9449
|
+
phaseDistance(a, b) {
|
|
9450
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9451
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9452
|
+
const ret = wasm.wasmtropicalopticalalgebra_phaseDistance(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
9453
|
+
if (ret[2]) {
|
|
9454
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9455
|
+
}
|
|
9456
|
+
return ret[0];
|
|
9457
|
+
}
|
|
9458
|
+
/**
|
|
9459
|
+
* Soft tropical addition using logsumexp-style smoothing.
|
|
9460
|
+
*
|
|
9461
|
+
* # Arguments
|
|
9462
|
+
* * `a`, `b` - Fields to combine
|
|
9463
|
+
* * `beta` - Temperature parameter (large = hard min, small = soft average)
|
|
9464
|
+
* @param {WasmOpticalRotorField} a
|
|
9465
|
+
* @param {WasmOpticalRotorField} b
|
|
9466
|
+
* @param {number} beta
|
|
9467
|
+
* @returns {WasmOpticalRotorField}
|
|
9468
|
+
*/
|
|
9469
|
+
softTropicalAdd(a, b, beta) {
|
|
9470
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9471
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9472
|
+
const ret = wasm.wasmtropicalopticalalgebra_softTropicalAdd(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr, beta);
|
|
9473
|
+
if (ret[2]) {
|
|
9474
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9475
|
+
}
|
|
9476
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
9477
|
+
}
|
|
9478
|
+
/**
|
|
9479
|
+
* Iterate attractor dynamics until convergence.
|
|
9480
|
+
*
|
|
9481
|
+
* # Arguments
|
|
9482
|
+
* * `initial` - Starting state
|
|
9483
|
+
* * `attractors` - Set of attractor fields
|
|
9484
|
+
* * `max_iterations` - Maximum iterations
|
|
9485
|
+
* * `tolerance` - Convergence tolerance
|
|
9486
|
+
*
|
|
9487
|
+
* Returns (final_state, iterations_taken).
|
|
9488
|
+
* @param {WasmOpticalRotorField} initial
|
|
9489
|
+
* @param {WasmOpticalRotorField[]} attractors
|
|
9490
|
+
* @param {number} max_iterations
|
|
9491
|
+
* @param {number} tolerance
|
|
9492
|
+
* @returns {WasmOpticalRotorField}
|
|
9493
|
+
*/
|
|
9494
|
+
attractorConverge(initial, attractors, max_iterations, tolerance) {
|
|
9495
|
+
_assertClass(initial, WasmOpticalRotorField);
|
|
9496
|
+
const ptr0 = passArrayJsValueToWasm0(attractors, wasm.__wbindgen_malloc);
|
|
9497
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9498
|
+
const ret = wasm.wasmtropicalopticalalgebra_attractorConverge(this.__wbg_ptr, initial.__wbg_ptr, ptr0, len0, max_iterations, tolerance);
|
|
9499
|
+
if (ret[2]) {
|
|
9500
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9501
|
+
}
|
|
9502
|
+
return WasmOpticalRotorField.__wrap(ret[0]);
|
|
9503
|
+
}
|
|
9504
|
+
/**
|
|
9505
|
+
* Compute normalized phase distance (average per pixel).
|
|
9506
|
+
* @param {WasmOpticalRotorField} a
|
|
9507
|
+
* @param {WasmOpticalRotorField} b
|
|
9508
|
+
* @returns {number}
|
|
9509
|
+
*/
|
|
9510
|
+
normalizedPhaseDistance(a, b) {
|
|
9511
|
+
_assertClass(a, WasmOpticalRotorField);
|
|
9512
|
+
_assertClass(b, WasmOpticalRotorField);
|
|
9513
|
+
const ret = wasm.wasmtropicalopticalalgebra_normalizedPhaseDistance(this.__wbg_ptr, a.__wbg_ptr, b.__wbg_ptr);
|
|
9514
|
+
if (ret[2]) {
|
|
9515
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
9516
|
+
}
|
|
9517
|
+
return ret[0];
|
|
9518
|
+
}
|
|
9519
|
+
/**
|
|
9520
|
+
* Create new tropical algebra instance for fields of the given dimensions.
|
|
9521
|
+
* @param {number} width
|
|
9522
|
+
* @param {number} height
|
|
9523
|
+
*/
|
|
9524
|
+
constructor(width, height) {
|
|
9525
|
+
const ret = wasm.wasmopticalfieldalgebra_new(width, height);
|
|
9526
|
+
this.__wbg_ptr = ret >>> 0;
|
|
9527
|
+
WasmTropicalOpticalAlgebraFinalization.register(this, this.__wbg_ptr, this);
|
|
9528
|
+
return this;
|
|
9529
|
+
}
|
|
9530
|
+
/**
|
|
9531
|
+
* Get algebra width.
|
|
9532
|
+
* @returns {number}
|
|
9533
|
+
*/
|
|
9534
|
+
get width() {
|
|
9535
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
9536
|
+
return ret >>> 0;
|
|
9537
|
+
}
|
|
9538
|
+
/**
|
|
9539
|
+
* Get algebra height.
|
|
9540
|
+
* @returns {number}
|
|
9541
|
+
*/
|
|
9542
|
+
get height() {
|
|
9543
|
+
const ret = wasm.wasmmodulispace_getMarkedPoints(this.__wbg_ptr);
|
|
9544
|
+
return ret >>> 0;
|
|
9545
|
+
}
|
|
9546
|
+
}
|
|
9547
|
+
|
|
7677
9548
|
const WasmTropicalPolynomialFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7678
9549
|
? { register: () => {}, unregister: () => {} }
|
|
7679
9550
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalpolynomial_free(ptr >>> 0, 1));
|
|
@@ -8264,12 +10135,12 @@ function __wbg_get_imports() {
|
|
|
8264
10135
|
const ret = arg0.length;
|
|
8265
10136
|
return ret;
|
|
8266
10137
|
};
|
|
10138
|
+
imports.wbg.__wbg_log_9f891854f8fc562b = function(arg0, arg1) {
|
|
10139
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
10140
|
+
};
|
|
8267
10141
|
imports.wbg.__wbg_log_ea240990d83e374e = function(arg0) {
|
|
8268
10142
|
console.log(arg0);
|
|
8269
10143
|
};
|
|
8270
|
-
imports.wbg.__wbg_log_fcb816babb5e424a = function(arg0, arg1) {
|
|
8271
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
8272
|
-
};
|
|
8273
10144
|
imports.wbg.__wbg_new_07b483f72211fd66 = function() {
|
|
8274
10145
|
const ret = new Object();
|
|
8275
10146
|
return ret;
|
|
@@ -8289,7 +10160,7 @@ function __wbg_get_imports() {
|
|
|
8289
10160
|
const a = state0.a;
|
|
8290
10161
|
state0.a = 0;
|
|
8291
10162
|
try {
|
|
8292
|
-
return
|
|
10163
|
+
return __wbg_adapter_683(a, state0.b, arg0, arg1);
|
|
8293
10164
|
} finally {
|
|
8294
10165
|
state0.a = a;
|
|
8295
10166
|
}
|
|
@@ -8364,6 +10235,10 @@ function __wbg_get_imports() {
|
|
|
8364
10235
|
const ret = WasmCommunity.__wrap(arg0);
|
|
8365
10236
|
return ret;
|
|
8366
10237
|
};
|
|
10238
|
+
imports.wbg.__wbg_wasmopticalrotorfield_unwrap = function(arg0) {
|
|
10239
|
+
const ret = WasmOpticalRotorField.__unwrap(arg0);
|
|
10240
|
+
return ret;
|
|
10241
|
+
};
|
|
8367
10242
|
imports.wbg.__wbg_wasmoptimizationresult_new = function(arg0) {
|
|
8368
10243
|
const ret = WasmOptimizationResult.__wrap(arg0);
|
|
8369
10244
|
return ret;
|
|
@@ -8389,8 +10264,8 @@ function __wbg_get_imports() {
|
|
|
8389
10264
|
const ret = false;
|
|
8390
10265
|
return ret;
|
|
8391
10266
|
};
|
|
8392
|
-
imports.wbg.
|
|
8393
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
10267
|
+
imports.wbg.__wbindgen_closure_wrapper1973 = function(arg0, arg1, arg2) {
|
|
10268
|
+
const ret = makeMutClosure(arg0, arg1, 43, __wbg_adapter_30);
|
|
8394
10269
|
return ret;
|
|
8395
10270
|
};
|
|
8396
10271
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
@@ -8434,6 +10309,14 @@ function __wbg_get_imports() {
|
|
|
8434
10309
|
const ret = arg0;
|
|
8435
10310
|
return ret;
|
|
8436
10311
|
};
|
|
10312
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
10313
|
+
const obj = arg1;
|
|
10314
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
10315
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
10316
|
+
var len1 = WASM_VECTOR_LEN;
|
|
10317
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
10318
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
10319
|
+
};
|
|
8437
10320
|
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
8438
10321
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
8439
10322
|
return ret;
|
|
@@ -8453,6 +10336,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
8453
10336
|
wasm = instance.exports;
|
|
8454
10337
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
8455
10338
|
cachedDataViewMemory0 = null;
|
|
10339
|
+
cachedFloat32ArrayMemory0 = null;
|
|
8456
10340
|
cachedFloat64ArrayMemory0 = null;
|
|
8457
10341
|
cachedUint32ArrayMemory0 = null;
|
|
8458
10342
|
cachedUint8ArrayMemory0 = null;
|