@justinelliottcobb/amari-wasm 0.9.9 → 0.10.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/README.md +24 -1
- package/amari_wasm.d.ts +292 -22
- package/amari_wasm.js +703 -83
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +2 -2
package/amari_wasm.js
CHANGED
|
@@ -222,39 +222,19 @@ function getArrayF64FromWasm0(ptr, len) {
|
|
|
222
222
|
ptr = ptr >>> 0;
|
|
223
223
|
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
let cachedUint32ArrayMemory0 = null;
|
|
233
|
-
|
|
234
|
-
function getUint32ArrayMemory0() {
|
|
235
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
236
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
237
|
-
}
|
|
238
|
-
return cachedUint32ArrayMemory0;
|
|
225
|
+
/**
|
|
226
|
+
* Initialize the WASM module
|
|
227
|
+
*/
|
|
228
|
+
export function init() {
|
|
229
|
+
wasm.init();
|
|
239
230
|
}
|
|
240
231
|
|
|
241
|
-
function
|
|
242
|
-
const ptr = malloc(arg.length *
|
|
243
|
-
|
|
232
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
233
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
234
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
244
235
|
WASM_VECTOR_LEN = arg.length;
|
|
245
236
|
return ptr;
|
|
246
237
|
}
|
|
247
|
-
|
|
248
|
-
function takeFromExternrefTable0(idx) {
|
|
249
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
250
|
-
wasm.__externref_table_dealloc(idx);
|
|
251
|
-
return value;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
255
|
-
ptr = ptr >>> 0;
|
|
256
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
257
|
-
}
|
|
258
238
|
/**
|
|
259
239
|
* Initialize the enumerative geometry module
|
|
260
240
|
*/
|
|
@@ -262,21 +242,22 @@ export function initEnumerative() {
|
|
|
262
242
|
wasm.initEnumerative();
|
|
263
243
|
}
|
|
264
244
|
|
|
265
|
-
function passArrayF64ToWasm0(arg, malloc) {
|
|
266
|
-
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
267
|
-
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
268
|
-
WASM_VECTOR_LEN = arg.length;
|
|
269
|
-
return ptr;
|
|
270
|
-
}
|
|
271
245
|
/**
|
|
272
|
-
*
|
|
273
|
-
* @
|
|
246
|
+
* Calculate light deflection angle for photon grazing massive object
|
|
247
|
+
* @param {number} impact_parameter
|
|
248
|
+
* @param {number} mass
|
|
249
|
+
* @returns {number}
|
|
274
250
|
*/
|
|
275
|
-
export function
|
|
276
|
-
const ret = wasm.
|
|
277
|
-
return ret
|
|
251
|
+
export function light_deflection_angle(impact_parameter, mass) {
|
|
252
|
+
const ret = wasm.light_deflection_angle(impact_parameter, mass);
|
|
253
|
+
return ret;
|
|
278
254
|
}
|
|
279
255
|
|
|
256
|
+
function takeFromExternrefTable0(idx) {
|
|
257
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
258
|
+
wasm.__externref_table_dealloc(idx);
|
|
259
|
+
return value;
|
|
260
|
+
}
|
|
280
261
|
/**
|
|
281
262
|
* Convert velocity to Lorentz factor
|
|
282
263
|
* @param {number} velocity_magnitude
|
|
@@ -290,17 +271,6 @@ export function velocity_to_gamma(velocity_magnitude) {
|
|
|
290
271
|
return ret[0];
|
|
291
272
|
}
|
|
292
273
|
|
|
293
|
-
/**
|
|
294
|
-
* Calculate light deflection angle for photon grazing massive object
|
|
295
|
-
* @param {number} impact_parameter
|
|
296
|
-
* @param {number} mass
|
|
297
|
-
* @returns {number}
|
|
298
|
-
*/
|
|
299
|
-
export function light_deflection_angle(impact_parameter, mass) {
|
|
300
|
-
const ret = wasm.light_deflection_angle(impact_parameter, mass);
|
|
301
|
-
return ret;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
274
|
/**
|
|
305
275
|
* Convert Lorentz factor to velocity
|
|
306
276
|
* @param {number} gamma
|
|
@@ -315,10 +285,12 @@ export function gamma_to_velocity(gamma) {
|
|
|
315
285
|
}
|
|
316
286
|
|
|
317
287
|
/**
|
|
318
|
-
*
|
|
288
|
+
* Validate that this module loaded correctly
|
|
289
|
+
* @returns {boolean}
|
|
319
290
|
*/
|
|
320
|
-
export function
|
|
321
|
-
wasm.
|
|
291
|
+
export function validate_relativistic_module() {
|
|
292
|
+
const ret = wasm.validate_relativistic_module();
|
|
293
|
+
return ret !== 0;
|
|
322
294
|
}
|
|
323
295
|
|
|
324
296
|
/**
|
|
@@ -328,6 +300,94 @@ export function initFusion() {
|
|
|
328
300
|
wasm.initFusion();
|
|
329
301
|
}
|
|
330
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Integrate a JavaScript function over an interval
|
|
305
|
+
*
|
|
306
|
+
* This function provides numerical integration capabilities to JavaScript.
|
|
307
|
+
*
|
|
308
|
+
* # Arguments
|
|
309
|
+
* * `f` - JavaScript function to integrate (must accept a number and return a number)
|
|
310
|
+
* * `a` - Lower bound of integration
|
|
311
|
+
* * `b` - Upper bound of integration
|
|
312
|
+
* * `points` - Number of sample points to use
|
|
313
|
+
* * `method` - Integration method to use
|
|
314
|
+
*
|
|
315
|
+
* # Returns
|
|
316
|
+
* Approximate value of the integral ∫_a^b f(x) dx
|
|
317
|
+
* @param {Function} f
|
|
318
|
+
* @param {number} a
|
|
319
|
+
* @param {number} b
|
|
320
|
+
* @param {number} points
|
|
321
|
+
* @param {WasmIntegrationMethod} method
|
|
322
|
+
* @returns {number}
|
|
323
|
+
*/
|
|
324
|
+
export function integrate(f, a, b, points, method) {
|
|
325
|
+
const ret = wasm.integrate(f, a, b, points, method);
|
|
326
|
+
if (ret[2]) {
|
|
327
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
328
|
+
}
|
|
329
|
+
return ret[0];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Compute expectation E[f(X)] for uniform distribution on [a, b]
|
|
334
|
+
*
|
|
335
|
+
* # Arguments
|
|
336
|
+
* * `f` - JavaScript function (must accept a number and return a number)
|
|
337
|
+
* * `a` - Lower bound
|
|
338
|
+
* * `b` - Upper bound
|
|
339
|
+
* * `samples` - Number of Monte Carlo samples
|
|
340
|
+
* @param {Function} f
|
|
341
|
+
* @param {number} a
|
|
342
|
+
* @param {number} b
|
|
343
|
+
* @param {number} samples
|
|
344
|
+
* @returns {number}
|
|
345
|
+
*/
|
|
346
|
+
export function expectation(f, a, b, samples) {
|
|
347
|
+
const ret = wasm.expectation(f, a, b, samples);
|
|
348
|
+
if (ret[2]) {
|
|
349
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
350
|
+
}
|
|
351
|
+
return ret[0];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function _assertClass(instance, klass) {
|
|
355
|
+
if (!(instance instanceof klass)) {
|
|
356
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Compute KL divergence D_KL(P||Q) between two distributions
|
|
361
|
+
*
|
|
362
|
+
* # Arguments
|
|
363
|
+
* * `p_density` - First distribution
|
|
364
|
+
* * `q_density` - Second distribution
|
|
365
|
+
* * `p_params` - Parameters for P
|
|
366
|
+
* * `q_params` - Parameters for Q
|
|
367
|
+
* * `sample_points` - Points to evaluate at
|
|
368
|
+
* @param {WasmParametricDensity} p_density
|
|
369
|
+
* @param {WasmParametricDensity} q_density
|
|
370
|
+
* @param {Float64Array} p_params
|
|
371
|
+
* @param {Float64Array} q_params
|
|
372
|
+
* @param {Float64Array} sample_points
|
|
373
|
+
* @returns {number}
|
|
374
|
+
*/
|
|
375
|
+
export function klDivergence(p_density, q_density, p_params, q_params, sample_points) {
|
|
376
|
+
_assertClass(p_density, WasmParametricDensity);
|
|
377
|
+
_assertClass(q_density, WasmParametricDensity);
|
|
378
|
+
const ptr0 = passArrayF64ToWasm0(p_params, wasm.__wbindgen_malloc);
|
|
379
|
+
const len0 = WASM_VECTOR_LEN;
|
|
380
|
+
const ptr1 = passArrayF64ToWasm0(q_params, wasm.__wbindgen_malloc);
|
|
381
|
+
const len1 = WASM_VECTOR_LEN;
|
|
382
|
+
const ptr2 = passArrayF64ToWasm0(sample_points, wasm.__wbindgen_malloc);
|
|
383
|
+
const len2 = WASM_VECTOR_LEN;
|
|
384
|
+
const ret = wasm.klDivergence(p_density.__wbg_ptr, q_density.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
385
|
+
if (ret[2]) {
|
|
386
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
387
|
+
}
|
|
388
|
+
return ret[0];
|
|
389
|
+
}
|
|
390
|
+
|
|
331
391
|
/**
|
|
332
392
|
* Initialize the automata module
|
|
333
393
|
*/
|
|
@@ -335,18 +395,66 @@ export function initAutomata() {
|
|
|
335
395
|
wasm.initAutomata();
|
|
336
396
|
}
|
|
337
397
|
|
|
398
|
+
let cachedUint32ArrayMemory0 = null;
|
|
399
|
+
|
|
400
|
+
function getUint32ArrayMemory0() {
|
|
401
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
402
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
403
|
+
}
|
|
404
|
+
return cachedUint32ArrayMemory0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
408
|
+
ptr = ptr >>> 0;
|
|
409
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
410
|
+
}
|
|
411
|
+
|
|
338
412
|
function getArrayU8FromWasm0(ptr, len) {
|
|
339
413
|
ptr = ptr >>> 0;
|
|
340
414
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
341
415
|
}
|
|
342
|
-
|
|
343
|
-
|
|
416
|
+
|
|
417
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
418
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
419
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
420
|
+
WASM_VECTOR_LEN = arg.length;
|
|
421
|
+
return ptr;
|
|
422
|
+
}
|
|
423
|
+
function wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2) {
|
|
424
|
+
wasm.wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2);
|
|
344
425
|
}
|
|
345
426
|
|
|
346
|
-
function
|
|
347
|
-
wasm.
|
|
427
|
+
function wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2, arg3) {
|
|
428
|
+
wasm.wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2, arg3);
|
|
348
429
|
}
|
|
349
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Integration methods available in WASM
|
|
433
|
+
* @enum {0 | 1 | 2 | 3 | 4}
|
|
434
|
+
*/
|
|
435
|
+
export const WasmIntegrationMethod = Object.freeze({
|
|
436
|
+
/**
|
|
437
|
+
* Riemann sum approximation
|
|
438
|
+
*/
|
|
439
|
+
Riemann: 0, "0": "Riemann",
|
|
440
|
+
/**
|
|
441
|
+
* Monte Carlo integration
|
|
442
|
+
*/
|
|
443
|
+
MonteCarlo: 1, "1": "MonteCarlo",
|
|
444
|
+
/**
|
|
445
|
+
* Trapezoidal rule
|
|
446
|
+
*/
|
|
447
|
+
Trapezoidal: 2, "2": "Trapezoidal",
|
|
448
|
+
/**
|
|
449
|
+
* Simpson's rule
|
|
450
|
+
*/
|
|
451
|
+
Simpson: 3, "3": "Simpson",
|
|
452
|
+
/**
|
|
453
|
+
* Adaptive quadrature
|
|
454
|
+
*/
|
|
455
|
+
Adaptive: 4, "4": "Adaptive",
|
|
456
|
+
});
|
|
457
|
+
|
|
350
458
|
const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
351
459
|
? { register: () => {}, unregister: () => {} }
|
|
352
460
|
: new FinalizationRegistry(ptr => wasm.__wbg_autodiff_free(ptr >>> 0, 1));
|
|
@@ -1825,6 +1933,60 @@ export class WasmCommunity {
|
|
|
1825
1933
|
}
|
|
1826
1934
|
if (Symbol.dispose) WasmCommunity.prototype[Symbol.dispose] = WasmCommunity.prototype.free;
|
|
1827
1935
|
|
|
1936
|
+
const WasmCountingMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1937
|
+
? { register: () => {}, unregister: () => {} }
|
|
1938
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcountingmeasure_free(ptr >>> 0, 1));
|
|
1939
|
+
/**
|
|
1940
|
+
* WASM wrapper for counting measure
|
|
1941
|
+
*
|
|
1942
|
+
* The counting measure assigns to each set the number of elements it contains.
|
|
1943
|
+
*/
|
|
1944
|
+
export class WasmCountingMeasure {
|
|
1945
|
+
|
|
1946
|
+
__destroy_into_raw() {
|
|
1947
|
+
const ptr = this.__wbg_ptr;
|
|
1948
|
+
this.__wbg_ptr = 0;
|
|
1949
|
+
WasmCountingMeasureFinalization.unregister(this);
|
|
1950
|
+
return ptr;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
free() {
|
|
1954
|
+
const ptr = this.__destroy_into_raw();
|
|
1955
|
+
wasm.__wbg_wasmcountingmeasure_free(ptr, 0);
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Check if a set is measurable under counting measure
|
|
1959
|
+
* (all sets are measurable under counting measure)
|
|
1960
|
+
* @returns {boolean}
|
|
1961
|
+
*/
|
|
1962
|
+
isMeasurable() {
|
|
1963
|
+
const ret = wasm.wasmcountingmeasure_isMeasurable(this.__wbg_ptr);
|
|
1964
|
+
return ret !== 0;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Measure a finite set (returns its cardinality)
|
|
1968
|
+
*
|
|
1969
|
+
* # Arguments
|
|
1970
|
+
* * `set_size` - The number of elements in the set
|
|
1971
|
+
* @param {number} set_size
|
|
1972
|
+
* @returns {number}
|
|
1973
|
+
*/
|
|
1974
|
+
measureFiniteSet(set_size) {
|
|
1975
|
+
const ret = wasm.wasmcountingmeasure_measureFiniteSet(this.__wbg_ptr, set_size);
|
|
1976
|
+
return ret;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Create a new counting measure
|
|
1980
|
+
*/
|
|
1981
|
+
constructor() {
|
|
1982
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
1983
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1984
|
+
WasmCountingMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
1985
|
+
return this;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
if (Symbol.dispose) WasmCountingMeasure.prototype[Symbol.dispose] = WasmCountingMeasure.prototype.free;
|
|
1989
|
+
|
|
1828
1990
|
const WasmDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1829
1991
|
? { register: () => {}, unregister: () => {} }
|
|
1830
1992
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdualnumber_free(ptr >>> 0, 1));
|
|
@@ -2329,6 +2491,83 @@ export class WasmFisherInformationMatrix {
|
|
|
2329
2491
|
}
|
|
2330
2492
|
if (Symbol.dispose) WasmFisherInformationMatrix.prototype[Symbol.dispose] = WasmFisherInformationMatrix.prototype.free;
|
|
2331
2493
|
|
|
2494
|
+
const WasmFisherMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2495
|
+
? { register: () => {}, unregister: () => {} }
|
|
2496
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfishermeasure_free(ptr >>> 0, 1));
|
|
2497
|
+
/**
|
|
2498
|
+
* Fisher-Riemannian geometry on statistical manifolds
|
|
2499
|
+
*/
|
|
2500
|
+
export class WasmFisherMeasure {
|
|
2501
|
+
|
|
2502
|
+
static __wrap(ptr) {
|
|
2503
|
+
ptr = ptr >>> 0;
|
|
2504
|
+
const obj = Object.create(WasmFisherMeasure.prototype);
|
|
2505
|
+
obj.__wbg_ptr = ptr;
|
|
2506
|
+
WasmFisherMeasureFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2507
|
+
return obj;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
__destroy_into_raw() {
|
|
2511
|
+
const ptr = this.__wbg_ptr;
|
|
2512
|
+
this.__wbg_ptr = 0;
|
|
2513
|
+
WasmFisherMeasureFinalization.unregister(this);
|
|
2514
|
+
return ptr;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
free() {
|
|
2518
|
+
const ptr = this.__destroy_into_raw();
|
|
2519
|
+
wasm.__wbg_wasmfishermeasure_free(ptr, 0);
|
|
2520
|
+
}
|
|
2521
|
+
/**
|
|
2522
|
+
* Create Fisher measure from a parametric density
|
|
2523
|
+
* @param {WasmParametricDensity} density
|
|
2524
|
+
* @returns {WasmFisherMeasure}
|
|
2525
|
+
*/
|
|
2526
|
+
static fromDensity(density) {
|
|
2527
|
+
_assertClass(density, WasmParametricDensity);
|
|
2528
|
+
var ptr0 = density.__destroy_into_raw();
|
|
2529
|
+
const ret = wasm.wasmfishermeasure_fromDensity(ptr0);
|
|
2530
|
+
return WasmFisherMeasure.__wrap(ret);
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Compute the Fisher information metric at parameter point θ
|
|
2534
|
+
* @param {Float64Array} data
|
|
2535
|
+
* @param {Float64Array} params
|
|
2536
|
+
* @returns {Float64Array}
|
|
2537
|
+
*/
|
|
2538
|
+
fisherMetric(data, params) {
|
|
2539
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2541
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
2542
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2543
|
+
const ret = wasm.wasmfishermeasure_fisherMetric(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2544
|
+
if (ret[3]) {
|
|
2545
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2546
|
+
}
|
|
2547
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2548
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2549
|
+
return v3;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Compute the Riemannian volume element √det(g(θ))
|
|
2553
|
+
* @param {Float64Array} data
|
|
2554
|
+
* @param {Float64Array} params
|
|
2555
|
+
* @returns {number}
|
|
2556
|
+
*/
|
|
2557
|
+
volumeElement(data, params) {
|
|
2558
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2559
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2560
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
2561
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2562
|
+
const ret = wasm.wasmfishermeasure_volumeElement(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2563
|
+
if (ret[2]) {
|
|
2564
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2565
|
+
}
|
|
2566
|
+
return ret[0];
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
if (Symbol.dispose) WasmFisherMeasure.prototype[Symbol.dispose] = WasmFisherMeasure.prototype.free;
|
|
2570
|
+
|
|
2332
2571
|
const WasmFourVelocityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2333
2572
|
? { register: () => {}, unregister: () => {} }
|
|
2334
2573
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfourvelocity_free(ptr >>> 0, 1));
|
|
@@ -3031,14 +3270,6 @@ export class WasmGpuOptimizer {
|
|
|
3031
3270
|
const ret = wasm.wasmgpuoptimizer_optimizeBatch(this.__wbg_ptr, ptr0, len0, problem_size, num_problems, max_iterations, tolerance);
|
|
3032
3271
|
return ret;
|
|
3033
3272
|
}
|
|
3034
|
-
/**
|
|
3035
|
-
* Check if GPU acceleration is available
|
|
3036
|
-
* @returns {boolean}
|
|
3037
|
-
*/
|
|
3038
|
-
isGpuAvailable() {
|
|
3039
|
-
const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
|
|
3040
|
-
return ret !== 0;
|
|
3041
|
-
}
|
|
3042
3273
|
/**
|
|
3043
3274
|
* Optimize a quadratic function with GPU acceleration
|
|
3044
3275
|
* @param {Float64Array} coefficients
|
|
@@ -3055,11 +3286,19 @@ export class WasmGpuOptimizer {
|
|
|
3055
3286
|
const ret = wasm.wasmgpuoptimizer_optimizeQuadraticGpu(this.__wbg_ptr, ptr0, len0, ptr1, len1, max_iterations, tolerance);
|
|
3056
3287
|
return ret;
|
|
3057
3288
|
}
|
|
3289
|
+
/**
|
|
3290
|
+
* Check if GPU acceleration is available
|
|
3291
|
+
* @returns {boolean}
|
|
3292
|
+
*/
|
|
3293
|
+
isGpuAvailable() {
|
|
3294
|
+
const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
|
|
3295
|
+
return ret !== 0;
|
|
3296
|
+
}
|
|
3058
3297
|
/**
|
|
3059
3298
|
* Create a new GPU optimizer
|
|
3060
3299
|
*/
|
|
3061
3300
|
constructor() {
|
|
3062
|
-
const ret = wasm.
|
|
3301
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
3063
3302
|
this.__wbg_ptr = ret >>> 0;
|
|
3064
3303
|
WasmGpuOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
3065
3304
|
return this;
|
|
@@ -3195,6 +3434,89 @@ export class WasmInverseCADesigner {
|
|
|
3195
3434
|
}
|
|
3196
3435
|
if (Symbol.dispose) WasmInverseCADesigner.prototype[Symbol.dispose] = WasmInverseCADesigner.prototype.free;
|
|
3197
3436
|
|
|
3437
|
+
const WasmLebesgueMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3438
|
+
? { register: () => {}, unregister: () => {} }
|
|
3439
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlebesguemeasure_free(ptr >>> 0, 1));
|
|
3440
|
+
/**
|
|
3441
|
+
* WASM wrapper for Lebesgue measure
|
|
3442
|
+
*
|
|
3443
|
+
* The Lebesgue measure generalizes the notion of length, area, and volume
|
|
3444
|
+
* to higher dimensions and more complex sets.
|
|
3445
|
+
*/
|
|
3446
|
+
export class WasmLebesgueMeasure {
|
|
3447
|
+
|
|
3448
|
+
__destroy_into_raw() {
|
|
3449
|
+
const ptr = this.__wbg_ptr;
|
|
3450
|
+
this.__wbg_ptr = 0;
|
|
3451
|
+
WasmLebesgueMeasureFinalization.unregister(this);
|
|
3452
|
+
return ptr;
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
free() {
|
|
3456
|
+
const ptr = this.__destroy_into_raw();
|
|
3457
|
+
wasm.__wbg_wasmlebesguemeasure_free(ptr, 0);
|
|
3458
|
+
}
|
|
3459
|
+
/**
|
|
3460
|
+
* Compute the measure of a box (hyper-rectangle) with given side lengths
|
|
3461
|
+
* @param {Float64Array} sides
|
|
3462
|
+
* @returns {number}
|
|
3463
|
+
*/
|
|
3464
|
+
measureBox(sides) {
|
|
3465
|
+
const ptr0 = passArrayF64ToWasm0(sides, wasm.__wbindgen_malloc);
|
|
3466
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3467
|
+
const ret = wasm.wasmlebesguemeasure_measureBox(this.__wbg_ptr, ptr0, len0);
|
|
3468
|
+
if (ret[2]) {
|
|
3469
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3470
|
+
}
|
|
3471
|
+
return ret[0];
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Get the dimension of this measure
|
|
3475
|
+
* @returns {number}
|
|
3476
|
+
*/
|
|
3477
|
+
getDimension() {
|
|
3478
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
3479
|
+
return ret >>> 0;
|
|
3480
|
+
}
|
|
3481
|
+
/**
|
|
3482
|
+
* Compute the measure of an interval [a, b]
|
|
3483
|
+
*
|
|
3484
|
+
* For 1D: returns length (b - a)
|
|
3485
|
+
* For higher dimensions: returns the product of interval lengths
|
|
3486
|
+
* @param {Float64Array} lower
|
|
3487
|
+
* @param {Float64Array} upper
|
|
3488
|
+
* @returns {number}
|
|
3489
|
+
*/
|
|
3490
|
+
measureInterval(lower, upper) {
|
|
3491
|
+
const ptr0 = passArrayF64ToWasm0(lower, wasm.__wbindgen_malloc);
|
|
3492
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3493
|
+
const ptr1 = passArrayF64ToWasm0(upper, wasm.__wbindgen_malloc);
|
|
3494
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3495
|
+
const ret = wasm.wasmlebesguemeasure_measureInterval(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
3496
|
+
if (ret[2]) {
|
|
3497
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3498
|
+
}
|
|
3499
|
+
return ret[0];
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Create a new Lebesgue measure for the specified dimension
|
|
3503
|
+
*
|
|
3504
|
+
* # Arguments
|
|
3505
|
+
* * `dimension` - The dimension of the space (1 for length, 2 for area, 3 for volume, etc.)
|
|
3506
|
+
* @param {number} dimension
|
|
3507
|
+
*/
|
|
3508
|
+
constructor(dimension) {
|
|
3509
|
+
const ret = wasm.wasmlebesguemeasure_new(dimension);
|
|
3510
|
+
if (ret[2]) {
|
|
3511
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3512
|
+
}
|
|
3513
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
3514
|
+
WasmLebesgueMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
3515
|
+
return this;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
if (Symbol.dispose) WasmLebesgueMeasure.prototype[Symbol.dispose] = WasmLebesgueMeasure.prototype.free;
|
|
3519
|
+
|
|
3198
3520
|
const WasmModuliSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3199
3521
|
? { register: () => {}, unregister: () => {} }
|
|
3200
3522
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmodulispace_free(ptr >>> 0, 1));
|
|
@@ -3253,7 +3575,7 @@ export class WasmModuliSpace {
|
|
|
3253
3575
|
* @returns {number}
|
|
3254
3576
|
*/
|
|
3255
3577
|
getGenus() {
|
|
3256
|
-
const ret = wasm.
|
|
3578
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
3257
3579
|
return ret >>> 0;
|
|
3258
3580
|
}
|
|
3259
3581
|
/**
|
|
@@ -3454,7 +3776,7 @@ export class WasmMultiObjectiveOptimizer {
|
|
|
3454
3776
|
* Create a new multi-objective optimizer
|
|
3455
3777
|
*/
|
|
3456
3778
|
constructor() {
|
|
3457
|
-
const ret = wasm.
|
|
3779
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
3458
3780
|
this.__wbg_ptr = ret >>> 0;
|
|
3459
3781
|
WasmMultiObjectiveOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
3460
3782
|
return this;
|
|
@@ -3964,6 +4286,220 @@ export class WasmOptimizationUtils {
|
|
|
3964
4286
|
}
|
|
3965
4287
|
if (Symbol.dispose) WasmOptimizationUtils.prototype[Symbol.dispose] = WasmOptimizationUtils.prototype.free;
|
|
3966
4288
|
|
|
4289
|
+
const WasmParametricDensityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4290
|
+
? { register: () => {}, unregister: () => {} }
|
|
4291
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmparametricdensity_free(ptr >>> 0, 1));
|
|
4292
|
+
/**
|
|
4293
|
+
* Parametric probability density families
|
|
4294
|
+
*/
|
|
4295
|
+
export class WasmParametricDensity {
|
|
4296
|
+
|
|
4297
|
+
static __wrap(ptr) {
|
|
4298
|
+
ptr = ptr >>> 0;
|
|
4299
|
+
const obj = Object.create(WasmParametricDensity.prototype);
|
|
4300
|
+
obj.__wbg_ptr = ptr;
|
|
4301
|
+
WasmParametricDensityFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4302
|
+
return obj;
|
|
4303
|
+
}
|
|
4304
|
+
|
|
4305
|
+
__destroy_into_raw() {
|
|
4306
|
+
const ptr = this.__wbg_ptr;
|
|
4307
|
+
this.__wbg_ptr = 0;
|
|
4308
|
+
WasmParametricDensityFinalization.unregister(this);
|
|
4309
|
+
return ptr;
|
|
4310
|
+
}
|
|
4311
|
+
|
|
4312
|
+
free() {
|
|
4313
|
+
const ptr = this.__destroy_into_raw();
|
|
4314
|
+
wasm.__wbg_wasmparametricdensity_free(ptr, 0);
|
|
4315
|
+
}
|
|
4316
|
+
/**
|
|
4317
|
+
* Create an Exponential density Exp(λ)
|
|
4318
|
+
* @returns {WasmParametricDensity}
|
|
4319
|
+
*/
|
|
4320
|
+
static exponential() {
|
|
4321
|
+
const ret = wasm.wasmparametricdensity_exponential();
|
|
4322
|
+
return WasmParametricDensity.__wrap(ret);
|
|
4323
|
+
}
|
|
4324
|
+
/**
|
|
4325
|
+
* Compute log-density log p(x|θ)
|
|
4326
|
+
* @param {number} x
|
|
4327
|
+
* @param {Float64Array} params
|
|
4328
|
+
* @returns {number}
|
|
4329
|
+
*/
|
|
4330
|
+
logDensity(x, params) {
|
|
4331
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
4332
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4333
|
+
const ret = wasm.wasmparametricdensity_logDensity(this.__wbg_ptr, x, ptr0, len0);
|
|
4334
|
+
if (ret[2]) {
|
|
4335
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4336
|
+
}
|
|
4337
|
+
return ret[0];
|
|
4338
|
+
}
|
|
4339
|
+
/**
|
|
4340
|
+
* Compute Fisher information matrix from data samples
|
|
4341
|
+
* @param {Float64Array} data
|
|
4342
|
+
* @param {Float64Array} params
|
|
4343
|
+
* @returns {Float64Array}
|
|
4344
|
+
*/
|
|
4345
|
+
fisherInformation(data, params) {
|
|
4346
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
4347
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4348
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
4349
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4350
|
+
const ret = wasm.wasmparametricdensity_fisherInformation(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
4351
|
+
if (ret[3]) {
|
|
4352
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4353
|
+
}
|
|
4354
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4355
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4356
|
+
return v3;
|
|
4357
|
+
}
|
|
4358
|
+
/**
|
|
4359
|
+
* Create a Cauchy density Cauchy(x₀, γ)
|
|
4360
|
+
* @returns {WasmParametricDensity}
|
|
4361
|
+
*/
|
|
4362
|
+
static cauchy() {
|
|
4363
|
+
const ret = wasm.wasmparametricdensity_cauchy();
|
|
4364
|
+
return WasmParametricDensity.__wrap(ret);
|
|
4365
|
+
}
|
|
4366
|
+
/**
|
|
4367
|
+
* Create a Laplace density Laplace(μ, b)
|
|
4368
|
+
* @returns {WasmParametricDensity}
|
|
4369
|
+
*/
|
|
4370
|
+
static laplace() {
|
|
4371
|
+
const ret = wasm.wasmparametricdensity_laplace();
|
|
4372
|
+
return WasmParametricDensity.__wrap(ret);
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* Evaluate density at point x with parameters
|
|
4376
|
+
*
|
|
4377
|
+
* # Arguments
|
|
4378
|
+
* * `x` - Point to evaluate
|
|
4379
|
+
* * `params` - Parameters (Gaussian: [μ, σ], Exponential: [λ], etc.)
|
|
4380
|
+
* @param {number} x
|
|
4381
|
+
* @param {Float64Array} params
|
|
4382
|
+
* @returns {number}
|
|
4383
|
+
*/
|
|
4384
|
+
evaluate(x, params) {
|
|
4385
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
4386
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4387
|
+
const ret = wasm.wasmparametricdensity_evaluate(this.__wbg_ptr, x, ptr0, len0);
|
|
4388
|
+
if (ret[2]) {
|
|
4389
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4390
|
+
}
|
|
4391
|
+
return ret[0];
|
|
4392
|
+
}
|
|
4393
|
+
/**
|
|
4394
|
+
* Create a Gaussian density N(μ, σ²)
|
|
4395
|
+
* @returns {WasmParametricDensity}
|
|
4396
|
+
*/
|
|
4397
|
+
static gaussian() {
|
|
4398
|
+
const ret = wasm.wasmparametricdensity_gaussian();
|
|
4399
|
+
return WasmParametricDensity.__wrap(ret);
|
|
4400
|
+
}
|
|
4401
|
+
/**
|
|
4402
|
+
* Compute numerical gradient ∇_θ p(x|θ)
|
|
4403
|
+
* @param {number} x
|
|
4404
|
+
* @param {Float64Array} params
|
|
4405
|
+
* @returns {Float64Array}
|
|
4406
|
+
*/
|
|
4407
|
+
gradient(x, params) {
|
|
4408
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
4409
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4410
|
+
const ret = wasm.wasmparametricdensity_gradient(this.__wbg_ptr, x, ptr0, len0);
|
|
4411
|
+
if (ret[3]) {
|
|
4412
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4413
|
+
}
|
|
4414
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4415
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4416
|
+
return v2;
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
if (Symbol.dispose) WasmParametricDensity.prototype[Symbol.dispose] = WasmParametricDensity.prototype.free;
|
|
4420
|
+
|
|
4421
|
+
const WasmProbabilityMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4422
|
+
? { register: () => {}, unregister: () => {} }
|
|
4423
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmprobabilitymeasure_free(ptr >>> 0, 1));
|
|
4424
|
+
/**
|
|
4425
|
+
* WASM wrapper for probability measures
|
|
4426
|
+
*
|
|
4427
|
+
* A probability measure assigns total measure 1 to the entire space.
|
|
4428
|
+
*/
|
|
4429
|
+
export class WasmProbabilityMeasure {
|
|
4430
|
+
|
|
4431
|
+
static __wrap(ptr) {
|
|
4432
|
+
ptr = ptr >>> 0;
|
|
4433
|
+
const obj = Object.create(WasmProbabilityMeasure.prototype);
|
|
4434
|
+
obj.__wbg_ptr = ptr;
|
|
4435
|
+
WasmProbabilityMeasureFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4436
|
+
return obj;
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4439
|
+
__destroy_into_raw() {
|
|
4440
|
+
const ptr = this.__wbg_ptr;
|
|
4441
|
+
this.__wbg_ptr = 0;
|
|
4442
|
+
WasmProbabilityMeasureFinalization.unregister(this);
|
|
4443
|
+
return ptr;
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
free() {
|
|
4447
|
+
const ptr = this.__destroy_into_raw();
|
|
4448
|
+
wasm.__wbg_wasmprobabilitymeasure_free(ptr, 0);
|
|
4449
|
+
}
|
|
4450
|
+
/**
|
|
4451
|
+
* Get a description of this probability measure
|
|
4452
|
+
* @returns {string}
|
|
4453
|
+
*/
|
|
4454
|
+
getDescription() {
|
|
4455
|
+
let deferred1_0;
|
|
4456
|
+
let deferred1_1;
|
|
4457
|
+
try {
|
|
4458
|
+
const ret = wasm.wasmprobabilitymeasure_getDescription(this.__wbg_ptr);
|
|
4459
|
+
deferred1_0 = ret[0];
|
|
4460
|
+
deferred1_1 = ret[1];
|
|
4461
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
4462
|
+
} finally {
|
|
4463
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* Compute P(X ∈ [a, b]) for uniform distribution
|
|
4468
|
+
* @param {number} a
|
|
4469
|
+
* @param {number} b
|
|
4470
|
+
* @param {number} lower
|
|
4471
|
+
* @param {number} upper
|
|
4472
|
+
* @returns {number}
|
|
4473
|
+
*/
|
|
4474
|
+
probabilityInterval(a, b, lower, upper) {
|
|
4475
|
+
const ret = wasm.wasmprobabilitymeasure_probabilityInterval(this.__wbg_ptr, a, b, lower, upper);
|
|
4476
|
+
return ret;
|
|
4477
|
+
}
|
|
4478
|
+
/**
|
|
4479
|
+
* Create a new uniform probability measure on [0, 1]
|
|
4480
|
+
*/
|
|
4481
|
+
constructor() {
|
|
4482
|
+
const ret = wasm.wasmprobabilitymeasure_new();
|
|
4483
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4484
|
+
WasmProbabilityMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
4485
|
+
return this;
|
|
4486
|
+
}
|
|
4487
|
+
/**
|
|
4488
|
+
* Create a uniform probability measure on [a, b]
|
|
4489
|
+
* @param {number} a
|
|
4490
|
+
* @param {number} b
|
|
4491
|
+
* @returns {WasmProbabilityMeasure}
|
|
4492
|
+
*/
|
|
4493
|
+
static uniform(a, b) {
|
|
4494
|
+
const ret = wasm.wasmprobabilitymeasure_uniform(a, b);
|
|
4495
|
+
if (ret[2]) {
|
|
4496
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4497
|
+
}
|
|
4498
|
+
return WasmProbabilityMeasure.__wrap(ret[0]);
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
if (Symbol.dispose) WasmProbabilityMeasure.prototype[Symbol.dispose] = WasmProbabilityMeasure.prototype.free;
|
|
4502
|
+
|
|
3967
4503
|
const WasmProjectiveSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3968
4504
|
? { register: () => {}, unregister: () => {} }
|
|
3969
4505
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmprojectivespace_free(ptr >>> 0, 1));
|
|
@@ -3988,7 +4524,7 @@ export class WasmProjectiveSpace {
|
|
|
3988
4524
|
* @returns {number}
|
|
3989
4525
|
*/
|
|
3990
4526
|
getDimension() {
|
|
3991
|
-
const ret = wasm.
|
|
4527
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
3992
4528
|
return ret >>> 0;
|
|
3993
4529
|
}
|
|
3994
4530
|
/**
|
|
@@ -4607,7 +5143,7 @@ export class WasmSimpleOptimizer {
|
|
|
4607
5143
|
* Create a new simple optimizer
|
|
4608
5144
|
*/
|
|
4609
5145
|
constructor() {
|
|
4610
|
-
const ret = wasm.
|
|
5146
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
4611
5147
|
this.__wbg_ptr = ret >>> 0;
|
|
4612
5148
|
WasmSimpleOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
4613
5149
|
return this;
|
|
@@ -4787,14 +5323,6 @@ export class WasmTrajectoryPoint {
|
|
|
4787
5323
|
const ptr = this.__destroy_into_raw();
|
|
4788
5324
|
wasm.__wbg_wasmtrajectorypoint_free(ptr, 0);
|
|
4789
5325
|
}
|
|
4790
|
-
/**
|
|
4791
|
-
* Get position
|
|
4792
|
-
* @returns {WasmSpacetimeVector}
|
|
4793
|
-
*/
|
|
4794
|
-
get position() {
|
|
4795
|
-
const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
|
|
4796
|
-
return WasmSpacetimeVector.__wrap(ret);
|
|
4797
|
-
}
|
|
4798
5326
|
/**
|
|
4799
5327
|
* Time coordinate
|
|
4800
5328
|
* @returns {number}
|
|
@@ -4810,6 +5338,14 @@ export class WasmTrajectoryPoint {
|
|
|
4810
5338
|
set time(arg0) {
|
|
4811
5339
|
wasm.__wbg_set_wasmtrajectorypoint_time(this.__wbg_ptr, arg0);
|
|
4812
5340
|
}
|
|
5341
|
+
/**
|
|
5342
|
+
* Get position
|
|
5343
|
+
* @returns {WasmSpacetimeVector}
|
|
5344
|
+
*/
|
|
5345
|
+
get position() {
|
|
5346
|
+
const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
|
|
5347
|
+
return WasmSpacetimeVector.__wrap(ret);
|
|
5348
|
+
}
|
|
4813
5349
|
}
|
|
4814
5350
|
if (Symbol.dispose) WasmTrajectoryPoint.prototype[Symbol.dispose] = WasmTrajectoryPoint.prototype.free;
|
|
4815
5351
|
|
|
@@ -5187,6 +5723,90 @@ export class WasmTropicalDualDistribution {
|
|
|
5187
5723
|
}
|
|
5188
5724
|
if (Symbol.dispose) WasmTropicalDualDistribution.prototype[Symbol.dispose] = WasmTropicalDualDistribution.prototype.free;
|
|
5189
5725
|
|
|
5726
|
+
const WasmTropicalMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5727
|
+
? { register: () => {}, unregister: () => {} }
|
|
5728
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalmeasure_free(ptr >>> 0, 1));
|
|
5729
|
+
/**
|
|
5730
|
+
* Tropical (max-plus) algebra operations for optimization
|
|
5731
|
+
*/
|
|
5732
|
+
export class WasmTropicalMeasure {
|
|
5733
|
+
|
|
5734
|
+
__destroy_into_raw() {
|
|
5735
|
+
const ptr = this.__wbg_ptr;
|
|
5736
|
+
this.__wbg_ptr = 0;
|
|
5737
|
+
WasmTropicalMeasureFinalization.unregister(this);
|
|
5738
|
+
return ptr;
|
|
5739
|
+
}
|
|
5740
|
+
|
|
5741
|
+
free() {
|
|
5742
|
+
const ptr = this.__destroy_into_raw();
|
|
5743
|
+
wasm.__wbg_wasmtropicalmeasure_free(ptr, 0);
|
|
5744
|
+
}
|
|
5745
|
+
/**
|
|
5746
|
+
* Tropical integration (supremum over region)
|
|
5747
|
+
* @param {Function} f
|
|
5748
|
+
* @param {number} a
|
|
5749
|
+
* @param {number} b
|
|
5750
|
+
* @param {number} samples
|
|
5751
|
+
* @returns {number}
|
|
5752
|
+
*/
|
|
5753
|
+
tropicalIntegrate(f, a, b, samples) {
|
|
5754
|
+
const ret = wasm.wasmtropicalmeasure_tropicalIntegrate(this.__wbg_ptr, f, a, b, samples);
|
|
5755
|
+
if (ret[2]) {
|
|
5756
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5757
|
+
}
|
|
5758
|
+
return ret[0];
|
|
5759
|
+
}
|
|
5760
|
+
/**
|
|
5761
|
+
* Create a new tropical measure
|
|
5762
|
+
*/
|
|
5763
|
+
constructor() {
|
|
5764
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
5765
|
+
this.__wbg_ptr = ret >>> 0;
|
|
5766
|
+
WasmTropicalMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
5767
|
+
return this;
|
|
5768
|
+
}
|
|
5769
|
+
/**
|
|
5770
|
+
* Compute tropical infimum (minimum) of function over sample points
|
|
5771
|
+
*
|
|
5772
|
+
* Returns the minimum value and the point where it occurs
|
|
5773
|
+
* @param {Function} f
|
|
5774
|
+
* @param {Float64Array} points
|
|
5775
|
+
* @returns {Float64Array}
|
|
5776
|
+
*/
|
|
5777
|
+
infimum(f, points) {
|
|
5778
|
+
const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
5779
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5780
|
+
const ret = wasm.wasmtropicalmeasure_infimum(this.__wbg_ptr, f, ptr0, len0);
|
|
5781
|
+
if (ret[3]) {
|
|
5782
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5783
|
+
}
|
|
5784
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5785
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5786
|
+
return v2;
|
|
5787
|
+
}
|
|
5788
|
+
/**
|
|
5789
|
+
* Compute tropical supremum (maximum) of function over sample points
|
|
5790
|
+
*
|
|
5791
|
+
* Returns the maximum value and the point where it occurs
|
|
5792
|
+
* @param {Function} f
|
|
5793
|
+
* @param {Float64Array} points
|
|
5794
|
+
* @returns {Float64Array}
|
|
5795
|
+
*/
|
|
5796
|
+
supremum(f, points) {
|
|
5797
|
+
const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
5798
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5799
|
+
const ret = wasm.wasmtropicalmeasure_supremum(this.__wbg_ptr, f, ptr0, len0);
|
|
5800
|
+
if (ret[3]) {
|
|
5801
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5802
|
+
}
|
|
5803
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5804
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5805
|
+
return v2;
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
if (Symbol.dispose) WasmTropicalMeasure.prototype[Symbol.dispose] = WasmTropicalMeasure.prototype.free;
|
|
5809
|
+
|
|
5190
5810
|
const WasmTropicalNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5191
5811
|
? { register: () => {}, unregister: () => {} }
|
|
5192
5812
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalnetwork_free(ptr >>> 0, 1));
|
|
@@ -5680,12 +6300,12 @@ function __wbg_get_imports() {
|
|
|
5680
6300
|
const ret = arg0.length;
|
|
5681
6301
|
return ret;
|
|
5682
6302
|
};
|
|
5683
|
-
imports.wbg.__wbg_log_78aa79d721d10880 = function(arg0, arg1) {
|
|
5684
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
5685
|
-
};
|
|
5686
6303
|
imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) {
|
|
5687
6304
|
console.log(arg0);
|
|
5688
6305
|
};
|
|
6306
|
+
imports.wbg.__wbg_log_b51718ac10a384d9 = function(arg0, arg1) {
|
|
6307
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
6308
|
+
};
|
|
5689
6309
|
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
5690
6310
|
const ret = new Object();
|
|
5691
6311
|
return ret;
|
|
@@ -5697,7 +6317,7 @@ function __wbg_get_imports() {
|
|
|
5697
6317
|
const a = state0.a;
|
|
5698
6318
|
state0.a = 0;
|
|
5699
6319
|
try {
|
|
5700
|
-
return
|
|
6320
|
+
return wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(a, state0.b, arg0, arg1);
|
|
5701
6321
|
} finally {
|
|
5702
6322
|
state0.a = a;
|
|
5703
6323
|
}
|
|
@@ -5800,7 +6420,7 @@ function __wbg_get_imports() {
|
|
|
5800
6420
|
};
|
|
5801
6421
|
imports.wbg.__wbindgen_cast_69f35aa0fcaecc47 = function(arg0, arg1) {
|
|
5802
6422
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 37, function: Function { arguments: [Externref], shim_idx: 38, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
5803
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
6423
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_83f782f110bf2942___closure__destroy___dyn_core_f622c628fd7f704e___ops__function__FnMut__wasm_bindgen_83f782f110bf2942___JsValue____Output_______, wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____);
|
|
5804
6424
|
return ret;
|
|
5805
6425
|
};
|
|
5806
6426
|
imports.wbg.__wbindgen_cast_b63aeb0d85365734 = function(arg0, arg1) {
|