@justinelliottcobb/amari-wasm 0.10.0 → 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/amari_wasm.d.ts CHANGED
@@ -340,6 +340,58 @@ export class InfoGeomUtils {
340
340
  */
341
341
  static normalize(values: Float64Array): Float64Array;
342
342
  }
343
+ /**
344
+ * Numerical integration operations
345
+ *
346
+ * Provides definite integrals, line integrals, and surface integrals
347
+ * using adaptive quadrature.
348
+ */
349
+ export class Integration {
350
+ private constructor();
351
+ free(): void;
352
+ [Symbol.dispose](): void;
353
+ /**
354
+ * Compute 1D definite integral using Simpson's rule
355
+ *
356
+ * ∫[a,b] f(x) dx
357
+ *
358
+ * # Arguments
359
+ *
360
+ * * `func` - JavaScript function to integrate
361
+ * * `a` - Lower bound
362
+ * * `b` - Upper bound
363
+ * * `n` - Number of subdivisions (must be even)
364
+ *
365
+ * # Returns
366
+ *
367
+ * Integral value
368
+ *
369
+ * # JavaScript Example
370
+ *
371
+ * ```javascript
372
+ * // Integrate x^2 from 0 to 1
373
+ * const result = Integration.integrate1D(x => x*x, 0, 1, 100);
374
+ * // Returns approximately 0.333...
375
+ * ```
376
+ */
377
+ static integrate1D(func: Function, a: number, b: number, n: number): number;
378
+ /**
379
+ * Compute 2D integral over a rectangle using Simpson's rule
380
+ *
381
+ * ∫∫[a,b]×[c,d] f(x,y) dx dy
382
+ *
383
+ * # Arguments
384
+ *
385
+ * * `func` - JavaScript function (x, y) => f(x, y)
386
+ * * `ax` - Lower x bound
387
+ * * `bx` - Upper x bound
388
+ * * `ay` - Lower y bound
389
+ * * `by` - Upper y bound
390
+ * * `nx` - Number of x subdivisions (must be even)
391
+ * * `ny` - Number of y subdivisions (must be even)
392
+ */
393
+ static integrate2D(func: Function, ax: number, bx: number, ay: number, by: number, nx: number, ny: number): number;
394
+ }
343
395
  /**
344
396
  * Advanced machine learning operations using dual numbers
345
397
  */
@@ -384,6 +436,92 @@ export class NetworkUtils {
384
436
  */
385
437
  static createSmallWorldNetwork(num_nodes: number, k: number, beta: number): WasmGeometricNetwork;
386
438
  }
439
+ /**
440
+ * Numerical derivative operations
441
+ *
442
+ * Provides gradient, divergence, curl, and Laplacian computations
443
+ * using centered finite differences.
444
+ */
445
+ export class NumericalDerivative {
446
+ free(): void;
447
+ [Symbol.dispose](): void;
448
+ /**
449
+ * Compute divergence of a vector field at a point
450
+ *
451
+ * ∇·F = ∂Fx/∂x + ∂Fy/∂y + ∂Fz/∂z
452
+ *
453
+ * # Arguments
454
+ *
455
+ * * `field` - Vector field
456
+ * * `point` - Evaluation point
457
+ *
458
+ * # Returns
459
+ *
460
+ * Divergence (scalar)
461
+ */
462
+ divergence(field: VectorField, point: Float64Array): number;
463
+ /**
464
+ * Create a new numerical derivative computer
465
+ *
466
+ * # Arguments
467
+ *
468
+ * * `step_size` - Optional step size for finite differences (default: 1e-5)
469
+ */
470
+ constructor(step_size?: number | null);
471
+ /**
472
+ * Compute curl of a 3D vector field at a point
473
+ *
474
+ * ∇×F = [∂Fz/∂y - ∂Fy/∂z, ∂Fx/∂z - ∂Fz/∂x, ∂Fy/∂x - ∂Fx/∂y]
475
+ *
476
+ * # Arguments
477
+ *
478
+ * * `field` - 3D vector field
479
+ * * `point` - Evaluation point [x, y, z]
480
+ *
481
+ * # Returns
482
+ *
483
+ * Curl vector [cx, cy, cz]
484
+ */
485
+ curl(field: VectorField, point: Float64Array): Float64Array;
486
+ /**
487
+ * Compute gradient of a scalar field at a point
488
+ *
489
+ * ∇f = [∂f/∂x, ∂f/∂y, ∂f/∂z]
490
+ *
491
+ * # Arguments
492
+ *
493
+ * * `field` - Scalar field
494
+ * * `point` - Evaluation point
495
+ *
496
+ * # Returns
497
+ *
498
+ * Gradient vector
499
+ *
500
+ * # JavaScript Example
501
+ *
502
+ * ```javascript
503
+ * const field = ScalarField.fromFunction2D((x, y) => x*x + y*y);
504
+ * const derivative = new NumericalDerivative();
505
+ * const grad = derivative.gradient(field, [1.0, 2.0]); // Returns [2.0, 4.0]
506
+ * ```
507
+ */
508
+ gradient(field: ScalarField, point: Float64Array): Float64Array;
509
+ /**
510
+ * Compute Laplacian of a scalar field at a point
511
+ *
512
+ * ∇²f = ∂²f/∂x² + ∂²f/∂y² + ∂²f/∂z²
513
+ *
514
+ * # Arguments
515
+ *
516
+ * * `field` - Scalar field
517
+ * * `point` - Evaluation point
518
+ *
519
+ * # Returns
520
+ *
521
+ * Laplacian (scalar)
522
+ */
523
+ laplacian(field: ScalarField, point: Float64Array): number;
524
+ }
387
525
  /**
388
526
  * High-performance WASM operations with memory pooling
389
527
  */
@@ -408,6 +546,184 @@ export class PerformanceOperations {
408
546
  */
409
547
  static fastGeometricProduct(lhs: Float64Array, rhs: Float64Array): Float64Array;
410
548
  }
549
+ /**
550
+ * Riemannian manifold with metric tensor
551
+ *
552
+ * Represents a curved space with a metric that defines distances and angles.
553
+ *
554
+ * # JavaScript Example
555
+ *
556
+ * ```javascript
557
+ * // Create a 2D sphere of radius 1
558
+ * const sphere = RiemannianManifold.sphere(1.0);
559
+ *
560
+ * // Compute scalar curvature at the north pole
561
+ * const R = sphere.scalarCurvature([0.0, 0.0]); // Returns 2.0 for unit sphere
562
+ * ```
563
+ */
564
+ export class RiemannianManifold {
565
+ private constructor();
566
+ free(): void;
567
+ [Symbol.dispose](): void;
568
+ /**
569
+ * Create a 2D hyperbolic plane (Poincaré half-plane model)
570
+ *
571
+ * Metric: ds² = (dx² + dy²) / y²
572
+ */
573
+ static hyperbolic(): RiemannianManifold;
574
+ /**
575
+ * Compute Christoffel symbol Γ^k_ij at a point
576
+ *
577
+ * # Arguments
578
+ *
579
+ * * `k` - Upper index
580
+ * * `i` - First lower index
581
+ * * `j` - Second lower index
582
+ * * `coords` - Coordinates
583
+ */
584
+ christoffel(k: number, i: number, j: number, coords: Float64Array): number;
585
+ /**
586
+ * Compute Ricci tensor component R_ij
587
+ *
588
+ * # Arguments
589
+ *
590
+ * * `i` - First index
591
+ * * `j` - Second index
592
+ * * `coords` - Coordinates
593
+ */
594
+ ricciTensor(i: number, j: number, coords: Float64Array): number;
595
+ /**
596
+ * Compute Riemann curvature tensor component R^i_jkl
597
+ *
598
+ * # Arguments
599
+ *
600
+ * * `i` - Upper index
601
+ * * `j` - First lower index
602
+ * * `k` - Second lower index
603
+ * * `l` - Third lower index
604
+ * * `coords` - Coordinates
605
+ */
606
+ riemannTensor(i: number, j: number, k: number, l: number, coords: Float64Array): number;
607
+ /**
608
+ * Compute scalar curvature R
609
+ *
610
+ * # Arguments
611
+ *
612
+ * * `coords` - Coordinates
613
+ *
614
+ * # Returns
615
+ *
616
+ * Scalar curvature value
617
+ */
618
+ scalarCurvature(coords: Float64Array): number;
619
+ /**
620
+ * Create a 2D sphere of given radius
621
+ *
622
+ * Metric: ds² = dθ² + sin²θ dφ²
623
+ *
624
+ * # Arguments
625
+ *
626
+ * * `radius` - Sphere radius
627
+ */
628
+ static sphere(radius: number): RiemannianManifold;
629
+ /**
630
+ * Compute geodesic trajectory
631
+ *
632
+ * Solves the geodesic equations using RK4 integration.
633
+ *
634
+ * # Arguments
635
+ *
636
+ * * `initial_pos` - Initial position
637
+ * * `initial_vel` - Initial velocity
638
+ * * `t_max` - Maximum time
639
+ * * `dt` - Time step
640
+ *
641
+ * # Returns
642
+ *
643
+ * Flat array of trajectory points and velocities:
644
+ * [x0, y0, vx0, vy0, x1, y1, vx1, vy1, ...]
645
+ */
646
+ geodesic(initial_pos: Float64Array, initial_vel: Float64Array, t_max: number, dt: number): Float64Array;
647
+ /**
648
+ * Create a Euclidean (flat) manifold
649
+ *
650
+ * # Arguments
651
+ *
652
+ * * `dimension` - Dimension (2 or 3)
653
+ */
654
+ static euclidean(dimension: number): RiemannianManifold;
655
+ /**
656
+ * Get the dimension of the manifold
657
+ */
658
+ readonly dimension: number;
659
+ }
660
+ /**
661
+ * Scalar field f: ℝⁿ → ℝ
662
+ *
663
+ * Represents a function that maps points in n-dimensional space to real numbers.
664
+ *
665
+ * # JavaScript Example
666
+ *
667
+ * ```javascript
668
+ * // Create a scalar field f(x, y) = x² + y²
669
+ * const field = WasmScalarField.fromFunction2D((x, y) => x*x + y*y);
670
+ *
671
+ * // Evaluate at a point
672
+ * const value = field.evaluate([1.0, 2.0]); // Returns 5.0
673
+ * ```
674
+ */
675
+ export class ScalarField {
676
+ free(): void;
677
+ [Symbol.dispose](): void;
678
+ /**
679
+ * Batch evaluate the field at multiple points
680
+ *
681
+ * # Arguments
682
+ *
683
+ * * `points` - Array of points as flat array [x1, y1, x2, y2, ...]
684
+ *
685
+ * # Returns
686
+ *
687
+ * Array of field values
688
+ */
689
+ batchEvaluate(points: Float64Array): Float64Array;
690
+ /**
691
+ * Create a 2D scalar field from a JavaScript function
692
+ *
693
+ * # Arguments
694
+ *
695
+ * * `func` - JavaScript function (x, y) => f(x, y)
696
+ */
697
+ static fromFunction2D(func: Function): ScalarField;
698
+ /**
699
+ * Create a 3D scalar field from a JavaScript function
700
+ *
701
+ * # Arguments
702
+ *
703
+ * * `func` - JavaScript function (x, y, z) => f(x, y, z)
704
+ */
705
+ static fromFunction3D(func: Function): ScalarField;
706
+ /**
707
+ * Create a 2D scalar field from a JavaScript function
708
+ *
709
+ * # Arguments
710
+ *
711
+ * * `func` - JavaScript function (x, y) => f(x, y)
712
+ */
713
+ constructor(func: Function, dimension: number);
714
+ /**
715
+ * Evaluate the scalar field at a point
716
+ *
717
+ * # Arguments
718
+ *
719
+ * * `point` - Coordinates [x, y] or [x, y, z]
720
+ *
721
+ * # Returns
722
+ *
723
+ * Field value at the point
724
+ */
725
+ evaluate(point: Float64Array): number;
726
+ }
411
727
  /**
412
728
  * Batch operations for tropical numbers
413
729
  */
@@ -452,6 +768,57 @@ export class TropicalMLOps {
452
768
  */
453
769
  static convexCombination(values: Float64Array, weights: Float64Array): number;
454
770
  }
771
+ /**
772
+ * Vector field F: ℝⁿ → ℝⁿ
773
+ *
774
+ * Represents a function that maps points to vectors.
775
+ *
776
+ * # JavaScript Example
777
+ *
778
+ * ```javascript
779
+ * // Create a 2D vector field F(x, y) = [y, -x] (rotation)
780
+ * const field = WasmVectorField.fromFunction2D((x, y) => [y, -x]);
781
+ *
782
+ * // Evaluate at a point
783
+ * const vector = field.evaluate([1.0, 2.0]); // Returns [2.0, -1.0]
784
+ * ```
785
+ */
786
+ export class VectorField {
787
+ free(): void;
788
+ [Symbol.dispose](): void;
789
+ /**
790
+ * Create a 2D vector field from a JavaScript function
791
+ *
792
+ * # Arguments
793
+ *
794
+ * * `func` - JavaScript function (x, y) => [fx, fy]
795
+ */
796
+ static fromFunction2D(func: Function): VectorField;
797
+ /**
798
+ * Create a 3D vector field from a JavaScript function
799
+ *
800
+ * # Arguments
801
+ *
802
+ * * `func` - JavaScript function (x, y, z) => [fx, fy, fz]
803
+ */
804
+ static fromFunction3D(func: Function): VectorField;
805
+ /**
806
+ * Create a vector field from a JavaScript function
807
+ */
808
+ constructor(func: Function, dimension: number);
809
+ /**
810
+ * Evaluate the vector field at a point
811
+ *
812
+ * # Arguments
813
+ *
814
+ * * `point` - Coordinates [x, y] or [x, y, z]
815
+ *
816
+ * # Returns
817
+ *
818
+ * Vector at the point
819
+ */
820
+ evaluate(point: Float64Array): Float64Array;
821
+ }
455
822
  /**
456
823
  * WASM wrapper for AlphaConnection
457
824
  */
@@ -2085,8 +2452,10 @@ export interface InitOutput {
2085
2452
  readonly memory: WebAssembly.Memory;
2086
2453
  readonly __wbg_autodiff_free: (a: number, b: number) => void;
2087
2454
  readonly __wbg_get_wasmtrajectorypoint_time: (a: number) => number;
2455
+ readonly __wbg_numericalderivative_free: (a: number, b: number) => void;
2456
+ readonly __wbg_riemannianmanifold_free: (a: number, b: number) => void;
2457
+ readonly __wbg_scalarfield_free: (a: number, b: number) => void;
2088
2458
  readonly __wbg_set_wasmtrajectorypoint_time: (a: number, b: number) => void;
2089
- readonly __wbg_wasmalphaconnection_free: (a: number, b: number) => void;
2090
2459
  readonly __wbg_wasmchowclass_free: (a: number, b: number) => void;
2091
2460
  readonly __wbg_wasmcommunity_free: (a: number, b: number) => void;
2092
2461
  readonly __wbg_wasmduallyflatmanifold_free: (a: number, b: number) => void;
@@ -2163,6 +2532,8 @@ export interface InitOutput {
2163
2532
  readonly initEnumerative: () => void;
2164
2533
  readonly initFusion: () => void;
2165
2534
  readonly integrate: (a: any, b: number, c: number, d: number, e: number) => [number, number, number];
2535
+ readonly integration_integrate1D: (a: any, b: number, c: number, d: number) => [number, number, number];
2536
+ readonly integration_integrate2D: (a: any, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
2166
2537
  readonly klDivergence: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
2167
2538
  readonly light_deflection_angle: (a: number, b: number) => number;
2168
2539
  readonly mlops_batchActivation: (a: number, b: number, c: number, d: number) => [number, number, number, number];
@@ -2172,10 +2543,29 @@ export interface InitOutput {
2172
2543
  readonly networkutils_clusteringCoefficient: (a: number) => number;
2173
2544
  readonly networkutils_createRandomNetwork: (a: number, b: number) => [number, number, number];
2174
2545
  readonly networkutils_createSmallWorldNetwork: (a: number, b: number, c: number) => [number, number, number];
2546
+ readonly numericalderivative_curl: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2547
+ readonly numericalderivative_divergence: (a: number, b: number, c: number, d: number) => [number, number, number];
2548
+ readonly numericalderivative_gradient: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2549
+ readonly numericalderivative_laplacian: (a: number, b: number, c: number, d: number) => [number, number, number];
2550
+ readonly numericalderivative_new: (a: number, b: number) => number;
2175
2551
  readonly performanceoperations_batchNormalize: (a: number, b: number, c: number) => [number, number];
2176
2552
  readonly performanceoperations_fastGeometricProduct: (a: number, b: number, c: number, d: number) => [number, number];
2177
2553
  readonly performanceoperations_vectorCrossProduct: (a: number, b: number, c: number, d: number) => [number, number];
2178
2554
  readonly performanceoperations_vectorDotProduct: (a: number, b: number, c: number, d: number) => number;
2555
+ readonly riemannianmanifold_christoffel: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2556
+ readonly riemannianmanifold_dimension: (a: number) => number;
2557
+ readonly riemannianmanifold_euclidean: (a: number) => [number, number, number];
2558
+ readonly riemannianmanifold_geodesic: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
2559
+ readonly riemannianmanifold_hyperbolic: () => number;
2560
+ readonly riemannianmanifold_ricciTensor: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
2561
+ readonly riemannianmanifold_riemannTensor: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
2562
+ readonly riemannianmanifold_scalarCurvature: (a: number, b: number, c: number) => [number, number, number];
2563
+ readonly riemannianmanifold_sphere: (a: number) => [number, number, number];
2564
+ readonly scalarfield_batchEvaluate: (a: number, b: number, c: number) => [number, number, number, number];
2565
+ readonly scalarfield_evaluate: (a: number, b: number, c: number) => [number, number, number];
2566
+ readonly scalarfield_fromFunction2D: (a: any) => number;
2567
+ readonly scalarfield_fromFunction3D: (a: any) => number;
2568
+ readonly scalarfield_new: (a: any, b: number) => number;
2179
2569
  readonly tropicalbatch_batchTropicalAdd: (a: number, b: number) => number;
2180
2570
  readonly tropicalbatch_batchTropicalMul: (a: number, b: number) => number;
2181
2571
  readonly tropicalbatch_maxLogProb: (a: number, b: number) => number;
@@ -2184,6 +2574,7 @@ export interface InitOutput {
2184
2574
  readonly tropicalmlops_matrixMultiply: (a: any, b: any) => [number, number, number];
2185
2575
  readonly tropicalmlops_shortestPaths: (a: any) => [number, number, number];
2186
2576
  readonly validate_relativistic_module: () => number;
2577
+ readonly vectorfield_evaluate: (a: number, b: number, c: number) => [number, number, number, number];
2187
2578
  readonly velocity_to_gamma: (a: number) => [number, number, number];
2188
2579
  readonly wasmalphaconnection_getAlpha: (a: number) => number;
2189
2580
  readonly wasmalphaconnection_isExponential: (a: number) => number;
@@ -2351,7 +2742,6 @@ export interface InitOutput {
2351
2742
  readonly wasmnodemetadata_set_label: (a: number, b: number, c: number) => void;
2352
2743
  readonly wasmnodemetadata_withLabel: (a: number, b: number) => number;
2353
2744
  readonly wasmoptimizationresult_converged: (a: number) => number;
2354
- readonly wasmoptimizationresult_iterations: (a: number) => number;
2355
2745
  readonly wasmoptimizationresult_solution: (a: number) => [number, number];
2356
2746
  readonly wasmoptimizationutils_dominates: (a: number, b: number, c: number, d: number) => number;
2357
2747
  readonly wasmoptimizationutils_numericalGradient: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
@@ -2468,6 +2858,8 @@ export interface InitOutput {
2468
2858
  readonly wasmtropicalviterbi_forward_probabilities: (a: number, b: number, c: number) => [number, number, number];
2469
2859
  readonly wasmtropicalviterbi_new: (a: any, b: any) => [number, number, number];
2470
2860
  readonly wasmtropicalnumber_new: (a: number) => number;
2861
+ readonly vectorfield_fromFunction2D: (a: any) => number;
2862
+ readonly vectorfield_fromFunction3D: (a: any) => number;
2471
2863
  readonly wasmmultivector_norm: (a: number) => number;
2472
2864
  readonly wasmspacetimevector_t: (a: number) => number;
2473
2865
  readonly wasmtropicalnumber_tropicalMul: (a: number, b: number) => number;
@@ -2475,6 +2867,8 @@ export interface InitOutput {
2475
2867
  readonly wasmtropicalpolynomial_coefficients_count: (a: number) => number;
2476
2868
  readonly __wbg_wasmparametricdensity_free: (a: number, b: number) => void;
2477
2869
  readonly __wbg_wasmprobabilitymeasure_free: (a: number, b: number) => void;
2870
+ readonly __wbg_vectorfield_free: (a: number, b: number) => void;
2871
+ readonly vectorfield_new: (a: any, b: number) => number;
2478
2872
  readonly wasmtropicalnumber_tropicalAdd: (a: number, b: number) => number;
2479
2873
  readonly wasmcommunity_cohesion_score: (a: number) => number;
2480
2874
  readonly wasmdualnumber_getReal: (a: number) => number;
@@ -2483,6 +2877,7 @@ export interface InitOutput {
2483
2877
  readonly wasmgeometricedge_weight: (a: number) => number;
2484
2878
  readonly wasmmodulispace_getGenus: (a: number) => number;
2485
2879
  readonly wasmmultidualnumber_getReal: (a: number) => number;
2880
+ readonly wasmoptimizationresult_iterations: (a: number) => number;
2486
2881
  readonly wasmoptimizationresult_objective_value: (a: number) => number;
2487
2882
  readonly wasmprojectivespace_getDimension: (a: number) => number;
2488
2883
  readonly wasmpropagationanalysis_convergence_time: (a: number) => number;
@@ -2502,11 +2897,13 @@ export interface InitOutput {
2502
2897
  readonly __wbg_fusionbatchoperations_free: (a: number, b: number) => void;
2503
2898
  readonly __wbg_fusionutils_free: (a: number, b: number) => void;
2504
2899
  readonly __wbg_infogeomutils_free: (a: number, b: number) => void;
2900
+ readonly __wbg_integration_free: (a: number, b: number) => void;
2505
2901
  readonly __wbg_mlops_free: (a: number, b: number) => void;
2506
2902
  readonly __wbg_networkutils_free: (a: number, b: number) => void;
2507
2903
  readonly __wbg_performanceoperations_free: (a: number, b: number) => void;
2508
2904
  readonly __wbg_tropicalbatch_free: (a: number, b: number) => void;
2509
2905
  readonly __wbg_tropicalmlops_free: (a: number, b: number) => void;
2906
+ readonly __wbg_wasmalphaconnection_free: (a: number, b: number) => void;
2510
2907
  readonly __wbg_wasmcountingmeasure_free: (a: number, b: number) => void;
2511
2908
  readonly __wbg_wasmdualnumber_free: (a: number, b: number) => void;
2512
2909
  readonly __wbg_wasmfourvelocity_free: (a: number, b: number) => void;
@@ -2528,9 +2925,9 @@ export interface InitOutput {
2528
2925
  readonly wasmmultiobjectiveoptimizer_new: () => number;
2529
2926
  readonly wasmsimpleoptimizer_new: () => number;
2530
2927
  readonly wasmtropicalmeasure_new: () => number;
2531
- readonly wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____: (a: number, b: number, c: any) => void;
2532
- readonly wasm_bindgen_83f782f110bf2942___closure__destroy___dyn_core_f622c628fd7f704e___ops__function__FnMut__wasm_bindgen_83f782f110bf2942___JsValue____Output_______: (a: number, b: number) => void;
2533
- readonly wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____: (a: number, b: number, c: any, d: any) => void;
2928
+ readonly wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue_____: (a: number, b: number, c: any) => void;
2929
+ readonly wasm_bindgen_e07ba2a7d21574bf___closure__destroy___dyn_core_a2b7f04d45112077___ops__function__FnMut__wasm_bindgen_e07ba2a7d21574bf___JsValue____Output_______: (a: number, b: number) => void;
2930
+ readonly wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue__wasm_bindgen_e07ba2a7d21574bf___JsValue_____: (a: number, b: number, c: any, d: any) => void;
2534
2931
  readonly __wbindgen_malloc: (a: number, b: number) => number;
2535
2932
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
2536
2933
  readonly __wbindgen_exn_store: (a: number) => void;
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,20 +222,6 @@ function makeMutClosure(arg0, arg1, dtor, f) {
208
222
  CLOSURE_DTORS.register(real, state, state);
209
223
  return real;
210
224
  }
211
-
212
- let cachedFloat64ArrayMemory0 = null;
213
-
214
- function getFloat64ArrayMemory0() {
215
- if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
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
225
  /**
226
226
  * Initialize the WASM module
227
227
  */
@@ -420,12 +420,12 @@ function passArray32ToWasm0(arg, malloc) {
420
420
  WASM_VECTOR_LEN = arg.length;
421
421
  return ptr;
422
422
  }
423
- function wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2) {
424
- wasm.wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2);
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);
425
425
  }
426
426
 
427
- function wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2, arg3) {
428
- wasm.wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(arg0, arg1, arg2, arg3);
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);
429
429
  }
430
430
 
431
431
  /**
@@ -1324,6 +1324,97 @@ export class InfoGeomUtils {
1324
1324
  }
1325
1325
  if (Symbol.dispose) InfoGeomUtils.prototype[Symbol.dispose] = InfoGeomUtils.prototype.free;
1326
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
+
1327
1418
  const MLOpsFinalization = (typeof FinalizationRegistry === 'undefined')
1328
1419
  ? { register: () => {}, unregister: () => {} }
1329
1420
  : new FinalizationRegistry(ptr => wasm.__wbg_mlops_free(ptr >>> 0, 1));
@@ -1474,6 +1565,165 @@ export class NetworkUtils {
1474
1565
  }
1475
1566
  if (Symbol.dispose) NetworkUtils.prototype[Symbol.dispose] = NetworkUtils.prototype.free;
1476
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
+
1477
1727
  const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
1478
1728
  ? { register: () => {}, unregister: () => {} }
1479
1729
  : new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
@@ -1556,6 +1806,358 @@ export class PerformanceOperations {
1556
1806
  }
1557
1807
  if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
1558
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
2129
+ */
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);
2151
+ const len0 = WASM_VECTOR_LEN;
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];
2157
+ }
2158
+ }
2159
+ if (Symbol.dispose) ScalarField.prototype[Symbol.dispose] = ScalarField.prototype.free;
2160
+
1559
2161
  const TropicalBatchFinalization = (typeof FinalizationRegistry === 'undefined')
1560
2162
  ? { register: () => {}, unregister: () => {} }
1561
2163
  : new FinalizationRegistry(ptr => wasm.__wbg_tropicalbatch_free(ptr >>> 0, 1));
@@ -1698,6 +2300,109 @@ export class TropicalMLOps {
1698
2300
  }
1699
2301
  if (Symbol.dispose) TropicalMLOps.prototype[Symbol.dispose] = TropicalMLOps.prototype.free;
1700
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
+
1701
2406
  const WasmAlphaConnectionFinalization = (typeof FinalizationRegistry === 'undefined')
1702
2407
  ? { register: () => {}, unregister: () => {} }
1703
2408
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmalphaconnection_free(ptr >>> 0, 1));
@@ -4198,7 +4903,7 @@ export class WasmOptimizationResult {
4198
4903
  * @returns {number}
4199
4904
  */
4200
4905
  get iterations() {
4201
- const ret = wasm.wasmoptimizationresult_iterations(this.__wbg_ptr);
4906
+ const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
4202
4907
  return ret >>> 0;
4203
4908
  }
4204
4909
  /**
@@ -4591,7 +5296,7 @@ export class WasmPropagationAnalysis {
4591
5296
  * @returns {number}
4592
5297
  */
4593
5298
  get convergenceTime() {
4594
- const ret = wasm.wasmoptimizationresult_iterations(this.__wbg_ptr);
5299
+ const ret = wasm.riemannianmanifold_dimension(this.__wbg_ptr);
4595
5300
  return ret >>> 0;
4596
5301
  }
4597
5302
  /**
@@ -6269,10 +6974,18 @@ function __wbg_get_imports() {
6269
6974
  const ret = arg0.apply(arg1, arg2);
6270
6975
  return ret;
6271
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) };
6272
6981
  imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
6273
6982
  const ret = arg0.call(arg1, arg2);
6274
6983
  return ret;
6275
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) };
6276
6989
  imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
6277
6990
  const ret = arg0.call(arg1);
6278
6991
  return ret;
@@ -6303,7 +7016,7 @@ function __wbg_get_imports() {
6303
7016
  imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) {
6304
7017
  console.log(arg0);
6305
7018
  };
6306
- imports.wbg.__wbg_log_b51718ac10a384d9 = function(arg0, arg1) {
7019
+ imports.wbg.__wbg_log_bf0922dbf69432a1 = function(arg0, arg1) {
6307
7020
  console.log(getStringFromWasm0(arg0, arg1));
6308
7021
  };
6309
7022
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
@@ -6317,7 +7030,7 @@ function __wbg_get_imports() {
6317
7030
  const a = state0.a;
6318
7031
  state0.a = 0;
6319
7032
  try {
6320
- return wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue__wasm_bindgen_83f782f110bf2942___JsValue_____(a, state0.b, arg0, arg1);
7033
+ return wasm_bindgen_e07ba2a7d21574bf___convert__closures_____invoke___wasm_bindgen_e07ba2a7d21574bf___JsValue__wasm_bindgen_e07ba2a7d21574bf___JsValue_____(a, state0.b, arg0, arg1);
6321
7034
  } finally {
6322
7035
  state0.a = a;
6323
7036
  }
@@ -6418,11 +7131,6 @@ function __wbg_get_imports() {
6418
7131
  const ret = BigInt.asUintN(64, arg0);
6419
7132
  return ret;
6420
7133
  };
6421
- imports.wbg.__wbindgen_cast_69f35aa0fcaecc47 = function(arg0, arg1) {
6422
- // Cast intrinsic for `Closure(Closure { dtor_idx: 37, function: Function { arguments: [Externref], shim_idx: 38, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
6423
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_83f782f110bf2942___closure__destroy___dyn_core_f622c628fd7f704e___ops__function__FnMut__wasm_bindgen_83f782f110bf2942___JsValue____Output_______, wasm_bindgen_83f782f110bf2942___convert__closures_____invoke___wasm_bindgen_83f782f110bf2942___JsValue_____);
6424
- return ret;
6425
- };
6426
7134
  imports.wbg.__wbindgen_cast_b63aeb0d85365734 = function(arg0, arg1) {
6427
7135
  var v0 = getArrayF64FromWasm0(arg0, arg1).slice();
6428
7136
  wasm.__wbindgen_free(arg0, arg1 * 8, 8);
@@ -6430,6 +7138,11 @@ function __wbg_get_imports() {
6430
7138
  const ret = v0;
6431
7139
  return ret;
6432
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
+ };
6433
7146
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
6434
7147
  // Cast intrinsic for `F64 -> Externref`.
6435
7148
  const ret = arg0;
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.10.0",
8
+ "version": "0.11.0",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",