@justinelliottcobb/amari-wasm 0.12.3 → 0.14.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 +91 -2
- package/amari_wasm.d.ts +515 -5
- package/amari_wasm.js +1087 -14
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/amari_wasm.js
CHANGED
|
@@ -429,11 +429,11 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
429
429
|
return ptr;
|
|
430
430
|
}
|
|
431
431
|
function __wbg_adapter_28(arg0, arg1, arg2) {
|
|
432
|
-
wasm.
|
|
432
|
+
wasm.closure41_externref_shim(arg0, arg1, arg2);
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
function
|
|
436
|
-
wasm.
|
|
435
|
+
function __wbg_adapter_550(arg0, arg1, arg2, arg3) {
|
|
436
|
+
wasm.closure34_externref_shim(arg0, arg1, arg2, arg3);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
/**
|
|
@@ -3362,6 +3362,194 @@ export class WasmFourVelocity {
|
|
|
3362
3362
|
}
|
|
3363
3363
|
}
|
|
3364
3364
|
|
|
3365
|
+
const WasmGaussianMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3366
|
+
? { register: () => {}, unregister: () => {} }
|
|
3367
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgaussianmultivector_free(ptr >>> 0, 1));
|
|
3368
|
+
/**
|
|
3369
|
+
* WASM wrapper for Gaussian distribution on Cl(3,0,0) multivector space
|
|
3370
|
+
*
|
|
3371
|
+
* A Gaussian distribution over 8-dimensional multivector space with
|
|
3372
|
+
* configurable mean and per-component standard deviation.
|
|
3373
|
+
*/
|
|
3374
|
+
export class WasmGaussianMultivector {
|
|
3375
|
+
|
|
3376
|
+
static __wrap(ptr) {
|
|
3377
|
+
ptr = ptr >>> 0;
|
|
3378
|
+
const obj = Object.create(WasmGaussianMultivector.prototype);
|
|
3379
|
+
obj.__wbg_ptr = ptr;
|
|
3380
|
+
WasmGaussianMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3381
|
+
return obj;
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
__destroy_into_raw() {
|
|
3385
|
+
const ptr = this.__wbg_ptr;
|
|
3386
|
+
this.__wbg_ptr = 0;
|
|
3387
|
+
WasmGaussianMultivectorFinalization.unregister(this);
|
|
3388
|
+
return ptr;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
free() {
|
|
3392
|
+
const ptr = this.__destroy_into_raw();
|
|
3393
|
+
wasm.__wbg_wasmgaussianmultivector_free(ptr, 0);
|
|
3394
|
+
}
|
|
3395
|
+
/**
|
|
3396
|
+
* Get the standard deviations
|
|
3397
|
+
*
|
|
3398
|
+
* Returns 8 values
|
|
3399
|
+
* @returns {Float64Array}
|
|
3400
|
+
*/
|
|
3401
|
+
getStdDevs() {
|
|
3402
|
+
const ret = wasm.wasmgaussianmultivector_getStdDevs(this.__wbg_ptr);
|
|
3403
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3404
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3405
|
+
return v1;
|
|
3406
|
+
}
|
|
3407
|
+
/**
|
|
3408
|
+
* Get the variance (square of std devs)
|
|
3409
|
+
*
|
|
3410
|
+
* Returns 8 values
|
|
3411
|
+
* @returns {Float64Array}
|
|
3412
|
+
*/
|
|
3413
|
+
getVariance() {
|
|
3414
|
+
const ret = wasm.wasmgaussianmultivector_getVariance(this.__wbg_ptr);
|
|
3415
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3416
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3417
|
+
return v1;
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* Draw multiple samples from this distribution
|
|
3421
|
+
*
|
|
3422
|
+
* Returns flat array of coefficients: num_samples * 8
|
|
3423
|
+
* @param {number} num_samples
|
|
3424
|
+
* @returns {Float64Array}
|
|
3425
|
+
*/
|
|
3426
|
+
sampleBatch(num_samples) {
|
|
3427
|
+
const ret = wasm.wasmgaussianmultivector_sampleBatch(this.__wbg_ptr, num_samples);
|
|
3428
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3429
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3430
|
+
return v1;
|
|
3431
|
+
}
|
|
3432
|
+
/**
|
|
3433
|
+
* Get the full covariance matrix (flattened, row-major)
|
|
3434
|
+
*
|
|
3435
|
+
* Returns 64 values (8x8 matrix)
|
|
3436
|
+
* @returns {Float64Array}
|
|
3437
|
+
*/
|
|
3438
|
+
getCovariance() {
|
|
3439
|
+
const ret = wasm.wasmgaussianmultivector_getCovariance(this.__wbg_ptr);
|
|
3440
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3441
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3442
|
+
return v1;
|
|
3443
|
+
}
|
|
3444
|
+
/**
|
|
3445
|
+
* Create a Gaussian with specified mean and standard deviation
|
|
3446
|
+
*
|
|
3447
|
+
* # Arguments
|
|
3448
|
+
* * `mean` - 8 coefficients for the mean multivector
|
|
3449
|
+
* * `std_dev` - 8 coefficients for per-coefficient standard deviation
|
|
3450
|
+
* @param {Float64Array} mean
|
|
3451
|
+
* @param {Float64Array} std_dev
|
|
3452
|
+
* @returns {WasmGaussianMultivector}
|
|
3453
|
+
*/
|
|
3454
|
+
static withParameters(mean, std_dev) {
|
|
3455
|
+
const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
|
|
3456
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3457
|
+
const ptr1 = passArrayF64ToWasm0(std_dev, wasm.__wbindgen_malloc);
|
|
3458
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3459
|
+
const ret = wasm.wasmgaussianmultivector_withParameters(ptr0, len0, ptr1, len1);
|
|
3460
|
+
if (ret[2]) {
|
|
3461
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3462
|
+
}
|
|
3463
|
+
return WasmGaussianMultivector.__wrap(ret[0]);
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Create a Gaussian concentrated on a specific grade
|
|
3467
|
+
*
|
|
3468
|
+
* # Arguments
|
|
3469
|
+
* * `grade` - The grade to concentrate on (0=scalar, 1=vectors, 2=bivectors, 3=pseudoscalar)
|
|
3470
|
+
* * `variance` - Variance for coefficients of that grade
|
|
3471
|
+
* @param {number} grade
|
|
3472
|
+
* @param {number} variance
|
|
3473
|
+
* @returns {WasmGaussianMultivector}
|
|
3474
|
+
*/
|
|
3475
|
+
static gradeConcentrated(grade, variance) {
|
|
3476
|
+
const ret = wasm.wasmgaussianmultivector_gradeConcentrated(grade, variance);
|
|
3477
|
+
if (ret[2]) {
|
|
3478
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3479
|
+
}
|
|
3480
|
+
return WasmGaussianMultivector.__wrap(ret[0]);
|
|
3481
|
+
}
|
|
3482
|
+
/**
|
|
3483
|
+
* Create a standard Gaussian (zero mean, unit variance per coefficient)
|
|
3484
|
+
*/
|
|
3485
|
+
constructor() {
|
|
3486
|
+
const ret = wasm.wasmgaussianmultivector_new();
|
|
3487
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3488
|
+
WasmGaussianMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
3489
|
+
return this;
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* Draw a sample from this distribution
|
|
3493
|
+
*
|
|
3494
|
+
* Returns 8 coefficients for the sampled multivector
|
|
3495
|
+
* @returns {Float64Array}
|
|
3496
|
+
*/
|
|
3497
|
+
sample() {
|
|
3498
|
+
const ret = wasm.wasmgaussianmultivector_sample(this.__wbg_ptr);
|
|
3499
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3500
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3501
|
+
return v1;
|
|
3502
|
+
}
|
|
3503
|
+
/**
|
|
3504
|
+
* Get the mean of this distribution
|
|
3505
|
+
*
|
|
3506
|
+
* Returns 8 coefficients
|
|
3507
|
+
* @returns {Float64Array}
|
|
3508
|
+
*/
|
|
3509
|
+
getMean() {
|
|
3510
|
+
const ret = wasm.wasmgaussianmultivector_getMean(this.__wbg_ptr);
|
|
3511
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3512
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3513
|
+
return v1;
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* Compute log probability of a multivector
|
|
3517
|
+
*
|
|
3518
|
+
* # Arguments
|
|
3519
|
+
* * `coefficients` - 8 coefficients of the multivector
|
|
3520
|
+
* @param {Float64Array} coefficients
|
|
3521
|
+
* @returns {number}
|
|
3522
|
+
*/
|
|
3523
|
+
logProb(coefficients) {
|
|
3524
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
3525
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3526
|
+
const ret = wasm.wasmgaussianmultivector_logProb(this.__wbg_ptr, ptr0, len0);
|
|
3527
|
+
if (ret[2]) {
|
|
3528
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3529
|
+
}
|
|
3530
|
+
return ret[0];
|
|
3531
|
+
}
|
|
3532
|
+
/**
|
|
3533
|
+
* Create an isotropic Gaussian with given mean and variance
|
|
3534
|
+
*
|
|
3535
|
+
* # Arguments
|
|
3536
|
+
* * `mean` - 8 coefficients for the mean multivector
|
|
3537
|
+
* * `variance` - Variance (same for all components)
|
|
3538
|
+
* @param {Float64Array} mean
|
|
3539
|
+
* @param {number} variance
|
|
3540
|
+
* @returns {WasmGaussianMultivector}
|
|
3541
|
+
*/
|
|
3542
|
+
static isotropic(mean, variance) {
|
|
3543
|
+
const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
|
|
3544
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3545
|
+
const ret = wasm.wasmgaussianmultivector_isotropic(ptr0, len0, variance);
|
|
3546
|
+
if (ret[2]) {
|
|
3547
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3548
|
+
}
|
|
3549
|
+
return WasmGaussianMultivector.__wrap(ret[0]);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3365
3553
|
const WasmGeodesicIntegratorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3366
3554
|
? { register: () => {}, unregister: () => {} }
|
|
3367
3555
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgeodesicintegrator_free(ptr >>> 0, 1));
|
|
@@ -3416,6 +3604,126 @@ export class WasmGeodesicIntegrator {
|
|
|
3416
3604
|
}
|
|
3417
3605
|
}
|
|
3418
3606
|
|
|
3607
|
+
const WasmGeometricBrownianMotionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3608
|
+
? { register: () => {}, unregister: () => {} }
|
|
3609
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricbrownianmotion_free(ptr >>> 0, 1));
|
|
3610
|
+
/**
|
|
3611
|
+
* WASM wrapper for Geometric Brownian Motion on multivector space
|
|
3612
|
+
*
|
|
3613
|
+
* dX = μX dt + σX dW
|
|
3614
|
+
*
|
|
3615
|
+
* Useful for modeling multiplicative noise processes in geometric algebra.
|
|
3616
|
+
*/
|
|
3617
|
+
export class WasmGeometricBrownianMotion {
|
|
3618
|
+
|
|
3619
|
+
__destroy_into_raw() {
|
|
3620
|
+
const ptr = this.__wbg_ptr;
|
|
3621
|
+
this.__wbg_ptr = 0;
|
|
3622
|
+
WasmGeometricBrownianMotionFinalization.unregister(this);
|
|
3623
|
+
return ptr;
|
|
3624
|
+
}
|
|
3625
|
+
|
|
3626
|
+
free() {
|
|
3627
|
+
const ptr = this.__destroy_into_raw();
|
|
3628
|
+
wasm.__wbg_wasmgeometricbrownianmotion_free(ptr, 0);
|
|
3629
|
+
}
|
|
3630
|
+
/**
|
|
3631
|
+
* Sample a single path of the process
|
|
3632
|
+
*
|
|
3633
|
+
* # Arguments
|
|
3634
|
+
* * `initial` - Initial multivector (8 coefficients)
|
|
3635
|
+
* * `t_end` - End time
|
|
3636
|
+
* * `num_steps` - Number of time steps
|
|
3637
|
+
*
|
|
3638
|
+
* Returns flat array: (num_steps + 1) * 9 values
|
|
3639
|
+
* Each point is [time, coeff0, coeff1, ..., coeff7]
|
|
3640
|
+
* @param {Float64Array} initial
|
|
3641
|
+
* @param {number} t_end
|
|
3642
|
+
* @param {number} num_steps
|
|
3643
|
+
* @returns {Float64Array}
|
|
3644
|
+
*/
|
|
3645
|
+
samplePath(initial, t_end, num_steps) {
|
|
3646
|
+
const ptr0 = passArrayF64ToWasm0(initial, wasm.__wbindgen_malloc);
|
|
3647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3648
|
+
const ret = wasm.wasmgeometricbrownianmotion_samplePath(this.__wbg_ptr, ptr0, len0, t_end, num_steps);
|
|
3649
|
+
if (ret[3]) {
|
|
3650
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3651
|
+
}
|
|
3652
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3653
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3654
|
+
return v2;
|
|
3655
|
+
}
|
|
3656
|
+
/**
|
|
3657
|
+
* Compute expected value at time t given initial value
|
|
3658
|
+
*
|
|
3659
|
+
* E[X(t)] = X(0) * exp(μt)
|
|
3660
|
+
* @param {Float64Array} initial
|
|
3661
|
+
* @param {number} t
|
|
3662
|
+
* @returns {Float64Array}
|
|
3663
|
+
*/
|
|
3664
|
+
expectedValue(initial, t) {
|
|
3665
|
+
const ptr0 = passArrayF64ToWasm0(initial, wasm.__wbindgen_malloc);
|
|
3666
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3667
|
+
const ret = wasm.wasmgeometricbrownianmotion_expectedValue(this.__wbg_ptr, ptr0, len0, t);
|
|
3668
|
+
if (ret[3]) {
|
|
3669
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3670
|
+
}
|
|
3671
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3672
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3673
|
+
return v2;
|
|
3674
|
+
}
|
|
3675
|
+
/**
|
|
3676
|
+
* Create a new Geometric Brownian Motion process
|
|
3677
|
+
*
|
|
3678
|
+
* # Arguments
|
|
3679
|
+
* * `mu` - Drift coefficient (expected growth rate)
|
|
3680
|
+
* * `sigma` - Diffusion coefficient (volatility)
|
|
3681
|
+
* @param {number} mu
|
|
3682
|
+
* @param {number} sigma
|
|
3683
|
+
*/
|
|
3684
|
+
constructor(mu, sigma) {
|
|
3685
|
+
const ret = wasm.wasmdualnumber_new(mu, sigma);
|
|
3686
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3687
|
+
WasmGeometricBrownianMotionFinalization.register(this, this.__wbg_ptr, this);
|
|
3688
|
+
return this;
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Get drift coefficient
|
|
3692
|
+
* @returns {number}
|
|
3693
|
+
*/
|
|
3694
|
+
getMu() {
|
|
3695
|
+
const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
|
|
3696
|
+
return ret;
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
* Compute variance at time t given initial value
|
|
3700
|
+
*
|
|
3701
|
+
* Var(X(t)) = X(0)² * exp(2μt) * (exp(σ²t) - 1)
|
|
3702
|
+
* @param {Float64Array} initial
|
|
3703
|
+
* @param {number} t
|
|
3704
|
+
* @returns {Float64Array}
|
|
3705
|
+
*/
|
|
3706
|
+
variance(initial, t) {
|
|
3707
|
+
const ptr0 = passArrayF64ToWasm0(initial, wasm.__wbindgen_malloc);
|
|
3708
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3709
|
+
const ret = wasm.wasmgeometricbrownianmotion_variance(this.__wbg_ptr, ptr0, len0, t);
|
|
3710
|
+
if (ret[3]) {
|
|
3711
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3712
|
+
}
|
|
3713
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3714
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3715
|
+
return v2;
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Get diffusion coefficient
|
|
3719
|
+
* @returns {number}
|
|
3720
|
+
*/
|
|
3721
|
+
getSigma() {
|
|
3722
|
+
const ret = wasm.wasmdualnumber_getDual(this.__wbg_ptr);
|
|
3723
|
+
return ret;
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3419
3727
|
const WasmGeometricCAFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3420
3728
|
? { register: () => {}, unregister: () => {} }
|
|
3421
3729
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricca_free(ptr >>> 0, 1));
|
|
@@ -3995,6 +4303,108 @@ export class WasmGpuOptimizer {
|
|
|
3995
4303
|
}
|
|
3996
4304
|
}
|
|
3997
4305
|
|
|
4306
|
+
const WasmGradeProjectedDistributionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4307
|
+
? { register: () => {}, unregister: () => {} }
|
|
4308
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgradeprojecteddistribution_free(ptr >>> 0, 1));
|
|
4309
|
+
/**
|
|
4310
|
+
* WASM wrapper for grade-projected distribution
|
|
4311
|
+
*
|
|
4312
|
+
* A distribution that only operates on components of a specific grade.
|
|
4313
|
+
*/
|
|
4314
|
+
export class WasmGradeProjectedDistribution {
|
|
4315
|
+
|
|
4316
|
+
__destroy_into_raw() {
|
|
4317
|
+
const ptr = this.__wbg_ptr;
|
|
4318
|
+
this.__wbg_ptr = 0;
|
|
4319
|
+
WasmGradeProjectedDistributionFinalization.unregister(this);
|
|
4320
|
+
return ptr;
|
|
4321
|
+
}
|
|
4322
|
+
|
|
4323
|
+
free() {
|
|
4324
|
+
const ptr = this.__destroy_into_raw();
|
|
4325
|
+
wasm.__wbg_wasmgradeprojecteddistribution_free(ptr, 0);
|
|
4326
|
+
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Sample and embed into full multivector (other grades are zero)
|
|
4329
|
+
*
|
|
4330
|
+
* Returns 8 coefficients
|
|
4331
|
+
* @returns {Float64Array}
|
|
4332
|
+
*/
|
|
4333
|
+
sampleFull() {
|
|
4334
|
+
const ret = wasm.wasmgradeprojecteddistribution_sampleFull(this.__wbg_ptr);
|
|
4335
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4336
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4337
|
+
return v1;
|
|
4338
|
+
}
|
|
4339
|
+
/**
|
|
4340
|
+
* Get standard deviations
|
|
4341
|
+
* @returns {Float64Array}
|
|
4342
|
+
*/
|
|
4343
|
+
getStdDevs() {
|
|
4344
|
+
const ret = wasm.wasmgradeprojecteddistribution_getStdDevs(this.__wbg_ptr);
|
|
4345
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4346
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4347
|
+
return v1;
|
|
4348
|
+
}
|
|
4349
|
+
/**
|
|
4350
|
+
* Get number of components in this grade
|
|
4351
|
+
* @returns {number}
|
|
4352
|
+
*/
|
|
4353
|
+
getNumComponents() {
|
|
4354
|
+
const ret = wasm.wasmgradeprojecteddistribution_getNumComponents(this.__wbg_ptr);
|
|
4355
|
+
return ret >>> 0;
|
|
4356
|
+
}
|
|
4357
|
+
/**
|
|
4358
|
+
* Create a grade-projected distribution from a Gaussian
|
|
4359
|
+
*
|
|
4360
|
+
* # Arguments
|
|
4361
|
+
* * `gaussian` - Source Gaussian distribution
|
|
4362
|
+
* * `grade` - Grade to project onto (0, 1, 2, or 3 for Cl(3,0,0))
|
|
4363
|
+
* @param {WasmGaussianMultivector} gaussian
|
|
4364
|
+
* @param {number} grade
|
|
4365
|
+
*/
|
|
4366
|
+
constructor(gaussian, grade) {
|
|
4367
|
+
_assertClass(gaussian, WasmGaussianMultivector);
|
|
4368
|
+
const ret = wasm.wasmgradeprojecteddistribution_new(gaussian.__wbg_ptr, grade);
|
|
4369
|
+
if (ret[2]) {
|
|
4370
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4371
|
+
}
|
|
4372
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
4373
|
+
WasmGradeProjectedDistributionFinalization.register(this, this.__wbg_ptr, this);
|
|
4374
|
+
return this;
|
|
4375
|
+
}
|
|
4376
|
+
/**
|
|
4377
|
+
* Sample from this grade-projected distribution
|
|
4378
|
+
*
|
|
4379
|
+
* Returns components for just this grade
|
|
4380
|
+
* @returns {Float64Array}
|
|
4381
|
+
*/
|
|
4382
|
+
sample() {
|
|
4383
|
+
const ret = wasm.wasmgradeprojecteddistribution_sample(this.__wbg_ptr);
|
|
4384
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4385
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4386
|
+
return v1;
|
|
4387
|
+
}
|
|
4388
|
+
/**
|
|
4389
|
+
* Get the mean for this grade's components
|
|
4390
|
+
* @returns {Float64Array}
|
|
4391
|
+
*/
|
|
4392
|
+
getMean() {
|
|
4393
|
+
const ret = wasm.wasmgradeprojecteddistribution_getMean(this.__wbg_ptr);
|
|
4394
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4395
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4396
|
+
return v1;
|
|
4397
|
+
}
|
|
4398
|
+
/**
|
|
4399
|
+
* Get the grade
|
|
4400
|
+
* @returns {number}
|
|
4401
|
+
*/
|
|
4402
|
+
getGrade() {
|
|
4403
|
+
const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
|
|
4404
|
+
return ret >>> 0;
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
|
|
3998
4408
|
const WasmGrassmannianFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3999
4409
|
? { register: () => {}, unregister: () => {} }
|
|
4000
4410
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmgrassmannian_free(ptr >>> 0, 1));
|
|
@@ -4347,6 +4757,184 @@ export class WasmLebesgueMeasure {
|
|
|
4347
4757
|
}
|
|
4348
4758
|
}
|
|
4349
4759
|
|
|
4760
|
+
const WasmMCMCDiagnosticsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4761
|
+
? { register: () => {}, unregister: () => {} }
|
|
4762
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmcmcdiagnostics_free(ptr >>> 0, 1));
|
|
4763
|
+
/**
|
|
4764
|
+
* WASM wrapper for MCMC diagnostics
|
|
4765
|
+
*/
|
|
4766
|
+
export class WasmMCMCDiagnostics {
|
|
4767
|
+
|
|
4768
|
+
static __wrap(ptr) {
|
|
4769
|
+
ptr = ptr >>> 0;
|
|
4770
|
+
const obj = Object.create(WasmMCMCDiagnostics.prototype);
|
|
4771
|
+
obj.__wbg_ptr = ptr;
|
|
4772
|
+
WasmMCMCDiagnosticsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4773
|
+
return obj;
|
|
4774
|
+
}
|
|
4775
|
+
|
|
4776
|
+
__destroy_into_raw() {
|
|
4777
|
+
const ptr = this.__wbg_ptr;
|
|
4778
|
+
this.__wbg_ptr = 0;
|
|
4779
|
+
WasmMCMCDiagnosticsFinalization.unregister(this);
|
|
4780
|
+
return ptr;
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
free() {
|
|
4784
|
+
const ptr = this.__destroy_into_raw();
|
|
4785
|
+
wasm.__wbg_wasmmcmcdiagnostics_free(ptr, 0);
|
|
4786
|
+
}
|
|
4787
|
+
/**
|
|
4788
|
+
* Total number of steps
|
|
4789
|
+
* @returns {number}
|
|
4790
|
+
*/
|
|
4791
|
+
get num_steps() {
|
|
4792
|
+
const ret = wasm.__wbg_get_wasmmcmcdiagnostics_num_steps(this.__wbg_ptr);
|
|
4793
|
+
return ret >>> 0;
|
|
4794
|
+
}
|
|
4795
|
+
/**
|
|
4796
|
+
* Total number of steps
|
|
4797
|
+
* @param {number} arg0
|
|
4798
|
+
*/
|
|
4799
|
+
set num_steps(arg0) {
|
|
4800
|
+
wasm.__wbg_set_wasmmcmcdiagnostics_num_steps(this.__wbg_ptr, arg0);
|
|
4801
|
+
}
|
|
4802
|
+
/**
|
|
4803
|
+
* Acceptance rate
|
|
4804
|
+
* @returns {number}
|
|
4805
|
+
*/
|
|
4806
|
+
get acceptance_rate() {
|
|
4807
|
+
const ret = wasm.__wbg_get_wasmmcmcdiagnostics_acceptance_rate(this.__wbg_ptr);
|
|
4808
|
+
return ret;
|
|
4809
|
+
}
|
|
4810
|
+
/**
|
|
4811
|
+
* Acceptance rate
|
|
4812
|
+
* @param {number} arg0
|
|
4813
|
+
*/
|
|
4814
|
+
set acceptance_rate(arg0) {
|
|
4815
|
+
wasm.__wbg_set_wasmmcmcdiagnostics_acceptance_rate(this.__wbg_ptr, arg0);
|
|
4816
|
+
}
|
|
4817
|
+
/**
|
|
4818
|
+
* Check if the sampler has converged (R-hat < 1.1)
|
|
4819
|
+
* @returns {boolean}
|
|
4820
|
+
*/
|
|
4821
|
+
isConverged() {
|
|
4822
|
+
const ret = wasm.wasmmcmcdiagnostics_isConverged(this.__wbg_ptr);
|
|
4823
|
+
return ret !== 0;
|
|
4824
|
+
}
|
|
4825
|
+
/**
|
|
4826
|
+
* Get effective sample size (or -1 if not computed)
|
|
4827
|
+
* @returns {number}
|
|
4828
|
+
*/
|
|
4829
|
+
getEffectiveSampleSize() {
|
|
4830
|
+
const ret = wasm.wasmmcmcdiagnostics_getEffectiveSampleSize(this.__wbg_ptr);
|
|
4831
|
+
return ret;
|
|
4832
|
+
}
|
|
4833
|
+
/**
|
|
4834
|
+
* Get R-hat statistic (or -1 if not computed)
|
|
4835
|
+
* @returns {number}
|
|
4836
|
+
*/
|
|
4837
|
+
getRHat() {
|
|
4838
|
+
const ret = wasm.wasmmcmcdiagnostics_getRHat(this.__wbg_ptr);
|
|
4839
|
+
return ret;
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
|
|
4843
|
+
const WasmMetropolisHastingsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4844
|
+
? { register: () => {}, unregister: () => {} }
|
|
4845
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmetropolishastings_free(ptr >>> 0, 1));
|
|
4846
|
+
/**
|
|
4847
|
+
* WASM wrapper for Metropolis-Hastings MCMC sampler
|
|
4848
|
+
*
|
|
4849
|
+
* Samples from a target distribution using random-walk proposals.
|
|
4850
|
+
*/
|
|
4851
|
+
export class WasmMetropolisHastings {
|
|
4852
|
+
|
|
4853
|
+
__destroy_into_raw() {
|
|
4854
|
+
const ptr = this.__wbg_ptr;
|
|
4855
|
+
this.__wbg_ptr = 0;
|
|
4856
|
+
WasmMetropolisHastingsFinalization.unregister(this);
|
|
4857
|
+
return ptr;
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
free() {
|
|
4861
|
+
const ptr = this.__destroy_into_raw();
|
|
4862
|
+
wasm.__wbg_wasmmetropolishastings_free(ptr, 0);
|
|
4863
|
+
}
|
|
4864
|
+
/**
|
|
4865
|
+
* Get sampling diagnostics
|
|
4866
|
+
* @returns {WasmMCMCDiagnostics}
|
|
4867
|
+
*/
|
|
4868
|
+
diagnostics() {
|
|
4869
|
+
const ret = wasm.wasmmetropolishastings_diagnostics(this.__wbg_ptr);
|
|
4870
|
+
return WasmMCMCDiagnostics.__wrap(ret);
|
|
4871
|
+
}
|
|
4872
|
+
/**
|
|
4873
|
+
* Get current sample
|
|
4874
|
+
* @returns {Float64Array}
|
|
4875
|
+
*/
|
|
4876
|
+
getCurrent() {
|
|
4877
|
+
const ret = wasm.wasmmetropolishastings_getCurrent(this.__wbg_ptr);
|
|
4878
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4879
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4880
|
+
return v1;
|
|
4881
|
+
}
|
|
4882
|
+
/**
|
|
4883
|
+
* Get current acceptance rate
|
|
4884
|
+
* @returns {number}
|
|
4885
|
+
*/
|
|
4886
|
+
getAcceptanceRate() {
|
|
4887
|
+
const ret = wasm.wasmmetropolishastings_getAcceptanceRate(this.__wbg_ptr);
|
|
4888
|
+
return ret;
|
|
4889
|
+
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Create a new Metropolis-Hastings sampler for a Gaussian target
|
|
4892
|
+
*
|
|
4893
|
+
* # Arguments
|
|
4894
|
+
* * `target` - The target Gaussian distribution to sample from
|
|
4895
|
+
* * `proposal_std` - Standard deviation for the proposal distribution
|
|
4896
|
+
* @param {WasmGaussianMultivector} target
|
|
4897
|
+
* @param {number} proposal_std
|
|
4898
|
+
*/
|
|
4899
|
+
constructor(target, proposal_std) {
|
|
4900
|
+
_assertClass(target, WasmGaussianMultivector);
|
|
4901
|
+
const ret = wasm.wasmmetropolishastings_new(target.__wbg_ptr, proposal_std);
|
|
4902
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4903
|
+
WasmMetropolisHastingsFinalization.register(this, this.__wbg_ptr, this);
|
|
4904
|
+
return this;
|
|
4905
|
+
}
|
|
4906
|
+
/**
|
|
4907
|
+
* Run the sampler for multiple steps
|
|
4908
|
+
*
|
|
4909
|
+
* # Arguments
|
|
4910
|
+
* * `num_samples` - Number of samples to collect
|
|
4911
|
+
* * `burnin` - Number of burn-in steps to discard
|
|
4912
|
+
*
|
|
4913
|
+
* Returns flat array of samples (num_samples * 8)
|
|
4914
|
+
* @param {number} num_samples
|
|
4915
|
+
* @param {number} burnin
|
|
4916
|
+
* @returns {Float64Array}
|
|
4917
|
+
*/
|
|
4918
|
+
run(num_samples, burnin) {
|
|
4919
|
+
const ret = wasm.wasmmetropolishastings_run(this.__wbg_ptr, num_samples, burnin);
|
|
4920
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4921
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4922
|
+
return v1;
|
|
4923
|
+
}
|
|
4924
|
+
/**
|
|
4925
|
+
* Take a single MCMC step
|
|
4926
|
+
*
|
|
4927
|
+
* Returns the new sample (8 coefficients)
|
|
4928
|
+
* @returns {Float64Array}
|
|
4929
|
+
*/
|
|
4930
|
+
step() {
|
|
4931
|
+
const ret = wasm.wasmmetropolishastings_step(this.__wbg_ptr);
|
|
4932
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4933
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4934
|
+
return v1;
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4350
4938
|
const WasmModuliSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4351
4939
|
? { register: () => {}, unregister: () => {} }
|
|
4352
4940
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmodulispace_free(ptr >>> 0, 1));
|
|
@@ -4422,9 +5010,113 @@ export class WasmModuliSpace {
|
|
|
4422
5010
|
* @param {number} marked_points
|
|
4423
5011
|
* @returns {WasmModuliSpace}
|
|
4424
5012
|
*/
|
|
4425
|
-
static ofCurves(genus, marked_points) {
|
|
4426
|
-
const ret = wasm.wasmmodulispace_ofCurves(genus, marked_points);
|
|
4427
|
-
return WasmModuliSpace.__wrap(ret);
|
|
5013
|
+
static ofCurves(genus, marked_points) {
|
|
5014
|
+
const ret = wasm.wasmmodulispace_ofCurves(genus, marked_points);
|
|
5015
|
+
return WasmModuliSpace.__wrap(ret);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
const WasmMonteCarloEstimatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5020
|
+
? { register: () => {}, unregister: () => {} }
|
|
5021
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmontecarloestimator_free(ptr >>> 0, 1));
|
|
5022
|
+
/**
|
|
5023
|
+
* Monte Carlo estimation utilities
|
|
5024
|
+
*/
|
|
5025
|
+
export class WasmMonteCarloEstimator {
|
|
5026
|
+
|
|
5027
|
+
__destroy_into_raw() {
|
|
5028
|
+
const ptr = this.__wbg_ptr;
|
|
5029
|
+
this.__wbg_ptr = 0;
|
|
5030
|
+
WasmMonteCarloEstimatorFinalization.unregister(this);
|
|
5031
|
+
return ptr;
|
|
5032
|
+
}
|
|
5033
|
+
|
|
5034
|
+
free() {
|
|
5035
|
+
const ptr = this.__destroy_into_raw();
|
|
5036
|
+
wasm.__wbg_wasmmontecarloestimator_free(ptr, 0);
|
|
5037
|
+
}
|
|
5038
|
+
/**
|
|
5039
|
+
* Compute sample mean from batch samples
|
|
5040
|
+
*
|
|
5041
|
+
* # Arguments
|
|
5042
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
5043
|
+
*
|
|
5044
|
+
* # Returns
|
|
5045
|
+
* 8 coefficients for the mean
|
|
5046
|
+
* @param {Float64Array} samples
|
|
5047
|
+
* @returns {Float64Array}
|
|
5048
|
+
*/
|
|
5049
|
+
static sampleMean(samples) {
|
|
5050
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
5051
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5052
|
+
const ret = wasm.wasmmontecarloestimator_sampleMean(ptr0, len0);
|
|
5053
|
+
if (ret[3]) {
|
|
5054
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5055
|
+
}
|
|
5056
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5057
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5058
|
+
return v2;
|
|
5059
|
+
}
|
|
5060
|
+
/**
|
|
5061
|
+
* Compute sample variance from batch samples
|
|
5062
|
+
*
|
|
5063
|
+
* # Arguments
|
|
5064
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
5065
|
+
*
|
|
5066
|
+
* # Returns
|
|
5067
|
+
* 8 values for per-coefficient variance
|
|
5068
|
+
* @param {Float64Array} samples
|
|
5069
|
+
* @returns {Float64Array}
|
|
5070
|
+
*/
|
|
5071
|
+
static sampleVariance(samples) {
|
|
5072
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
5073
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5074
|
+
const ret = wasm.wasmmontecarloestimator_sampleVariance(ptr0, len0);
|
|
5075
|
+
if (ret[3]) {
|
|
5076
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5077
|
+
}
|
|
5078
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5079
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5080
|
+
return v2;
|
|
5081
|
+
}
|
|
5082
|
+
/**
|
|
5083
|
+
* Compute sample covariance matrix from batch samples
|
|
5084
|
+
*
|
|
5085
|
+
* # Arguments
|
|
5086
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
5087
|
+
*
|
|
5088
|
+
* # Returns
|
|
5089
|
+
* 64 values for 8x8 covariance matrix (row-major)
|
|
5090
|
+
* @param {Float64Array} samples
|
|
5091
|
+
* @returns {Float64Array}
|
|
5092
|
+
*/
|
|
5093
|
+
static sampleCovariance(samples) {
|
|
5094
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
5095
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5096
|
+
const ret = wasm.wasmmontecarloestimator_sampleCovariance(ptr0, len0);
|
|
5097
|
+
if (ret[3]) {
|
|
5098
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5099
|
+
}
|
|
5100
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5101
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5102
|
+
return v2;
|
|
5103
|
+
}
|
|
5104
|
+
/**
|
|
5105
|
+
* Monte Carlo estimate of expectation E[f(X)] where f is the geometric product
|
|
5106
|
+
*
|
|
5107
|
+
* Estimates E[X * Y] for independent X ~ dist_x, Y ~ dist_y
|
|
5108
|
+
* @param {WasmGaussianMultivector} dist_x
|
|
5109
|
+
* @param {WasmGaussianMultivector} dist_y
|
|
5110
|
+
* @param {number} num_samples
|
|
5111
|
+
* @returns {Float64Array}
|
|
5112
|
+
*/
|
|
5113
|
+
static expectationGeometricProduct(dist_x, dist_y, num_samples) {
|
|
5114
|
+
_assertClass(dist_x, WasmGaussianMultivector);
|
|
5115
|
+
_assertClass(dist_y, WasmGaussianMultivector);
|
|
5116
|
+
const ret = wasm.wasmmontecarloestimator_expectationGeometricProduct(dist_x.__wbg_ptr, dist_y.__wbg_ptr, num_samples);
|
|
5117
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5118
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5119
|
+
return v1;
|
|
4428
5120
|
}
|
|
4429
5121
|
}
|
|
4430
5122
|
|
|
@@ -6214,7 +6906,7 @@ export class WasmTrajectoryPoint {
|
|
|
6214
6906
|
* @returns {number}
|
|
6215
6907
|
*/
|
|
6216
6908
|
get time() {
|
|
6217
|
-
const ret = wasm.
|
|
6909
|
+
const ret = wasm.__wbg_get_wasmmcmcdiagnostics_acceptance_rate(this.__wbg_ptr);
|
|
6218
6910
|
return ret;
|
|
6219
6911
|
}
|
|
6220
6912
|
/**
|
|
@@ -6222,7 +6914,7 @@ export class WasmTrajectoryPoint {
|
|
|
6222
6914
|
* @param {number} arg0
|
|
6223
6915
|
*/
|
|
6224
6916
|
set time(arg0) {
|
|
6225
|
-
wasm.
|
|
6917
|
+
wasm.__wbg_set_wasmmcmcdiagnostics_acceptance_rate(this.__wbg_ptr, arg0);
|
|
6226
6918
|
}
|
|
6227
6919
|
/**
|
|
6228
6920
|
* Get position
|
|
@@ -7110,6 +7802,387 @@ export class WasmTropicalViterbi {
|
|
|
7110
7802
|
}
|
|
7111
7803
|
}
|
|
7112
7804
|
|
|
7805
|
+
const WasmUncertainMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7806
|
+
? { register: () => {}, unregister: () => {} }
|
|
7807
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmuncertainmultivector_free(ptr >>> 0, 1));
|
|
7808
|
+
/**
|
|
7809
|
+
* WASM wrapper for uncertain multivector (mean + covariance)
|
|
7810
|
+
*
|
|
7811
|
+
* Represents a multivector with associated uncertainty, useful for
|
|
7812
|
+
* error propagation through geometric operations.
|
|
7813
|
+
*/
|
|
7814
|
+
export class WasmUncertainMultivector {
|
|
7815
|
+
|
|
7816
|
+
static __wrap(ptr) {
|
|
7817
|
+
ptr = ptr >>> 0;
|
|
7818
|
+
const obj = Object.create(WasmUncertainMultivector.prototype);
|
|
7819
|
+
obj.__wbg_ptr = ptr;
|
|
7820
|
+
WasmUncertainMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7821
|
+
return obj;
|
|
7822
|
+
}
|
|
7823
|
+
|
|
7824
|
+
__destroy_into_raw() {
|
|
7825
|
+
const ptr = this.__wbg_ptr;
|
|
7826
|
+
this.__wbg_ptr = 0;
|
|
7827
|
+
WasmUncertainMultivectorFinalization.unregister(this);
|
|
7828
|
+
return ptr;
|
|
7829
|
+
}
|
|
7830
|
+
|
|
7831
|
+
free() {
|
|
7832
|
+
const ptr = this.__destroy_into_raw();
|
|
7833
|
+
wasm.__wbg_wasmuncertainmultivector_free(ptr, 0);
|
|
7834
|
+
}
|
|
7835
|
+
/**
|
|
7836
|
+
* Get standard deviations
|
|
7837
|
+
* @returns {Float64Array}
|
|
7838
|
+
*/
|
|
7839
|
+
getStdDevs() {
|
|
7840
|
+
const ret = wasm.wasmuncertainmultivector_getStdDevs(this.__wbg_ptr);
|
|
7841
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7842
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7843
|
+
return v1;
|
|
7844
|
+
}
|
|
7845
|
+
/**
|
|
7846
|
+
* Create a deterministic (zero variance) uncertain multivector
|
|
7847
|
+
* @param {Float64Array} value
|
|
7848
|
+
* @returns {WasmUncertainMultivector}
|
|
7849
|
+
*/
|
|
7850
|
+
static deterministic(value) {
|
|
7851
|
+
const ptr0 = passArrayF64ToWasm0(value, wasm.__wbindgen_malloc);
|
|
7852
|
+
const len0 = WASM_VECTOR_LEN;
|
|
7853
|
+
const ret = wasm.wasmuncertainmultivector_deterministic(ptr0, len0);
|
|
7854
|
+
if (ret[2]) {
|
|
7855
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7856
|
+
}
|
|
7857
|
+
return WasmUncertainMultivector.__wrap(ret[0]);
|
|
7858
|
+
}
|
|
7859
|
+
/**
|
|
7860
|
+
* Get variances (diagonal of covariance)
|
|
7861
|
+
* @returns {Float64Array}
|
|
7862
|
+
*/
|
|
7863
|
+
getVariances() {
|
|
7864
|
+
const ret = wasm.wasmuncertainmultivector_getVariances(this.__wbg_ptr);
|
|
7865
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7866
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7867
|
+
return v1;
|
|
7868
|
+
}
|
|
7869
|
+
/**
|
|
7870
|
+
* Get the covariance matrix (64 values, row-major)
|
|
7871
|
+
* @returns {Float64Array}
|
|
7872
|
+
*/
|
|
7873
|
+
getCovariance() {
|
|
7874
|
+
const ret = wasm.wasmuncertainmultivector_getCovariance(this.__wbg_ptr);
|
|
7875
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7876
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7877
|
+
return v1;
|
|
7878
|
+
}
|
|
7879
|
+
/**
|
|
7880
|
+
* Create with full covariance matrix
|
|
7881
|
+
*
|
|
7882
|
+
* # Arguments
|
|
7883
|
+
* * `mean` - 8 coefficients for the mean
|
|
7884
|
+
* * `covariance` - 64 values for 8x8 covariance matrix (row-major)
|
|
7885
|
+
* @param {Float64Array} mean
|
|
7886
|
+
* @param {Float64Array} covariance
|
|
7887
|
+
* @returns {WasmUncertainMultivector}
|
|
7888
|
+
*/
|
|
7889
|
+
static withCovariance(mean, covariance) {
|
|
7890
|
+
const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
|
|
7891
|
+
const len0 = WASM_VECTOR_LEN;
|
|
7892
|
+
const ptr1 = passArrayF64ToWasm0(covariance, wasm.__wbindgen_malloc);
|
|
7893
|
+
const len1 = WASM_VECTOR_LEN;
|
|
7894
|
+
const ret = wasm.wasmuncertainmultivector_withCovariance(ptr0, len0, ptr1, len1);
|
|
7895
|
+
if (ret[2]) {
|
|
7896
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7897
|
+
}
|
|
7898
|
+
return WasmUncertainMultivector.__wrap(ret[0]);
|
|
7899
|
+
}
|
|
7900
|
+
/**
|
|
7901
|
+
* Get total variance (trace of covariance)
|
|
7902
|
+
* @returns {number}
|
|
7903
|
+
*/
|
|
7904
|
+
getTotalVariance() {
|
|
7905
|
+
const ret = wasm.wasmuncertainmultivector_getTotalVariance(this.__wbg_ptr);
|
|
7906
|
+
return ret;
|
|
7907
|
+
}
|
|
7908
|
+
/**
|
|
7909
|
+
* Add two uncertain multivectors (assuming independence)
|
|
7910
|
+
*
|
|
7911
|
+
* For Z = X + Y: E[Z] = E[X] + E[Y], Var(Z) = Var(X) + Var(Y)
|
|
7912
|
+
* @param {WasmUncertainMultivector} other
|
|
7913
|
+
* @returns {WasmUncertainMultivector}
|
|
7914
|
+
*/
|
|
7915
|
+
add(other) {
|
|
7916
|
+
_assertClass(other, WasmUncertainMultivector);
|
|
7917
|
+
const ret = wasm.wasmuncertainmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
|
|
7918
|
+
return WasmUncertainMultivector.__wrap(ret);
|
|
7919
|
+
}
|
|
7920
|
+
/**
|
|
7921
|
+
* Create an uncertain multivector with diagonal covariance
|
|
7922
|
+
*
|
|
7923
|
+
* # Arguments
|
|
7924
|
+
* * `mean` - 8 coefficients for the mean
|
|
7925
|
+
* * `variances` - 8 values for per-coefficient variance
|
|
7926
|
+
* @param {Float64Array} mean
|
|
7927
|
+
* @param {Float64Array} variances
|
|
7928
|
+
*/
|
|
7929
|
+
constructor(mean, variances) {
|
|
7930
|
+
const ptr0 = passArrayF64ToWasm0(mean, wasm.__wbindgen_malloc);
|
|
7931
|
+
const len0 = WASM_VECTOR_LEN;
|
|
7932
|
+
const ptr1 = passArrayF64ToWasm0(variances, wasm.__wbindgen_malloc);
|
|
7933
|
+
const len1 = WASM_VECTOR_LEN;
|
|
7934
|
+
const ret = wasm.wasmuncertainmultivector_new(ptr0, len0, ptr1, len1);
|
|
7935
|
+
if (ret[2]) {
|
|
7936
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7937
|
+
}
|
|
7938
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
7939
|
+
WasmUncertainMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
7940
|
+
return this;
|
|
7941
|
+
}
|
|
7942
|
+
/**
|
|
7943
|
+
* Linear propagation: scale by a constant
|
|
7944
|
+
*
|
|
7945
|
+
* For Y = aX: E[Y] = aE[X], Var(Y) = a²Var(X)
|
|
7946
|
+
* @param {number} scalar
|
|
7947
|
+
* @returns {WasmUncertainMultivector}
|
|
7948
|
+
*/
|
|
7949
|
+
scale(scalar) {
|
|
7950
|
+
const ret = wasm.wasmuncertainmultivector_scale(this.__wbg_ptr, scalar);
|
|
7951
|
+
return WasmUncertainMultivector.__wrap(ret);
|
|
7952
|
+
}
|
|
7953
|
+
/**
|
|
7954
|
+
* Get the mean
|
|
7955
|
+
* @returns {Float64Array}
|
|
7956
|
+
*/
|
|
7957
|
+
getMean() {
|
|
7958
|
+
const ret = wasm.wasmuncertainmultivector_getMean(this.__wbg_ptr);
|
|
7959
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7960
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7961
|
+
return v1;
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
|
|
7965
|
+
const WasmUniformMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7966
|
+
? { register: () => {}, unregister: () => {} }
|
|
7967
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmuniformmultivector_free(ptr >>> 0, 1));
|
|
7968
|
+
/**
|
|
7969
|
+
* WASM wrapper for Uniform distribution on Cl(3,0,0) multivector space
|
|
7970
|
+
*
|
|
7971
|
+
* A uniform distribution over a hyperrectangle in 8-dimensional multivector space.
|
|
7972
|
+
*/
|
|
7973
|
+
export class WasmUniformMultivector {
|
|
7974
|
+
|
|
7975
|
+
static __wrap(ptr) {
|
|
7976
|
+
ptr = ptr >>> 0;
|
|
7977
|
+
const obj = Object.create(WasmUniformMultivector.prototype);
|
|
7978
|
+
obj.__wbg_ptr = ptr;
|
|
7979
|
+
WasmUniformMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7980
|
+
return obj;
|
|
7981
|
+
}
|
|
7982
|
+
|
|
7983
|
+
__destroy_into_raw() {
|
|
7984
|
+
const ptr = this.__wbg_ptr;
|
|
7985
|
+
this.__wbg_ptr = 0;
|
|
7986
|
+
WasmUniformMultivectorFinalization.unregister(this);
|
|
7987
|
+
return ptr;
|
|
7988
|
+
}
|
|
7989
|
+
|
|
7990
|
+
free() {
|
|
7991
|
+
const ptr = this.__destroy_into_raw();
|
|
7992
|
+
wasm.__wbg_wasmuniformmultivector_free(ptr, 0);
|
|
7993
|
+
}
|
|
7994
|
+
/**
|
|
7995
|
+
* Create a uniform distribution with specified bounds
|
|
7996
|
+
*
|
|
7997
|
+
* # Arguments
|
|
7998
|
+
* * `lower` - 8 coefficients for lower bounds
|
|
7999
|
+
* * `upper` - 8 coefficients for upper bounds
|
|
8000
|
+
* @param {Float64Array} lower
|
|
8001
|
+
* @param {Float64Array} upper
|
|
8002
|
+
* @returns {WasmUniformMultivector}
|
|
8003
|
+
*/
|
|
8004
|
+
static withBounds(lower, upper) {
|
|
8005
|
+
const ptr0 = passArrayF64ToWasm0(lower, wasm.__wbindgen_malloc);
|
|
8006
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8007
|
+
const ptr1 = passArrayF64ToWasm0(upper, wasm.__wbindgen_malloc);
|
|
8008
|
+
const len1 = WASM_VECTOR_LEN;
|
|
8009
|
+
const ret = wasm.wasmuniformmultivector_withBounds(ptr0, len0, ptr1, len1);
|
|
8010
|
+
if (ret[2]) {
|
|
8011
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8012
|
+
}
|
|
8013
|
+
return WasmUniformMultivector.__wrap(ret[0]);
|
|
8014
|
+
}
|
|
8015
|
+
/**
|
|
8016
|
+
* Get the variance of this distribution
|
|
8017
|
+
* @returns {Float64Array}
|
|
8018
|
+
*/
|
|
8019
|
+
getVariance() {
|
|
8020
|
+
const ret = wasm.wasmuniformmultivector_getVariance(this.__wbg_ptr);
|
|
8021
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8022
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8023
|
+
return v1;
|
|
8024
|
+
}
|
|
8025
|
+
/**
|
|
8026
|
+
* Draw multiple samples from this distribution
|
|
8027
|
+
*
|
|
8028
|
+
* Returns flat array of coefficients: num_samples * 8
|
|
8029
|
+
* @param {number} num_samples
|
|
8030
|
+
* @returns {Float64Array}
|
|
8031
|
+
*/
|
|
8032
|
+
sampleBatch(num_samples) {
|
|
8033
|
+
const ret = wasm.wasmuniformmultivector_sampleBatch(this.__wbg_ptr, num_samples);
|
|
8034
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8035
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8036
|
+
return v1;
|
|
8037
|
+
}
|
|
8038
|
+
/**
|
|
8039
|
+
* Create a standard uniform distribution on [-1, 1]^8
|
|
8040
|
+
*/
|
|
8041
|
+
constructor() {
|
|
8042
|
+
const ret = wasm.wasmuniformmultivector_new();
|
|
8043
|
+
if (ret[2]) {
|
|
8044
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8045
|
+
}
|
|
8046
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
8047
|
+
WasmUniformMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
8048
|
+
return this;
|
|
8049
|
+
}
|
|
8050
|
+
/**
|
|
8051
|
+
* Draw a sample from this distribution
|
|
8052
|
+
*
|
|
8053
|
+
* Returns 8 coefficients for the sampled multivector
|
|
8054
|
+
* @returns {Float64Array}
|
|
8055
|
+
*/
|
|
8056
|
+
sample() {
|
|
8057
|
+
const ret = wasm.wasmuniformmultivector_sample(this.__wbg_ptr);
|
|
8058
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8059
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8060
|
+
return v1;
|
|
8061
|
+
}
|
|
8062
|
+
/**
|
|
8063
|
+
* Get the mean of this distribution
|
|
8064
|
+
* @returns {Float64Array}
|
|
8065
|
+
*/
|
|
8066
|
+
getMean() {
|
|
8067
|
+
const ret = wasm.wasmuniformmultivector_getMean(this.__wbg_ptr);
|
|
8068
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8069
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8070
|
+
return v1;
|
|
8071
|
+
}
|
|
8072
|
+
/**
|
|
8073
|
+
* Compute log probability of a multivector
|
|
8074
|
+
*
|
|
8075
|
+
* Returns log(1/volume) if inside bounds, error otherwise
|
|
8076
|
+
* @param {Float64Array} coefficients
|
|
8077
|
+
* @returns {number}
|
|
8078
|
+
*/
|
|
8079
|
+
logProb(coefficients) {
|
|
8080
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
8081
|
+
const len0 = WASM_VECTOR_LEN;
|
|
8082
|
+
const ret = wasm.wasmuniformmultivector_logProb(this.__wbg_ptr, ptr0, len0);
|
|
8083
|
+
if (ret[2]) {
|
|
8084
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8085
|
+
}
|
|
8086
|
+
return ret[0];
|
|
8087
|
+
}
|
|
8088
|
+
/**
|
|
8089
|
+
* Get the lower bounds
|
|
8090
|
+
* @returns {Float64Array}
|
|
8091
|
+
*/
|
|
8092
|
+
getLower() {
|
|
8093
|
+
const ret = wasm.wasmuniformmultivector_getLower(this.__wbg_ptr);
|
|
8094
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8095
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8096
|
+
return v1;
|
|
8097
|
+
}
|
|
8098
|
+
/**
|
|
8099
|
+
* Get the upper bounds
|
|
8100
|
+
* @returns {Float64Array}
|
|
8101
|
+
*/
|
|
8102
|
+
getUpper() {
|
|
8103
|
+
const ret = wasm.wasmuniformmultivector_getUpper(this.__wbg_ptr);
|
|
8104
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8105
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8106
|
+
return v1;
|
|
8107
|
+
}
|
|
8108
|
+
/**
|
|
8109
|
+
* Create a uniform distribution on a hypercube [min, max]^8
|
|
8110
|
+
* @param {number} min
|
|
8111
|
+
* @param {number} max
|
|
8112
|
+
* @returns {WasmUniformMultivector}
|
|
8113
|
+
*/
|
|
8114
|
+
static hypercube(min, max) {
|
|
8115
|
+
const ret = wasm.wasmuniformmultivector_hypercube(min, max);
|
|
8116
|
+
if (ret[2]) {
|
|
8117
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8118
|
+
}
|
|
8119
|
+
return WasmUniformMultivector.__wrap(ret[0]);
|
|
8120
|
+
}
|
|
8121
|
+
}
|
|
8122
|
+
|
|
8123
|
+
const WasmWienerProcessFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
8124
|
+
? { register: () => {}, unregister: () => {} }
|
|
8125
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmwienerprocess_free(ptr >>> 0, 1));
|
|
8126
|
+
/**
|
|
8127
|
+
* WASM wrapper for Wiener process (Brownian motion)
|
|
8128
|
+
*
|
|
8129
|
+
* Standard Brownian motion W(t) with W(0) = 0
|
|
8130
|
+
*/
|
|
8131
|
+
export class WasmWienerProcess {
|
|
8132
|
+
|
|
8133
|
+
__destroy_into_raw() {
|
|
8134
|
+
const ptr = this.__wbg_ptr;
|
|
8135
|
+
this.__wbg_ptr = 0;
|
|
8136
|
+
WasmWienerProcessFinalization.unregister(this);
|
|
8137
|
+
return ptr;
|
|
8138
|
+
}
|
|
8139
|
+
|
|
8140
|
+
free() {
|
|
8141
|
+
const ptr = this.__destroy_into_raw();
|
|
8142
|
+
wasm.__wbg_wasmwienerprocess_free(ptr, 0);
|
|
8143
|
+
}
|
|
8144
|
+
/**
|
|
8145
|
+
* Sample a path of the Wiener process
|
|
8146
|
+
*
|
|
8147
|
+
* # Arguments
|
|
8148
|
+
* * `t_end` - End time
|
|
8149
|
+
* * `num_steps` - Number of time steps
|
|
8150
|
+
*
|
|
8151
|
+
* Returns flat array: (num_steps + 1) * (dim + 1) values
|
|
8152
|
+
* Each point is [time, w0, w1, ...]
|
|
8153
|
+
* @param {number} t_end
|
|
8154
|
+
* @param {number} num_steps
|
|
8155
|
+
* @returns {Float64Array}
|
|
8156
|
+
*/
|
|
8157
|
+
samplePath(t_end, num_steps) {
|
|
8158
|
+
const ret = wasm.wasmwienerprocess_samplePath(this.__wbg_ptr, t_end, num_steps);
|
|
8159
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
8160
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
8161
|
+
return v1;
|
|
8162
|
+
}
|
|
8163
|
+
/**
|
|
8164
|
+
* Create a new Wiener process
|
|
8165
|
+
*
|
|
8166
|
+
* # Arguments
|
|
8167
|
+
* * `dim` - Dimension of the process (default 8 for multivector space)
|
|
8168
|
+
* @param {number | null} [dim]
|
|
8169
|
+
*/
|
|
8170
|
+
constructor(dim) {
|
|
8171
|
+
const ret = wasm.wasmwienerprocess_new(isLikeNone(dim) ? 0x100000001 : (dim) >>> 0);
|
|
8172
|
+
this.__wbg_ptr = ret >>> 0;
|
|
8173
|
+
WasmWienerProcessFinalization.register(this, this.__wbg_ptr, this);
|
|
8174
|
+
return this;
|
|
8175
|
+
}
|
|
8176
|
+
/**
|
|
8177
|
+
* Get dimension
|
|
8178
|
+
* @returns {number}
|
|
8179
|
+
*/
|
|
8180
|
+
getDim() {
|
|
8181
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
8182
|
+
return ret >>> 0;
|
|
8183
|
+
}
|
|
8184
|
+
}
|
|
8185
|
+
|
|
7113
8186
|
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
7114
8187
|
|
|
7115
8188
|
async function __wbg_load(module, imports) {
|
|
@@ -7191,12 +8264,12 @@ function __wbg_get_imports() {
|
|
|
7191
8264
|
const ret = arg0.length;
|
|
7192
8265
|
return ret;
|
|
7193
8266
|
};
|
|
7194
|
-
imports.wbg.__wbg_log_73e7856ded7435b4 = function(arg0, arg1) {
|
|
7195
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
7196
|
-
};
|
|
7197
8267
|
imports.wbg.__wbg_log_ea240990d83e374e = function(arg0) {
|
|
7198
8268
|
console.log(arg0);
|
|
7199
8269
|
};
|
|
8270
|
+
imports.wbg.__wbg_log_fcb816babb5e424a = function(arg0, arg1) {
|
|
8271
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
8272
|
+
};
|
|
7200
8273
|
imports.wbg.__wbg_new_07b483f72211fd66 = function() {
|
|
7201
8274
|
const ret = new Object();
|
|
7202
8275
|
return ret;
|
|
@@ -7216,7 +8289,7 @@ function __wbg_get_imports() {
|
|
|
7216
8289
|
const a = state0.a;
|
|
7217
8290
|
state0.a = 0;
|
|
7218
8291
|
try {
|
|
7219
|
-
return
|
|
8292
|
+
return __wbg_adapter_550(a, state0.b, arg0, arg1);
|
|
7220
8293
|
} finally {
|
|
7221
8294
|
state0.a = a;
|
|
7222
8295
|
}
|
|
@@ -7316,8 +8389,8 @@ function __wbg_get_imports() {
|
|
|
7316
8389
|
const ret = false;
|
|
7317
8390
|
return ret;
|
|
7318
8391
|
};
|
|
7319
|
-
imports.wbg.
|
|
7320
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
8392
|
+
imports.wbg.__wbindgen_closure_wrapper1708 = function(arg0, arg1, arg2) {
|
|
8393
|
+
const ret = makeMutClosure(arg0, arg1, 40, __wbg_adapter_28);
|
|
7321
8394
|
return ret;
|
|
7322
8395
|
};
|
|
7323
8396
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|