@justinelliottcobb/amari-wasm 0.9.10 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -1
- package/amari_wasm.d.ts +691 -24
- package/amari_wasm.js +1467 -134
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +2 -2
package/amari_wasm.js
CHANGED
|
@@ -177,6 +177,20 @@ function handleError(f, args) {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
181
|
+
|
|
182
|
+
function getFloat64ArrayMemory0() {
|
|
183
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
184
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
185
|
+
}
|
|
186
|
+
return cachedFloat64ArrayMemory0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
190
|
+
ptr = ptr >>> 0;
|
|
191
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
192
|
+
}
|
|
193
|
+
|
|
180
194
|
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
181
195
|
? { register: () => {}, unregister: () => {} }
|
|
182
196
|
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
@@ -208,53 +222,19 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|
|
208
222
|
CLOSURE_DTORS.register(real, state, state);
|
|
209
223
|
return real;
|
|
210
224
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
217
|
-
}
|
|
218
|
-
return cachedFloat64ArrayMemory0;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function getArrayF64FromWasm0(ptr, len) {
|
|
222
|
-
ptr = ptr >>> 0;
|
|
223
|
-
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function _assertClass(instance, klass) {
|
|
227
|
-
if (!(instance instanceof klass)) {
|
|
228
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
let cachedUint32ArrayMemory0 = null;
|
|
233
|
-
|
|
234
|
-
function getUint32ArrayMemory0() {
|
|
235
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
236
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
237
|
-
}
|
|
238
|
-
return cachedUint32ArrayMemory0;
|
|
225
|
+
/**
|
|
226
|
+
* Initialize the WASM module
|
|
227
|
+
*/
|
|
228
|
+
export function init() {
|
|
229
|
+
wasm.init();
|
|
239
230
|
}
|
|
240
231
|
|
|
241
|
-
function
|
|
242
|
-
const ptr = malloc(arg.length *
|
|
243
|
-
|
|
232
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
233
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
234
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
244
235
|
WASM_VECTOR_LEN = arg.length;
|
|
245
236
|
return ptr;
|
|
246
237
|
}
|
|
247
|
-
|
|
248
|
-
function takeFromExternrefTable0(idx) {
|
|
249
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
250
|
-
wasm.__externref_table_dealloc(idx);
|
|
251
|
-
return value;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
255
|
-
ptr = ptr >>> 0;
|
|
256
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
257
|
-
}
|
|
258
238
|
/**
|
|
259
239
|
* Initialize the enumerative geometry module
|
|
260
240
|
*/
|
|
@@ -262,11 +242,21 @@ export function initEnumerative() {
|
|
|
262
242
|
wasm.initEnumerative();
|
|
263
243
|
}
|
|
264
244
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Calculate light deflection angle for photon grazing massive object
|
|
247
|
+
* @param {number} impact_parameter
|
|
248
|
+
* @param {number} mass
|
|
249
|
+
* @returns {number}
|
|
250
|
+
*/
|
|
251
|
+
export function light_deflection_angle(impact_parameter, mass) {
|
|
252
|
+
const ret = wasm.light_deflection_angle(impact_parameter, mass);
|
|
253
|
+
return ret;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function takeFromExternrefTable0(idx) {
|
|
257
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
258
|
+
wasm.__externref_table_dealloc(idx);
|
|
259
|
+
return value;
|
|
270
260
|
}
|
|
271
261
|
/**
|
|
272
262
|
* Convert velocity to Lorentz factor
|
|
@@ -304,28 +294,98 @@ export function validate_relativistic_module() {
|
|
|
304
294
|
}
|
|
305
295
|
|
|
306
296
|
/**
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
297
|
+
* Initialize the fusion module
|
|
298
|
+
*/
|
|
299
|
+
export function initFusion() {
|
|
300
|
+
wasm.initFusion();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Integrate a JavaScript function over an interval
|
|
305
|
+
*
|
|
306
|
+
* This function provides numerical integration capabilities to JavaScript.
|
|
307
|
+
*
|
|
308
|
+
* # Arguments
|
|
309
|
+
* * `f` - JavaScript function to integrate (must accept a number and return a number)
|
|
310
|
+
* * `a` - Lower bound of integration
|
|
311
|
+
* * `b` - Upper bound of integration
|
|
312
|
+
* * `points` - Number of sample points to use
|
|
313
|
+
* * `method` - Integration method to use
|
|
314
|
+
*
|
|
315
|
+
* # Returns
|
|
316
|
+
* Approximate value of the integral ∫_a^b f(x) dx
|
|
317
|
+
* @param {Function} f
|
|
318
|
+
* @param {number} a
|
|
319
|
+
* @param {number} b
|
|
320
|
+
* @param {number} points
|
|
321
|
+
* @param {WasmIntegrationMethod} method
|
|
310
322
|
* @returns {number}
|
|
311
323
|
*/
|
|
312
|
-
export function
|
|
313
|
-
const ret = wasm.
|
|
314
|
-
|
|
324
|
+
export function integrate(f, a, b, points, method) {
|
|
325
|
+
const ret = wasm.integrate(f, a, b, points, method);
|
|
326
|
+
if (ret[2]) {
|
|
327
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
328
|
+
}
|
|
329
|
+
return ret[0];
|
|
315
330
|
}
|
|
316
331
|
|
|
317
332
|
/**
|
|
318
|
-
*
|
|
333
|
+
* Compute expectation E[f(X)] for uniform distribution on [a, b]
|
|
334
|
+
*
|
|
335
|
+
* # Arguments
|
|
336
|
+
* * `f` - JavaScript function (must accept a number and return a number)
|
|
337
|
+
* * `a` - Lower bound
|
|
338
|
+
* * `b` - Upper bound
|
|
339
|
+
* * `samples` - Number of Monte Carlo samples
|
|
340
|
+
* @param {Function} f
|
|
341
|
+
* @param {number} a
|
|
342
|
+
* @param {number} b
|
|
343
|
+
* @param {number} samples
|
|
344
|
+
* @returns {number}
|
|
319
345
|
*/
|
|
320
|
-
export function
|
|
321
|
-
wasm.
|
|
346
|
+
export function expectation(f, a, b, samples) {
|
|
347
|
+
const ret = wasm.expectation(f, a, b, samples);
|
|
348
|
+
if (ret[2]) {
|
|
349
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
350
|
+
}
|
|
351
|
+
return ret[0];
|
|
322
352
|
}
|
|
323
353
|
|
|
354
|
+
function _assertClass(instance, klass) {
|
|
355
|
+
if (!(instance instanceof klass)) {
|
|
356
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
324
359
|
/**
|
|
325
|
-
*
|
|
360
|
+
* Compute KL divergence D_KL(P||Q) between two distributions
|
|
361
|
+
*
|
|
362
|
+
* # Arguments
|
|
363
|
+
* * `p_density` - First distribution
|
|
364
|
+
* * `q_density` - Second distribution
|
|
365
|
+
* * `p_params` - Parameters for P
|
|
366
|
+
* * `q_params` - Parameters for Q
|
|
367
|
+
* * `sample_points` - Points to evaluate at
|
|
368
|
+
* @param {WasmParametricDensity} p_density
|
|
369
|
+
* @param {WasmParametricDensity} q_density
|
|
370
|
+
* @param {Float64Array} p_params
|
|
371
|
+
* @param {Float64Array} q_params
|
|
372
|
+
* @param {Float64Array} sample_points
|
|
373
|
+
* @returns {number}
|
|
326
374
|
*/
|
|
327
|
-
export function
|
|
328
|
-
|
|
375
|
+
export function klDivergence(p_density, q_density, p_params, q_params, sample_points) {
|
|
376
|
+
_assertClass(p_density, WasmParametricDensity);
|
|
377
|
+
_assertClass(q_density, WasmParametricDensity);
|
|
378
|
+
const ptr0 = passArrayF64ToWasm0(p_params, wasm.__wbindgen_malloc);
|
|
379
|
+
const len0 = WASM_VECTOR_LEN;
|
|
380
|
+
const ptr1 = passArrayF64ToWasm0(q_params, wasm.__wbindgen_malloc);
|
|
381
|
+
const len1 = WASM_VECTOR_LEN;
|
|
382
|
+
const ptr2 = passArrayF64ToWasm0(sample_points, wasm.__wbindgen_malloc);
|
|
383
|
+
const len2 = WASM_VECTOR_LEN;
|
|
384
|
+
const ret = wasm.klDivergence(p_density.__wbg_ptr, q_density.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
385
|
+
if (ret[2]) {
|
|
386
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
387
|
+
}
|
|
388
|
+
return ret[0];
|
|
329
389
|
}
|
|
330
390
|
|
|
331
391
|
/**
|
|
@@ -335,18 +395,66 @@ export function initAutomata() {
|
|
|
335
395
|
wasm.initAutomata();
|
|
336
396
|
}
|
|
337
397
|
|
|
398
|
+
let cachedUint32ArrayMemory0 = null;
|
|
399
|
+
|
|
400
|
+
function getUint32ArrayMemory0() {
|
|
401
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
402
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
403
|
+
}
|
|
404
|
+
return cachedUint32ArrayMemory0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
408
|
+
ptr = ptr >>> 0;
|
|
409
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
410
|
+
}
|
|
411
|
+
|
|
338
412
|
function getArrayU8FromWasm0(ptr, len) {
|
|
339
413
|
ptr = ptr >>> 0;
|
|
340
414
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
341
415
|
}
|
|
342
|
-
|
|
343
|
-
|
|
416
|
+
|
|
417
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
418
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
419
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
420
|
+
WASM_VECTOR_LEN = arg.length;
|
|
421
|
+
return ptr;
|
|
422
|
+
}
|
|
423
|
+
function wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue_____(arg0, arg1, arg2) {
|
|
424
|
+
wasm.wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue_____(arg0, arg1, arg2);
|
|
344
425
|
}
|
|
345
426
|
|
|
346
|
-
function
|
|
347
|
-
wasm.
|
|
427
|
+
function wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue__wasm_bindgen_e07ba2a7d21574bf___JsValue_____(arg0, arg1, arg2, arg3) {
|
|
428
|
+
wasm.wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue__wasm_bindgen_e07ba2a7d21574bf___JsValue_____(arg0, arg1, arg2, arg3);
|
|
348
429
|
}
|
|
349
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Integration methods available in WASM
|
|
433
|
+
* @enum {0 | 1 | 2 | 3 | 4}
|
|
434
|
+
*/
|
|
435
|
+
export const WasmIntegrationMethod = Object.freeze({
|
|
436
|
+
/**
|
|
437
|
+
* Riemann sum approximation
|
|
438
|
+
*/
|
|
439
|
+
Riemann: 0, "0": "Riemann",
|
|
440
|
+
/**
|
|
441
|
+
* Monte Carlo integration
|
|
442
|
+
*/
|
|
443
|
+
MonteCarlo: 1, "1": "MonteCarlo",
|
|
444
|
+
/**
|
|
445
|
+
* Trapezoidal rule
|
|
446
|
+
*/
|
|
447
|
+
Trapezoidal: 2, "2": "Trapezoidal",
|
|
448
|
+
/**
|
|
449
|
+
* Simpson's rule
|
|
450
|
+
*/
|
|
451
|
+
Simpson: 3, "3": "Simpson",
|
|
452
|
+
/**
|
|
453
|
+
* Adaptive quadrature
|
|
454
|
+
*/
|
|
455
|
+
Adaptive: 4, "4": "Adaptive",
|
|
456
|
+
});
|
|
457
|
+
|
|
350
458
|
const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
351
459
|
? { register: () => {}, unregister: () => {} }
|
|
352
460
|
: new FinalizationRegistry(ptr => wasm.__wbg_autodiff_free(ptr >>> 0, 1));
|
|
@@ -1216,6 +1324,97 @@ export class InfoGeomUtils {
|
|
|
1216
1324
|
}
|
|
1217
1325
|
if (Symbol.dispose) InfoGeomUtils.prototype[Symbol.dispose] = InfoGeomUtils.prototype.free;
|
|
1218
1326
|
|
|
1327
|
+
const IntegrationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1328
|
+
? { register: () => {}, unregister: () => {} }
|
|
1329
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_integration_free(ptr >>> 0, 1));
|
|
1330
|
+
/**
|
|
1331
|
+
* Numerical integration operations
|
|
1332
|
+
*
|
|
1333
|
+
* Provides definite integrals, line integrals, and surface integrals
|
|
1334
|
+
* using adaptive quadrature.
|
|
1335
|
+
*/
|
|
1336
|
+
export class Integration {
|
|
1337
|
+
|
|
1338
|
+
__destroy_into_raw() {
|
|
1339
|
+
const ptr = this.__wbg_ptr;
|
|
1340
|
+
this.__wbg_ptr = 0;
|
|
1341
|
+
IntegrationFinalization.unregister(this);
|
|
1342
|
+
return ptr;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
free() {
|
|
1346
|
+
const ptr = this.__destroy_into_raw();
|
|
1347
|
+
wasm.__wbg_integration_free(ptr, 0);
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Compute 1D definite integral using Simpson's rule
|
|
1351
|
+
*
|
|
1352
|
+
* ∫[a,b] f(x) dx
|
|
1353
|
+
*
|
|
1354
|
+
* # Arguments
|
|
1355
|
+
*
|
|
1356
|
+
* * `func` - JavaScript function to integrate
|
|
1357
|
+
* * `a` - Lower bound
|
|
1358
|
+
* * `b` - Upper bound
|
|
1359
|
+
* * `n` - Number of subdivisions (must be even)
|
|
1360
|
+
*
|
|
1361
|
+
* # Returns
|
|
1362
|
+
*
|
|
1363
|
+
* Integral value
|
|
1364
|
+
*
|
|
1365
|
+
* # JavaScript Example
|
|
1366
|
+
*
|
|
1367
|
+
* ```javascript
|
|
1368
|
+
* // Integrate x^2 from 0 to 1
|
|
1369
|
+
* const result = Integration.integrate1D(x => x*x, 0, 1, 100);
|
|
1370
|
+
* // Returns approximately 0.333...
|
|
1371
|
+
* ```
|
|
1372
|
+
* @param {Function} func
|
|
1373
|
+
* @param {number} a
|
|
1374
|
+
* @param {number} b
|
|
1375
|
+
* @param {number} n
|
|
1376
|
+
* @returns {number}
|
|
1377
|
+
*/
|
|
1378
|
+
static integrate1D(func, a, b, n) {
|
|
1379
|
+
const ret = wasm.integration_integrate1D(func, a, b, n);
|
|
1380
|
+
if (ret[2]) {
|
|
1381
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1382
|
+
}
|
|
1383
|
+
return ret[0];
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Compute 2D integral over a rectangle using Simpson's rule
|
|
1387
|
+
*
|
|
1388
|
+
* ∫∫[a,b]×[c,d] f(x,y) dx dy
|
|
1389
|
+
*
|
|
1390
|
+
* # Arguments
|
|
1391
|
+
*
|
|
1392
|
+
* * `func` - JavaScript function (x, y) => f(x, y)
|
|
1393
|
+
* * `ax` - Lower x bound
|
|
1394
|
+
* * `bx` - Upper x bound
|
|
1395
|
+
* * `ay` - Lower y bound
|
|
1396
|
+
* * `by` - Upper y bound
|
|
1397
|
+
* * `nx` - Number of x subdivisions (must be even)
|
|
1398
|
+
* * `ny` - Number of y subdivisions (must be even)
|
|
1399
|
+
* @param {Function} func
|
|
1400
|
+
* @param {number} ax
|
|
1401
|
+
* @param {number} bx
|
|
1402
|
+
* @param {number} ay
|
|
1403
|
+
* @param {number} by
|
|
1404
|
+
* @param {number} nx
|
|
1405
|
+
* @param {number} ny
|
|
1406
|
+
* @returns {number}
|
|
1407
|
+
*/
|
|
1408
|
+
static integrate2D(func, ax, bx, ay, by, nx, ny) {
|
|
1409
|
+
const ret = wasm.integration_integrate2D(func, ax, bx, ay, by, nx, ny);
|
|
1410
|
+
if (ret[2]) {
|
|
1411
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1412
|
+
}
|
|
1413
|
+
return ret[0];
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
if (Symbol.dispose) Integration.prototype[Symbol.dispose] = Integration.prototype.free;
|
|
1417
|
+
|
|
1219
1418
|
const MLOpsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1220
1419
|
? { register: () => {}, unregister: () => {} }
|
|
1221
1420
|
: new FinalizationRegistry(ptr => wasm.__wbg_mlops_free(ptr >>> 0, 1));
|
|
@@ -1366,6 +1565,165 @@ export class NetworkUtils {
|
|
|
1366
1565
|
}
|
|
1367
1566
|
if (Symbol.dispose) NetworkUtils.prototype[Symbol.dispose] = NetworkUtils.prototype.free;
|
|
1368
1567
|
|
|
1568
|
+
const NumericalDerivativeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1569
|
+
? { register: () => {}, unregister: () => {} }
|
|
1570
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_numericalderivative_free(ptr >>> 0, 1));
|
|
1571
|
+
/**
|
|
1572
|
+
* Numerical derivative operations
|
|
1573
|
+
*
|
|
1574
|
+
* Provides gradient, divergence, curl, and Laplacian computations
|
|
1575
|
+
* using centered finite differences.
|
|
1576
|
+
*/
|
|
1577
|
+
export class NumericalDerivative {
|
|
1578
|
+
|
|
1579
|
+
__destroy_into_raw() {
|
|
1580
|
+
const ptr = this.__wbg_ptr;
|
|
1581
|
+
this.__wbg_ptr = 0;
|
|
1582
|
+
NumericalDerivativeFinalization.unregister(this);
|
|
1583
|
+
return ptr;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
free() {
|
|
1587
|
+
const ptr = this.__destroy_into_raw();
|
|
1588
|
+
wasm.__wbg_numericalderivative_free(ptr, 0);
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Compute divergence of a vector field at a point
|
|
1592
|
+
*
|
|
1593
|
+
* ∇·F = ∂Fx/∂x + ∂Fy/∂y + ∂Fz/∂z
|
|
1594
|
+
*
|
|
1595
|
+
* # Arguments
|
|
1596
|
+
*
|
|
1597
|
+
* * `field` - Vector field
|
|
1598
|
+
* * `point` - Evaluation point
|
|
1599
|
+
*
|
|
1600
|
+
* # Returns
|
|
1601
|
+
*
|
|
1602
|
+
* Divergence (scalar)
|
|
1603
|
+
* @param {VectorField} field
|
|
1604
|
+
* @param {Float64Array} point
|
|
1605
|
+
* @returns {number}
|
|
1606
|
+
*/
|
|
1607
|
+
divergence(field, point) {
|
|
1608
|
+
_assertClass(field, VectorField);
|
|
1609
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
1610
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1611
|
+
const ret = wasm.numericalderivative_divergence(this.__wbg_ptr, field.__wbg_ptr, ptr0, len0);
|
|
1612
|
+
if (ret[2]) {
|
|
1613
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1614
|
+
}
|
|
1615
|
+
return ret[0];
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Create a new numerical derivative computer
|
|
1619
|
+
*
|
|
1620
|
+
* # Arguments
|
|
1621
|
+
*
|
|
1622
|
+
* * `step_size` - Optional step size for finite differences (default: 1e-5)
|
|
1623
|
+
* @param {number | null} [step_size]
|
|
1624
|
+
*/
|
|
1625
|
+
constructor(step_size) {
|
|
1626
|
+
const ret = wasm.numericalderivative_new(!isLikeNone(step_size), isLikeNone(step_size) ? 0 : step_size);
|
|
1627
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1628
|
+
NumericalDerivativeFinalization.register(this, this.__wbg_ptr, this);
|
|
1629
|
+
return this;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Compute curl of a 3D vector field at a point
|
|
1633
|
+
*
|
|
1634
|
+
* ∇×F = [∂Fz/∂y - ∂Fy/∂z, ∂Fx/∂z - ∂Fz/∂x, ∂Fy/∂x - ∂Fx/∂y]
|
|
1635
|
+
*
|
|
1636
|
+
* # Arguments
|
|
1637
|
+
*
|
|
1638
|
+
* * `field` - 3D vector field
|
|
1639
|
+
* * `point` - Evaluation point [x, y, z]
|
|
1640
|
+
*
|
|
1641
|
+
* # Returns
|
|
1642
|
+
*
|
|
1643
|
+
* Curl vector [cx, cy, cz]
|
|
1644
|
+
* @param {VectorField} field
|
|
1645
|
+
* @param {Float64Array} point
|
|
1646
|
+
* @returns {Float64Array}
|
|
1647
|
+
*/
|
|
1648
|
+
curl(field, point) {
|
|
1649
|
+
_assertClass(field, VectorField);
|
|
1650
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
1651
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1652
|
+
const ret = wasm.numericalderivative_curl(this.__wbg_ptr, field.__wbg_ptr, ptr0, len0);
|
|
1653
|
+
if (ret[3]) {
|
|
1654
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1655
|
+
}
|
|
1656
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1657
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1658
|
+
return v2;
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Compute gradient of a scalar field at a point
|
|
1662
|
+
*
|
|
1663
|
+
* ∇f = [∂f/∂x, ∂f/∂y, ∂f/∂z]
|
|
1664
|
+
*
|
|
1665
|
+
* # Arguments
|
|
1666
|
+
*
|
|
1667
|
+
* * `field` - Scalar field
|
|
1668
|
+
* * `point` - Evaluation point
|
|
1669
|
+
*
|
|
1670
|
+
* # Returns
|
|
1671
|
+
*
|
|
1672
|
+
* Gradient vector
|
|
1673
|
+
*
|
|
1674
|
+
* # JavaScript Example
|
|
1675
|
+
*
|
|
1676
|
+
* ```javascript
|
|
1677
|
+
* const field = ScalarField.fromFunction2D((x, y) => x*x + y*y);
|
|
1678
|
+
* const derivative = new NumericalDerivative();
|
|
1679
|
+
* const grad = derivative.gradient(field, [1.0, 2.0]); // Returns [2.0, 4.0]
|
|
1680
|
+
* ```
|
|
1681
|
+
* @param {ScalarField} field
|
|
1682
|
+
* @param {Float64Array} point
|
|
1683
|
+
* @returns {Float64Array}
|
|
1684
|
+
*/
|
|
1685
|
+
gradient(field, point) {
|
|
1686
|
+
_assertClass(field, ScalarField);
|
|
1687
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
1688
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1689
|
+
const ret = wasm.numericalderivative_gradient(this.__wbg_ptr, field.__wbg_ptr, ptr0, len0);
|
|
1690
|
+
if (ret[3]) {
|
|
1691
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1692
|
+
}
|
|
1693
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1694
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1695
|
+
return v2;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Compute Laplacian of a scalar field at a point
|
|
1699
|
+
*
|
|
1700
|
+
* ∇²f = ∂²f/∂x² + ∂²f/∂y² + ∂²f/∂z²
|
|
1701
|
+
*
|
|
1702
|
+
* # Arguments
|
|
1703
|
+
*
|
|
1704
|
+
* * `field` - Scalar field
|
|
1705
|
+
* * `point` - Evaluation point
|
|
1706
|
+
*
|
|
1707
|
+
* # Returns
|
|
1708
|
+
*
|
|
1709
|
+
* Laplacian (scalar)
|
|
1710
|
+
* @param {ScalarField} field
|
|
1711
|
+
* @param {Float64Array} point
|
|
1712
|
+
* @returns {number}
|
|
1713
|
+
*/
|
|
1714
|
+
laplacian(field, point) {
|
|
1715
|
+
_assertClass(field, ScalarField);
|
|
1716
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
1717
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1718
|
+
const ret = wasm.numericalderivative_laplacian(this.__wbg_ptr, field.__wbg_ptr, ptr0, len0);
|
|
1719
|
+
if (ret[2]) {
|
|
1720
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1721
|
+
}
|
|
1722
|
+
return ret[0];
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
if (Symbol.dispose) NumericalDerivative.prototype[Symbol.dispose] = NumericalDerivative.prototype.free;
|
|
1726
|
+
|
|
1369
1727
|
const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1370
1728
|
? { register: () => {}, unregister: () => {} }
|
|
1371
1729
|
: new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
|
|
@@ -1430,23 +1788,375 @@ export class PerformanceOperations {
|
|
|
1430
1788
|
return v3;
|
|
1431
1789
|
}
|
|
1432
1790
|
/**
|
|
1433
|
-
* Fast geometric product for hot paths with memory pooling
|
|
1434
|
-
* @param {Float64Array} lhs
|
|
1435
|
-
* @param {Float64Array} rhs
|
|
1436
|
-
* @returns {Float64Array}
|
|
1791
|
+
* Fast geometric product for hot paths with memory pooling
|
|
1792
|
+
* @param {Float64Array} lhs
|
|
1793
|
+
* @param {Float64Array} rhs
|
|
1794
|
+
* @returns {Float64Array}
|
|
1795
|
+
*/
|
|
1796
|
+
static fastGeometricProduct(lhs, rhs) {
|
|
1797
|
+
const ptr0 = passArrayF64ToWasm0(lhs, wasm.__wbindgen_malloc);
|
|
1798
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1799
|
+
const ptr1 = passArrayF64ToWasm0(rhs, wasm.__wbindgen_malloc);
|
|
1800
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1801
|
+
const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
|
|
1802
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1803
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1804
|
+
return v3;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
|
|
1808
|
+
|
|
1809
|
+
const RiemannianManifoldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1810
|
+
? { register: () => {}, unregister: () => {} }
|
|
1811
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_riemannianmanifold_free(ptr >>> 0, 1));
|
|
1812
|
+
/**
|
|
1813
|
+
* Riemannian manifold with metric tensor
|
|
1814
|
+
*
|
|
1815
|
+
* Represents a curved space with a metric that defines distances and angles.
|
|
1816
|
+
*
|
|
1817
|
+
* # JavaScript Example
|
|
1818
|
+
*
|
|
1819
|
+
* ```javascript
|
|
1820
|
+
* // Create a 2D sphere of radius 1
|
|
1821
|
+
* const sphere = RiemannianManifold.sphere(1.0);
|
|
1822
|
+
*
|
|
1823
|
+
* // Compute scalar curvature at the north pole
|
|
1824
|
+
* const R = sphere.scalarCurvature([0.0, 0.0]); // Returns 2.0 for unit sphere
|
|
1825
|
+
* ```
|
|
1826
|
+
*/
|
|
1827
|
+
export class RiemannianManifold {
|
|
1828
|
+
|
|
1829
|
+
static __wrap(ptr) {
|
|
1830
|
+
ptr = ptr >>> 0;
|
|
1831
|
+
const obj = Object.create(RiemannianManifold.prototype);
|
|
1832
|
+
obj.__wbg_ptr = ptr;
|
|
1833
|
+
RiemannianManifoldFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1834
|
+
return obj;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
__destroy_into_raw() {
|
|
1838
|
+
const ptr = this.__wbg_ptr;
|
|
1839
|
+
this.__wbg_ptr = 0;
|
|
1840
|
+
RiemannianManifoldFinalization.unregister(this);
|
|
1841
|
+
return ptr;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
free() {
|
|
1845
|
+
const ptr = this.__destroy_into_raw();
|
|
1846
|
+
wasm.__wbg_riemannianmanifold_free(ptr, 0);
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Create a 2D hyperbolic plane (Poincaré half-plane model)
|
|
1850
|
+
*
|
|
1851
|
+
* Metric: ds² = (dx² + dy²) / y²
|
|
1852
|
+
* @returns {RiemannianManifold}
|
|
1853
|
+
*/
|
|
1854
|
+
static hyperbolic() {
|
|
1855
|
+
const ret = wasm.riemannianmanifold_hyperbolic();
|
|
1856
|
+
return RiemannianManifold.__wrap(ret);
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Compute Christoffel symbol Γ^k_ij at a point
|
|
1860
|
+
*
|
|
1861
|
+
* # Arguments
|
|
1862
|
+
*
|
|
1863
|
+
* * `k` - Upper index
|
|
1864
|
+
* * `i` - First lower index
|
|
1865
|
+
* * `j` - Second lower index
|
|
1866
|
+
* * `coords` - Coordinates
|
|
1867
|
+
* @param {number} k
|
|
1868
|
+
* @param {number} i
|
|
1869
|
+
* @param {number} j
|
|
1870
|
+
* @param {Float64Array} coords
|
|
1871
|
+
* @returns {number}
|
|
1872
|
+
*/
|
|
1873
|
+
christoffel(k, i, j, coords) {
|
|
1874
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1875
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1876
|
+
const ret = wasm.riemannianmanifold_christoffel(this.__wbg_ptr, k, i, j, ptr0, len0);
|
|
1877
|
+
if (ret[2]) {
|
|
1878
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1879
|
+
}
|
|
1880
|
+
return ret[0];
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Compute Ricci tensor component R_ij
|
|
1884
|
+
*
|
|
1885
|
+
* # Arguments
|
|
1886
|
+
*
|
|
1887
|
+
* * `i` - First index
|
|
1888
|
+
* * `j` - Second index
|
|
1889
|
+
* * `coords` - Coordinates
|
|
1890
|
+
* @param {number} i
|
|
1891
|
+
* @param {number} j
|
|
1892
|
+
* @param {Float64Array} coords
|
|
1893
|
+
* @returns {number}
|
|
1894
|
+
*/
|
|
1895
|
+
ricciTensor(i, j, coords) {
|
|
1896
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1897
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1898
|
+
const ret = wasm.riemannianmanifold_ricciTensor(this.__wbg_ptr, i, j, ptr0, len0);
|
|
1899
|
+
if (ret[2]) {
|
|
1900
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1901
|
+
}
|
|
1902
|
+
return ret[0];
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Compute Riemann curvature tensor component R^i_jkl
|
|
1906
|
+
*
|
|
1907
|
+
* # Arguments
|
|
1908
|
+
*
|
|
1909
|
+
* * `i` - Upper index
|
|
1910
|
+
* * `j` - First lower index
|
|
1911
|
+
* * `k` - Second lower index
|
|
1912
|
+
* * `l` - Third lower index
|
|
1913
|
+
* * `coords` - Coordinates
|
|
1914
|
+
* @param {number} i
|
|
1915
|
+
* @param {number} j
|
|
1916
|
+
* @param {number} k
|
|
1917
|
+
* @param {number} l
|
|
1918
|
+
* @param {Float64Array} coords
|
|
1919
|
+
* @returns {number}
|
|
1920
|
+
*/
|
|
1921
|
+
riemannTensor(i, j, k, l, coords) {
|
|
1922
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1923
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1924
|
+
const ret = wasm.riemannianmanifold_riemannTensor(this.__wbg_ptr, i, j, k, l, ptr0, len0);
|
|
1925
|
+
if (ret[2]) {
|
|
1926
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1927
|
+
}
|
|
1928
|
+
return ret[0];
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Compute scalar curvature R
|
|
1932
|
+
*
|
|
1933
|
+
* # Arguments
|
|
1934
|
+
*
|
|
1935
|
+
* * `coords` - Coordinates
|
|
1936
|
+
*
|
|
1937
|
+
* # Returns
|
|
1938
|
+
*
|
|
1939
|
+
* Scalar curvature value
|
|
1940
|
+
* @param {Float64Array} coords
|
|
1941
|
+
* @returns {number}
|
|
1942
|
+
*/
|
|
1943
|
+
scalarCurvature(coords) {
|
|
1944
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1945
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1946
|
+
const ret = wasm.riemannianmanifold_scalarCurvature(this.__wbg_ptr, ptr0, len0);
|
|
1947
|
+
if (ret[2]) {
|
|
1948
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1949
|
+
}
|
|
1950
|
+
return ret[0];
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Create a 2D sphere of given radius
|
|
1954
|
+
*
|
|
1955
|
+
* Metric: ds² = dθ² + sin²θ dφ²
|
|
1956
|
+
*
|
|
1957
|
+
* # Arguments
|
|
1958
|
+
*
|
|
1959
|
+
* * `radius` - Sphere radius
|
|
1960
|
+
* @param {number} radius
|
|
1961
|
+
* @returns {RiemannianManifold}
|
|
1962
|
+
*/
|
|
1963
|
+
static sphere(radius) {
|
|
1964
|
+
const ret = wasm.riemannianmanifold_sphere(radius);
|
|
1965
|
+
if (ret[2]) {
|
|
1966
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1967
|
+
}
|
|
1968
|
+
return RiemannianManifold.__wrap(ret[0]);
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Compute geodesic trajectory
|
|
1972
|
+
*
|
|
1973
|
+
* Solves the geodesic equations using RK4 integration.
|
|
1974
|
+
*
|
|
1975
|
+
* # Arguments
|
|
1976
|
+
*
|
|
1977
|
+
* * `initial_pos` - Initial position
|
|
1978
|
+
* * `initial_vel` - Initial velocity
|
|
1979
|
+
* * `t_max` - Maximum time
|
|
1980
|
+
* * `dt` - Time step
|
|
1981
|
+
*
|
|
1982
|
+
* # Returns
|
|
1983
|
+
*
|
|
1984
|
+
* Flat array of trajectory points and velocities:
|
|
1985
|
+
* [x0, y0, vx0, vy0, x1, y1, vx1, vy1, ...]
|
|
1986
|
+
* @param {Float64Array} initial_pos
|
|
1987
|
+
* @param {Float64Array} initial_vel
|
|
1988
|
+
* @param {number} t_max
|
|
1989
|
+
* @param {number} dt
|
|
1990
|
+
* @returns {Float64Array}
|
|
1991
|
+
*/
|
|
1992
|
+
geodesic(initial_pos, initial_vel, t_max, dt) {
|
|
1993
|
+
const ptr0 = passArrayF64ToWasm0(initial_pos, wasm.__wbindgen_malloc);
|
|
1994
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1995
|
+
const ptr1 = passArrayF64ToWasm0(initial_vel, wasm.__wbindgen_malloc);
|
|
1996
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1997
|
+
const ret = wasm.riemannianmanifold_geodesic(this.__wbg_ptr, ptr0, len0, ptr1, len1, t_max, dt);
|
|
1998
|
+
if (ret[3]) {
|
|
1999
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2000
|
+
}
|
|
2001
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2002
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2003
|
+
return v3;
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Get the dimension of the manifold
|
|
2007
|
+
* @returns {number}
|
|
2008
|
+
*/
|
|
2009
|
+
get dimension() {
|
|
2010
|
+
const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
|
|
2011
|
+
return ret >>> 0;
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Create a Euclidean (flat) manifold
|
|
2015
|
+
*
|
|
2016
|
+
* # Arguments
|
|
2017
|
+
*
|
|
2018
|
+
* * `dimension` - Dimension (2 or 3)
|
|
2019
|
+
* @param {number} dimension
|
|
2020
|
+
* @returns {RiemannianManifold}
|
|
2021
|
+
*/
|
|
2022
|
+
static euclidean(dimension) {
|
|
2023
|
+
const ret = wasm.riemannianmanifold_euclidean(dimension);
|
|
2024
|
+
if (ret[2]) {
|
|
2025
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2026
|
+
}
|
|
2027
|
+
return RiemannianManifold.__wrap(ret[0]);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
if (Symbol.dispose) RiemannianManifold.prototype[Symbol.dispose] = RiemannianManifold.prototype.free;
|
|
2031
|
+
|
|
2032
|
+
const ScalarFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2033
|
+
? { register: () => {}, unregister: () => {} }
|
|
2034
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_scalarfield_free(ptr >>> 0, 1));
|
|
2035
|
+
/**
|
|
2036
|
+
* Scalar field f: ℝⁿ → ℝ
|
|
2037
|
+
*
|
|
2038
|
+
* Represents a function that maps points in n-dimensional space to real numbers.
|
|
2039
|
+
*
|
|
2040
|
+
* # JavaScript Example
|
|
2041
|
+
*
|
|
2042
|
+
* ```javascript
|
|
2043
|
+
* // Create a scalar field f(x, y) = x² + y²
|
|
2044
|
+
* const field = WasmScalarField.fromFunction2D((x, y) => x*x + y*y);
|
|
2045
|
+
*
|
|
2046
|
+
* // Evaluate at a point
|
|
2047
|
+
* const value = field.evaluate([1.0, 2.0]); // Returns 5.0
|
|
2048
|
+
* ```
|
|
2049
|
+
*/
|
|
2050
|
+
export class ScalarField {
|
|
2051
|
+
|
|
2052
|
+
static __wrap(ptr) {
|
|
2053
|
+
ptr = ptr >>> 0;
|
|
2054
|
+
const obj = Object.create(ScalarField.prototype);
|
|
2055
|
+
obj.__wbg_ptr = ptr;
|
|
2056
|
+
ScalarFieldFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2057
|
+
return obj;
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
__destroy_into_raw() {
|
|
2061
|
+
const ptr = this.__wbg_ptr;
|
|
2062
|
+
this.__wbg_ptr = 0;
|
|
2063
|
+
ScalarFieldFinalization.unregister(this);
|
|
2064
|
+
return ptr;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
free() {
|
|
2068
|
+
const ptr = this.__destroy_into_raw();
|
|
2069
|
+
wasm.__wbg_scalarfield_free(ptr, 0);
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Batch evaluate the field at multiple points
|
|
2073
|
+
*
|
|
2074
|
+
* # Arguments
|
|
2075
|
+
*
|
|
2076
|
+
* * `points` - Array of points as flat array [x1, y1, x2, y2, ...]
|
|
2077
|
+
*
|
|
2078
|
+
* # Returns
|
|
2079
|
+
*
|
|
2080
|
+
* Array of field values
|
|
2081
|
+
* @param {Float64Array} points
|
|
2082
|
+
* @returns {Float64Array}
|
|
2083
|
+
*/
|
|
2084
|
+
batchEvaluate(points) {
|
|
2085
|
+
const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
2086
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2087
|
+
const ret = wasm.scalarfield_batchEvaluate(this.__wbg_ptr, ptr0, len0);
|
|
2088
|
+
if (ret[3]) {
|
|
2089
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2090
|
+
}
|
|
2091
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2092
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2093
|
+
return v2;
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Create a 2D scalar field from a JavaScript function
|
|
2097
|
+
*
|
|
2098
|
+
* # Arguments
|
|
2099
|
+
*
|
|
2100
|
+
* * `func` - JavaScript function (x, y) => f(x, y)
|
|
2101
|
+
* @param {Function} func
|
|
2102
|
+
* @returns {ScalarField}
|
|
2103
|
+
*/
|
|
2104
|
+
static fromFunction2D(func) {
|
|
2105
|
+
const ret = wasm.scalarfield_fromFunction2D(func);
|
|
2106
|
+
return ScalarField.__wrap(ret);
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Create a 3D scalar field from a JavaScript function
|
|
2110
|
+
*
|
|
2111
|
+
* # Arguments
|
|
2112
|
+
*
|
|
2113
|
+
* * `func` - JavaScript function (x, y, z) => f(x, y, z)
|
|
2114
|
+
* @param {Function} func
|
|
2115
|
+
* @returns {ScalarField}
|
|
2116
|
+
*/
|
|
2117
|
+
static fromFunction3D(func) {
|
|
2118
|
+
const ret = wasm.scalarfield_fromFunction3D(func);
|
|
2119
|
+
return ScalarField.__wrap(ret);
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Create a 2D scalar field from a JavaScript function
|
|
2123
|
+
*
|
|
2124
|
+
* # Arguments
|
|
2125
|
+
*
|
|
2126
|
+
* * `func` - JavaScript function (x, y) => f(x, y)
|
|
2127
|
+
* @param {Function} func
|
|
2128
|
+
* @param {number} dimension
|
|
1437
2129
|
*/
|
|
1438
|
-
|
|
1439
|
-
const
|
|
2130
|
+
constructor(func, dimension) {
|
|
2131
|
+
const ret = wasm.scalarfield_new(func, dimension);
|
|
2132
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2133
|
+
ScalarFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
2134
|
+
return this;
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Evaluate the scalar field at a point
|
|
2138
|
+
*
|
|
2139
|
+
* # Arguments
|
|
2140
|
+
*
|
|
2141
|
+
* * `point` - Coordinates [x, y] or [x, y, z]
|
|
2142
|
+
*
|
|
2143
|
+
* # Returns
|
|
2144
|
+
*
|
|
2145
|
+
* Field value at the point
|
|
2146
|
+
* @param {Float64Array} point
|
|
2147
|
+
* @returns {number}
|
|
2148
|
+
*/
|
|
2149
|
+
evaluate(point) {
|
|
2150
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
1440
2151
|
const len0 = WASM_VECTOR_LEN;
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
return v3;
|
|
2152
|
+
const ret = wasm.scalarfield_evaluate(this.__wbg_ptr, ptr0, len0);
|
|
2153
|
+
if (ret[2]) {
|
|
2154
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2155
|
+
}
|
|
2156
|
+
return ret[0];
|
|
1447
2157
|
}
|
|
1448
2158
|
}
|
|
1449
|
-
if (Symbol.dispose)
|
|
2159
|
+
if (Symbol.dispose) ScalarField.prototype[Symbol.dispose] = ScalarField.prototype.free;
|
|
1450
2160
|
|
|
1451
2161
|
const TropicalBatchFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1452
2162
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -1590,6 +2300,109 @@ export class TropicalMLOps {
|
|
|
1590
2300
|
}
|
|
1591
2301
|
if (Symbol.dispose) TropicalMLOps.prototype[Symbol.dispose] = TropicalMLOps.prototype.free;
|
|
1592
2302
|
|
|
2303
|
+
const VectorFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2304
|
+
? { register: () => {}, unregister: () => {} }
|
|
2305
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_vectorfield_free(ptr >>> 0, 1));
|
|
2306
|
+
/**
|
|
2307
|
+
* Vector field F: ℝⁿ → ℝⁿ
|
|
2308
|
+
*
|
|
2309
|
+
* Represents a function that maps points to vectors.
|
|
2310
|
+
*
|
|
2311
|
+
* # JavaScript Example
|
|
2312
|
+
*
|
|
2313
|
+
* ```javascript
|
|
2314
|
+
* // Create a 2D vector field F(x, y) = [y, -x] (rotation)
|
|
2315
|
+
* const field = WasmVectorField.fromFunction2D((x, y) => [y, -x]);
|
|
2316
|
+
*
|
|
2317
|
+
* // Evaluate at a point
|
|
2318
|
+
* const vector = field.evaluate([1.0, 2.0]); // Returns [2.0, -1.0]
|
|
2319
|
+
* ```
|
|
2320
|
+
*/
|
|
2321
|
+
export class VectorField {
|
|
2322
|
+
|
|
2323
|
+
static __wrap(ptr) {
|
|
2324
|
+
ptr = ptr >>> 0;
|
|
2325
|
+
const obj = Object.create(VectorField.prototype);
|
|
2326
|
+
obj.__wbg_ptr = ptr;
|
|
2327
|
+
VectorFieldFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2328
|
+
return obj;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
__destroy_into_raw() {
|
|
2332
|
+
const ptr = this.__wbg_ptr;
|
|
2333
|
+
this.__wbg_ptr = 0;
|
|
2334
|
+
VectorFieldFinalization.unregister(this);
|
|
2335
|
+
return ptr;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
free() {
|
|
2339
|
+
const ptr = this.__destroy_into_raw();
|
|
2340
|
+
wasm.__wbg_vectorfield_free(ptr, 0);
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Create a 2D vector field from a JavaScript function
|
|
2344
|
+
*
|
|
2345
|
+
* # Arguments
|
|
2346
|
+
*
|
|
2347
|
+
* * `func` - JavaScript function (x, y) => [fx, fy]
|
|
2348
|
+
* @param {Function} func
|
|
2349
|
+
* @returns {VectorField}
|
|
2350
|
+
*/
|
|
2351
|
+
static fromFunction2D(func) {
|
|
2352
|
+
const ret = wasm.vectorfield_fromFunction2D(func);
|
|
2353
|
+
return VectorField.__wrap(ret);
|
|
2354
|
+
}
|
|
2355
|
+
/**
|
|
2356
|
+
* Create a 3D vector field from a JavaScript function
|
|
2357
|
+
*
|
|
2358
|
+
* # Arguments
|
|
2359
|
+
*
|
|
2360
|
+
* * `func` - JavaScript function (x, y, z) => [fx, fy, fz]
|
|
2361
|
+
* @param {Function} func
|
|
2362
|
+
* @returns {VectorField}
|
|
2363
|
+
*/
|
|
2364
|
+
static fromFunction3D(func) {
|
|
2365
|
+
const ret = wasm.vectorfield_fromFunction3D(func);
|
|
2366
|
+
return VectorField.__wrap(ret);
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
* Create a vector field from a JavaScript function
|
|
2370
|
+
* @param {Function} func
|
|
2371
|
+
* @param {number} dimension
|
|
2372
|
+
*/
|
|
2373
|
+
constructor(func, dimension) {
|
|
2374
|
+
const ret = wasm.vectorfield_new(func, dimension);
|
|
2375
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2376
|
+
VectorFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
2377
|
+
return this;
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Evaluate the vector field at a point
|
|
2381
|
+
*
|
|
2382
|
+
* # Arguments
|
|
2383
|
+
*
|
|
2384
|
+
* * `point` - Coordinates [x, y] or [x, y, z]
|
|
2385
|
+
*
|
|
2386
|
+
* # Returns
|
|
2387
|
+
*
|
|
2388
|
+
* Vector at the point
|
|
2389
|
+
* @param {Float64Array} point
|
|
2390
|
+
* @returns {Float64Array}
|
|
2391
|
+
*/
|
|
2392
|
+
evaluate(point) {
|
|
2393
|
+
const ptr0 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
|
|
2394
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2395
|
+
const ret = wasm.vectorfield_evaluate(this.__wbg_ptr, ptr0, len0);
|
|
2396
|
+
if (ret[3]) {
|
|
2397
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2398
|
+
}
|
|
2399
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2400
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2401
|
+
return v2;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
if (Symbol.dispose) VectorField.prototype[Symbol.dispose] = VectorField.prototype.free;
|
|
2405
|
+
|
|
1593
2406
|
const WasmAlphaConnectionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1594
2407
|
? { register: () => {}, unregister: () => {} }
|
|
1595
2408
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmalphaconnection_free(ptr >>> 0, 1));
|
|
@@ -1825,6 +2638,60 @@ export class WasmCommunity {
|
|
|
1825
2638
|
}
|
|
1826
2639
|
if (Symbol.dispose) WasmCommunity.prototype[Symbol.dispose] = WasmCommunity.prototype.free;
|
|
1827
2640
|
|
|
2641
|
+
const WasmCountingMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2642
|
+
? { register: () => {}, unregister: () => {} }
|
|
2643
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcountingmeasure_free(ptr >>> 0, 1));
|
|
2644
|
+
/**
|
|
2645
|
+
* WASM wrapper for counting measure
|
|
2646
|
+
*
|
|
2647
|
+
* The counting measure assigns to each set the number of elements it contains.
|
|
2648
|
+
*/
|
|
2649
|
+
export class WasmCountingMeasure {
|
|
2650
|
+
|
|
2651
|
+
__destroy_into_raw() {
|
|
2652
|
+
const ptr = this.__wbg_ptr;
|
|
2653
|
+
this.__wbg_ptr = 0;
|
|
2654
|
+
WasmCountingMeasureFinalization.unregister(this);
|
|
2655
|
+
return ptr;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
free() {
|
|
2659
|
+
const ptr = this.__destroy_into_raw();
|
|
2660
|
+
wasm.__wbg_wasmcountingmeasure_free(ptr, 0);
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* Check if a set is measurable under counting measure
|
|
2664
|
+
* (all sets are measurable under counting measure)
|
|
2665
|
+
* @returns {boolean}
|
|
2666
|
+
*/
|
|
2667
|
+
isMeasurable() {
|
|
2668
|
+
const ret = wasm.wasmcountingmeasure_isMeasurable(this.__wbg_ptr);
|
|
2669
|
+
return ret !== 0;
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Measure a finite set (returns its cardinality)
|
|
2673
|
+
*
|
|
2674
|
+
* # Arguments
|
|
2675
|
+
* * `set_size` - The number of elements in the set
|
|
2676
|
+
* @param {number} set_size
|
|
2677
|
+
* @returns {number}
|
|
2678
|
+
*/
|
|
2679
|
+
measureFiniteSet(set_size) {
|
|
2680
|
+
const ret = wasm.wasmcountingmeasure_measureFiniteSet(this.__wbg_ptr, set_size);
|
|
2681
|
+
return ret;
|
|
2682
|
+
}
|
|
2683
|
+
/**
|
|
2684
|
+
* Create a new counting measure
|
|
2685
|
+
*/
|
|
2686
|
+
constructor() {
|
|
2687
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
2688
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2689
|
+
WasmCountingMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
2690
|
+
return this;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (Symbol.dispose) WasmCountingMeasure.prototype[Symbol.dispose] = WasmCountingMeasure.prototype.free;
|
|
2694
|
+
|
|
1828
2695
|
const WasmDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1829
2696
|
? { register: () => {}, unregister: () => {} }
|
|
1830
2697
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdualnumber_free(ptr >>> 0, 1));
|
|
@@ -2329,6 +3196,83 @@ export class WasmFisherInformationMatrix {
|
|
|
2329
3196
|
}
|
|
2330
3197
|
if (Symbol.dispose) WasmFisherInformationMatrix.prototype[Symbol.dispose] = WasmFisherInformationMatrix.prototype.free;
|
|
2331
3198
|
|
|
3199
|
+
const WasmFisherMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3200
|
+
? { register: () => {}, unregister: () => {} }
|
|
3201
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfishermeasure_free(ptr >>> 0, 1));
|
|
3202
|
+
/**
|
|
3203
|
+
* Fisher-Riemannian geometry on statistical manifolds
|
|
3204
|
+
*/
|
|
3205
|
+
export class WasmFisherMeasure {
|
|
3206
|
+
|
|
3207
|
+
static __wrap(ptr) {
|
|
3208
|
+
ptr = ptr >>> 0;
|
|
3209
|
+
const obj = Object.create(WasmFisherMeasure.prototype);
|
|
3210
|
+
obj.__wbg_ptr = ptr;
|
|
3211
|
+
WasmFisherMeasureFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3212
|
+
return obj;
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
__destroy_into_raw() {
|
|
3216
|
+
const ptr = this.__wbg_ptr;
|
|
3217
|
+
this.__wbg_ptr = 0;
|
|
3218
|
+
WasmFisherMeasureFinalization.unregister(this);
|
|
3219
|
+
return ptr;
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
free() {
|
|
3223
|
+
const ptr = this.__destroy_into_raw();
|
|
3224
|
+
wasm.__wbg_wasmfishermeasure_free(ptr, 0);
|
|
3225
|
+
}
|
|
3226
|
+
/**
|
|
3227
|
+
* Create Fisher measure from a parametric density
|
|
3228
|
+
* @param {WasmParametricDensity} density
|
|
3229
|
+
* @returns {WasmFisherMeasure}
|
|
3230
|
+
*/
|
|
3231
|
+
static fromDensity(density) {
|
|
3232
|
+
_assertClass(density, WasmParametricDensity);
|
|
3233
|
+
var ptr0 = density.__destroy_into_raw();
|
|
3234
|
+
const ret = wasm.wasmfishermeasure_fromDensity(ptr0);
|
|
3235
|
+
return WasmFisherMeasure.__wrap(ret);
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Compute the Fisher information metric at parameter point θ
|
|
3239
|
+
* @param {Float64Array} data
|
|
3240
|
+
* @param {Float64Array} params
|
|
3241
|
+
* @returns {Float64Array}
|
|
3242
|
+
*/
|
|
3243
|
+
fisherMetric(data, params) {
|
|
3244
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
3245
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3246
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
3247
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3248
|
+
const ret = wasm.wasmfishermeasure_fisherMetric(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
3249
|
+
if (ret[3]) {
|
|
3250
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3251
|
+
}
|
|
3252
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3253
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3254
|
+
return v3;
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Compute the Riemannian volume element √det(g(θ))
|
|
3258
|
+
* @param {Float64Array} data
|
|
3259
|
+
* @param {Float64Array} params
|
|
3260
|
+
* @returns {number}
|
|
3261
|
+
*/
|
|
3262
|
+
volumeElement(data, params) {
|
|
3263
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
3264
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3265
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
3266
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3267
|
+
const ret = wasm.wasmfishermeasure_volumeElement(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
3268
|
+
if (ret[2]) {
|
|
3269
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3270
|
+
}
|
|
3271
|
+
return ret[0];
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
if (Symbol.dispose) WasmFisherMeasure.prototype[Symbol.dispose] = WasmFisherMeasure.prototype.free;
|
|
3275
|
+
|
|
2332
3276
|
const WasmFourVelocityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2333
3277
|
? { register: () => {}, unregister: () => {} }
|
|
2334
3278
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfourvelocity_free(ptr >>> 0, 1));
|
|
@@ -3031,14 +3975,6 @@ export class WasmGpuOptimizer {
|
|
|
3031
3975
|
const ret = wasm.wasmgpuoptimizer_optimizeBatch(this.__wbg_ptr, ptr0, len0, problem_size, num_problems, max_iterations, tolerance);
|
|
3032
3976
|
return ret;
|
|
3033
3977
|
}
|
|
3034
|
-
/**
|
|
3035
|
-
* Check if GPU acceleration is available
|
|
3036
|
-
* @returns {boolean}
|
|
3037
|
-
*/
|
|
3038
|
-
isGpuAvailable() {
|
|
3039
|
-
const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
|
|
3040
|
-
return ret !== 0;
|
|
3041
|
-
}
|
|
3042
3978
|
/**
|
|
3043
3979
|
* Optimize a quadratic function with GPU acceleration
|
|
3044
3980
|
* @param {Float64Array} coefficients
|
|
@@ -3055,11 +3991,19 @@ export class WasmGpuOptimizer {
|
|
|
3055
3991
|
const ret = wasm.wasmgpuoptimizer_optimizeQuadraticGpu(this.__wbg_ptr, ptr0, len0, ptr1, len1, max_iterations, tolerance);
|
|
3056
3992
|
return ret;
|
|
3057
3993
|
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Check if GPU acceleration is available
|
|
3996
|
+
* @returns {boolean}
|
|
3997
|
+
*/
|
|
3998
|
+
isGpuAvailable() {
|
|
3999
|
+
const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
|
|
4000
|
+
return ret !== 0;
|
|
4001
|
+
}
|
|
3058
4002
|
/**
|
|
3059
4003
|
* Create a new GPU optimizer
|
|
3060
4004
|
*/
|
|
3061
4005
|
constructor() {
|
|
3062
|
-
const ret = wasm.
|
|
4006
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
3063
4007
|
this.__wbg_ptr = ret >>> 0;
|
|
3064
4008
|
WasmGpuOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
3065
4009
|
return this;
|
|
@@ -3157,43 +4101,126 @@ export class WasmInverseCADesigner {
|
|
|
3157
4101
|
* @param {Float64Array} candidate
|
|
3158
4102
|
* @returns {number}
|
|
3159
4103
|
*/
|
|
3160
|
-
evaluateFitness(candidate) {
|
|
3161
|
-
const ptr0 = passArrayF64ToWasm0(candidate, wasm.__wbindgen_malloc);
|
|
4104
|
+
evaluateFitness(candidate) {
|
|
4105
|
+
const ptr0 = passArrayF64ToWasm0(candidate, wasm.__wbindgen_malloc);
|
|
4106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4107
|
+
const ret = wasm.wasminversecadesigner_evaluateFitness(this.__wbg_ptr, ptr0, len0);
|
|
4108
|
+
if (ret[2]) {
|
|
4109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4110
|
+
}
|
|
4111
|
+
return ret[0];
|
|
4112
|
+
}
|
|
4113
|
+
/**
|
|
4114
|
+
* Create a new inverse designer for finding CA seeds
|
|
4115
|
+
* @param {number} target_width
|
|
4116
|
+
* @param {number} target_height
|
|
4117
|
+
*/
|
|
4118
|
+
constructor(target_width, target_height) {
|
|
4119
|
+
const ret = wasm.wasminversecadesigner_new(target_width, target_height);
|
|
4120
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4121
|
+
WasmInverseCADesignerFinalization.register(this, this.__wbg_ptr, this);
|
|
4122
|
+
return this;
|
|
4123
|
+
}
|
|
4124
|
+
/**
|
|
4125
|
+
* Find a seed configuration that produces the target after evolution (simplified)
|
|
4126
|
+
* @param {number} _max_generations
|
|
4127
|
+
* @param {number} max_attempts
|
|
4128
|
+
* @returns {Float64Array}
|
|
4129
|
+
*/
|
|
4130
|
+
findSeed(_max_generations, max_attempts) {
|
|
4131
|
+
const ret = wasm.wasminversecadesigner_findSeed(this.__wbg_ptr, _max_generations, max_attempts);
|
|
4132
|
+
if (ret[3]) {
|
|
4133
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
4134
|
+
}
|
|
4135
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
4136
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
4137
|
+
return v1;
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
if (Symbol.dispose) WasmInverseCADesigner.prototype[Symbol.dispose] = WasmInverseCADesigner.prototype.free;
|
|
4141
|
+
|
|
4142
|
+
const WasmLebesgueMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4143
|
+
? { register: () => {}, unregister: () => {} }
|
|
4144
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlebesguemeasure_free(ptr >>> 0, 1));
|
|
4145
|
+
/**
|
|
4146
|
+
* WASM wrapper for Lebesgue measure
|
|
4147
|
+
*
|
|
4148
|
+
* The Lebesgue measure generalizes the notion of length, area, and volume
|
|
4149
|
+
* to higher dimensions and more complex sets.
|
|
4150
|
+
*/
|
|
4151
|
+
export class WasmLebesgueMeasure {
|
|
4152
|
+
|
|
4153
|
+
__destroy_into_raw() {
|
|
4154
|
+
const ptr = this.__wbg_ptr;
|
|
4155
|
+
this.__wbg_ptr = 0;
|
|
4156
|
+
WasmLebesgueMeasureFinalization.unregister(this);
|
|
4157
|
+
return ptr;
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
free() {
|
|
4161
|
+
const ptr = this.__destroy_into_raw();
|
|
4162
|
+
wasm.__wbg_wasmlebesguemeasure_free(ptr, 0);
|
|
4163
|
+
}
|
|
4164
|
+
/**
|
|
4165
|
+
* Compute the measure of a box (hyper-rectangle) with given side lengths
|
|
4166
|
+
* @param {Float64Array} sides
|
|
4167
|
+
* @returns {number}
|
|
4168
|
+
*/
|
|
4169
|
+
measureBox(sides) {
|
|
4170
|
+
const ptr0 = passArrayF64ToWasm0(sides, wasm.__wbindgen_malloc);
|
|
4171
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4172
|
+
const ret = wasm.wasmlebesguemeasure_measureBox(this.__wbg_ptr, ptr0, len0);
|
|
4173
|
+
if (ret[2]) {
|
|
4174
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4175
|
+
}
|
|
4176
|
+
return ret[0];
|
|
4177
|
+
}
|
|
4178
|
+
/**
|
|
4179
|
+
* Get the dimension of this measure
|
|
4180
|
+
* @returns {number}
|
|
4181
|
+
*/
|
|
4182
|
+
getDimension() {
|
|
4183
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
4184
|
+
return ret >>> 0;
|
|
4185
|
+
}
|
|
4186
|
+
/**
|
|
4187
|
+
* Compute the measure of an interval [a, b]
|
|
4188
|
+
*
|
|
4189
|
+
* For 1D: returns length (b - a)
|
|
4190
|
+
* For higher dimensions: returns the product of interval lengths
|
|
4191
|
+
* @param {Float64Array} lower
|
|
4192
|
+
* @param {Float64Array} upper
|
|
4193
|
+
* @returns {number}
|
|
4194
|
+
*/
|
|
4195
|
+
measureInterval(lower, upper) {
|
|
4196
|
+
const ptr0 = passArrayF64ToWasm0(lower, wasm.__wbindgen_malloc);
|
|
3162
4197
|
const len0 = WASM_VECTOR_LEN;
|
|
3163
|
-
const
|
|
4198
|
+
const ptr1 = passArrayF64ToWasm0(upper, wasm.__wbindgen_malloc);
|
|
4199
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4200
|
+
const ret = wasm.wasmlebesguemeasure_measureInterval(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
3164
4201
|
if (ret[2]) {
|
|
3165
4202
|
throw takeFromExternrefTable0(ret[1]);
|
|
3166
4203
|
}
|
|
3167
4204
|
return ret[0];
|
|
3168
4205
|
}
|
|
3169
4206
|
/**
|
|
3170
|
-
* Create a new
|
|
3171
|
-
*
|
|
3172
|
-
*
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
const ret = wasm.wasminversecadesigner_new(target_width, target_height);
|
|
3176
|
-
this.__wbg_ptr = ret >>> 0;
|
|
3177
|
-
WasmInverseCADesignerFinalization.register(this, this.__wbg_ptr, this);
|
|
3178
|
-
return this;
|
|
3179
|
-
}
|
|
3180
|
-
/**
|
|
3181
|
-
* Find a seed configuration that produces the target after evolution (simplified)
|
|
3182
|
-
* @param {number} _max_generations
|
|
3183
|
-
* @param {number} max_attempts
|
|
3184
|
-
* @returns {Float64Array}
|
|
4207
|
+
* Create a new Lebesgue measure for the specified dimension
|
|
4208
|
+
*
|
|
4209
|
+
* # Arguments
|
|
4210
|
+
* * `dimension` - The dimension of the space (1 for length, 2 for area, 3 for volume, etc.)
|
|
4211
|
+
* @param {number} dimension
|
|
3185
4212
|
*/
|
|
3186
|
-
|
|
3187
|
-
const ret = wasm.
|
|
3188
|
-
if (ret[
|
|
3189
|
-
throw takeFromExternrefTable0(ret[
|
|
4213
|
+
constructor(dimension) {
|
|
4214
|
+
const ret = wasm.wasmlebesguemeasure_new(dimension);
|
|
4215
|
+
if (ret[2]) {
|
|
4216
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3190
4217
|
}
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
return
|
|
4218
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
4219
|
+
WasmLebesgueMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
4220
|
+
return this;
|
|
3194
4221
|
}
|
|
3195
4222
|
}
|
|
3196
|
-
if (Symbol.dispose)
|
|
4223
|
+
if (Symbol.dispose) WasmLebesgueMeasure.prototype[Symbol.dispose] = WasmLebesgueMeasure.prototype.free;
|
|
3197
4224
|
|
|
3198
4225
|
const WasmModuliSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3199
4226
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -3253,7 +4280,7 @@ export class WasmModuliSpace {
|
|
|
3253
4280
|
* @returns {number}
|
|
3254
4281
|
*/
|
|
3255
4282
|
getGenus() {
|
|
3256
|
-
const ret = wasm.
|
|
4283
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
3257
4284
|
return ret >>> 0;
|
|
3258
4285
|
}
|
|
3259
4286
|
/**
|
|
@@ -3454,7 +4481,7 @@ export class WasmMultiObjectiveOptimizer {
|
|
|
3454
4481
|
* Create a new multi-objective optimizer
|
|
3455
4482
|
*/
|
|
3456
4483
|
constructor() {
|
|
3457
|
-
const ret = wasm.
|
|
4484
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
3458
4485
|
this.__wbg_ptr = ret >>> 0;
|
|
3459
4486
|
WasmMultiObjectiveOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
3460
4487
|
return this;
|
|
@@ -3876,7 +4903,7 @@ export class WasmOptimizationResult {
|
|
|
3876
4903
|
* @returns {number}
|
|
3877
4904
|
*/
|
|
3878
4905
|
get iterations() {
|
|
3879
|
-
const ret = wasm.
|
|
4906
|
+
const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
|
|
3880
4907
|
return ret >>> 0;
|
|
3881
4908
|
}
|
|
3882
4909
|
/**
|
|
@@ -3964,6 +4991,220 @@ export class WasmOptimizationUtils {
|
|
|
3964
4991
|
}
|
|
3965
4992
|
if (Symbol.dispose) WasmOptimizationUtils.prototype[Symbol.dispose] = WasmOptimizationUtils.prototype.free;
|
|
3966
4993
|
|
|
4994
|
+
const WasmParametricDensityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4995
|
+
? { register: () => {}, unregister: () => {} }
|
|
4996
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmparametricdensity_free(ptr >>> 0, 1));
|
|
4997
|
+
/**
|
|
4998
|
+
* Parametric probability density families
|
|
4999
|
+
*/
|
|
5000
|
+
export class WasmParametricDensity {
|
|
5001
|
+
|
|
5002
|
+
static __wrap(ptr) {
|
|
5003
|
+
ptr = ptr >>> 0;
|
|
5004
|
+
const obj = Object.create(WasmParametricDensity.prototype);
|
|
5005
|
+
obj.__wbg_ptr = ptr;
|
|
5006
|
+
WasmParametricDensityFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
5007
|
+
return obj;
|
|
5008
|
+
}
|
|
5009
|
+
|
|
5010
|
+
__destroy_into_raw() {
|
|
5011
|
+
const ptr = this.__wbg_ptr;
|
|
5012
|
+
this.__wbg_ptr = 0;
|
|
5013
|
+
WasmParametricDensityFinalization.unregister(this);
|
|
5014
|
+
return ptr;
|
|
5015
|
+
}
|
|
5016
|
+
|
|
5017
|
+
free() {
|
|
5018
|
+
const ptr = this.__destroy_into_raw();
|
|
5019
|
+
wasm.__wbg_wasmparametricdensity_free(ptr, 0);
|
|
5020
|
+
}
|
|
5021
|
+
/**
|
|
5022
|
+
* Create an Exponential density Exp(λ)
|
|
5023
|
+
* @returns {WasmParametricDensity}
|
|
5024
|
+
*/
|
|
5025
|
+
static exponential() {
|
|
5026
|
+
const ret = wasm.wasmparametricdensity_exponential();
|
|
5027
|
+
return WasmParametricDensity.__wrap(ret);
|
|
5028
|
+
}
|
|
5029
|
+
/**
|
|
5030
|
+
* Compute log-density log p(x|θ)
|
|
5031
|
+
* @param {number} x
|
|
5032
|
+
* @param {Float64Array} params
|
|
5033
|
+
* @returns {number}
|
|
5034
|
+
*/
|
|
5035
|
+
logDensity(x, params) {
|
|
5036
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
5037
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5038
|
+
const ret = wasm.wasmparametricdensity_logDensity(this.__wbg_ptr, x, ptr0, len0);
|
|
5039
|
+
if (ret[2]) {
|
|
5040
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5041
|
+
}
|
|
5042
|
+
return ret[0];
|
|
5043
|
+
}
|
|
5044
|
+
/**
|
|
5045
|
+
* Compute Fisher information matrix from data samples
|
|
5046
|
+
* @param {Float64Array} data
|
|
5047
|
+
* @param {Float64Array} params
|
|
5048
|
+
* @returns {Float64Array}
|
|
5049
|
+
*/
|
|
5050
|
+
fisherInformation(data, params) {
|
|
5051
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
5052
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5053
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
5054
|
+
const len1 = WASM_VECTOR_LEN;
|
|
5055
|
+
const ret = wasm.wasmparametricdensity_fisherInformation(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
5056
|
+
if (ret[3]) {
|
|
5057
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5058
|
+
}
|
|
5059
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5060
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5061
|
+
return v3;
|
|
5062
|
+
}
|
|
5063
|
+
/**
|
|
5064
|
+
* Create a Cauchy density Cauchy(x₀, γ)
|
|
5065
|
+
* @returns {WasmParametricDensity}
|
|
5066
|
+
*/
|
|
5067
|
+
static cauchy() {
|
|
5068
|
+
const ret = wasm.wasmparametricdensity_cauchy();
|
|
5069
|
+
return WasmParametricDensity.__wrap(ret);
|
|
5070
|
+
}
|
|
5071
|
+
/**
|
|
5072
|
+
* Create a Laplace density Laplace(μ, b)
|
|
5073
|
+
* @returns {WasmParametricDensity}
|
|
5074
|
+
*/
|
|
5075
|
+
static laplace() {
|
|
5076
|
+
const ret = wasm.wasmparametricdensity_laplace();
|
|
5077
|
+
return WasmParametricDensity.__wrap(ret);
|
|
5078
|
+
}
|
|
5079
|
+
/**
|
|
5080
|
+
* Evaluate density at point x with parameters
|
|
5081
|
+
*
|
|
5082
|
+
* # Arguments
|
|
5083
|
+
* * `x` - Point to evaluate
|
|
5084
|
+
* * `params` - Parameters (Gaussian: [μ, σ], Exponential: [λ], etc.)
|
|
5085
|
+
* @param {number} x
|
|
5086
|
+
* @param {Float64Array} params
|
|
5087
|
+
* @returns {number}
|
|
5088
|
+
*/
|
|
5089
|
+
evaluate(x, params) {
|
|
5090
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
5091
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5092
|
+
const ret = wasm.wasmparametricdensity_evaluate(this.__wbg_ptr, x, ptr0, len0);
|
|
5093
|
+
if (ret[2]) {
|
|
5094
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5095
|
+
}
|
|
5096
|
+
return ret[0];
|
|
5097
|
+
}
|
|
5098
|
+
/**
|
|
5099
|
+
* Create a Gaussian density N(μ, σ²)
|
|
5100
|
+
* @returns {WasmParametricDensity}
|
|
5101
|
+
*/
|
|
5102
|
+
static gaussian() {
|
|
5103
|
+
const ret = wasm.wasmparametricdensity_gaussian();
|
|
5104
|
+
return WasmParametricDensity.__wrap(ret);
|
|
5105
|
+
}
|
|
5106
|
+
/**
|
|
5107
|
+
* Compute numerical gradient ∇_θ p(x|θ)
|
|
5108
|
+
* @param {number} x
|
|
5109
|
+
* @param {Float64Array} params
|
|
5110
|
+
* @returns {Float64Array}
|
|
5111
|
+
*/
|
|
5112
|
+
gradient(x, params) {
|
|
5113
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
5114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5115
|
+
const ret = wasm.wasmparametricdensity_gradient(this.__wbg_ptr, x, ptr0, len0);
|
|
5116
|
+
if (ret[3]) {
|
|
5117
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5118
|
+
}
|
|
5119
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
5120
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
5121
|
+
return v2;
|
|
5122
|
+
}
|
|
5123
|
+
}
|
|
5124
|
+
if (Symbol.dispose) WasmParametricDensity.prototype[Symbol.dispose] = WasmParametricDensity.prototype.free;
|
|
5125
|
+
|
|
5126
|
+
const WasmProbabilityMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5127
|
+
? { register: () => {}, unregister: () => {} }
|
|
5128
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmprobabilitymeasure_free(ptr >>> 0, 1));
|
|
5129
|
+
/**
|
|
5130
|
+
* WASM wrapper for probability measures
|
|
5131
|
+
*
|
|
5132
|
+
* A probability measure assigns total measure 1 to the entire space.
|
|
5133
|
+
*/
|
|
5134
|
+
export class WasmProbabilityMeasure {
|
|
5135
|
+
|
|
5136
|
+
static __wrap(ptr) {
|
|
5137
|
+
ptr = ptr >>> 0;
|
|
5138
|
+
const obj = Object.create(WasmProbabilityMeasure.prototype);
|
|
5139
|
+
obj.__wbg_ptr = ptr;
|
|
5140
|
+
WasmProbabilityMeasureFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
5141
|
+
return obj;
|
|
5142
|
+
}
|
|
5143
|
+
|
|
5144
|
+
__destroy_into_raw() {
|
|
5145
|
+
const ptr = this.__wbg_ptr;
|
|
5146
|
+
this.__wbg_ptr = 0;
|
|
5147
|
+
WasmProbabilityMeasureFinalization.unregister(this);
|
|
5148
|
+
return ptr;
|
|
5149
|
+
}
|
|
5150
|
+
|
|
5151
|
+
free() {
|
|
5152
|
+
const ptr = this.__destroy_into_raw();
|
|
5153
|
+
wasm.__wbg_wasmprobabilitymeasure_free(ptr, 0);
|
|
5154
|
+
}
|
|
5155
|
+
/**
|
|
5156
|
+
* Get a description of this probability measure
|
|
5157
|
+
* @returns {string}
|
|
5158
|
+
*/
|
|
5159
|
+
getDescription() {
|
|
5160
|
+
let deferred1_0;
|
|
5161
|
+
let deferred1_1;
|
|
5162
|
+
try {
|
|
5163
|
+
const ret = wasm.wasmprobabilitymeasure_getDescription(this.__wbg_ptr);
|
|
5164
|
+
deferred1_0 = ret[0];
|
|
5165
|
+
deferred1_1 = ret[1];
|
|
5166
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
5167
|
+
} finally {
|
|
5168
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5171
|
+
/**
|
|
5172
|
+
* Compute P(X ∈ [a, b]) for uniform distribution
|
|
5173
|
+
* @param {number} a
|
|
5174
|
+
* @param {number} b
|
|
5175
|
+
* @param {number} lower
|
|
5176
|
+
* @param {number} upper
|
|
5177
|
+
* @returns {number}
|
|
5178
|
+
*/
|
|
5179
|
+
probabilityInterval(a, b, lower, upper) {
|
|
5180
|
+
const ret = wasm.wasmprobabilitymeasure_probabilityInterval(this.__wbg_ptr, a, b, lower, upper);
|
|
5181
|
+
return ret;
|
|
5182
|
+
}
|
|
5183
|
+
/**
|
|
5184
|
+
* Create a new uniform probability measure on [0, 1]
|
|
5185
|
+
*/
|
|
5186
|
+
constructor() {
|
|
5187
|
+
const ret = wasm.wasmprobabilitymeasure_new();
|
|
5188
|
+
this.__wbg_ptr = ret >>> 0;
|
|
5189
|
+
WasmProbabilityMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
5190
|
+
return this;
|
|
5191
|
+
}
|
|
5192
|
+
/**
|
|
5193
|
+
* Create a uniform probability measure on [a, b]
|
|
5194
|
+
* @param {number} a
|
|
5195
|
+
* @param {number} b
|
|
5196
|
+
* @returns {WasmProbabilityMeasure}
|
|
5197
|
+
*/
|
|
5198
|
+
static uniform(a, b) {
|
|
5199
|
+
const ret = wasm.wasmprobabilitymeasure_uniform(a, b);
|
|
5200
|
+
if (ret[2]) {
|
|
5201
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5202
|
+
}
|
|
5203
|
+
return WasmProbabilityMeasure.__wrap(ret[0]);
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
if (Symbol.dispose) WasmProbabilityMeasure.prototype[Symbol.dispose] = WasmProbabilityMeasure.prototype.free;
|
|
5207
|
+
|
|
3967
5208
|
const WasmProjectiveSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3968
5209
|
? { register: () => {}, unregister: () => {} }
|
|
3969
5210
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmprojectivespace_free(ptr >>> 0, 1));
|
|
@@ -3988,7 +5229,7 @@ export class WasmProjectiveSpace {
|
|
|
3988
5229
|
* @returns {number}
|
|
3989
5230
|
*/
|
|
3990
5231
|
getDimension() {
|
|
3991
|
-
const ret = wasm.
|
|
5232
|
+
const ret = wasm.wasmlebesguemeasure_getDimension(this.__wbg_ptr);
|
|
3992
5233
|
return ret >>> 0;
|
|
3993
5234
|
}
|
|
3994
5235
|
/**
|
|
@@ -4055,7 +5296,7 @@ export class WasmPropagationAnalysis {
|
|
|
4055
5296
|
* @returns {number}
|
|
4056
5297
|
*/
|
|
4057
5298
|
get convergenceTime() {
|
|
4058
|
-
const ret = wasm.
|
|
5299
|
+
const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
|
|
4059
5300
|
return ret >>> 0;
|
|
4060
5301
|
}
|
|
4061
5302
|
/**
|
|
@@ -4607,7 +5848,7 @@ export class WasmSimpleOptimizer {
|
|
|
4607
5848
|
* Create a new simple optimizer
|
|
4608
5849
|
*/
|
|
4609
5850
|
constructor() {
|
|
4610
|
-
const ret = wasm.
|
|
5851
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
4611
5852
|
this.__wbg_ptr = ret >>> 0;
|
|
4612
5853
|
WasmSimpleOptimizerFinalization.register(this, this.__wbg_ptr, this);
|
|
4613
5854
|
return this;
|
|
@@ -4787,14 +6028,6 @@ export class WasmTrajectoryPoint {
|
|
|
4787
6028
|
const ptr = this.__destroy_into_raw();
|
|
4788
6029
|
wasm.__wbg_wasmtrajectorypoint_free(ptr, 0);
|
|
4789
6030
|
}
|
|
4790
|
-
/**
|
|
4791
|
-
* Get position
|
|
4792
|
-
* @returns {WasmSpacetimeVector}
|
|
4793
|
-
*/
|
|
4794
|
-
get position() {
|
|
4795
|
-
const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
|
|
4796
|
-
return WasmSpacetimeVector.__wrap(ret);
|
|
4797
|
-
}
|
|
4798
6031
|
/**
|
|
4799
6032
|
* Time coordinate
|
|
4800
6033
|
* @returns {number}
|
|
@@ -4810,6 +6043,14 @@ export class WasmTrajectoryPoint {
|
|
|
4810
6043
|
set time(arg0) {
|
|
4811
6044
|
wasm.__wbg_set_wasmtrajectorypoint_time(this.__wbg_ptr, arg0);
|
|
4812
6045
|
}
|
|
6046
|
+
/**
|
|
6047
|
+
* Get position
|
|
6048
|
+
* @returns {WasmSpacetimeVector}
|
|
6049
|
+
*/
|
|
6050
|
+
get position() {
|
|
6051
|
+
const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
|
|
6052
|
+
return WasmSpacetimeVector.__wrap(ret);
|
|
6053
|
+
}
|
|
4813
6054
|
}
|
|
4814
6055
|
if (Symbol.dispose) WasmTrajectoryPoint.prototype[Symbol.dispose] = WasmTrajectoryPoint.prototype.free;
|
|
4815
6056
|
|
|
@@ -5187,6 +6428,90 @@ export class WasmTropicalDualDistribution {
|
|
|
5187
6428
|
}
|
|
5188
6429
|
if (Symbol.dispose) WasmTropicalDualDistribution.prototype[Symbol.dispose] = WasmTropicalDualDistribution.prototype.free;
|
|
5189
6430
|
|
|
6431
|
+
const WasmTropicalMeasureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6432
|
+
? { register: () => {}, unregister: () => {} }
|
|
6433
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalmeasure_free(ptr >>> 0, 1));
|
|
6434
|
+
/**
|
|
6435
|
+
* Tropical (max-plus) algebra operations for optimization
|
|
6436
|
+
*/
|
|
6437
|
+
export class WasmTropicalMeasure {
|
|
6438
|
+
|
|
6439
|
+
__destroy_into_raw() {
|
|
6440
|
+
const ptr = this.__wbg_ptr;
|
|
6441
|
+
this.__wbg_ptr = 0;
|
|
6442
|
+
WasmTropicalMeasureFinalization.unregister(this);
|
|
6443
|
+
return ptr;
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
free() {
|
|
6447
|
+
const ptr = this.__destroy_into_raw();
|
|
6448
|
+
wasm.__wbg_wasmtropicalmeasure_free(ptr, 0);
|
|
6449
|
+
}
|
|
6450
|
+
/**
|
|
6451
|
+
* Tropical integration (supremum over region)
|
|
6452
|
+
* @param {Function} f
|
|
6453
|
+
* @param {number} a
|
|
6454
|
+
* @param {number} b
|
|
6455
|
+
* @param {number} samples
|
|
6456
|
+
* @returns {number}
|
|
6457
|
+
*/
|
|
6458
|
+
tropicalIntegrate(f, a, b, samples) {
|
|
6459
|
+
const ret = wasm.wasmtropicalmeasure_tropicalIntegrate(this.__wbg_ptr, f, a, b, samples);
|
|
6460
|
+
if (ret[2]) {
|
|
6461
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
6462
|
+
}
|
|
6463
|
+
return ret[0];
|
|
6464
|
+
}
|
|
6465
|
+
/**
|
|
6466
|
+
* Create a new tropical measure
|
|
6467
|
+
*/
|
|
6468
|
+
constructor() {
|
|
6469
|
+
const ret = wasm.wasmcountingmeasure_new();
|
|
6470
|
+
this.__wbg_ptr = ret >>> 0;
|
|
6471
|
+
WasmTropicalMeasureFinalization.register(this, this.__wbg_ptr, this);
|
|
6472
|
+
return this;
|
|
6473
|
+
}
|
|
6474
|
+
/**
|
|
6475
|
+
* Compute tropical infimum (minimum) of function over sample points
|
|
6476
|
+
*
|
|
6477
|
+
* Returns the minimum value and the point where it occurs
|
|
6478
|
+
* @param {Function} f
|
|
6479
|
+
* @param {Float64Array} points
|
|
6480
|
+
* @returns {Float64Array}
|
|
6481
|
+
*/
|
|
6482
|
+
infimum(f, points) {
|
|
6483
|
+
const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
6484
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6485
|
+
const ret = wasm.wasmtropicalmeasure_infimum(this.__wbg_ptr, f, ptr0, len0);
|
|
6486
|
+
if (ret[3]) {
|
|
6487
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
6488
|
+
}
|
|
6489
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
6490
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
6491
|
+
return v2;
|
|
6492
|
+
}
|
|
6493
|
+
/**
|
|
6494
|
+
* Compute tropical supremum (maximum) of function over sample points
|
|
6495
|
+
*
|
|
6496
|
+
* Returns the maximum value and the point where it occurs
|
|
6497
|
+
* @param {Function} f
|
|
6498
|
+
* @param {Float64Array} points
|
|
6499
|
+
* @returns {Float64Array}
|
|
6500
|
+
*/
|
|
6501
|
+
supremum(f, points) {
|
|
6502
|
+
const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
6503
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6504
|
+
const ret = wasm.wasmtropicalmeasure_supremum(this.__wbg_ptr, f, ptr0, len0);
|
|
6505
|
+
if (ret[3]) {
|
|
6506
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
6507
|
+
}
|
|
6508
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
6509
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
6510
|
+
return v2;
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
if (Symbol.dispose) WasmTropicalMeasure.prototype[Symbol.dispose] = WasmTropicalMeasure.prototype.free;
|
|
6514
|
+
|
|
5190
6515
|
const WasmTropicalNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5191
6516
|
? { register: () => {}, unregister: () => {} }
|
|
5192
6517
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalnetwork_free(ptr >>> 0, 1));
|
|
@@ -5649,10 +6974,18 @@ function __wbg_get_imports() {
|
|
|
5649
6974
|
const ret = arg0.apply(arg1, arg2);
|
|
5650
6975
|
return ret;
|
|
5651
6976
|
}, arguments) };
|
|
6977
|
+
imports.wbg.__wbg_call_357bb72daee10695 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
6978
|
+
const ret = arg0.call(arg1, arg2, arg3, arg4);
|
|
6979
|
+
return ret;
|
|
6980
|
+
}, arguments) };
|
|
5652
6981
|
imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
|
|
5653
6982
|
const ret = arg0.call(arg1, arg2);
|
|
5654
6983
|
return ret;
|
|
5655
6984
|
}, arguments) };
|
|
6985
|
+
imports.wbg.__wbg_call_e45d2cf9fc925fcf = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
6986
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
6987
|
+
return ret;
|
|
6988
|
+
}, arguments) };
|
|
5656
6989
|
imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
|
|
5657
6990
|
const ret = arg0.call(arg1);
|
|
5658
6991
|
return ret;
|
|
@@ -5680,12 +7013,12 @@ function __wbg_get_imports() {
|
|
|
5680
7013
|
const ret = arg0.length;
|
|
5681
7014
|
return ret;
|
|
5682
7015
|
};
|
|
5683
|
-
imports.wbg.__wbg_log_660547816007a991 = function(arg0, arg1) {
|
|
5684
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
5685
|
-
};
|
|
5686
7016
|
imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) {
|
|
5687
7017
|
console.log(arg0);
|
|
5688
7018
|
};
|
|
7019
|
+
imports.wbg.__wbg_log_bf0922dbf69432a1 = function(arg0, arg1) {
|
|
7020
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
7021
|
+
};
|
|
5689
7022
|
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
5690
7023
|
const ret = new Object();
|
|
5691
7024
|
return ret;
|
|
@@ -5697,7 +7030,7 @@ function __wbg_get_imports() {
|
|
|
5697
7030
|
const a = state0.a;
|
|
5698
7031
|
state0.a = 0;
|
|
5699
7032
|
try {
|
|
5700
|
-
return
|
|
7033
|
+
return wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue__wasm_bindgen_e07ba2a7d21574bf___JsValue_____(a, state0.b, arg0, arg1);
|
|
5701
7034
|
} finally {
|
|
5702
7035
|
state0.a = a;
|
|
5703
7036
|
}
|
|
@@ -5798,11 +7131,6 @@ function __wbg_get_imports() {
|
|
|
5798
7131
|
const ret = BigInt.asUintN(64, arg0);
|
|
5799
7132
|
return ret;
|
|
5800
7133
|
};
|
|
5801
|
-
imports.wbg.__wbindgen_cast_69f35aa0fcaecc47 = function(arg0, arg1) {
|
|
5802
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 37, function: Function { arguments: [Externref], shim_idx: 38, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
5803
|
-
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__ha65d378aaf4b53b1, wasm_bindgen__convert__closures_____invoke__h9e55f7f912fc76ac);
|
|
5804
|
-
return ret;
|
|
5805
|
-
};
|
|
5806
7134
|
imports.wbg.__wbindgen_cast_b63aeb0d85365734 = function(arg0, arg1) {
|
|
5807
7135
|
var v0 = getArrayF64FromWasm0(arg0, arg1).slice();
|
|
5808
7136
|
wasm.__wbindgen_free(arg0, arg1 * 8, 8);
|
|
@@ -5810,6 +7138,11 @@ function __wbg_get_imports() {
|
|
|
5810
7138
|
const ret = v0;
|
|
5811
7139
|
return ret;
|
|
5812
7140
|
};
|
|
7141
|
+
imports.wbg.__wbindgen_cast_d2d0cc24b1b6ed59 = function(arg0, arg1) {
|
|
7142
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 42, function: Function { arguments: [Externref], shim_idx: 43, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
7143
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_e07ba2a7d21574bf___closure__destroy___dyn_core_a2b7f04d45112077___ops__function__FnMut__wasm_bindgen_e07ba2a7d21574bf___JsValue____Output_______, wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue_____);
|
|
7144
|
+
return ret;
|
|
7145
|
+
};
|
|
5813
7146
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
5814
7147
|
// Cast intrinsic for `F64 -> Externref`.
|
|
5815
7148
|
const ret = arg0;
|