@justinelliottcobb/amari-wasm 0.4.0 → 0.7.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
@@ -29,6 +29,7 @@ export class BatchOperations {
29
29
  [Symbol.dispose](): void;
30
30
  /**
31
31
  * Batch geometric product: compute a[i] * b[i] for all i
32
+ * Optimized for WebAssembly performance with reduced allocations
32
33
  */
33
34
  static batchGeometricProduct(a_batch: Float64Array, b_batch: Float64Array): Float64Array;
34
35
  /**
@@ -89,6 +90,30 @@ export class InfoGeomUtils {
89
90
  */
90
91
  static randomSimplex(dimension: number): Float64Array;
91
92
  }
93
+ /**
94
+ * High-performance WASM operations with memory pooling
95
+ */
96
+ export class PerformanceOperations {
97
+ private constructor();
98
+ free(): void;
99
+ [Symbol.dispose](): void;
100
+ /**
101
+ * Fast geometric product for hot paths with memory pooling
102
+ */
103
+ static fastGeometricProduct(lhs: Float64Array, rhs: Float64Array): Float64Array;
104
+ /**
105
+ * Optimized vector operations for 3D space
106
+ */
107
+ static vectorCrossProduct(v1: Float64Array, v2: Float64Array): Float64Array;
108
+ /**
109
+ * Optimized vector dot product
110
+ */
111
+ static vectorDotProduct(v1: Float64Array, v2: Float64Array): number;
112
+ /**
113
+ * Batch normalize vectors for efficiency
114
+ */
115
+ static batchNormalize(vectors: Float64Array, vector_size: number): Float64Array;
116
+ }
92
117
  /**
93
118
  * Batch operations for tropical numbers
94
119
  */
@@ -669,6 +694,10 @@ export interface InitOutput {
669
694
  readonly wasmrotor_fromBivector: (a: number, b: number) => number;
670
695
  readonly wasmrotor_apply: (a: number, b: number) => number;
671
696
  readonly wasmrotor_compose: (a: number, b: number) => number;
697
+ readonly performanceoperations_fastGeometricProduct: (a: number, b: number, c: number, d: number) => [number, number];
698
+ readonly performanceoperations_vectorCrossProduct: (a: number, b: number, c: number, d: number) => [number, number];
699
+ readonly performanceoperations_vectorDotProduct: (a: number, b: number, c: number, d: number) => number;
700
+ readonly performanceoperations_batchNormalize: (a: number, b: number, c: number) => [number, number];
672
701
  readonly init: () => void;
673
702
  readonly wasmtropicalnumber_new: (a: number) => number;
674
703
  readonly wasmmultivector_norm: (a: number) => number;
@@ -683,6 +712,7 @@ export interface InitOutput {
683
712
  readonly __wbg_wasmtropicalnumber_free: (a: number, b: number) => void;
684
713
  readonly __wbg_tropicalbatch_free: (a: number, b: number) => void;
685
714
  readonly __wbg_batchoperations_free: (a: number, b: number) => void;
715
+ readonly __wbg_performanceoperations_free: (a: number, b: number) => void;
686
716
  readonly wasmrotor_inverse: (a: number) => number;
687
717
  readonly __wbg_wasmrotor_free: (a: number, b: number) => void;
688
718
  readonly __wbindgen_exn_store: (a: number) => void;
package/amari_wasm.js CHANGED
@@ -168,6 +168,7 @@ export class BatchOperations {
168
168
  }
169
169
  /**
170
170
  * Batch geometric product: compute a[i] * b[i] for all i
171
+ * Optimized for WebAssembly performance with reduced allocations
171
172
  * @param {Float64Array} a_batch
172
173
  * @param {Float64Array} b_batch
173
174
  * @returns {Float64Array}
@@ -390,6 +391,88 @@ export class InfoGeomUtils {
390
391
  }
391
392
  if (Symbol.dispose) InfoGeomUtils.prototype[Symbol.dispose] = InfoGeomUtils.prototype.free;
392
393
 
394
+ const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
395
+ ? { register: () => {}, unregister: () => {} }
396
+ : new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
397
+ /**
398
+ * High-performance WASM operations with memory pooling
399
+ */
400
+ export class PerformanceOperations {
401
+
402
+ __destroy_into_raw() {
403
+ const ptr = this.__wbg_ptr;
404
+ this.__wbg_ptr = 0;
405
+ PerformanceOperationsFinalization.unregister(this);
406
+ return ptr;
407
+ }
408
+
409
+ free() {
410
+ const ptr = this.__destroy_into_raw();
411
+ wasm.__wbg_performanceoperations_free(ptr, 0);
412
+ }
413
+ /**
414
+ * Fast geometric product for hot paths with memory pooling
415
+ * @param {Float64Array} lhs
416
+ * @param {Float64Array} rhs
417
+ * @returns {Float64Array}
418
+ */
419
+ static fastGeometricProduct(lhs, rhs) {
420
+ const ptr0 = passArrayF64ToWasm0(lhs, wasm.__wbindgen_malloc);
421
+ const len0 = WASM_VECTOR_LEN;
422
+ const ptr1 = passArrayF64ToWasm0(rhs, wasm.__wbindgen_malloc);
423
+ const len1 = WASM_VECTOR_LEN;
424
+ const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
425
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
426
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
427
+ return v3;
428
+ }
429
+ /**
430
+ * Optimized vector operations for 3D space
431
+ * @param {Float64Array} v1
432
+ * @param {Float64Array} v2
433
+ * @returns {Float64Array}
434
+ */
435
+ static vectorCrossProduct(v1, v2) {
436
+ const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
437
+ const len0 = WASM_VECTOR_LEN;
438
+ const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
439
+ const len1 = WASM_VECTOR_LEN;
440
+ const ret = wasm.performanceoperations_vectorCrossProduct(ptr0, len0, ptr1, len1);
441
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
442
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
443
+ return v3;
444
+ }
445
+ /**
446
+ * Optimized vector dot product
447
+ * @param {Float64Array} v1
448
+ * @param {Float64Array} v2
449
+ * @returns {number}
450
+ */
451
+ static vectorDotProduct(v1, v2) {
452
+ const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
453
+ const len0 = WASM_VECTOR_LEN;
454
+ const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
455
+ const len1 = WASM_VECTOR_LEN;
456
+ const ret = wasm.performanceoperations_vectorDotProduct(ptr0, len0, ptr1, len1);
457
+ return ret;
458
+ }
459
+ /**
460
+ * Batch normalize vectors for efficiency
461
+ * @param {Float64Array} vectors
462
+ * @param {number} vector_size
463
+ * @returns {Float64Array}
464
+ */
465
+ static batchNormalize(vectors, vector_size) {
466
+ const ptr0 = passArrayF64ToWasm0(vectors, wasm.__wbindgen_malloc);
467
+ const len0 = WASM_VECTOR_LEN;
468
+ const ret = wasm.performanceoperations_batchNormalize(ptr0, len0, vector_size);
469
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
470
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
471
+ return v2;
472
+ }
473
+ }
474
+ if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
475
+
393
476
  const TropicalBatchFinalization = (typeof FinalizationRegistry === 'undefined')
394
477
  ? { register: () => {}, unregister: () => {} }
395
478
  : new FinalizationRegistry(ptr => wasm.__wbg_tropicalbatch_free(ptr >>> 0, 1));
@@ -1697,7 +1780,7 @@ function __wbg_get_imports() {
1697
1780
  const ret = arg0.apply(arg1, arg2);
1698
1781
  return ret;
1699
1782
  }, arguments) };
1700
- imports.wbg.__wbg_log_7d5bd3f05c55b7ed = function(arg0, arg1) {
1783
+ imports.wbg.__wbg_log_2855aa4ea73e1eff = function(arg0, arg1) {
1701
1784
  console.log(getStringFromWasm0(arg0, arg1));
1702
1785
  };
1703
1786
  imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
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, fusion systems, and information geometry",
8
- "version": "0.4.0",
8
+ "version": "0.7.0",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",