@justinelliottcobb/amari-wasm 0.12.3 → 0.13.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 +211 -2
- package/amari_wasm.js +457 -7
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @justinelliottcobb/amari-wasm v0.
|
|
1
|
+
# @justinelliottcobb/amari-wasm v0.13.0
|
|
2
2
|
|
|
3
3
|
**Unified Mathematical Computing Library with High-Precision WebAssembly Support**
|
|
4
4
|
|
|
@@ -16,7 +16,8 @@ Amari is a comprehensive mathematical computing library that brings advanced alg
|
|
|
16
16
|
- **Tropical Algebra**: Max-plus semiring operations for optimization and neural network applications
|
|
17
17
|
- **Automatic Differentiation**: Forward-mode AD with dual numbers for exact derivatives
|
|
18
18
|
- **Measure Theory** *(v0.10.0)*: Lebesgue integration, probability measures, and measure-theoretic foundations
|
|
19
|
-
- **Holographic Memory** *(v0.12.
|
|
19
|
+
- **Holographic Memory** *(v0.12.3)*: Vector Symbolic Architecture for associative memory with binding and bundling operations
|
|
20
|
+
- **Probability Theory** *(v0.13.0)*: Distributions on multivector spaces, MCMC sampling, and Monte Carlo estimation
|
|
20
21
|
- **Relativistic Physics**: Spacetime algebra (Cl(1,3)) with WebAssembly-compatible precision
|
|
21
22
|
- **Spacecraft Orbital Mechanics**: Full-precision trajectory calculations in browsers
|
|
22
23
|
- **Cellular Automata**: Geometric cellular automata with multivector states
|
|
@@ -275,6 +276,82 @@ async function holographicDemo() {
|
|
|
275
276
|
holographicDemo();
|
|
276
277
|
```
|
|
277
278
|
|
|
279
|
+
### Probability on Geometric Algebra *(v0.13.0)*
|
|
280
|
+
|
|
281
|
+
Sample from distributions on multivector spaces and perform Monte Carlo estimation:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import init, {
|
|
285
|
+
WasmGaussianMultivector,
|
|
286
|
+
WasmUniformMultivector,
|
|
287
|
+
WasmMonteCarloEstimator
|
|
288
|
+
} from '@justinelliottcobb/amari-wasm';
|
|
289
|
+
|
|
290
|
+
async function probabilisticDemo() {
|
|
291
|
+
await init();
|
|
292
|
+
|
|
293
|
+
// Create a standard Gaussian distribution on Cl(3,0,0)
|
|
294
|
+
const gaussian = WasmGaussianMultivector.standard();
|
|
295
|
+
|
|
296
|
+
// Draw samples
|
|
297
|
+
const samples = [];
|
|
298
|
+
for (let i = 0; i < 1000; i++) {
|
|
299
|
+
samples.push(gaussian.sample());
|
|
300
|
+
}
|
|
301
|
+
console.log(`Drew ${samples.length} Gaussian samples`);
|
|
302
|
+
|
|
303
|
+
// Compute log probability
|
|
304
|
+
const sample = gaussian.sample();
|
|
305
|
+
const logProb = gaussian.logProb(sample);
|
|
306
|
+
console.log(`Log probability: ${logProb}`);
|
|
307
|
+
|
|
308
|
+
// Grade-concentrated distribution (e.g., only on bivectors)
|
|
309
|
+
const bivectorDist = WasmGaussianMultivector.gradeConcentrated(2, 1.0);
|
|
310
|
+
const bivectorSample = bivectorDist.sample();
|
|
311
|
+
|
|
312
|
+
// Uniform distribution on unit multivectors
|
|
313
|
+
const uniform = WasmUniformMultivector.unitSphere();
|
|
314
|
+
const unitSample = uniform.sample();
|
|
315
|
+
|
|
316
|
+
// Monte Carlo estimation
|
|
317
|
+
const estimator = new WasmMonteCarloEstimator();
|
|
318
|
+
|
|
319
|
+
// Estimate expectation of a function
|
|
320
|
+
const estimate = estimator.estimate((mv) => mv.norm(), gaussian, 10000);
|
|
321
|
+
console.log(`Expected norm: ${estimate.mean} ± ${estimate.stdError}`);
|
|
322
|
+
|
|
323
|
+
// Clean up WASM memory
|
|
324
|
+
gaussian.free();
|
|
325
|
+
bivectorDist.free();
|
|
326
|
+
uniform.free();
|
|
327
|
+
sample.free();
|
|
328
|
+
bivectorSample.free();
|
|
329
|
+
unitSample.free();
|
|
330
|
+
estimator.free();
|
|
331
|
+
samples.forEach(s => s.free());
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
probabilisticDemo();
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
#### Probability API
|
|
338
|
+
|
|
339
|
+
**WasmGaussianMultivector:**
|
|
340
|
+
- `standard()`: Create standard Gaussian on full multivector space
|
|
341
|
+
- `new(mean, covariance)`: Create with specified mean and covariance
|
|
342
|
+
- `gradeConcentrated(grade, scale)`: Gaussian concentrated on specific grade
|
|
343
|
+
- `sample()`: Draw a random sample
|
|
344
|
+
- `logProb(sample)`: Compute log probability density
|
|
345
|
+
|
|
346
|
+
**WasmUniformMultivector:**
|
|
347
|
+
- `unitSphere()`: Uniform distribution on unit multivectors
|
|
348
|
+
- `gradeSimplex(grade)`: Uniform on grade components summing to 1
|
|
349
|
+
- `sample()`: Draw a random sample
|
|
350
|
+
|
|
351
|
+
**WasmMonteCarloEstimator:**
|
|
352
|
+
- `estimate(fn, distribution, nSamples)`: Estimate expectation
|
|
353
|
+
- `estimateVariance(fn, distribution, nSamples)`: Estimate variance
|
|
354
|
+
|
|
278
355
|
#### Holographic Memory API
|
|
279
356
|
|
|
280
357
|
**TropicalDualClifford Operations:**
|
|
@@ -307,6 +384,8 @@ holographicDemo();
|
|
|
307
384
|
- **Optimization**: Tropical algebra for shortest path and scheduling problems
|
|
308
385
|
- **Scientific Computing**: High-performance mathematical operations with orbital-grade precision
|
|
309
386
|
- **Probability & Statistics**: Measure theory and numerical integration for statistical computations
|
|
387
|
+
- **Bayesian Inference**: Probabilistic modeling on geometric algebra spaces
|
|
388
|
+
- **Uncertainty Quantification**: Monte Carlo methods for error propagation
|
|
310
389
|
- **Game Development**: Efficient spatial transformations and physics
|
|
311
390
|
- **Spacecraft Trajectory Planning**: High-precision orbital mechanics in web applications
|
|
312
391
|
- **Symbolic AI**: Holographic memory for associative reasoning and concept binding
|
|
@@ -348,6 +427,16 @@ holographicDemo();
|
|
|
348
427
|
- `WasmHolographicMemory.retrieve(key)`: Retrieve by key
|
|
349
428
|
- `WasmResonator.cleanup(input)`: Clean up noisy input
|
|
350
429
|
|
|
430
|
+
### Probabilistic Operations
|
|
431
|
+
|
|
432
|
+
- `WasmGaussianMultivector.standard()`: Standard Gaussian distribution
|
|
433
|
+
- `WasmGaussianMultivector.gradeConcentrated(grade, scale)`: Grade-specific Gaussian
|
|
434
|
+
- `WasmGaussianMultivector.sample()`: Draw random sample
|
|
435
|
+
- `WasmGaussianMultivector.logProb(sample)`: Log probability density
|
|
436
|
+
- `WasmUniformMultivector.unitSphere()`: Uniform on unit sphere
|
|
437
|
+
- `WasmUniformMultivector.sample()`: Draw random sample
|
|
438
|
+
- `WasmMonteCarloEstimator.estimate(fn, dist, n)`: Monte Carlo expectation
|
|
439
|
+
|
|
351
440
|
## Examples
|
|
352
441
|
|
|
353
442
|
Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tree/master/examples) for more detailed usage:
|
package/amari_wasm.d.ts
CHANGED
|
@@ -1165,6 +1165,86 @@ export class WasmFourVelocity {
|
|
|
1165
1165
|
*/
|
|
1166
1166
|
to_string(): string;
|
|
1167
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* WASM wrapper for Gaussian distribution on Cl(3,0,0) multivector space
|
|
1170
|
+
*
|
|
1171
|
+
* A Gaussian distribution over 8-dimensional multivector space with
|
|
1172
|
+
* configurable mean and per-component standard deviation.
|
|
1173
|
+
*/
|
|
1174
|
+
export class WasmGaussianMultivector {
|
|
1175
|
+
free(): void;
|
|
1176
|
+
/**
|
|
1177
|
+
* Get the standard deviations
|
|
1178
|
+
*
|
|
1179
|
+
* Returns 8 values
|
|
1180
|
+
*/
|
|
1181
|
+
getStdDevs(): Float64Array;
|
|
1182
|
+
/**
|
|
1183
|
+
* Get the variance (square of std devs)
|
|
1184
|
+
*
|
|
1185
|
+
* Returns 8 values
|
|
1186
|
+
*/
|
|
1187
|
+
getVariance(): Float64Array;
|
|
1188
|
+
/**
|
|
1189
|
+
* Draw multiple samples from this distribution
|
|
1190
|
+
*
|
|
1191
|
+
* Returns flat array of coefficients: num_samples * 8
|
|
1192
|
+
*/
|
|
1193
|
+
sampleBatch(num_samples: number): Float64Array;
|
|
1194
|
+
/**
|
|
1195
|
+
* Get the full covariance matrix (flattened, row-major)
|
|
1196
|
+
*
|
|
1197
|
+
* Returns 64 values (8x8 matrix)
|
|
1198
|
+
*/
|
|
1199
|
+
getCovariance(): Float64Array;
|
|
1200
|
+
/**
|
|
1201
|
+
* Create a Gaussian with specified mean and standard deviation
|
|
1202
|
+
*
|
|
1203
|
+
* # Arguments
|
|
1204
|
+
* * `mean` - 8 coefficients for the mean multivector
|
|
1205
|
+
* * `std_dev` - 8 coefficients for per-coefficient standard deviation
|
|
1206
|
+
*/
|
|
1207
|
+
static withParameters(mean: Float64Array, std_dev: Float64Array): WasmGaussianMultivector;
|
|
1208
|
+
/**
|
|
1209
|
+
* Create a Gaussian concentrated on a specific grade
|
|
1210
|
+
*
|
|
1211
|
+
* # Arguments
|
|
1212
|
+
* * `grade` - The grade to concentrate on (0=scalar, 1=vectors, 2=bivectors, 3=pseudoscalar)
|
|
1213
|
+
* * `variance` - Variance for coefficients of that grade
|
|
1214
|
+
*/
|
|
1215
|
+
static gradeConcentrated(grade: number, variance: number): WasmGaussianMultivector;
|
|
1216
|
+
/**
|
|
1217
|
+
* Create a standard Gaussian (zero mean, unit variance per coefficient)
|
|
1218
|
+
*/
|
|
1219
|
+
constructor();
|
|
1220
|
+
/**
|
|
1221
|
+
* Draw a sample from this distribution
|
|
1222
|
+
*
|
|
1223
|
+
* Returns 8 coefficients for the sampled multivector
|
|
1224
|
+
*/
|
|
1225
|
+
sample(): Float64Array;
|
|
1226
|
+
/**
|
|
1227
|
+
* Get the mean of this distribution
|
|
1228
|
+
*
|
|
1229
|
+
* Returns 8 coefficients
|
|
1230
|
+
*/
|
|
1231
|
+
getMean(): Float64Array;
|
|
1232
|
+
/**
|
|
1233
|
+
* Compute log probability of a multivector
|
|
1234
|
+
*
|
|
1235
|
+
* # Arguments
|
|
1236
|
+
* * `coefficients` - 8 coefficients of the multivector
|
|
1237
|
+
*/
|
|
1238
|
+
logProb(coefficients: Float64Array): number;
|
|
1239
|
+
/**
|
|
1240
|
+
* Create an isotropic Gaussian with given mean and variance
|
|
1241
|
+
*
|
|
1242
|
+
* # Arguments
|
|
1243
|
+
* * `mean` - 8 coefficients for the mean multivector
|
|
1244
|
+
* * `variance` - Variance (same for all components)
|
|
1245
|
+
*/
|
|
1246
|
+
static isotropic(mean: Float64Array, variance: number): WasmGaussianMultivector;
|
|
1247
|
+
}
|
|
1168
1248
|
/**
|
|
1169
1249
|
* WASM wrapper for geodesic integration
|
|
1170
1250
|
*/
|
|
@@ -1536,6 +1616,49 @@ export class WasmModuliSpace {
|
|
|
1536
1616
|
*/
|
|
1537
1617
|
static ofCurves(genus: number, marked_points: number): WasmModuliSpace;
|
|
1538
1618
|
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Monte Carlo estimation utilities
|
|
1621
|
+
*/
|
|
1622
|
+
export class WasmMonteCarloEstimator {
|
|
1623
|
+
private constructor();
|
|
1624
|
+
free(): void;
|
|
1625
|
+
/**
|
|
1626
|
+
* Compute sample mean from batch samples
|
|
1627
|
+
*
|
|
1628
|
+
* # Arguments
|
|
1629
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
1630
|
+
*
|
|
1631
|
+
* # Returns
|
|
1632
|
+
* 8 coefficients for the mean
|
|
1633
|
+
*/
|
|
1634
|
+
static sampleMean(samples: Float64Array): Float64Array;
|
|
1635
|
+
/**
|
|
1636
|
+
* Compute sample variance from batch samples
|
|
1637
|
+
*
|
|
1638
|
+
* # Arguments
|
|
1639
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
1640
|
+
*
|
|
1641
|
+
* # Returns
|
|
1642
|
+
* 8 values for per-coefficient variance
|
|
1643
|
+
*/
|
|
1644
|
+
static sampleVariance(samples: Float64Array): Float64Array;
|
|
1645
|
+
/**
|
|
1646
|
+
* Compute sample covariance matrix from batch samples
|
|
1647
|
+
*
|
|
1648
|
+
* # Arguments
|
|
1649
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
1650
|
+
*
|
|
1651
|
+
* # Returns
|
|
1652
|
+
* 64 values for 8x8 covariance matrix (row-major)
|
|
1653
|
+
*/
|
|
1654
|
+
static sampleCovariance(samples: Float64Array): Float64Array;
|
|
1655
|
+
/**
|
|
1656
|
+
* Monte Carlo estimate of expectation E[f(X)] where f is the geometric product
|
|
1657
|
+
*
|
|
1658
|
+
* Estimates E[X * Y] for independent X ~ dist_x, Y ~ dist_y
|
|
1659
|
+
*/
|
|
1660
|
+
static expectationGeometricProduct(dist_x: WasmGaussianMultivector, dist_y: WasmGaussianMultivector, num_samples: number): Float64Array;
|
|
1661
|
+
}
|
|
1539
1662
|
/**
|
|
1540
1663
|
* WASM wrapper for multi-variable dual numbers
|
|
1541
1664
|
*/
|
|
@@ -2509,6 +2632,64 @@ export class WasmTropicalViterbi {
|
|
|
2509
2632
|
*/
|
|
2510
2633
|
decode(observations: Uint32Array): any;
|
|
2511
2634
|
}
|
|
2635
|
+
/**
|
|
2636
|
+
* WASM wrapper for Uniform distribution on Cl(3,0,0) multivector space
|
|
2637
|
+
*
|
|
2638
|
+
* A uniform distribution over a hyperrectangle in 8-dimensional multivector space.
|
|
2639
|
+
*/
|
|
2640
|
+
export class WasmUniformMultivector {
|
|
2641
|
+
free(): void;
|
|
2642
|
+
/**
|
|
2643
|
+
* Create a uniform distribution with specified bounds
|
|
2644
|
+
*
|
|
2645
|
+
* # Arguments
|
|
2646
|
+
* * `lower` - 8 coefficients for lower bounds
|
|
2647
|
+
* * `upper` - 8 coefficients for upper bounds
|
|
2648
|
+
*/
|
|
2649
|
+
static withBounds(lower: Float64Array, upper: Float64Array): WasmUniformMultivector;
|
|
2650
|
+
/**
|
|
2651
|
+
* Get the variance of this distribution
|
|
2652
|
+
*/
|
|
2653
|
+
getVariance(): Float64Array;
|
|
2654
|
+
/**
|
|
2655
|
+
* Draw multiple samples from this distribution
|
|
2656
|
+
*
|
|
2657
|
+
* Returns flat array of coefficients: num_samples * 8
|
|
2658
|
+
*/
|
|
2659
|
+
sampleBatch(num_samples: number): Float64Array;
|
|
2660
|
+
/**
|
|
2661
|
+
* Create a standard uniform distribution on [-1, 1]^8
|
|
2662
|
+
*/
|
|
2663
|
+
constructor();
|
|
2664
|
+
/**
|
|
2665
|
+
* Draw a sample from this distribution
|
|
2666
|
+
*
|
|
2667
|
+
* Returns 8 coefficients for the sampled multivector
|
|
2668
|
+
*/
|
|
2669
|
+
sample(): Float64Array;
|
|
2670
|
+
/**
|
|
2671
|
+
* Get the mean of this distribution
|
|
2672
|
+
*/
|
|
2673
|
+
getMean(): Float64Array;
|
|
2674
|
+
/**
|
|
2675
|
+
* Compute log probability of a multivector
|
|
2676
|
+
*
|
|
2677
|
+
* Returns log(1/volume) if inside bounds, error otherwise
|
|
2678
|
+
*/
|
|
2679
|
+
logProb(coefficients: Float64Array): number;
|
|
2680
|
+
/**
|
|
2681
|
+
* Get the lower bounds
|
|
2682
|
+
*/
|
|
2683
|
+
getLower(): Float64Array;
|
|
2684
|
+
/**
|
|
2685
|
+
* Get the upper bounds
|
|
2686
|
+
*/
|
|
2687
|
+
getUpper(): Float64Array;
|
|
2688
|
+
/**
|
|
2689
|
+
* Create a uniform distribution on a hypercube [min, max]^8
|
|
2690
|
+
*/
|
|
2691
|
+
static hypercube(min: number, max: number): WasmUniformMultivector;
|
|
2692
|
+
}
|
|
2512
2693
|
|
|
2513
2694
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
2514
2695
|
|
|
@@ -2526,6 +2707,7 @@ export interface InitOutput {
|
|
|
2526
2707
|
readonly __wbg_wasmevaluationresult_free: (a: number, b: number) => void;
|
|
2527
2708
|
readonly __wbg_wasmfisherinformationmatrix_free: (a: number, b: number) => void;
|
|
2528
2709
|
readonly __wbg_wasmfishermeasure_free: (a: number, b: number) => void;
|
|
2710
|
+
readonly __wbg_wasmgaussianmultivector_free: (a: number, b: number) => void;
|
|
2529
2711
|
readonly __wbg_wasmgeodesicintegrator_free: (a: number, b: number) => void;
|
|
2530
2712
|
readonly __wbg_wasmgeometricca_free: (a: number, b: number) => void;
|
|
2531
2713
|
readonly __wbg_wasmgeometricnetwork_free: (a: number, b: number) => void;
|
|
@@ -2549,6 +2731,7 @@ export interface InitOutput {
|
|
|
2549
2731
|
readonly __wbg_wasmtropicalnetwork_free: (a: number, b: number) => void;
|
|
2550
2732
|
readonly __wbg_wasmtropicalpolynomial_free: (a: number, b: number) => void;
|
|
2551
2733
|
readonly __wbg_wasmtropicalviterbi_free: (a: number, b: number) => void;
|
|
2734
|
+
readonly __wbg_wasmuniformmultivector_free: (a: number, b: number) => void;
|
|
2552
2735
|
readonly autodiff_evaluatePolynomial: (a: number, b: number, c: number) => number;
|
|
2553
2736
|
readonly autodiff_linearLayer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2554
2737
|
readonly autodiff_meanSquaredError: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
@@ -2707,6 +2890,17 @@ export interface InitOutput {
|
|
|
2707
2890
|
readonly wasmfourvelocity_rapidity: (a: number) => number;
|
|
2708
2891
|
readonly wasmfourvelocity_spatial_velocity_magnitude: (a: number) => number;
|
|
2709
2892
|
readonly wasmfourvelocity_to_string: (a: number) => [number, number];
|
|
2893
|
+
readonly wasmgaussianmultivector_getCovariance: (a: number) => [number, number];
|
|
2894
|
+
readonly wasmgaussianmultivector_getMean: (a: number) => [number, number];
|
|
2895
|
+
readonly wasmgaussianmultivector_getStdDevs: (a: number) => [number, number];
|
|
2896
|
+
readonly wasmgaussianmultivector_getVariance: (a: number) => [number, number];
|
|
2897
|
+
readonly wasmgaussianmultivector_gradeConcentrated: (a: number, b: number) => [number, number, number];
|
|
2898
|
+
readonly wasmgaussianmultivector_isotropic: (a: number, b: number, c: number) => [number, number, number];
|
|
2899
|
+
readonly wasmgaussianmultivector_logProb: (a: number, b: number, c: number) => [number, number, number];
|
|
2900
|
+
readonly wasmgaussianmultivector_new: () => number;
|
|
2901
|
+
readonly wasmgaussianmultivector_sample: (a: number) => [number, number];
|
|
2902
|
+
readonly wasmgaussianmultivector_sampleBatch: (a: number, b: number) => [number, number];
|
|
2903
|
+
readonly wasmgaussianmultivector_withParameters: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2710
2904
|
readonly wasmgeodesicintegrator_propagate_particle: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2711
2905
|
readonly wasmgeodesicintegrator_with_schwarzschild: (a: number) => number;
|
|
2712
2906
|
readonly wasmgeometricca_addGlider: (a: number, b: number, c: number) => [number, number];
|
|
@@ -2778,6 +2972,10 @@ export interface InitOutput {
|
|
|
2778
2972
|
readonly wasmmodulispace_isProper: (a: number) => number;
|
|
2779
2973
|
readonly wasmmodulispace_ofCurves: (a: number, b: number) => number;
|
|
2780
2974
|
readonly wasmmodulispace_ofStableCurves: (a: number, b: number) => number;
|
|
2975
|
+
readonly wasmmontecarloestimator_expectationGeometricProduct: (a: number, b: number, c: number) => [number, number];
|
|
2976
|
+
readonly wasmmontecarloestimator_sampleCovariance: (a: number, b: number) => [number, number, number, number];
|
|
2977
|
+
readonly wasmmontecarloestimator_sampleMean: (a: number, b: number) => [number, number, number, number];
|
|
2978
|
+
readonly wasmmontecarloestimator_sampleVariance: (a: number, b: number) => [number, number, number, number];
|
|
2781
2979
|
readonly wasmmultidualnumber_add: (a: number, b: number) => [number, number, number];
|
|
2782
2980
|
readonly wasmmultidualnumber_constant: (a: number, b: number) => number;
|
|
2783
2981
|
readonly wasmmultidualnumber_getGradient: (a: number) => [number, number];
|
|
@@ -2938,6 +3136,16 @@ export interface InitOutput {
|
|
|
2938
3136
|
readonly wasmtropicalviterbi_decode: (a: number, b: number, c: number) => [number, number, number];
|
|
2939
3137
|
readonly wasmtropicalviterbi_forward_probabilities: (a: number, b: number, c: number) => [number, number, number];
|
|
2940
3138
|
readonly wasmtropicalviterbi_new: (a: any, b: any) => [number, number, number];
|
|
3139
|
+
readonly wasmuniformmultivector_getLower: (a: number) => [number, number];
|
|
3140
|
+
readonly wasmuniformmultivector_getMean: (a: number) => [number, number];
|
|
3141
|
+
readonly wasmuniformmultivector_getUpper: (a: number) => [number, number];
|
|
3142
|
+
readonly wasmuniformmultivector_getVariance: (a: number) => [number, number];
|
|
3143
|
+
readonly wasmuniformmultivector_hypercube: (a: number, b: number) => [number, number, number];
|
|
3144
|
+
readonly wasmuniformmultivector_logProb: (a: number, b: number, c: number) => [number, number, number];
|
|
3145
|
+
readonly wasmuniformmultivector_new: () => [number, number, number];
|
|
3146
|
+
readonly wasmuniformmultivector_sample: (a: number) => [number, number];
|
|
3147
|
+
readonly wasmuniformmultivector_sampleBatch: (a: number, b: number) => [number, number];
|
|
3148
|
+
readonly wasmuniformmultivector_withBounds: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2941
3149
|
readonly wasmtropicalnumber_new: (a: number) => number;
|
|
2942
3150
|
readonly vectorfield_fromFunction2D: (a: any) => number;
|
|
2943
3151
|
readonly vectorfield_fromFunction3D: (a: any) => number;
|
|
@@ -2993,6 +3201,7 @@ export interface InitOutput {
|
|
|
2993
3201
|
readonly __wbg_wasmfourvelocity_free: (a: number, b: number) => void;
|
|
2994
3202
|
readonly __wbg_wasmgeometricedge_free: (a: number, b: number) => void;
|
|
2995
3203
|
readonly __wbg_wasmgpuoptimizer_free: (a: number, b: number) => void;
|
|
3204
|
+
readonly __wbg_wasmmontecarloestimator_free: (a: number, b: number) => void;
|
|
2996
3205
|
readonly __wbg_wasmmultiobjectiveoptimizer_free: (a: number, b: number) => void;
|
|
2997
3206
|
readonly __wbg_wasmoptimizationutils_free: (a: number, b: number) => void;
|
|
2998
3207
|
readonly __wbg_wasmprojectivespace_free: (a: number, b: number) => void;
|
|
@@ -3017,8 +3226,8 @@ export interface InitOutput {
|
|
|
3017
3226
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
3018
3227
|
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
3019
3228
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
3020
|
-
readonly
|
|
3021
|
-
readonly
|
|
3229
|
+
readonly closure41_externref_shim: (a: number, b: number, c: any) => void;
|
|
3230
|
+
readonly closure34_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
3022
3231
|
readonly __wbindgen_start: () => void;
|
|
3023
3232
|
}
|
|
3024
3233
|
|
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_511(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));
|
|
@@ -4428,6 +4616,110 @@ export class WasmModuliSpace {
|
|
|
4428
4616
|
}
|
|
4429
4617
|
}
|
|
4430
4618
|
|
|
4619
|
+
const WasmMonteCarloEstimatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4620
|
+
? { register: () => {}, unregister: () => {} }
|
|
4621
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmontecarloestimator_free(ptr >>> 0, 1));
|
|
4622
|
+
/**
|
|
4623
|
+
* Monte Carlo estimation utilities
|
|
4624
|
+
*/
|
|
4625
|
+
export class WasmMonteCarloEstimator {
|
|
4626
|
+
|
|
4627
|
+
__destroy_into_raw() {
|
|
4628
|
+
const ptr = this.__wbg_ptr;
|
|
4629
|
+
this.__wbg_ptr = 0;
|
|
4630
|
+
WasmMonteCarloEstimatorFinalization.unregister(this);
|
|
4631
|
+
return ptr;
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
free() {
|
|
4635
|
+
const ptr = this.__destroy_into_raw();
|
|
4636
|
+
wasm.__wbg_wasmmontecarloestimator_free(ptr, 0);
|
|
4637
|
+
}
|
|
4638
|
+
/**
|
|
4639
|
+
* Compute sample mean from batch samples
|
|
4640
|
+
*
|
|
4641
|
+
* # Arguments
|
|
4642
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
4643
|
+
*
|
|
4644
|
+
* # Returns
|
|
4645
|
+
* 8 coefficients for the mean
|
|
4646
|
+
* @param {Float64Array} samples
|
|
4647
|
+
* @returns {Float64Array}
|
|
4648
|
+
*/
|
|
4649
|
+
static sampleMean(samples) {
|
|
4650
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
4651
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4652
|
+
const ret = wasm.wasmmontecarloestimator_sampleMean(ptr0, len0);
|
|
4653
|
+
if (ret[3]) {
|
|
4654
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4655
|
+
}
|
|
4656
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4657
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4658
|
+
return v2;
|
|
4659
|
+
}
|
|
4660
|
+
/**
|
|
4661
|
+
* Compute sample variance from batch samples
|
|
4662
|
+
*
|
|
4663
|
+
* # Arguments
|
|
4664
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
4665
|
+
*
|
|
4666
|
+
* # Returns
|
|
4667
|
+
* 8 values for per-coefficient variance
|
|
4668
|
+
* @param {Float64Array} samples
|
|
4669
|
+
* @returns {Float64Array}
|
|
4670
|
+
*/
|
|
4671
|
+
static sampleVariance(samples) {
|
|
4672
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
4673
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4674
|
+
const ret = wasm.wasmmontecarloestimator_sampleVariance(ptr0, len0);
|
|
4675
|
+
if (ret[3]) {
|
|
4676
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4677
|
+
}
|
|
4678
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4679
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4680
|
+
return v2;
|
|
4681
|
+
}
|
|
4682
|
+
/**
|
|
4683
|
+
* Compute sample covariance matrix from batch samples
|
|
4684
|
+
*
|
|
4685
|
+
* # Arguments
|
|
4686
|
+
* * `samples` - Flat array of samples (num_samples * 8)
|
|
4687
|
+
*
|
|
4688
|
+
* # Returns
|
|
4689
|
+
* 64 values for 8x8 covariance matrix (row-major)
|
|
4690
|
+
* @param {Float64Array} samples
|
|
4691
|
+
* @returns {Float64Array}
|
|
4692
|
+
*/
|
|
4693
|
+
static sampleCovariance(samples) {
|
|
4694
|
+
const ptr0 = passArrayF64ToWasm0(samples, wasm.__wbindgen_malloc);
|
|
4695
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4696
|
+
const ret = wasm.wasmmontecarloestimator_sampleCovariance(ptr0, len0);
|
|
4697
|
+
if (ret[3]) {
|
|
4698
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4699
|
+
}
|
|
4700
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4701
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4702
|
+
return v2;
|
|
4703
|
+
}
|
|
4704
|
+
/**
|
|
4705
|
+
* Monte Carlo estimate of expectation E[f(X)] where f is the geometric product
|
|
4706
|
+
*
|
|
4707
|
+
* Estimates E[X * Y] for independent X ~ dist_x, Y ~ dist_y
|
|
4708
|
+
* @param {WasmGaussianMultivector} dist_x
|
|
4709
|
+
* @param {WasmGaussianMultivector} dist_y
|
|
4710
|
+
* @param {number} num_samples
|
|
4711
|
+
* @returns {Float64Array}
|
|
4712
|
+
*/
|
|
4713
|
+
static expectationGeometricProduct(dist_x, dist_y, num_samples) {
|
|
4714
|
+
_assertClass(dist_x, WasmGaussianMultivector);
|
|
4715
|
+
_assertClass(dist_y, WasmGaussianMultivector);
|
|
4716
|
+
const ret = wasm.wasmmontecarloestimator_expectationGeometricProduct(dist_x.__wbg_ptr, dist_y.__wbg_ptr, num_samples);
|
|
4717
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4718
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4719
|
+
return v1;
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
|
|
4431
4723
|
const WasmMultiDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4432
4724
|
? { register: () => {}, unregister: () => {} }
|
|
4433
4725
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmultidualnumber_free(ptr >>> 0, 1));
|
|
@@ -7110,6 +7402,164 @@ export class WasmTropicalViterbi {
|
|
|
7110
7402
|
}
|
|
7111
7403
|
}
|
|
7112
7404
|
|
|
7405
|
+
const WasmUniformMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7406
|
+
? { register: () => {}, unregister: () => {} }
|
|
7407
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmuniformmultivector_free(ptr >>> 0, 1));
|
|
7408
|
+
/**
|
|
7409
|
+
* WASM wrapper for Uniform distribution on Cl(3,0,0) multivector space
|
|
7410
|
+
*
|
|
7411
|
+
* A uniform distribution over a hyperrectangle in 8-dimensional multivector space.
|
|
7412
|
+
*/
|
|
7413
|
+
export class WasmUniformMultivector {
|
|
7414
|
+
|
|
7415
|
+
static __wrap(ptr) {
|
|
7416
|
+
ptr = ptr >>> 0;
|
|
7417
|
+
const obj = Object.create(WasmUniformMultivector.prototype);
|
|
7418
|
+
obj.__wbg_ptr = ptr;
|
|
7419
|
+
WasmUniformMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7420
|
+
return obj;
|
|
7421
|
+
}
|
|
7422
|
+
|
|
7423
|
+
__destroy_into_raw() {
|
|
7424
|
+
const ptr = this.__wbg_ptr;
|
|
7425
|
+
this.__wbg_ptr = 0;
|
|
7426
|
+
WasmUniformMultivectorFinalization.unregister(this);
|
|
7427
|
+
return ptr;
|
|
7428
|
+
}
|
|
7429
|
+
|
|
7430
|
+
free() {
|
|
7431
|
+
const ptr = this.__destroy_into_raw();
|
|
7432
|
+
wasm.__wbg_wasmuniformmultivector_free(ptr, 0);
|
|
7433
|
+
}
|
|
7434
|
+
/**
|
|
7435
|
+
* Create a uniform distribution with specified bounds
|
|
7436
|
+
*
|
|
7437
|
+
* # Arguments
|
|
7438
|
+
* * `lower` - 8 coefficients for lower bounds
|
|
7439
|
+
* * `upper` - 8 coefficients for upper bounds
|
|
7440
|
+
* @param {Float64Array} lower
|
|
7441
|
+
* @param {Float64Array} upper
|
|
7442
|
+
* @returns {WasmUniformMultivector}
|
|
7443
|
+
*/
|
|
7444
|
+
static withBounds(lower, upper) {
|
|
7445
|
+
const ptr0 = passArrayF64ToWasm0(lower, wasm.__wbindgen_malloc);
|
|
7446
|
+
const len0 = WASM_VECTOR_LEN;
|
|
7447
|
+
const ptr1 = passArrayF64ToWasm0(upper, wasm.__wbindgen_malloc);
|
|
7448
|
+
const len1 = WASM_VECTOR_LEN;
|
|
7449
|
+
const ret = wasm.wasmuniformmultivector_withBounds(ptr0, len0, ptr1, len1);
|
|
7450
|
+
if (ret[2]) {
|
|
7451
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7452
|
+
}
|
|
7453
|
+
return WasmUniformMultivector.__wrap(ret[0]);
|
|
7454
|
+
}
|
|
7455
|
+
/**
|
|
7456
|
+
* Get the variance of this distribution
|
|
7457
|
+
* @returns {Float64Array}
|
|
7458
|
+
*/
|
|
7459
|
+
getVariance() {
|
|
7460
|
+
const ret = wasm.wasmuniformmultivector_getVariance(this.__wbg_ptr);
|
|
7461
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7462
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7463
|
+
return v1;
|
|
7464
|
+
}
|
|
7465
|
+
/**
|
|
7466
|
+
* Draw multiple samples from this distribution
|
|
7467
|
+
*
|
|
7468
|
+
* Returns flat array of coefficients: num_samples * 8
|
|
7469
|
+
* @param {number} num_samples
|
|
7470
|
+
* @returns {Float64Array}
|
|
7471
|
+
*/
|
|
7472
|
+
sampleBatch(num_samples) {
|
|
7473
|
+
const ret = wasm.wasmuniformmultivector_sampleBatch(this.__wbg_ptr, num_samples);
|
|
7474
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7475
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7476
|
+
return v1;
|
|
7477
|
+
}
|
|
7478
|
+
/**
|
|
7479
|
+
* Create a standard uniform distribution on [-1, 1]^8
|
|
7480
|
+
*/
|
|
7481
|
+
constructor() {
|
|
7482
|
+
const ret = wasm.wasmuniformmultivector_new();
|
|
7483
|
+
if (ret[2]) {
|
|
7484
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7485
|
+
}
|
|
7486
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
7487
|
+
WasmUniformMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
7488
|
+
return this;
|
|
7489
|
+
}
|
|
7490
|
+
/**
|
|
7491
|
+
* Draw a sample from this distribution
|
|
7492
|
+
*
|
|
7493
|
+
* Returns 8 coefficients for the sampled multivector
|
|
7494
|
+
* @returns {Float64Array}
|
|
7495
|
+
*/
|
|
7496
|
+
sample() {
|
|
7497
|
+
const ret = wasm.wasmuniformmultivector_sample(this.__wbg_ptr);
|
|
7498
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7499
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7500
|
+
return v1;
|
|
7501
|
+
}
|
|
7502
|
+
/**
|
|
7503
|
+
* Get the mean of this distribution
|
|
7504
|
+
* @returns {Float64Array}
|
|
7505
|
+
*/
|
|
7506
|
+
getMean() {
|
|
7507
|
+
const ret = wasm.wasmuniformmultivector_getMean(this.__wbg_ptr);
|
|
7508
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7509
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7510
|
+
return v1;
|
|
7511
|
+
}
|
|
7512
|
+
/**
|
|
7513
|
+
* Compute log probability of a multivector
|
|
7514
|
+
*
|
|
7515
|
+
* Returns log(1/volume) if inside bounds, error otherwise
|
|
7516
|
+
* @param {Float64Array} coefficients
|
|
7517
|
+
* @returns {number}
|
|
7518
|
+
*/
|
|
7519
|
+
logProb(coefficients) {
|
|
7520
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
7521
|
+
const len0 = WASM_VECTOR_LEN;
|
|
7522
|
+
const ret = wasm.wasmuniformmultivector_logProb(this.__wbg_ptr, ptr0, len0);
|
|
7523
|
+
if (ret[2]) {
|
|
7524
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7525
|
+
}
|
|
7526
|
+
return ret[0];
|
|
7527
|
+
}
|
|
7528
|
+
/**
|
|
7529
|
+
* Get the lower bounds
|
|
7530
|
+
* @returns {Float64Array}
|
|
7531
|
+
*/
|
|
7532
|
+
getLower() {
|
|
7533
|
+
const ret = wasm.wasmuniformmultivector_getLower(this.__wbg_ptr);
|
|
7534
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7535
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7536
|
+
return v1;
|
|
7537
|
+
}
|
|
7538
|
+
/**
|
|
7539
|
+
* Get the upper bounds
|
|
7540
|
+
* @returns {Float64Array}
|
|
7541
|
+
*/
|
|
7542
|
+
getUpper() {
|
|
7543
|
+
const ret = wasm.wasmuniformmultivector_getUpper(this.__wbg_ptr);
|
|
7544
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
7545
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
7546
|
+
return v1;
|
|
7547
|
+
}
|
|
7548
|
+
/**
|
|
7549
|
+
* Create a uniform distribution on a hypercube [min, max]^8
|
|
7550
|
+
* @param {number} min
|
|
7551
|
+
* @param {number} max
|
|
7552
|
+
* @returns {WasmUniformMultivector}
|
|
7553
|
+
*/
|
|
7554
|
+
static hypercube(min, max) {
|
|
7555
|
+
const ret = wasm.wasmuniformmultivector_hypercube(min, max);
|
|
7556
|
+
if (ret[2]) {
|
|
7557
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
7558
|
+
}
|
|
7559
|
+
return WasmUniformMultivector.__wrap(ret[0]);
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
|
|
7113
7563
|
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
7114
7564
|
|
|
7115
7565
|
async function __wbg_load(module, imports) {
|
|
@@ -7191,7 +7641,7 @@ function __wbg_get_imports() {
|
|
|
7191
7641
|
const ret = arg0.length;
|
|
7192
7642
|
return ret;
|
|
7193
7643
|
};
|
|
7194
|
-
imports.wbg.
|
|
7644
|
+
imports.wbg.__wbg_log_7696259bf4d9d36d = function(arg0, arg1) {
|
|
7195
7645
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
7196
7646
|
};
|
|
7197
7647
|
imports.wbg.__wbg_log_ea240990d83e374e = function(arg0) {
|
|
@@ -7216,7 +7666,7 @@ function __wbg_get_imports() {
|
|
|
7216
7666
|
const a = state0.a;
|
|
7217
7667
|
state0.a = 0;
|
|
7218
7668
|
try {
|
|
7219
|
-
return
|
|
7669
|
+
return __wbg_adapter_511(a, state0.b, arg0, arg1);
|
|
7220
7670
|
} finally {
|
|
7221
7671
|
state0.a = a;
|
|
7222
7672
|
}
|
|
@@ -7316,8 +7766,8 @@ function __wbg_get_imports() {
|
|
|
7316
7766
|
const ret = false;
|
|
7317
7767
|
return ret;
|
|
7318
7768
|
};
|
|
7319
|
-
imports.wbg.
|
|
7320
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
7769
|
+
imports.wbg.__wbindgen_closure_wrapper1647 = function(arg0, arg1, arg2) {
|
|
7770
|
+
const ret = makeMutClosure(arg0, arg1, 40, __wbg_adapter_28);
|
|
7321
7771
|
return ret;
|
|
7322
7772
|
};
|
|
7323
7773
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
package/amari_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Amari Contributors"
|
|
6
6
|
],
|
|
7
7
|
"description": "WebAssembly bindings for Amari mathematical computing library - geometric algebra, tropical algebra, automatic differentiation, measure theory, fusion systems, and information geometry",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.13.0",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|