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