@justinelliottcobb/amari-wasm 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/amari_wasm.js CHANGED
@@ -1,5 +1,20 @@
1
1
  let wasm;
2
2
 
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function handleError(f, args) {
10
+ try {
11
+ return f.apply(this, args);
12
+ } catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
+ }
17
+
3
18
  let cachedUint8ArrayMemory0 = null;
4
19
 
5
20
  function getUint8ArrayMemory0() {
@@ -30,6 +45,31 @@ function getStringFromWasm0(ptr, len) {
30
45
  return decodeText(ptr, len);
31
46
  }
32
47
 
48
+ function isLikeNone(x) {
49
+ return x === undefined || x === null;
50
+ }
51
+
52
+ let cachedDataViewMemory0 = null;
53
+
54
+ function getDataViewMemory0() {
55
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
56
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
57
+ }
58
+ return cachedDataViewMemory0;
59
+ }
60
+
61
+ function _assertClass(instance, klass) {
62
+ if (!(instance instanceof klass)) {
63
+ throw new Error(`expected instance of ${klass.name}`);
64
+ }
65
+ }
66
+
67
+ function takeFromExternrefTable0(idx) {
68
+ const value = wasm.__wbindgen_export_2.get(idx);
69
+ wasm.__externref_table_dealloc(idx);
70
+ return value;
71
+ }
72
+
33
73
  let cachedFloat64ArrayMemory0 = null;
34
74
 
35
75
  function getFloat64ArrayMemory0() {
@@ -48,22 +88,10 @@ function passArrayF64ToWasm0(arg, malloc) {
48
88
  return ptr;
49
89
  }
50
90
 
51
- function takeFromExternrefTable0(idx) {
52
- const value = wasm.__wbindgen_export_0.get(idx);
53
- wasm.__externref_table_dealloc(idx);
54
- return value;
55
- }
56
-
57
91
  function getArrayF64FromWasm0(ptr, len) {
58
92
  ptr = ptr >>> 0;
59
93
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
60
94
  }
61
-
62
- function _assertClass(instance, klass) {
63
- if (!(instance instanceof klass)) {
64
- throw new Error(`expected instance of ${klass.name}`);
65
- }
66
- }
67
95
  /**
68
96
  * Initialize the WASM module
69
97
  */
@@ -71,6 +99,54 @@ export function init() {
71
99
  wasm.init();
72
100
  }
73
101
 
102
+ const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
103
+ ? { register: () => {}, unregister: () => {} }
104
+ : new FinalizationRegistry(ptr => wasm.__wbg_autodiff_free(ptr >>> 0, 1));
105
+ /**
106
+ * Automatic differentiation utilities
107
+ */
108
+ export class AutoDiff {
109
+
110
+ __destroy_into_raw() {
111
+ const ptr = this.__wbg_ptr;
112
+ this.__wbg_ptr = 0;
113
+ AutoDiffFinalization.unregister(this);
114
+ return ptr;
115
+ }
116
+
117
+ free() {
118
+ const ptr = this.__destroy_into_raw();
119
+ wasm.__wbg_autodiff_free(ptr, 0);
120
+ }
121
+ /**
122
+ * Compute numerical derivative using finite differences (fallback implementation)
123
+ * @param {number} x
124
+ * @param {Function} f
125
+ * @param {number} h
126
+ * @returns {number}
127
+ */
128
+ static numericalDerivative(x, f, h) {
129
+ const ret = wasm.autodiff_numericalDerivative(x, f, h);
130
+ if (ret[2]) {
131
+ throw takeFromExternrefTable0(ret[1]);
132
+ }
133
+ return ret[0];
134
+ }
135
+ /**
136
+ * Create a dual number and evaluate a polynomial
137
+ * @param {number} x
138
+ * @param {Float64Array} coefficients
139
+ * @returns {WasmDualNumber}
140
+ */
141
+ static evaluatePolynomial(x, coefficients) {
142
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ const ret = wasm.autodiff_evaluatePolynomial(x, ptr0, len0);
145
+ return WasmDualNumber.__wrap(ret);
146
+ }
147
+ }
148
+ if (Symbol.dispose) AutoDiff.prototype[Symbol.dispose] = AutoDiff.prototype.free;
149
+
74
150
  const BatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
75
151
  ? { register: () => {}, unregister: () => {} }
76
152
  : new FinalizationRegistry(ptr => wasm.__wbg_batchoperations_free(ptr >>> 0, 1));
@@ -85,51 +161,864 @@ export class BatchOperations {
85
161
  BatchOperationsFinalization.unregister(this);
86
162
  return ptr;
87
163
  }
88
-
89
- free() {
90
- const ptr = this.__destroy_into_raw();
91
- wasm.__wbg_batchoperations_free(ptr, 0);
164
+
165
+ free() {
166
+ const ptr = this.__destroy_into_raw();
167
+ wasm.__wbg_batchoperations_free(ptr, 0);
168
+ }
169
+ /**
170
+ * Batch geometric product: compute a[i] * b[i] for all i
171
+ * @param {Float64Array} a_batch
172
+ * @param {Float64Array} b_batch
173
+ * @returns {Float64Array}
174
+ */
175
+ static batchGeometricProduct(a_batch, b_batch) {
176
+ const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
177
+ const len0 = WASM_VECTOR_LEN;
178
+ const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
179
+ const len1 = WASM_VECTOR_LEN;
180
+ const ret = wasm.batchoperations_batchGeometricProduct(ptr0, len0, ptr1, len1);
181
+ if (ret[3]) {
182
+ throw takeFromExternrefTable0(ret[2]);
183
+ }
184
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
185
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
186
+ return v3;
187
+ }
188
+ /**
189
+ * Batch addition
190
+ * @param {Float64Array} a_batch
191
+ * @param {Float64Array} b_batch
192
+ * @returns {Float64Array}
193
+ */
194
+ static batchAdd(a_batch, b_batch) {
195
+ const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
198
+ const len1 = WASM_VECTOR_LEN;
199
+ const ret = wasm.batchoperations_batchAdd(ptr0, len0, ptr1, len1);
200
+ if (ret[3]) {
201
+ throw takeFromExternrefTable0(ret[2]);
202
+ }
203
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
204
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
205
+ return v3;
206
+ }
207
+ }
208
+ if (Symbol.dispose) BatchOperations.prototype[Symbol.dispose] = BatchOperations.prototype.free;
209
+
210
+ const FusionBatchFinalization = (typeof FinalizationRegistry === 'undefined')
211
+ ? { register: () => {}, unregister: () => {} }
212
+ : new FinalizationRegistry(ptr => wasm.__wbg_fusionbatch_free(ptr >>> 0, 1));
213
+ /**
214
+ * Fusion utilities for batch operations
215
+ */
216
+ export class FusionBatch {
217
+
218
+ __destroy_into_raw() {
219
+ const ptr = this.__wbg_ptr;
220
+ this.__wbg_ptr = 0;
221
+ FusionBatchFinalization.unregister(this);
222
+ return ptr;
223
+ }
224
+
225
+ free() {
226
+ const ptr = this.__destroy_into_raw();
227
+ wasm.__wbg_fusionbatch_free(ptr, 0);
228
+ }
229
+ /**
230
+ * Batch tropical attention across multiple queries
231
+ * @param {Float64Array} queries
232
+ * @param {Float64Array} keys
233
+ * @param {Float64Array} values
234
+ * @param {number} query_dim
235
+ * @returns {Float64Array}
236
+ */
237
+ static batchTropicalAttention(queries, keys, values, query_dim) {
238
+ const ptr0 = passArrayF64ToWasm0(queries, wasm.__wbindgen_malloc);
239
+ const len0 = WASM_VECTOR_LEN;
240
+ const ptr1 = passArrayF64ToWasm0(keys, wasm.__wbindgen_malloc);
241
+ const len1 = WASM_VECTOR_LEN;
242
+ const ptr2 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
243
+ const len2 = WASM_VECTOR_LEN;
244
+ const ret = wasm.fusionbatch_batchTropicalAttention(ptr0, len0, ptr1, len1, ptr2, len2, query_dim);
245
+ if (ret[3]) {
246
+ throw takeFromExternrefTable0(ret[2]);
247
+ }
248
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
249
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
250
+ return v4;
251
+ }
252
+ /**
253
+ * Compute fusion similarity between two TDC objects
254
+ * @param {WasmTropicalDualClifford} tdc1
255
+ * @param {WasmTropicalDualClifford} tdc2
256
+ * @returns {number}
257
+ */
258
+ static fusionSimilarity(tdc1, tdc2) {
259
+ _assertClass(tdc1, WasmTropicalDualClifford);
260
+ _assertClass(tdc2, WasmTropicalDualClifford);
261
+ const ret = wasm.fusionbatch_fusionSimilarity(tdc1.__wbg_ptr, tdc2.__wbg_ptr);
262
+ return ret;
263
+ }
264
+ /**
265
+ * Optimize TDC parameters using gradient information
266
+ * @param {WasmTropicalDualClifford} tdc
267
+ * @param {number} learning_rate
268
+ * @returns {WasmTropicalDualClifford}
269
+ */
270
+ static gradientStep(tdc, learning_rate) {
271
+ _assertClass(tdc, WasmTropicalDualClifford);
272
+ const ret = wasm.fusionbatch_gradientStep(tdc.__wbg_ptr, learning_rate);
273
+ return WasmTropicalDualClifford.__wrap(ret);
274
+ }
275
+ }
276
+ if (Symbol.dispose) FusionBatch.prototype[Symbol.dispose] = FusionBatch.prototype.free;
277
+
278
+ const InfoGeomUtilsFinalization = (typeof FinalizationRegistry === 'undefined')
279
+ ? { register: () => {}, unregister: () => {} }
280
+ : new FinalizationRegistry(ptr => wasm.__wbg_infogeomutils_free(ptr >>> 0, 1));
281
+ /**
282
+ * Information geometry utilities
283
+ */
284
+ export class InfoGeomUtils {
285
+
286
+ __destroy_into_raw() {
287
+ const ptr = this.__wbg_ptr;
288
+ this.__wbg_ptr = 0;
289
+ InfoGeomUtilsFinalization.unregister(this);
290
+ return ptr;
291
+ }
292
+
293
+ free() {
294
+ const ptr = this.__destroy_into_raw();
295
+ wasm.__wbg_infogeomutils_free(ptr, 0);
296
+ }
297
+ /**
298
+ * Normalize array to probability distribution
299
+ * @param {Float64Array} values
300
+ * @returns {Float64Array}
301
+ */
302
+ static normalize(values) {
303
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
304
+ const len0 = WASM_VECTOR_LEN;
305
+ const ret = wasm.infogeomutils_normalize(ptr0, len0);
306
+ if (ret[3]) {
307
+ throw takeFromExternrefTable0(ret[2]);
308
+ }
309
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
310
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
311
+ return v2;
312
+ }
313
+ /**
314
+ * Convert log probabilities to probabilities
315
+ * @param {Float64Array} logits
316
+ * @returns {Float64Array}
317
+ */
318
+ static softmax(logits) {
319
+ const ptr0 = passArrayF64ToWasm0(logits, wasm.__wbindgen_malloc);
320
+ const len0 = WASM_VECTOR_LEN;
321
+ const ret = wasm.infogeomutils_softmax(ptr0, len0);
322
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
323
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
324
+ return v2;
325
+ }
326
+ /**
327
+ * Compute entropy of a probability distribution
328
+ * @param {Float64Array} p
329
+ * @returns {number}
330
+ */
331
+ static entropy(p) {
332
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ const ret = wasm.infogeomutils_entropy(ptr0, len0);
335
+ if (ret[2]) {
336
+ throw takeFromExternrefTable0(ret[1]);
337
+ }
338
+ return ret[0];
339
+ }
340
+ /**
341
+ * Compute cross-entropy between two distributions
342
+ * @param {Float64Array} p
343
+ * @param {Float64Array} q
344
+ * @returns {number}
345
+ */
346
+ static crossEntropy(p, q) {
347
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
348
+ const len0 = WASM_VECTOR_LEN;
349
+ const ptr1 = passArrayF64ToWasm0(q, wasm.__wbindgen_malloc);
350
+ const len1 = WASM_VECTOR_LEN;
351
+ const ret = wasm.infogeomutils_crossEntropy(ptr0, len0, ptr1, len1);
352
+ if (ret[2]) {
353
+ throw takeFromExternrefTable0(ret[1]);
354
+ }
355
+ return ret[0];
356
+ }
357
+ /**
358
+ * Compute mutual information between two discrete distributions
359
+ * @param {Float64Array} joint
360
+ * @param {Float64Array} marginal_x
361
+ * @param {Float64Array} marginal_y
362
+ * @param {number} dim_x
363
+ * @returns {number}
364
+ */
365
+ static mutualInformation(joint, marginal_x, marginal_y, dim_x) {
366
+ const ptr0 = passArrayF64ToWasm0(joint, wasm.__wbindgen_malloc);
367
+ const len0 = WASM_VECTOR_LEN;
368
+ const ptr1 = passArrayF64ToWasm0(marginal_x, wasm.__wbindgen_malloc);
369
+ const len1 = WASM_VECTOR_LEN;
370
+ const ptr2 = passArrayF64ToWasm0(marginal_y, wasm.__wbindgen_malloc);
371
+ const len2 = WASM_VECTOR_LEN;
372
+ const ret = wasm.infogeomutils_mutualInformation(ptr0, len0, ptr1, len1, ptr2, len2, dim_x);
373
+ if (ret[2]) {
374
+ throw takeFromExternrefTable0(ret[1]);
375
+ }
376
+ return ret[0];
377
+ }
378
+ /**
379
+ * Generate points on the probability simplex for testing
380
+ * Note: Uses a simple deterministic sequence for reproducibility in WASM
381
+ * @param {number} dimension
382
+ * @returns {Float64Array}
383
+ */
384
+ static randomSimplex(dimension) {
385
+ const ret = wasm.infogeomutils_randomSimplex(dimension);
386
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
387
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
388
+ return v1;
389
+ }
390
+ }
391
+ if (Symbol.dispose) InfoGeomUtils.prototype[Symbol.dispose] = InfoGeomUtils.prototype.free;
392
+
393
+ const TropicalBatchFinalization = (typeof FinalizationRegistry === 'undefined')
394
+ ? { register: () => {}, unregister: () => {} }
395
+ : new FinalizationRegistry(ptr => wasm.__wbg_tropicalbatch_free(ptr >>> 0, 1));
396
+ /**
397
+ * Batch operations for tropical numbers
398
+ */
399
+ export class TropicalBatch {
400
+
401
+ __destroy_into_raw() {
402
+ const ptr = this.__wbg_ptr;
403
+ this.__wbg_ptr = 0;
404
+ TropicalBatchFinalization.unregister(this);
405
+ return ptr;
406
+ }
407
+
408
+ free() {
409
+ const ptr = this.__destroy_into_raw();
410
+ wasm.__wbg_tropicalbatch_free(ptr, 0);
411
+ }
412
+ /**
413
+ * Batch tropical addition (max operation)
414
+ * @param {Float64Array} values
415
+ * @returns {number}
416
+ */
417
+ static batchTropicalAdd(values) {
418
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
419
+ const len0 = WASM_VECTOR_LEN;
420
+ const ret = wasm.tropicalbatch_batchTropicalAdd(ptr0, len0);
421
+ return ret;
422
+ }
423
+ /**
424
+ * Batch tropical multiplication (addition)
425
+ * @param {Float64Array} values
426
+ * @returns {number}
427
+ */
428
+ static batchTropicalMul(values) {
429
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
430
+ const len0 = WASM_VECTOR_LEN;
431
+ const ret = wasm.tropicalbatch_batchTropicalMul(ptr0, len0);
432
+ return ret;
433
+ }
434
+ /**
435
+ * Convert array of log probabilities to tropical numbers and find maximum
436
+ * @param {Float64Array} log_probs
437
+ * @returns {number}
438
+ */
439
+ static maxLogProb(log_probs) {
440
+ const ptr0 = passArrayF64ToWasm0(log_probs, wasm.__wbindgen_malloc);
441
+ const len0 = WASM_VECTOR_LEN;
442
+ const ret = wasm.tropicalbatch_maxLogProb(ptr0, len0);
443
+ return ret;
444
+ }
445
+ /**
446
+ * Viterbi algorithm helper: find best path through trellis
447
+ * @param {Float64Array} prev_scores
448
+ * @param {Float64Array} transition_scores
449
+ * @param {Float64Array} emission_scores
450
+ * @param {number} num_states
451
+ * @returns {Float64Array}
452
+ */
453
+ static viterbiStep(prev_scores, transition_scores, emission_scores, num_states) {
454
+ const ptr0 = passArrayF64ToWasm0(prev_scores, wasm.__wbindgen_malloc);
455
+ const len0 = WASM_VECTOR_LEN;
456
+ const ptr1 = passArrayF64ToWasm0(transition_scores, wasm.__wbindgen_malloc);
457
+ const len1 = WASM_VECTOR_LEN;
458
+ const ptr2 = passArrayF64ToWasm0(emission_scores, wasm.__wbindgen_malloc);
459
+ const len2 = WASM_VECTOR_LEN;
460
+ const ret = wasm.tropicalbatch_viterbiStep(ptr0, len0, ptr1, len1, ptr2, len2, num_states);
461
+ if (ret[3]) {
462
+ throw takeFromExternrefTable0(ret[2]);
463
+ }
464
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
465
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
466
+ return v4;
467
+ }
468
+ }
469
+ if (Symbol.dispose) TropicalBatch.prototype[Symbol.dispose] = TropicalBatch.prototype.free;
470
+
471
+ const WasmAlphaConnectionFinalization = (typeof FinalizationRegistry === 'undefined')
472
+ ? { register: () => {}, unregister: () => {} }
473
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmalphaconnection_free(ptr >>> 0, 1));
474
+ /**
475
+ * WASM wrapper for AlphaConnection
476
+ */
477
+ export class WasmAlphaConnection {
478
+
479
+ __destroy_into_raw() {
480
+ const ptr = this.__wbg_ptr;
481
+ this.__wbg_ptr = 0;
482
+ WasmAlphaConnectionFinalization.unregister(this);
483
+ return ptr;
484
+ }
485
+
486
+ free() {
487
+ const ptr = this.__destroy_into_raw();
488
+ wasm.__wbg_wasmalphaconnection_free(ptr, 0);
489
+ }
490
+ /**
491
+ * Create a new α-connection
492
+ * @param {number} alpha
493
+ */
494
+ constructor(alpha) {
495
+ const ret = wasm.wasmalphaconnection_new(alpha);
496
+ if (ret[2]) {
497
+ throw takeFromExternrefTable0(ret[1]);
498
+ }
499
+ this.__wbg_ptr = ret[0] >>> 0;
500
+ WasmAlphaConnectionFinalization.register(this, this.__wbg_ptr, this);
501
+ return this;
502
+ }
503
+ /**
504
+ * Get the α parameter
505
+ * @returns {number}
506
+ */
507
+ getAlpha() {
508
+ const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
509
+ return ret;
510
+ }
511
+ /**
512
+ * Check if this is the exponential connection (α = 1)
513
+ * @returns {boolean}
514
+ */
515
+ isExponential() {
516
+ const ret = wasm.wasmalphaconnection_isExponential(this.__wbg_ptr);
517
+ return ret !== 0;
518
+ }
519
+ /**
520
+ * Check if this is the mixture connection (α = -1)
521
+ * @returns {boolean}
522
+ */
523
+ isMixture() {
524
+ const ret = wasm.wasmalphaconnection_isMixture(this.__wbg_ptr);
525
+ return ret !== 0;
526
+ }
527
+ /**
528
+ * Check if this is the Levi-Civita connection (α = 0)
529
+ * @returns {boolean}
530
+ */
531
+ isLeviCivita() {
532
+ const ret = wasm.wasmalphaconnection_isLeviCivita(this.__wbg_ptr);
533
+ return ret !== 0;
534
+ }
535
+ }
536
+ if (Symbol.dispose) WasmAlphaConnection.prototype[Symbol.dispose] = WasmAlphaConnection.prototype.free;
537
+
538
+ const WasmDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
539
+ ? { register: () => {}, unregister: () => {} }
540
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmdualnumber_free(ptr >>> 0, 1));
541
+ /**
542
+ * WASM wrapper for single-variable dual numbers
543
+ */
544
+ export class WasmDualNumber {
545
+
546
+ static __wrap(ptr) {
547
+ ptr = ptr >>> 0;
548
+ const obj = Object.create(WasmDualNumber.prototype);
549
+ obj.__wbg_ptr = ptr;
550
+ WasmDualNumberFinalization.register(obj, obj.__wbg_ptr, obj);
551
+ return obj;
552
+ }
553
+
554
+ __destroy_into_raw() {
555
+ const ptr = this.__wbg_ptr;
556
+ this.__wbg_ptr = 0;
557
+ WasmDualNumberFinalization.unregister(this);
558
+ return ptr;
559
+ }
560
+
561
+ free() {
562
+ const ptr = this.__destroy_into_raw();
563
+ wasm.__wbg_wasmdualnumber_free(ptr, 0);
564
+ }
565
+ /**
566
+ * Create a new dual number with given real and dual parts
567
+ * @param {number} real
568
+ * @param {number} dual
569
+ */
570
+ constructor(real, dual) {
571
+ const ret = wasm.wasmdualnumber_new(real, dual);
572
+ this.__wbg_ptr = ret >>> 0;
573
+ WasmDualNumberFinalization.register(this, this.__wbg_ptr, this);
574
+ return this;
575
+ }
576
+ /**
577
+ * Create a variable (derivative = 1)
578
+ * @param {number} value
579
+ * @returns {WasmDualNumber}
580
+ */
581
+ static variable(value) {
582
+ const ret = wasm.wasmdualnumber_variable(value);
583
+ return WasmDualNumber.__wrap(ret);
584
+ }
585
+ /**
586
+ * Create a constant (derivative = 0)
587
+ * @param {number} value
588
+ * @returns {WasmDualNumber}
589
+ */
590
+ static constant(value) {
591
+ const ret = wasm.wasmdualnumber_constant(value);
592
+ return WasmDualNumber.__wrap(ret);
593
+ }
594
+ /**
595
+ * Get the real part (function value)
596
+ * @returns {number}
597
+ */
598
+ getReal() {
599
+ const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
600
+ return ret;
601
+ }
602
+ /**
603
+ * Get the dual part (derivative)
604
+ * @returns {number}
605
+ */
606
+ getDual() {
607
+ const ret = wasm.wasmdualnumber_getDual(this.__wbg_ptr);
608
+ return ret;
609
+ }
610
+ /**
611
+ * Addition
612
+ * @param {WasmDualNumber} other
613
+ * @returns {WasmDualNumber}
614
+ */
615
+ add(other) {
616
+ _assertClass(other, WasmDualNumber);
617
+ const ret = wasm.wasmdualnumber_add(this.__wbg_ptr, other.__wbg_ptr);
618
+ return WasmDualNumber.__wrap(ret);
619
+ }
620
+ /**
621
+ * Subtraction
622
+ * @param {WasmDualNumber} other
623
+ * @returns {WasmDualNumber}
624
+ */
625
+ sub(other) {
626
+ _assertClass(other, WasmDualNumber);
627
+ const ret = wasm.wasmdualnumber_sub(this.__wbg_ptr, other.__wbg_ptr);
628
+ return WasmDualNumber.__wrap(ret);
629
+ }
630
+ /**
631
+ * Multiplication
632
+ * @param {WasmDualNumber} other
633
+ * @returns {WasmDualNumber}
634
+ */
635
+ mul(other) {
636
+ _assertClass(other, WasmDualNumber);
637
+ const ret = wasm.wasmdualnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
638
+ return WasmDualNumber.__wrap(ret);
639
+ }
640
+ /**
641
+ * Division
642
+ * @param {WasmDualNumber} other
643
+ * @returns {WasmDualNumber}
644
+ */
645
+ div(other) {
646
+ _assertClass(other, WasmDualNumber);
647
+ const ret = wasm.wasmdualnumber_div(this.__wbg_ptr, other.__wbg_ptr);
648
+ if (ret[2]) {
649
+ throw takeFromExternrefTable0(ret[1]);
650
+ }
651
+ return WasmDualNumber.__wrap(ret[0]);
652
+ }
653
+ /**
654
+ * Negation
655
+ * @returns {WasmDualNumber}
656
+ */
657
+ neg() {
658
+ const ret = wasm.wasmdualnumber_neg(this.__wbg_ptr);
659
+ return WasmDualNumber.__wrap(ret);
660
+ }
661
+ /**
662
+ * Power function
663
+ * @param {number} exponent
664
+ * @returns {WasmDualNumber}
665
+ */
666
+ pow(exponent) {
667
+ const ret = wasm.wasmdualnumber_pow(this.__wbg_ptr, exponent);
668
+ return WasmDualNumber.__wrap(ret);
669
+ }
670
+ /**
671
+ * Exponential function
672
+ * @returns {WasmDualNumber}
673
+ */
674
+ exp() {
675
+ const ret = wasm.wasmdualnumber_exp(this.__wbg_ptr);
676
+ return WasmDualNumber.__wrap(ret);
677
+ }
678
+ /**
679
+ * Natural logarithm
680
+ * @returns {WasmDualNumber}
681
+ */
682
+ ln() {
683
+ const ret = wasm.wasmdualnumber_ln(this.__wbg_ptr);
684
+ if (ret[2]) {
685
+ throw takeFromExternrefTable0(ret[1]);
686
+ }
687
+ return WasmDualNumber.__wrap(ret[0]);
688
+ }
689
+ /**
690
+ * Sine function
691
+ * @returns {WasmDualNumber}
692
+ */
693
+ sin() {
694
+ const ret = wasm.wasmdualnumber_sin(this.__wbg_ptr);
695
+ return WasmDualNumber.__wrap(ret);
696
+ }
697
+ /**
698
+ * Cosine function
699
+ * @returns {WasmDualNumber}
700
+ */
701
+ cos() {
702
+ const ret = wasm.wasmdualnumber_cos(this.__wbg_ptr);
703
+ return WasmDualNumber.__wrap(ret);
704
+ }
705
+ /**
706
+ * Square root
707
+ * @returns {WasmDualNumber}
708
+ */
709
+ sqrt() {
710
+ const ret = wasm.wasmdualnumber_sqrt(this.__wbg_ptr);
711
+ if (ret[2]) {
712
+ throw takeFromExternrefTable0(ret[1]);
713
+ }
714
+ return WasmDualNumber.__wrap(ret[0]);
715
+ }
716
+ }
717
+ if (Symbol.dispose) WasmDualNumber.prototype[Symbol.dispose] = WasmDualNumber.prototype.free;
718
+
719
+ const WasmDuallyFlatManifoldFinalization = (typeof FinalizationRegistry === 'undefined')
720
+ ? { register: () => {}, unregister: () => {} }
721
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmduallyflatmanifold_free(ptr >>> 0, 1));
722
+ /**
723
+ * WASM wrapper for DuallyFlatManifold
724
+ */
725
+ export class WasmDuallyFlatManifold {
726
+
727
+ __destroy_into_raw() {
728
+ const ptr = this.__wbg_ptr;
729
+ this.__wbg_ptr = 0;
730
+ WasmDuallyFlatManifoldFinalization.unregister(this);
731
+ return ptr;
732
+ }
733
+
734
+ free() {
735
+ const ptr = this.__destroy_into_raw();
736
+ wasm.__wbg_wasmduallyflatmanifold_free(ptr, 0);
737
+ }
738
+ /**
739
+ * Create a new dually flat manifold
740
+ * @param {number} dimension
741
+ * @param {number} alpha
742
+ */
743
+ constructor(dimension, alpha) {
744
+ const ret = wasm.wasmduallyflatmanifold_new(dimension, alpha);
745
+ this.__wbg_ptr = ret >>> 0;
746
+ WasmDuallyFlatManifoldFinalization.register(this, this.__wbg_ptr, this);
747
+ return this;
748
+ }
749
+ /**
750
+ * Compute Fisher information metric at a point
751
+ * @param {Float64Array} point
752
+ * @returns {WasmFisherInformationMatrix}
753
+ */
754
+ fisherMetricAt(point) {
755
+ const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
756
+ const len0 = WASM_VECTOR_LEN;
757
+ const ret = wasm.wasmduallyflatmanifold_fisherMetricAt(this.__wbg_ptr, ptr0, len0);
758
+ return WasmFisherInformationMatrix.__wrap(ret);
759
+ }
760
+ /**
761
+ * Compute Bregman divergence (KL divergence for probability distributions)
762
+ * @param {Float64Array} p
763
+ * @param {Float64Array} q
764
+ * @returns {number}
765
+ */
766
+ bregmanDivergence(p, q) {
767
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
768
+ const len0 = WASM_VECTOR_LEN;
769
+ const ptr1 = passArrayF64ToWasm0(q, wasm.__wbindgen_malloc);
770
+ const len1 = WASM_VECTOR_LEN;
771
+ const ret = wasm.wasmduallyflatmanifold_bregmanDivergence(this.__wbg_ptr, ptr0, len0, ptr1, len1);
772
+ return ret;
773
+ }
774
+ /**
775
+ * Compute KL divergence between two probability distributions
776
+ * @param {Float64Array} p
777
+ * @param {Float64Array} q
778
+ * @returns {number}
779
+ */
780
+ klDivergence(p, q) {
781
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
782
+ const len0 = WASM_VECTOR_LEN;
783
+ const ptr1 = passArrayF64ToWasm0(q, wasm.__wbindgen_malloc);
784
+ const len1 = WASM_VECTOR_LEN;
785
+ const ret = wasm.wasmduallyflatmanifold_klDivergence(this.__wbg_ptr, ptr0, len0, ptr1, len1);
786
+ if (ret[2]) {
787
+ throw takeFromExternrefTable0(ret[1]);
788
+ }
789
+ return ret[0];
790
+ }
791
+ /**
792
+ * Compute JS divergence (symmetric version of KL divergence)
793
+ * @param {Float64Array} p
794
+ * @param {Float64Array} q
795
+ * @returns {number}
796
+ */
797
+ jsDivergence(p, q) {
798
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
799
+ const len0 = WASM_VECTOR_LEN;
800
+ const ptr1 = passArrayF64ToWasm0(q, wasm.__wbindgen_malloc);
801
+ const len1 = WASM_VECTOR_LEN;
802
+ const ret = wasm.wasmduallyflatmanifold_jsDivergence(this.__wbg_ptr, ptr0, len0, ptr1, len1);
803
+ if (ret[2]) {
804
+ throw takeFromExternrefTable0(ret[1]);
805
+ }
806
+ return ret[0];
807
+ }
808
+ /**
809
+ * Compute Wasserstein-1 distance (Earth Mover's Distance)
810
+ * @param {Float64Array} p
811
+ * @param {Float64Array} q
812
+ * @returns {number}
813
+ */
814
+ wassersteinDistance(p, q) {
815
+ const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
816
+ const len0 = WASM_VECTOR_LEN;
817
+ const ptr1 = passArrayF64ToWasm0(q, wasm.__wbindgen_malloc);
818
+ const len1 = WASM_VECTOR_LEN;
819
+ const ret = wasm.wasmduallyflatmanifold_wassersteinDistance(this.__wbg_ptr, ptr0, len0, ptr1, len1);
820
+ if (ret[2]) {
821
+ throw takeFromExternrefTable0(ret[1]);
822
+ }
823
+ return ret[0];
824
+ }
825
+ }
826
+ if (Symbol.dispose) WasmDuallyFlatManifold.prototype[Symbol.dispose] = WasmDuallyFlatManifold.prototype.free;
827
+
828
+ const WasmFisherInformationMatrixFinalization = (typeof FinalizationRegistry === 'undefined')
829
+ ? { register: () => {}, unregister: () => {} }
830
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmfisherinformationmatrix_free(ptr >>> 0, 1));
831
+ /**
832
+ * WASM wrapper for FisherInformationMatrix
833
+ */
834
+ export class WasmFisherInformationMatrix {
835
+
836
+ static __wrap(ptr) {
837
+ ptr = ptr >>> 0;
838
+ const obj = Object.create(WasmFisherInformationMatrix.prototype);
839
+ obj.__wbg_ptr = ptr;
840
+ WasmFisherInformationMatrixFinalization.register(obj, obj.__wbg_ptr, obj);
841
+ return obj;
842
+ }
843
+
844
+ __destroy_into_raw() {
845
+ const ptr = this.__wbg_ptr;
846
+ this.__wbg_ptr = 0;
847
+ WasmFisherInformationMatrixFinalization.unregister(this);
848
+ return ptr;
849
+ }
850
+
851
+ free() {
852
+ const ptr = this.__destroy_into_raw();
853
+ wasm.__wbg_wasmfisherinformationmatrix_free(ptr, 0);
854
+ }
855
+ /**
856
+ * Get eigenvalues of the Fisher matrix
857
+ * @returns {Float64Array}
858
+ */
859
+ getEigenvalues() {
860
+ const ret = wasm.wasmfisherinformationmatrix_getEigenvalues(this.__wbg_ptr);
861
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
862
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
863
+ return v1;
864
+ }
865
+ /**
866
+ * Check if the matrix is positive definite
867
+ * @returns {boolean}
868
+ */
869
+ isPositiveDefinite() {
870
+ const ret = wasm.wasmfisherinformationmatrix_isPositiveDefinite(this.__wbg_ptr);
871
+ return ret !== 0;
872
+ }
873
+ /**
874
+ * Compute condition number (ratio of largest to smallest eigenvalue)
875
+ * @returns {number}
876
+ */
877
+ conditionNumber() {
878
+ const ret = wasm.wasmfisherinformationmatrix_conditionNumber(this.__wbg_ptr);
879
+ return ret;
880
+ }
881
+ }
882
+ if (Symbol.dispose) WasmFisherInformationMatrix.prototype[Symbol.dispose] = WasmFisherInformationMatrix.prototype.free;
883
+
884
+ const WasmMultiDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
885
+ ? { register: () => {}, unregister: () => {} }
886
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultidualnumber_free(ptr >>> 0, 1));
887
+ /**
888
+ * WASM wrapper for multi-variable dual numbers
889
+ */
890
+ export class WasmMultiDualNumber {
891
+
892
+ static __wrap(ptr) {
893
+ ptr = ptr >>> 0;
894
+ const obj = Object.create(WasmMultiDualNumber.prototype);
895
+ obj.__wbg_ptr = ptr;
896
+ WasmMultiDualNumberFinalization.register(obj, obj.__wbg_ptr, obj);
897
+ return obj;
898
+ }
899
+
900
+ __destroy_into_raw() {
901
+ const ptr = this.__wbg_ptr;
902
+ this.__wbg_ptr = 0;
903
+ WasmMultiDualNumberFinalization.unregister(this);
904
+ return ptr;
905
+ }
906
+
907
+ free() {
908
+ const ptr = this.__destroy_into_raw();
909
+ wasm.__wbg_wasmmultidualnumber_free(ptr, 0);
910
+ }
911
+ /**
912
+ * Create a new multi-dual number
913
+ * @param {number} real
914
+ * @param {Float64Array} duals
915
+ */
916
+ constructor(real, duals) {
917
+ const ptr0 = passArrayF64ToWasm0(duals, wasm.__wbindgen_malloc);
918
+ const len0 = WASM_VECTOR_LEN;
919
+ const ret = wasm.wasmmultidualnumber_new(real, ptr0, len0);
920
+ this.__wbg_ptr = ret >>> 0;
921
+ WasmMultiDualNumberFinalization.register(this, this.__wbg_ptr, this);
922
+ return this;
923
+ }
924
+ /**
925
+ * Create a variable with derivative 1 at the specified index
926
+ * @param {number} value
927
+ * @param {number} num_vars
928
+ * @param {number} var_index
929
+ * @returns {WasmMultiDualNumber}
930
+ */
931
+ static variable(value, num_vars, var_index) {
932
+ const ret = wasm.wasmmultidualnumber_variable(value, num_vars, var_index);
933
+ return WasmMultiDualNumber.__wrap(ret);
92
934
  }
93
935
  /**
94
- * Batch geometric product: compute a[i] * b[i] for all i
95
- * @param {Float64Array} a_batch
96
- * @param {Float64Array} b_batch
936
+ * Create a constant (all derivatives are zero)
937
+ * @param {number} value
938
+ * @param {number} num_vars
939
+ * @returns {WasmMultiDualNumber}
940
+ */
941
+ static constant(value, num_vars) {
942
+ const ret = wasm.wasmmultidualnumber_constant(value, num_vars);
943
+ return WasmMultiDualNumber.__wrap(ret);
944
+ }
945
+ /**
946
+ * Get the real part (function value)
947
+ * @returns {number}
948
+ */
949
+ getReal() {
950
+ const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
951
+ return ret;
952
+ }
953
+ /**
954
+ * Get the gradient (all partial derivatives)
97
955
  * @returns {Float64Array}
98
956
  */
99
- static batchGeometricProduct(a_batch, b_batch) {
100
- const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
101
- const len0 = WASM_VECTOR_LEN;
102
- const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
103
- const len1 = WASM_VECTOR_LEN;
104
- const ret = wasm.batchoperations_batchGeometricProduct(ptr0, len0, ptr1, len1);
105
- if (ret[3]) {
106
- throw takeFromExternrefTable0(ret[2]);
107
- }
108
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
957
+ getGradient() {
958
+ const ret = wasm.wasmmultidualnumber_getGradient(this.__wbg_ptr);
959
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
109
960
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
110
- return v3;
961
+ return v1;
111
962
  }
112
963
  /**
113
- * Batch addition
114
- * @param {Float64Array} a_batch
115
- * @param {Float64Array} b_batch
116
- * @returns {Float64Array}
964
+ * Get a specific partial derivative
965
+ * @param {number} index
966
+ * @returns {number}
117
967
  */
118
- static batchAdd(a_batch, b_batch) {
119
- const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
120
- const len0 = WASM_VECTOR_LEN;
121
- const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
122
- const len1 = WASM_VECTOR_LEN;
123
- const ret = wasm.batchoperations_batchAdd(ptr0, len0, ptr1, len1);
124
- if (ret[3]) {
125
- throw takeFromExternrefTable0(ret[2]);
968
+ getPartial(index) {
969
+ const ret = wasm.wasmmultidualnumber_getPartial(this.__wbg_ptr, index);
970
+ if (ret[2]) {
971
+ throw takeFromExternrefTable0(ret[1]);
126
972
  }
127
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
128
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
129
- return v3;
973
+ return ret[0];
974
+ }
975
+ /**
976
+ * Get number of variables
977
+ * @returns {number}
978
+ */
979
+ getNumVars() {
980
+ const ret = wasm.wasmmultidualnumber_getNumVars(this.__wbg_ptr);
981
+ return ret >>> 0;
982
+ }
983
+ /**
984
+ * Addition
985
+ * @param {WasmMultiDualNumber} other
986
+ * @returns {WasmMultiDualNumber}
987
+ */
988
+ add(other) {
989
+ _assertClass(other, WasmMultiDualNumber);
990
+ const ret = wasm.wasmmultidualnumber_add(this.__wbg_ptr, other.__wbg_ptr);
991
+ if (ret[2]) {
992
+ throw takeFromExternrefTable0(ret[1]);
993
+ }
994
+ return WasmMultiDualNumber.__wrap(ret[0]);
995
+ }
996
+ /**
997
+ * Multiplication
998
+ * @param {WasmMultiDualNumber} other
999
+ * @returns {WasmMultiDualNumber}
1000
+ */
1001
+ mul(other) {
1002
+ _assertClass(other, WasmMultiDualNumber);
1003
+ const ret = wasm.wasmmultidualnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
1004
+ if (ret[2]) {
1005
+ throw takeFromExternrefTable0(ret[1]);
1006
+ }
1007
+ return WasmMultiDualNumber.__wrap(ret[0]);
1008
+ }
1009
+ /**
1010
+ * Square root
1011
+ * @returns {WasmMultiDualNumber}
1012
+ */
1013
+ sqrt() {
1014
+ const ret = wasm.wasmmultidualnumber_sqrt(this.__wbg_ptr);
1015
+ if (ret[2]) {
1016
+ throw takeFromExternrefTable0(ret[1]);
1017
+ }
1018
+ return WasmMultiDualNumber.__wrap(ret[0]);
130
1019
  }
131
1020
  }
132
- if (Symbol.dispose) BatchOperations.prototype[Symbol.dispose] = BatchOperations.prototype.free;
1021
+ if (Symbol.dispose) WasmMultiDualNumber.prototype[Symbol.dispose] = WasmMultiDualNumber.prototype.free;
133
1022
 
134
1023
  const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
135
1024
  ? { register: () => {}, unregister: () => {} }
@@ -433,6 +1322,339 @@ export class WasmRotor {
433
1322
  }
434
1323
  if (Symbol.dispose) WasmRotor.prototype[Symbol.dispose] = WasmRotor.prototype.free;
435
1324
 
1325
+ const WasmTropicalDualCliffordFinalization = (typeof FinalizationRegistry === 'undefined')
1326
+ ? { register: () => {}, unregister: () => {} }
1327
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicaldualclifford_free(ptr >>> 0, 1));
1328
+ /**
1329
+ * WASM wrapper for TropicalDualClifford fusion system
1330
+ */
1331
+ export class WasmTropicalDualClifford {
1332
+
1333
+ static __wrap(ptr) {
1334
+ ptr = ptr >>> 0;
1335
+ const obj = Object.create(WasmTropicalDualClifford.prototype);
1336
+ obj.__wbg_ptr = ptr;
1337
+ WasmTropicalDualCliffordFinalization.register(obj, obj.__wbg_ptr, obj);
1338
+ return obj;
1339
+ }
1340
+
1341
+ __destroy_into_raw() {
1342
+ const ptr = this.__wbg_ptr;
1343
+ this.__wbg_ptr = 0;
1344
+ WasmTropicalDualCliffordFinalization.unregister(this);
1345
+ return ptr;
1346
+ }
1347
+
1348
+ free() {
1349
+ const ptr = this.__destroy_into_raw();
1350
+ wasm.__wbg_wasmtropicaldualclifford_free(ptr, 0);
1351
+ }
1352
+ /**
1353
+ * Create a zero TDC object
1354
+ */
1355
+ constructor() {
1356
+ const ret = wasm.wasmtropicaldualclifford_new();
1357
+ this.__wbg_ptr = ret >>> 0;
1358
+ WasmTropicalDualCliffordFinalization.register(this, this.__wbg_ptr, this);
1359
+ return this;
1360
+ }
1361
+ /**
1362
+ * Create from logits (array of log-probabilities)
1363
+ * @param {Float64Array} logits
1364
+ * @returns {WasmTropicalDualClifford}
1365
+ */
1366
+ static fromLogits(logits) {
1367
+ const ptr0 = passArrayF64ToWasm0(logits, wasm.__wbindgen_malloc);
1368
+ const len0 = WASM_VECTOR_LEN;
1369
+ const ret = wasm.wasmtropicaldualclifford_fromLogits(ptr0, len0);
1370
+ return WasmTropicalDualClifford.__wrap(ret);
1371
+ }
1372
+ /**
1373
+ * Create random TDC for testing
1374
+ * @returns {WasmTropicalDualClifford}
1375
+ */
1376
+ static random() {
1377
+ const ret = wasm.wasmtropicaldualclifford_random();
1378
+ return WasmTropicalDualClifford.__wrap(ret);
1379
+ }
1380
+ /**
1381
+ * Create random TDC with specific scale
1382
+ * @param {number} scale
1383
+ * @returns {WasmTropicalDualClifford}
1384
+ */
1385
+ static randomWithScale(scale) {
1386
+ const ret = wasm.wasmtropicaldualclifford_randomWithScale(scale);
1387
+ return WasmTropicalDualClifford.__wrap(ret);
1388
+ }
1389
+ /**
1390
+ * Check if TDC is zero
1391
+ * @returns {boolean}
1392
+ */
1393
+ isZero() {
1394
+ const ret = wasm.wasmtropicaldualclifford_isZero(this.__wbg_ptr);
1395
+ return ret !== 0;
1396
+ }
1397
+ /**
1398
+ * Extract tropical features as array
1399
+ * @returns {Float64Array}
1400
+ */
1401
+ getTropicalFeatures() {
1402
+ const ret = wasm.wasmtropicaldualclifford_getTropicalFeatures(this.__wbg_ptr);
1403
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1404
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1405
+ return v1;
1406
+ }
1407
+ /**
1408
+ * Extract dual features as array of real parts
1409
+ * @returns {Float64Array}
1410
+ */
1411
+ getDualReals() {
1412
+ const ret = wasm.wasmtropicaldualclifford_getDualReals(this.__wbg_ptr);
1413
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1414
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1415
+ return v1;
1416
+ }
1417
+ /**
1418
+ * Extract dual features as array of dual parts (derivatives)
1419
+ * @returns {Float64Array}
1420
+ */
1421
+ getDualDerivatives() {
1422
+ const ret = wasm.wasmtropicaldualclifford_getDualDerivatives(this.__wbg_ptr);
1423
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1424
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1425
+ return v1;
1426
+ }
1427
+ /**
1428
+ * Get Clifford coefficients
1429
+ * @returns {Float64Array}
1430
+ */
1431
+ getCliffordCoefficients() {
1432
+ const ret = wasm.wasmtropicaldualclifford_getCliffordCoefficients(this.__wbg_ptr);
1433
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1434
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1435
+ return v1;
1436
+ }
1437
+ /**
1438
+ * Add two TDC objects
1439
+ * @param {WasmTropicalDualClifford} other
1440
+ * @returns {WasmTropicalDualClifford}
1441
+ */
1442
+ add(other) {
1443
+ _assertClass(other, WasmTropicalDualClifford);
1444
+ const ret = wasm.wasmtropicaldualclifford_add(this.__wbg_ptr, other.__wbg_ptr);
1445
+ return WasmTropicalDualClifford.__wrap(ret);
1446
+ }
1447
+ /**
1448
+ * Scale TDC object
1449
+ * @param {number} factor
1450
+ * @returns {WasmTropicalDualClifford}
1451
+ */
1452
+ scale(factor) {
1453
+ const ret = wasm.wasmtropicaldualclifford_scale(this.__wbg_ptr, factor);
1454
+ return WasmTropicalDualClifford.__wrap(ret);
1455
+ }
1456
+ /**
1457
+ * Compute fusion norm (combined measure across all systems)
1458
+ * @returns {number}
1459
+ */
1460
+ fusionNorm() {
1461
+ const ret = wasm.wasmtropicaldualclifford_fusionNorm(this.__wbg_ptr);
1462
+ return ret;
1463
+ }
1464
+ /**
1465
+ * Perform tropical attention operation
1466
+ * @param {Float64Array} keys
1467
+ * @param {Float64Array} values
1468
+ * @returns {Float64Array}
1469
+ */
1470
+ tropicalAttention(keys, values) {
1471
+ const ptr0 = passArrayF64ToWasm0(keys, wasm.__wbindgen_malloc);
1472
+ const len0 = WASM_VECTOR_LEN;
1473
+ const ptr1 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
1474
+ const len1 = WASM_VECTOR_LEN;
1475
+ const ret = wasm.wasmtropicaldualclifford_tropicalAttention(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1476
+ if (ret[3]) {
1477
+ throw takeFromExternrefTable0(ret[2]);
1478
+ }
1479
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1480
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1481
+ return v3;
1482
+ }
1483
+ /**
1484
+ * Extract geometric features using Clifford operations
1485
+ * @returns {Float64Array}
1486
+ */
1487
+ extractGeometricFeatures() {
1488
+ const ret = wasm.wasmtropicaldualclifford_extractGeometricFeatures(this.__wbg_ptr);
1489
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1490
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1491
+ return v1;
1492
+ }
1493
+ }
1494
+ if (Symbol.dispose) WasmTropicalDualClifford.prototype[Symbol.dispose] = WasmTropicalDualClifford.prototype.free;
1495
+
1496
+ const WasmTropicalNumberFinalization = (typeof FinalizationRegistry === 'undefined')
1497
+ ? { register: () => {}, unregister: () => {} }
1498
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalnumber_free(ptr >>> 0, 1));
1499
+ /**
1500
+ * WASM wrapper for TropicalNumber
1501
+ */
1502
+ export class WasmTropicalNumber {
1503
+
1504
+ static __wrap(ptr) {
1505
+ ptr = ptr >>> 0;
1506
+ const obj = Object.create(WasmTropicalNumber.prototype);
1507
+ obj.__wbg_ptr = ptr;
1508
+ WasmTropicalNumberFinalization.register(obj, obj.__wbg_ptr, obj);
1509
+ return obj;
1510
+ }
1511
+
1512
+ __destroy_into_raw() {
1513
+ const ptr = this.__wbg_ptr;
1514
+ this.__wbg_ptr = 0;
1515
+ WasmTropicalNumberFinalization.unregister(this);
1516
+ return ptr;
1517
+ }
1518
+
1519
+ free() {
1520
+ const ptr = this.__destroy_into_raw();
1521
+ wasm.__wbg_wasmtropicalnumber_free(ptr, 0);
1522
+ }
1523
+ /**
1524
+ * Create a new tropical number from a regular number
1525
+ * @param {number} value
1526
+ */
1527
+ constructor(value) {
1528
+ const ret = wasm.wasmtropicalnumber_fromLogProb(value);
1529
+ this.__wbg_ptr = ret >>> 0;
1530
+ WasmTropicalNumberFinalization.register(this, this.__wbg_ptr, this);
1531
+ return this;
1532
+ }
1533
+ /**
1534
+ * Create tropical zero (negative infinity)
1535
+ * @returns {WasmTropicalNumber}
1536
+ */
1537
+ static zero() {
1538
+ const ret = wasm.wasmtropicalnumber_zero();
1539
+ return WasmTropicalNumber.__wrap(ret);
1540
+ }
1541
+ /**
1542
+ * Create tropical one (regular zero)
1543
+ * @returns {WasmTropicalNumber}
1544
+ */
1545
+ static one() {
1546
+ const ret = wasm.wasmtropicalnumber_one();
1547
+ return WasmTropicalNumber.__wrap(ret);
1548
+ }
1549
+ /**
1550
+ * Create from log probability
1551
+ * @param {number} log_p
1552
+ * @returns {WasmTropicalNumber}
1553
+ */
1554
+ static fromLogProb(log_p) {
1555
+ const ret = wasm.wasmtropicalnumber_fromLogProb(log_p);
1556
+ return WasmTropicalNumber.__wrap(ret);
1557
+ }
1558
+ /**
1559
+ * Get the underlying value
1560
+ * @returns {number}
1561
+ */
1562
+ getValue() {
1563
+ const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
1564
+ return ret;
1565
+ }
1566
+ /**
1567
+ * Convert to probability (via exp)
1568
+ * @returns {number}
1569
+ */
1570
+ toProb() {
1571
+ const ret = wasm.wasmtropicalnumber_toProb(this.__wbg_ptr);
1572
+ return ret;
1573
+ }
1574
+ /**
1575
+ * Check if this is tropical zero (negative infinity)
1576
+ * @returns {boolean}
1577
+ */
1578
+ isZero() {
1579
+ const ret = wasm.wasmtropicalnumber_isZero(this.__wbg_ptr);
1580
+ return ret !== 0;
1581
+ }
1582
+ /**
1583
+ * Check if this is tropical one (zero)
1584
+ * @returns {boolean}
1585
+ */
1586
+ isOne() {
1587
+ const ret = wasm.wasmtropicalnumber_isOne(this.__wbg_ptr);
1588
+ return ret !== 0;
1589
+ }
1590
+ /**
1591
+ * Check if this is infinite
1592
+ * @returns {boolean}
1593
+ */
1594
+ isInfinity() {
1595
+ const ret = wasm.wasmtropicalnumber_isInfinity(this.__wbg_ptr);
1596
+ return ret !== 0;
1597
+ }
1598
+ /**
1599
+ * Tropical addition (max operation)
1600
+ * @param {WasmTropicalNumber} other
1601
+ * @returns {WasmTropicalNumber}
1602
+ */
1603
+ tropicalAdd(other) {
1604
+ _assertClass(other, WasmTropicalNumber);
1605
+ const ret = wasm.wasmtropicalnumber_add(this.__wbg_ptr, other.__wbg_ptr);
1606
+ return WasmTropicalNumber.__wrap(ret);
1607
+ }
1608
+ /**
1609
+ * Tropical multiplication (addition)
1610
+ * @param {WasmTropicalNumber} other
1611
+ * @returns {WasmTropicalNumber}
1612
+ */
1613
+ tropicalMul(other) {
1614
+ _assertClass(other, WasmTropicalNumber);
1615
+ const ret = wasm.wasmtropicalnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
1616
+ return WasmTropicalNumber.__wrap(ret);
1617
+ }
1618
+ /**
1619
+ * Tropical power (scalar multiplication)
1620
+ * @param {number} n
1621
+ * @returns {WasmTropicalNumber}
1622
+ */
1623
+ tropicalPow(n) {
1624
+ const ret = wasm.wasmtropicalnumber_tropicalPow(this.__wbg_ptr, n);
1625
+ return WasmTropicalNumber.__wrap(ret);
1626
+ }
1627
+ /**
1628
+ * Standard addition (for convenience)
1629
+ * @param {WasmTropicalNumber} other
1630
+ * @returns {WasmTropicalNumber}
1631
+ */
1632
+ add(other) {
1633
+ _assertClass(other, WasmTropicalNumber);
1634
+ const ret = wasm.wasmtropicalnumber_add(this.__wbg_ptr, other.__wbg_ptr);
1635
+ return WasmTropicalNumber.__wrap(ret);
1636
+ }
1637
+ /**
1638
+ * Standard multiplication (for convenience)
1639
+ * @param {WasmTropicalNumber} other
1640
+ * @returns {WasmTropicalNumber}
1641
+ */
1642
+ mul(other) {
1643
+ _assertClass(other, WasmTropicalNumber);
1644
+ const ret = wasm.wasmtropicalnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
1645
+ return WasmTropicalNumber.__wrap(ret);
1646
+ }
1647
+ /**
1648
+ * Negation
1649
+ * @returns {WasmTropicalNumber}
1650
+ */
1651
+ neg() {
1652
+ const ret = wasm.wasmtropicalnumber_neg(this.__wbg_ptr);
1653
+ return WasmTropicalNumber.__wrap(ret);
1654
+ }
1655
+ }
1656
+ if (Symbol.dispose) WasmTropicalNumber.prototype[Symbol.dispose] = WasmTropicalNumber.prototype.free;
1657
+
436
1658
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
437
1659
 
438
1660
  async function __wbg_load(module, imports) {
@@ -471,9 +1693,27 @@ async function __wbg_load(module, imports) {
471
1693
  function __wbg_get_imports() {
472
1694
  const imports = {};
473
1695
  imports.wbg = {};
474
- imports.wbg.__wbg_log_21b8c47c8527c444 = function(arg0, arg1) {
1696
+ imports.wbg.__wbg_apply_dc50eb58583d2a57 = function() { return handleError(function (arg0, arg1, arg2) {
1697
+ const ret = arg0.apply(arg1, arg2);
1698
+ return ret;
1699
+ }, arguments) };
1700
+ imports.wbg.__wbg_log_7d5bd3f05c55b7ed = function(arg0, arg1) {
475
1701
  console.log(getStringFromWasm0(arg0, arg1));
476
1702
  };
1703
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
1704
+ const ret = new Array();
1705
+ return ret;
1706
+ };
1707
+ imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
1708
+ const ret = arg0.push(arg1);
1709
+ return ret;
1710
+ };
1711
+ imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
1712
+ const obj = arg1;
1713
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1714
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1715
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1716
+ };
477
1717
  imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
478
1718
  throw new Error(getStringFromWasm0(arg0, arg1));
479
1719
  };
@@ -482,8 +1722,13 @@ function __wbg_get_imports() {
482
1722
  const ret = getStringFromWasm0(arg0, arg1);
483
1723
  return ret;
484
1724
  };
1725
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1726
+ // Cast intrinsic for `F64 -> Externref`.
1727
+ const ret = arg0;
1728
+ return ret;
1729
+ };
485
1730
  imports.wbg.__wbindgen_init_externref_table = function() {
486
- const table = wasm.__wbindgen_export_0;
1731
+ const table = wasm.__wbindgen_export_2;
487
1732
  const offset = table.grow(4);
488
1733
  table.set(0, undefined);
489
1734
  table.set(offset + 0, undefined);
@@ -503,6 +1748,7 @@ function __wbg_init_memory(imports, memory) {
503
1748
  function __wbg_finalize_init(instance, module) {
504
1749
  wasm = instance.exports;
505
1750
  __wbg_init.__wbindgen_wasm_module = module;
1751
+ cachedDataViewMemory0 = null;
506
1752
  cachedFloat64ArrayMemory0 = null;
507
1753
  cachedUint8ArrayMemory0 = null;
508
1754