@justinelliottcobb/amari-wasm 0.9.1 → 0.9.3

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.js CHANGED
@@ -1,5 +1,20 @@
1
1
  let wasm;
2
2
 
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function handleError(f, args) {
10
+ try {
11
+ return f.apply(this, args);
12
+ } catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
+ }
17
+
3
18
  let cachedUint8ArrayMemory0 = null;
4
19
 
5
20
  function getUint8ArrayMemory0() {
@@ -30,6 +45,195 @@ function getStringFromWasm0(ptr, len) {
30
45
  return decodeText(ptr, len);
31
46
  }
32
47
 
48
+ function debugString(val) {
49
+ // primitive types
50
+ const type = typeof val;
51
+ if (type == 'number' || type == 'boolean' || val == null) {
52
+ return `${val}`;
53
+ }
54
+ if (type == 'string') {
55
+ return `"${val}"`;
56
+ }
57
+ if (type == 'symbol') {
58
+ const description = val.description;
59
+ if (description == null) {
60
+ return 'Symbol';
61
+ } else {
62
+ return `Symbol(${description})`;
63
+ }
64
+ }
65
+ if (type == 'function') {
66
+ const name = val.name;
67
+ if (typeof name == 'string' && name.length > 0) {
68
+ return `Function(${name})`;
69
+ } else {
70
+ return 'Function';
71
+ }
72
+ }
73
+ // objects
74
+ if (Array.isArray(val)) {
75
+ const length = val.length;
76
+ let debug = '[';
77
+ if (length > 0) {
78
+ debug += debugString(val[0]);
79
+ }
80
+ for(let i = 1; i < length; i++) {
81
+ debug += ', ' + debugString(val[i]);
82
+ }
83
+ debug += ']';
84
+ return debug;
85
+ }
86
+ // Test for built-in
87
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
88
+ let className;
89
+ if (builtInMatches && builtInMatches.length > 1) {
90
+ className = builtInMatches[1];
91
+ } else {
92
+ // Failed to match the standard '[object ClassName]'
93
+ return toString.call(val);
94
+ }
95
+ if (className == 'Object') {
96
+ // we're a user defined class or Object
97
+ // JSON.stringify avoids problems with cycles, and is generally much
98
+ // easier than looping through ownProperties of `val`.
99
+ try {
100
+ return 'Object(' + JSON.stringify(val) + ')';
101
+ } catch (_) {
102
+ return 'Object';
103
+ }
104
+ }
105
+ // errors
106
+ if (val instanceof Error) {
107
+ return `${val.name}: ${val.message}\n${val.stack}`;
108
+ }
109
+ // TODO we could test for more things here, like `Set`s and `Map`s.
110
+ return className;
111
+ }
112
+
113
+ let WASM_VECTOR_LEN = 0;
114
+
115
+ const cachedTextEncoder = new TextEncoder();
116
+
117
+ if (!('encodeInto' in cachedTextEncoder)) {
118
+ cachedTextEncoder.encodeInto = function (arg, view) {
119
+ const buf = cachedTextEncoder.encode(arg);
120
+ view.set(buf);
121
+ return {
122
+ read: arg.length,
123
+ written: buf.length
124
+ };
125
+ }
126
+ }
127
+
128
+ function passStringToWasm0(arg, malloc, realloc) {
129
+
130
+ if (realloc === undefined) {
131
+ const buf = cachedTextEncoder.encode(arg);
132
+ const ptr = malloc(buf.length, 1) >>> 0;
133
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
134
+ WASM_VECTOR_LEN = buf.length;
135
+ return ptr;
136
+ }
137
+
138
+ let len = arg.length;
139
+ let ptr = malloc(len, 1) >>> 0;
140
+
141
+ const mem = getUint8ArrayMemory0();
142
+
143
+ let offset = 0;
144
+
145
+ for (; offset < len; offset++) {
146
+ const code = arg.charCodeAt(offset);
147
+ if (code > 0x7F) break;
148
+ mem[ptr + offset] = code;
149
+ }
150
+
151
+ if (offset !== len) {
152
+ if (offset !== 0) {
153
+ arg = arg.slice(offset);
154
+ }
155
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
156
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
157
+ const ret = cachedTextEncoder.encodeInto(arg, view);
158
+
159
+ offset += ret.written;
160
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
161
+ }
162
+
163
+ WASM_VECTOR_LEN = offset;
164
+ return ptr;
165
+ }
166
+
167
+ let cachedDataViewMemory0 = null;
168
+
169
+ function getDataViewMemory0() {
170
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
171
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
172
+ }
173
+ return cachedDataViewMemory0;
174
+ }
175
+
176
+ function isLikeNone(x) {
177
+ return x === undefined || x === null;
178
+ }
179
+
180
+ function takeFromExternrefTable0(idx) {
181
+ const value = wasm.__wbindgen_export_2.get(idx);
182
+ wasm.__externref_table_dealloc(idx);
183
+ return value;
184
+ }
185
+
186
+ function _assertClass(instance, klass) {
187
+ if (!(instance instanceof klass)) {
188
+ throw new Error(`expected instance of ${klass.name}`);
189
+ }
190
+ }
191
+ /**
192
+ * Convert velocity to Lorentz factor
193
+ * @param {number} velocity_magnitude
194
+ * @returns {number}
195
+ */
196
+ export function velocity_to_gamma(velocity_magnitude) {
197
+ const ret = wasm.velocity_to_gamma(velocity_magnitude);
198
+ if (ret[2]) {
199
+ throw takeFromExternrefTable0(ret[1]);
200
+ }
201
+ return ret[0];
202
+ }
203
+
204
+ /**
205
+ * Convert Lorentz factor to velocity
206
+ * @param {number} gamma
207
+ * @returns {number}
208
+ */
209
+ export function gamma_to_velocity(gamma) {
210
+ const ret = wasm.gamma_to_velocity(gamma);
211
+ if (ret[2]) {
212
+ throw takeFromExternrefTable0(ret[1]);
213
+ }
214
+ return ret[0];
215
+ }
216
+
217
+ /**
218
+ * Calculate light deflection angle for photon grazing massive object
219
+ * @param {number} impact_parameter
220
+ * @param {number} mass
221
+ * @returns {number}
222
+ */
223
+ export function light_deflection_angle(impact_parameter, mass) {
224
+ const ret = wasm.light_deflection_angle(impact_parameter, mass);
225
+ return ret;
226
+ }
227
+
228
+ /**
229
+ * Validate that this module loaded correctly
230
+ * @returns {boolean}
231
+ */
232
+ export function validate_relativistic_module() {
233
+ const ret = wasm.validate_relativistic_module();
234
+ return ret !== 0;
235
+ }
236
+
33
237
  let cachedFloat64ArrayMemory0 = null;
34
238
 
35
239
  function getFloat64ArrayMemory0() {
@@ -39,8 +243,6 @@ function getFloat64ArrayMemory0() {
39
243
  return cachedFloat64ArrayMemory0;
40
244
  }
41
245
 
42
- let WASM_VECTOR_LEN = 0;
43
-
44
246
  function passArrayF64ToWasm0(arg, malloc) {
45
247
  const ptr = malloc(arg.length * 8, 8) >>> 0;
46
248
  getFloat64ArrayMemory0().set(arg, ptr / 8);
@@ -48,22 +250,10 @@ function passArrayF64ToWasm0(arg, malloc) {
48
250
  return ptr;
49
251
  }
50
252
 
51
- function takeFromExternrefTable0(idx) {
52
- const value = wasm.__wbindgen_export_0.get(idx);
53
- wasm.__externref_table_dealloc(idx);
54
- return value;
55
- }
56
-
57
253
  function getArrayF64FromWasm0(ptr, len) {
58
254
  ptr = ptr >>> 0;
59
255
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
60
256
  }
61
-
62
- function _assertClass(instance, klass) {
63
- if (!(instance instanceof klass)) {
64
- throw new Error(`expected instance of ${klass.name}`);
65
- }
66
- }
67
257
  /**
68
258
  * Initialize the WASM module
69
259
  */
@@ -71,6 +261,116 @@ export function init() {
71
261
  wasm.init();
72
262
  }
73
263
 
264
+ let cachedUint32ArrayMemory0 = null;
265
+
266
+ function getUint32ArrayMemory0() {
267
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
268
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
269
+ }
270
+ return cachedUint32ArrayMemory0;
271
+ }
272
+
273
+ function getArrayU32FromWasm0(ptr, len) {
274
+ ptr = ptr >>> 0;
275
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
276
+ }
277
+
278
+ function passArray32ToWasm0(arg, malloc) {
279
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
280
+ getUint32ArrayMemory0().set(arg, ptr / 4);
281
+ WASM_VECTOR_LEN = arg.length;
282
+ return ptr;
283
+ }
284
+
285
+ const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
286
+ ? { register: () => {}, unregister: () => {} }
287
+ : new FinalizationRegistry(ptr => wasm.__wbg_autodiff_free(ptr >>> 0, 1));
288
+ /**
289
+ * Automatic differentiation utilities
290
+ */
291
+ export class AutoDiff {
292
+
293
+ __destroy_into_raw() {
294
+ const ptr = this.__wbg_ptr;
295
+ this.__wbg_ptr = 0;
296
+ AutoDiffFinalization.unregister(this);
297
+ return ptr;
298
+ }
299
+
300
+ free() {
301
+ const ptr = this.__destroy_into_raw();
302
+ wasm.__wbg_autodiff_free(ptr, 0);
303
+ }
304
+ /**
305
+ * Linear layer forward pass (y = Wx + b) with automatic gradients
306
+ * @param {Float64Array} inputs
307
+ * @param {Float64Array} weights
308
+ * @param {Float64Array} bias
309
+ * @param {number} input_size
310
+ * @param {number} output_size
311
+ * @returns {Float64Array}
312
+ */
313
+ static linearLayer(inputs, weights, bias, input_size, output_size) {
314
+ const ptr0 = passArrayF64ToWasm0(inputs, wasm.__wbindgen_malloc);
315
+ const len0 = WASM_VECTOR_LEN;
316
+ const ptr1 = passArrayF64ToWasm0(weights, wasm.__wbindgen_malloc);
317
+ const len1 = WASM_VECTOR_LEN;
318
+ const ptr2 = passArrayF64ToWasm0(bias, wasm.__wbindgen_malloc);
319
+ const len2 = WASM_VECTOR_LEN;
320
+ const ret = wasm.autodiff_linearLayer(ptr0, len0, ptr1, len1, ptr2, len2, input_size, output_size);
321
+ if (ret[3]) {
322
+ throw takeFromExternrefTable0(ret[2]);
323
+ }
324
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
325
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
326
+ return v4;
327
+ }
328
+ /**
329
+ * Compute mean squared error with automatic gradients
330
+ * @param {Float64Array} predictions
331
+ * @param {Float64Array} targets
332
+ * @returns {WasmDualNumber}
333
+ */
334
+ static meanSquaredError(predictions, targets) {
335
+ const ptr0 = passArrayF64ToWasm0(predictions, wasm.__wbindgen_malloc);
336
+ const len0 = WASM_VECTOR_LEN;
337
+ const ptr1 = passArrayF64ToWasm0(targets, wasm.__wbindgen_malloc);
338
+ const len1 = WASM_VECTOR_LEN;
339
+ const ret = wasm.autodiff_meanSquaredError(ptr0, len0, ptr1, len1);
340
+ if (ret[2]) {
341
+ throw takeFromExternrefTable0(ret[1]);
342
+ }
343
+ return WasmDualNumber.__wrap(ret[0]);
344
+ }
345
+ /**
346
+ * Create a dual number and evaluate a polynomial
347
+ * @param {number} x
348
+ * @param {Float64Array} coefficients
349
+ * @returns {WasmDualNumber}
350
+ */
351
+ static evaluatePolynomial(x, coefficients) {
352
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
353
+ const len0 = WASM_VECTOR_LEN;
354
+ const ret = wasm.autodiff_evaluatePolynomial(x, ptr0, len0);
355
+ return WasmDualNumber.__wrap(ret);
356
+ }
357
+ /**
358
+ * Compute numerical derivative using finite differences (fallback implementation)
359
+ * @param {number} x
360
+ * @param {Function} f
361
+ * @param {number} h
362
+ * @returns {number}
363
+ */
364
+ static numericalDerivative(x, f, h) {
365
+ const ret = wasm.autodiff_numericalDerivative(x, f, h);
366
+ if (ret[2]) {
367
+ throw takeFromExternrefTable0(ret[1]);
368
+ }
369
+ return ret[0];
370
+ }
371
+ }
372
+ if (Symbol.dispose) AutoDiff.prototype[Symbol.dispose] = AutoDiff.prototype.free;
373
+
74
374
  const BatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
75
375
  ? { register: () => {}, unregister: () => {} }
76
376
  : new FinalizationRegistry(ptr => wasm.__wbg_batchoperations_free(ptr >>> 0, 1));
@@ -132,389 +432,2312 @@ export class BatchOperations {
132
432
  }
133
433
  if (Symbol.dispose) BatchOperations.prototype[Symbol.dispose] = BatchOperations.prototype.free;
134
434
 
135
- const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
435
+ const BatchOpsFinalization = (typeof FinalizationRegistry === 'undefined')
136
436
  ? { register: () => {}, unregister: () => {} }
137
- : new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
437
+ : new FinalizationRegistry(ptr => wasm.__wbg_batchops_free(ptr >>> 0, 1));
138
438
  /**
139
- * High-performance WASM operations with memory pooling
439
+ * Batch operations for efficient computation
140
440
  */
141
- export class PerformanceOperations {
441
+ export class BatchOps {
142
442
 
143
443
  __destroy_into_raw() {
144
444
  const ptr = this.__wbg_ptr;
145
445
  this.__wbg_ptr = 0;
146
- PerformanceOperationsFinalization.unregister(this);
446
+ BatchOpsFinalization.unregister(this);
147
447
  return ptr;
148
448
  }
149
449
 
150
450
  free() {
151
451
  const ptr = this.__destroy_into_raw();
152
- wasm.__wbg_performanceoperations_free(ptr, 0);
452
+ wasm.__wbg_batchops_free(ptr, 0);
153
453
  }
154
454
  /**
155
- * Batch normalize vectors for efficiency
156
- * @param {Float64Array} vectors
157
- * @param {number} vector_size
455
+ * Matrix multiplication with automatic gradients
456
+ * @param {Float64Array} a
457
+ * @param {Float64Array} b
458
+ * @param {number} a_rows
459
+ * @param {number} a_cols
460
+ * @param {number} b_rows
461
+ * @param {number} b_cols
158
462
  * @returns {Float64Array}
159
463
  */
160
- static batchNormalize(vectors, vector_size) {
161
- const ptr0 = passArrayF64ToWasm0(vectors, wasm.__wbindgen_malloc);
162
- const len0 = WASM_VECTOR_LEN;
163
- const ret = wasm.performanceoperations_batchNormalize(ptr0, len0, vector_size);
164
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
165
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
166
- return v2;
167
- }
168
- /**
169
- * Optimized vector dot product
170
- * @param {Float64Array} v1
171
- * @param {Float64Array} v2
172
- * @returns {number}
173
- */
174
- static vectorDotProduct(v1, v2) {
175
- const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
464
+ static matrixMultiply(a, b, a_rows, a_cols, b_rows, b_cols) {
465
+ const ptr0 = passArrayF64ToWasm0(a, wasm.__wbindgen_malloc);
176
466
  const len0 = WASM_VECTOR_LEN;
177
- const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
467
+ const ptr1 = passArrayF64ToWasm0(b, wasm.__wbindgen_malloc);
178
468
  const len1 = WASM_VECTOR_LEN;
179
- const ret = wasm.performanceoperations_vectorDotProduct(ptr0, len0, ptr1, len1);
180
- return ret;
469
+ const ret = wasm.batchops_matrixMultiply(ptr0, len0, ptr1, len1, a_rows, a_cols, b_rows, b_cols);
470
+ if (ret[3]) {
471
+ throw takeFromExternrefTable0(ret[2]);
472
+ }
473
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
474
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
475
+ return v3;
181
476
  }
182
477
  /**
183
- * Optimized vector operations for 3D space
184
- * @param {Float64Array} v1
185
- * @param {Float64Array} v2
478
+ * Batch evaluate polynomial with derivatives
479
+ * @param {Float64Array} x_values
480
+ * @param {Float64Array} coefficients
186
481
  * @returns {Float64Array}
187
482
  */
188
- static vectorCrossProduct(v1, v2) {
189
- const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
483
+ static batchPolynomial(x_values, coefficients) {
484
+ const ptr0 = passArrayF64ToWasm0(x_values, wasm.__wbindgen_malloc);
190
485
  const len0 = WASM_VECTOR_LEN;
191
- const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
486
+ const ptr1 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
192
487
  const len1 = WASM_VECTOR_LEN;
193
- const ret = wasm.performanceoperations_vectorCrossProduct(ptr0, len0, ptr1, len1);
488
+ const ret = wasm.batchops_batchPolynomial(ptr0, len0, ptr1, len1);
489
+ if (ret[3]) {
490
+ throw takeFromExternrefTable0(ret[2]);
491
+ }
194
492
  var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
195
493
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
196
494
  return v3;
197
495
  }
198
496
  /**
199
- * Fast geometric product for hot paths with memory pooling
200
- * @param {Float64Array} lhs
201
- * @param {Float64Array} rhs
497
+ * Compute Jacobian matrix for vector function
498
+ * @param {Float64Array} input_values
499
+ * @param {string} function_name
202
500
  * @returns {Float64Array}
203
501
  */
204
- static fastGeometricProduct(lhs, rhs) {
205
- const ptr0 = passArrayF64ToWasm0(lhs, wasm.__wbindgen_malloc);
502
+ static computeJacobian(input_values, function_name) {
503
+ const ptr0 = passArrayF64ToWasm0(input_values, wasm.__wbindgen_malloc);
206
504
  const len0 = WASM_VECTOR_LEN;
207
- const ptr1 = passArrayF64ToWasm0(rhs, wasm.__wbindgen_malloc);
505
+ const ptr1 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
208
506
  const len1 = WASM_VECTOR_LEN;
209
- const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
507
+ const ret = wasm.batchops_computeJacobian(ptr0, len0, ptr1, len1);
508
+ if (ret[3]) {
509
+ throw takeFromExternrefTable0(ret[2]);
510
+ }
210
511
  var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
211
512
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
212
513
  return v3;
213
514
  }
214
515
  }
215
- if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
516
+ if (Symbol.dispose) BatchOps.prototype[Symbol.dispose] = BatchOps.prototype.free;
216
517
 
217
- const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
518
+ const MLOpsFinalization = (typeof FinalizationRegistry === 'undefined')
218
519
  ? { register: () => {}, unregister: () => {} }
219
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
520
+ : new FinalizationRegistry(ptr => wasm.__wbg_mlops_free(ptr >>> 0, 1));
220
521
  /**
221
- * WASM wrapper for Multivector with TypedArray support
522
+ * Advanced machine learning operations using dual numbers
222
523
  */
223
- export class WasmMultivector {
224
-
225
- static __wrap(ptr) {
226
- ptr = ptr >>> 0;
227
- const obj = Object.create(WasmMultivector.prototype);
228
- obj.__wbg_ptr = ptr;
229
- WasmMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
230
- return obj;
231
- }
524
+ export class MLOps {
232
525
 
233
526
  __destroy_into_raw() {
234
527
  const ptr = this.__wbg_ptr;
235
528
  this.__wbg_ptr = 0;
236
- WasmMultivectorFinalization.unregister(this);
529
+ MLOpsFinalization.unregister(this);
237
530
  return ptr;
238
531
  }
239
532
 
240
533
  free() {
241
534
  const ptr = this.__destroy_into_raw();
242
- wasm.__wbg_wasmmultivector_free(ptr, 0);
535
+ wasm.__wbg_mlops_free(ptr, 0);
243
536
  }
244
537
  /**
245
- * Create a basis vector (0-indexed)
246
- * @param {number} index
247
- * @returns {WasmMultivector}
538
+ * Batch apply activation function with gradients
539
+ * @param {Float64Array} inputs
540
+ * @param {string} activation
541
+ * @returns {Float64Array}
248
542
  */
249
- static basisVector(index) {
250
- const ret = wasm.wasmmultivector_basisVector(index);
543
+ static batchActivation(inputs, activation) {
544
+ const ptr0 = passArrayF64ToWasm0(inputs, wasm.__wbindgen_malloc);
545
+ const len0 = WASM_VECTOR_LEN;
546
+ const ptr1 = passStringToWasm0(activation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
547
+ const len1 = WASM_VECTOR_LEN;
548
+ const ret = wasm.mlops_batchActivation(ptr0, len0, ptr1, len1);
549
+ if (ret[3]) {
550
+ throw takeFromExternrefTable0(ret[2]);
551
+ }
552
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
553
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
554
+ return v3;
555
+ }
556
+ /**
557
+ * Compute cross-entropy loss with automatic gradients
558
+ * @param {Float64Array} predictions
559
+ * @param {Float64Array} targets
560
+ * @returns {WasmDualNumber}
561
+ */
562
+ static crossEntropyLoss(predictions, targets) {
563
+ const ptr0 = passArrayF64ToWasm0(predictions, wasm.__wbindgen_malloc);
564
+ const len0 = WASM_VECTOR_LEN;
565
+ const ptr1 = passArrayF64ToWasm0(targets, wasm.__wbindgen_malloc);
566
+ const len1 = WASM_VECTOR_LEN;
567
+ const ret = wasm.mlops_crossEntropyLoss(ptr0, len0, ptr1, len1);
251
568
  if (ret[2]) {
252
569
  throw takeFromExternrefTable0(ret[1]);
253
570
  }
254
- return WasmMultivector.__wrap(ret[0]);
571
+ return WasmDualNumber.__wrap(ret[0]);
255
572
  }
256
573
  /**
257
- * Inner product (dot product for vectors)
258
- * @param {WasmMultivector} other
259
- * @returns {WasmMultivector}
574
+ * Gradient descent step
575
+ * @param {Float64Array} parameters
576
+ * @param {Float64Array} gradients
577
+ * @param {number} learning_rate
578
+ * @returns {Float64Array}
260
579
  */
261
- innerProduct(other) {
262
- _assertClass(other, WasmMultivector);
263
- const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
264
- return WasmMultivector.__wrap(ret);
580
+ static gradientDescentStep(parameters, gradients, learning_rate) {
581
+ const ptr0 = passArrayF64ToWasm0(parameters, wasm.__wbindgen_malloc);
582
+ const len0 = WASM_VECTOR_LEN;
583
+ const ptr1 = passArrayF64ToWasm0(gradients, wasm.__wbindgen_malloc);
584
+ const len1 = WASM_VECTOR_LEN;
585
+ const ret = wasm.mlops_gradientDescentStep(ptr0, len0, ptr1, len1, learning_rate);
586
+ if (ret[3]) {
587
+ throw takeFromExternrefTable0(ret[2]);
588
+ }
589
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
590
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
591
+ return v3;
265
592
  }
266
593
  /**
267
- * Outer product (wedge product)
594
+ * Compute softmax with automatic gradients
595
+ * @param {Float64Array} inputs
596
+ * @returns {Float64Array}
597
+ */
598
+ static softmax(inputs) {
599
+ const ptr0 = passArrayF64ToWasm0(inputs, wasm.__wbindgen_malloc);
600
+ const len0 = WASM_VECTOR_LEN;
601
+ const ret = wasm.mlops_softmax(ptr0, len0);
602
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
603
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
604
+ return v2;
605
+ }
606
+ }
607
+ if (Symbol.dispose) MLOps.prototype[Symbol.dispose] = MLOps.prototype.free;
608
+
609
+ const NetworkBatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
610
+ ? { register: () => {}, unregister: () => {} }
611
+ : new FinalizationRegistry(ptr => wasm.__wbg_networkbatchoperations_free(ptr >>> 0, 1));
612
+ /**
613
+ * Batch network operations for performance
614
+ */
615
+ export class NetworkBatchOperations {
616
+
617
+ __destroy_into_raw() {
618
+ const ptr = this.__wbg_ptr;
619
+ this.__wbg_ptr = 0;
620
+ NetworkBatchOperationsFinalization.unregister(this);
621
+ return ptr;
622
+ }
623
+
624
+ free() {
625
+ const ptr = this.__destroy_into_raw();
626
+ wasm.__wbg_networkbatchoperations_free(ptr, 0);
627
+ }
628
+ /**
629
+ * Fast geometric clustering using k-means in 3D space
630
+ * @param {Float64Array} positions
631
+ * @param {number} num_nodes
632
+ * @param {number} k
633
+ * @param {number} max_iterations
634
+ * @returns {Uint32Array}
635
+ */
636
+ static geometricKMeansClustering(positions, num_nodes, k, max_iterations) {
637
+ const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
638
+ const len0 = WASM_VECTOR_LEN;
639
+ const ret = wasm.networkbatchoperations_geometricKMeansClustering(ptr0, len0, num_nodes, k, max_iterations);
640
+ if (ret[3]) {
641
+ throw takeFromExternrefTable0(ret[2]);
642
+ }
643
+ var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
644
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
645
+ return v2;
646
+ }
647
+ /**
648
+ * Compute all pairwise distances in a network
649
+ * @param {Float64Array} positions
650
+ * @param {number} num_nodes
651
+ * @returns {Float64Array}
652
+ */
653
+ static computeAllPairwiseDistances(positions, num_nodes) {
654
+ const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
655
+ const len0 = WASM_VECTOR_LEN;
656
+ const ret = wasm.networkbatchoperations_computeAllPairwiseDistances(ptr0, len0, num_nodes);
657
+ if (ret[3]) {
658
+ throw takeFromExternrefTable0(ret[2]);
659
+ }
660
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
661
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
662
+ return v2;
663
+ }
664
+ }
665
+ if (Symbol.dispose) NetworkBatchOperations.prototype[Symbol.dispose] = NetworkBatchOperations.prototype.free;
666
+
667
+ const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
668
+ ? { register: () => {}, unregister: () => {} }
669
+ : new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
670
+ /**
671
+ * High-performance WASM operations with memory pooling
672
+ */
673
+ export class PerformanceOperations {
674
+
675
+ __destroy_into_raw() {
676
+ const ptr = this.__wbg_ptr;
677
+ this.__wbg_ptr = 0;
678
+ PerformanceOperationsFinalization.unregister(this);
679
+ return ptr;
680
+ }
681
+
682
+ free() {
683
+ const ptr = this.__destroy_into_raw();
684
+ wasm.__wbg_performanceoperations_free(ptr, 0);
685
+ }
686
+ /**
687
+ * Batch normalize vectors for efficiency
688
+ * @param {Float64Array} vectors
689
+ * @param {number} vector_size
690
+ * @returns {Float64Array}
691
+ */
692
+ static batchNormalize(vectors, vector_size) {
693
+ const ptr0 = passArrayF64ToWasm0(vectors, wasm.__wbindgen_malloc);
694
+ const len0 = WASM_VECTOR_LEN;
695
+ const ret = wasm.performanceoperations_batchNormalize(ptr0, len0, vector_size);
696
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
697
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
698
+ return v2;
699
+ }
700
+ /**
701
+ * Optimized vector dot product
702
+ * @param {Float64Array} v1
703
+ * @param {Float64Array} v2
704
+ * @returns {number}
705
+ */
706
+ static vectorDotProduct(v1, v2) {
707
+ const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
708
+ const len0 = WASM_VECTOR_LEN;
709
+ const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
710
+ const len1 = WASM_VECTOR_LEN;
711
+ const ret = wasm.performanceoperations_vectorDotProduct(ptr0, len0, ptr1, len1);
712
+ return ret;
713
+ }
714
+ /**
715
+ * Optimized vector operations for 3D space
716
+ * @param {Float64Array} v1
717
+ * @param {Float64Array} v2
718
+ * @returns {Float64Array}
719
+ */
720
+ static vectorCrossProduct(v1, v2) {
721
+ const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
722
+ const len0 = WASM_VECTOR_LEN;
723
+ const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
724
+ const len1 = WASM_VECTOR_LEN;
725
+ const ret = wasm.performanceoperations_vectorCrossProduct(ptr0, len0, ptr1, len1);
726
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
727
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
728
+ return v3;
729
+ }
730
+ /**
731
+ * Fast geometric product for hot paths with memory pooling
732
+ * @param {Float64Array} lhs
733
+ * @param {Float64Array} rhs
734
+ * @returns {Float64Array}
735
+ */
736
+ static fastGeometricProduct(lhs, rhs) {
737
+ const ptr0 = passArrayF64ToWasm0(lhs, wasm.__wbindgen_malloc);
738
+ const len0 = WASM_VECTOR_LEN;
739
+ const ptr1 = passArrayF64ToWasm0(rhs, wasm.__wbindgen_malloc);
740
+ const len1 = WASM_VECTOR_LEN;
741
+ const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
742
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
743
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
744
+ return v3;
745
+ }
746
+ }
747
+ if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
748
+
749
+ const TropicalBatchFinalization = (typeof FinalizationRegistry === 'undefined')
750
+ ? { register: () => {}, unregister: () => {} }
751
+ : new FinalizationRegistry(ptr => wasm.__wbg_tropicalbatch_free(ptr >>> 0, 1));
752
+ /**
753
+ * Batch operations for tropical numbers
754
+ */
755
+ export class TropicalBatch {
756
+
757
+ __destroy_into_raw() {
758
+ const ptr = this.__wbg_ptr;
759
+ this.__wbg_ptr = 0;
760
+ TropicalBatchFinalization.unregister(this);
761
+ return ptr;
762
+ }
763
+
764
+ free() {
765
+ const ptr = this.__destroy_into_raw();
766
+ wasm.__wbg_tropicalbatch_free(ptr, 0);
767
+ }
768
+ /**
769
+ * Convert array of log probabilities to tropical numbers and find maximum
770
+ * @param {Float64Array} log_probs
771
+ * @returns {number}
772
+ */
773
+ static maxLogProb(log_probs) {
774
+ const ptr0 = passArrayF64ToWasm0(log_probs, wasm.__wbindgen_malloc);
775
+ const len0 = WASM_VECTOR_LEN;
776
+ const ret = wasm.tropicalbatch_maxLogProb(ptr0, len0);
777
+ return ret;
778
+ }
779
+ /**
780
+ * Viterbi algorithm helper: find best path through trellis
781
+ * @param {Float64Array} prev_scores
782
+ * @param {Float64Array} transition_scores
783
+ * @param {Float64Array} emission_scores
784
+ * @param {number} num_states
785
+ * @returns {Float64Array}
786
+ */
787
+ static viterbiStep(prev_scores, transition_scores, emission_scores, num_states) {
788
+ const ptr0 = passArrayF64ToWasm0(prev_scores, wasm.__wbindgen_malloc);
789
+ const len0 = WASM_VECTOR_LEN;
790
+ const ptr1 = passArrayF64ToWasm0(transition_scores, wasm.__wbindgen_malloc);
791
+ const len1 = WASM_VECTOR_LEN;
792
+ const ptr2 = passArrayF64ToWasm0(emission_scores, wasm.__wbindgen_malloc);
793
+ const len2 = WASM_VECTOR_LEN;
794
+ const ret = wasm.tropicalbatch_viterbiStep(ptr0, len0, ptr1, len1, ptr2, len2, num_states);
795
+ if (ret[3]) {
796
+ throw takeFromExternrefTable0(ret[2]);
797
+ }
798
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
799
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
800
+ return v4;
801
+ }
802
+ /**
803
+ * Batch tropical addition (max operation)
804
+ * @param {Float64Array} values
805
+ * @returns {number}
806
+ */
807
+ static batchTropicalAdd(values) {
808
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
809
+ const len0 = WASM_VECTOR_LEN;
810
+ const ret = wasm.tropicalbatch_batchTropicalAdd(ptr0, len0);
811
+ return ret;
812
+ }
813
+ /**
814
+ * Batch tropical multiplication (addition)
815
+ * @param {Float64Array} values
816
+ * @returns {number}
817
+ */
818
+ static batchTropicalMul(values) {
819
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
820
+ const len0 = WASM_VECTOR_LEN;
821
+ const ret = wasm.tropicalbatch_batchTropicalMul(ptr0, len0);
822
+ return ret;
823
+ }
824
+ }
825
+ if (Symbol.dispose) TropicalBatch.prototype[Symbol.dispose] = TropicalBatch.prototype.free;
826
+
827
+ const TropicalMLOpsFinalization = (typeof FinalizationRegistry === 'undefined')
828
+ ? { register: () => {}, unregister: () => {} }
829
+ : new FinalizationRegistry(ptr => wasm.__wbg_tropicalmlops_free(ptr >>> 0, 1));
830
+ /**
831
+ * Advanced tropical operations for machine learning and optimization
832
+ */
833
+ export class TropicalMLOps {
834
+
835
+ __destroy_into_raw() {
836
+ const ptr = this.__wbg_ptr;
837
+ this.__wbg_ptr = 0;
838
+ TropicalMLOpsFinalization.unregister(this);
839
+ return ptr;
840
+ }
841
+
842
+ free() {
843
+ const ptr = this.__destroy_into_raw();
844
+ wasm.__wbg_tropicalmlops_free(ptr, 0);
845
+ }
846
+ /**
847
+ * Compute shortest paths using tropical algebra (Floyd-Warshall)
848
+ * @param {any} distance_matrix
849
+ * @returns {Array<any>}
850
+ */
851
+ static shortestPaths(distance_matrix) {
852
+ const ret = wasm.tropicalmlops_shortestPaths(distance_matrix);
853
+ if (ret[2]) {
854
+ throw takeFromExternrefTable0(ret[1]);
855
+ }
856
+ return takeFromExternrefTable0(ret[0]);
857
+ }
858
+ /**
859
+ * Compute tropical matrix multiplication for pathfinding
860
+ * @param {any} a
861
+ * @param {any} b
862
+ * @returns {Array<any>}
863
+ */
864
+ static matrixMultiply(a, b) {
865
+ const ret = wasm.tropicalmlops_matrixMultiply(a, b);
866
+ if (ret[2]) {
867
+ throw takeFromExternrefTable0(ret[1]);
868
+ }
869
+ return takeFromExternrefTable0(ret[0]);
870
+ }
871
+ /**
872
+ * Compute tropical convex combination (used in optimization)
873
+ * @param {Float64Array} values
874
+ * @param {Float64Array} weights
875
+ * @returns {number}
876
+ */
877
+ static convexCombination(values, weights) {
878
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
879
+ const len0 = WASM_VECTOR_LEN;
880
+ const ptr1 = passArrayF64ToWasm0(weights, wasm.__wbindgen_malloc);
881
+ const len1 = WASM_VECTOR_LEN;
882
+ const ret = wasm.tropicalmlops_convexCombination(ptr0, len0, ptr1, len1);
883
+ if (ret[2]) {
884
+ throw takeFromExternrefTable0(ret[1]);
885
+ }
886
+ return ret[0];
887
+ }
888
+ }
889
+ if (Symbol.dispose) TropicalMLOps.prototype[Symbol.dispose] = TropicalMLOps.prototype.free;
890
+
891
+ const WasmDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
892
+ ? { register: () => {}, unregister: () => {} }
893
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmdualnumber_free(ptr >>> 0, 1));
894
+ /**
895
+ * WASM wrapper for single-variable dual numbers
896
+ */
897
+ export class WasmDualNumber {
898
+
899
+ static __wrap(ptr) {
900
+ ptr = ptr >>> 0;
901
+ const obj = Object.create(WasmDualNumber.prototype);
902
+ obj.__wbg_ptr = ptr;
903
+ WasmDualNumberFinalization.register(obj, obj.__wbg_ptr, obj);
904
+ return obj;
905
+ }
906
+
907
+ __destroy_into_raw() {
908
+ const ptr = this.__wbg_ptr;
909
+ this.__wbg_ptr = 0;
910
+ WasmDualNumberFinalization.unregister(this);
911
+ return ptr;
912
+ }
913
+
914
+ free() {
915
+ const ptr = this.__destroy_into_raw();
916
+ wasm.__wbg_wasmdualnumber_free(ptr, 0);
917
+ }
918
+ /**
919
+ * Natural logarithm
920
+ * @returns {WasmDualNumber}
921
+ */
922
+ ln() {
923
+ const ret = wasm.wasmdualnumber_ln(this.__wbg_ptr);
924
+ if (ret[2]) {
925
+ throw takeFromExternrefTable0(ret[1]);
926
+ }
927
+ return WasmDualNumber.__wrap(ret[0]);
928
+ }
929
+ /**
930
+ * Addition
931
+ * @param {WasmDualNumber} other
932
+ * @returns {WasmDualNumber}
933
+ */
934
+ add(other) {
935
+ _assertClass(other, WasmDualNumber);
936
+ const ret = wasm.wasmdualnumber_add(this.__wbg_ptr, other.__wbg_ptr);
937
+ return WasmDualNumber.__wrap(ret);
938
+ }
939
+ /**
940
+ * Cosine function
941
+ * @returns {WasmDualNumber}
942
+ */
943
+ cos() {
944
+ const ret = wasm.wasmdualnumber_cos(this.__wbg_ptr);
945
+ return WasmDualNumber.__wrap(ret);
946
+ }
947
+ /**
948
+ * Division
949
+ * @param {WasmDualNumber} other
950
+ * @returns {WasmDualNumber}
951
+ */
952
+ div(other) {
953
+ _assertClass(other, WasmDualNumber);
954
+ const ret = wasm.wasmdualnumber_div(this.__wbg_ptr, other.__wbg_ptr);
955
+ if (ret[2]) {
956
+ throw takeFromExternrefTable0(ret[1]);
957
+ }
958
+ return WasmDualNumber.__wrap(ret[0]);
959
+ }
960
+ /**
961
+ * Exponential function
962
+ * @returns {WasmDualNumber}
963
+ */
964
+ exp() {
965
+ const ret = wasm.wasmdualnumber_exp(this.__wbg_ptr);
966
+ return WasmDualNumber.__wrap(ret);
967
+ }
968
+ /**
969
+ * Maximum of two dual numbers
970
+ * @param {WasmDualNumber} other
971
+ * @returns {WasmDualNumber}
972
+ */
973
+ max(other) {
974
+ _assertClass(other, WasmDualNumber);
975
+ const ret = wasm.wasmdualnumber_max(this.__wbg_ptr, other.__wbg_ptr);
976
+ return WasmDualNumber.__wrap(ret);
977
+ }
978
+ /**
979
+ * Minimum of two dual numbers
980
+ * @param {WasmDualNumber} other
981
+ * @returns {WasmDualNumber}
982
+ */
983
+ min(other) {
984
+ _assertClass(other, WasmDualNumber);
985
+ const ret = wasm.wasmdualnumber_min(this.__wbg_ptr, other.__wbg_ptr);
986
+ return WasmDualNumber.__wrap(ret);
987
+ }
988
+ /**
989
+ * Multiplication
990
+ * @param {WasmDualNumber} other
991
+ * @returns {WasmDualNumber}
992
+ */
993
+ mul(other) {
994
+ _assertClass(other, WasmDualNumber);
995
+ const ret = wasm.wasmdualnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
996
+ return WasmDualNumber.__wrap(ret);
997
+ }
998
+ /**
999
+ * Negation
1000
+ * @returns {WasmDualNumber}
1001
+ */
1002
+ neg() {
1003
+ const ret = wasm.wasmdualnumber_neg(this.__wbg_ptr);
1004
+ return WasmDualNumber.__wrap(ret);
1005
+ }
1006
+ /**
1007
+ * Create a new dual number with given real and dual parts
1008
+ * @param {number} real
1009
+ * @param {number} dual
1010
+ */
1011
+ constructor(real, dual) {
1012
+ const ret = wasm.wasmdualnumber_new(real, dual);
1013
+ this.__wbg_ptr = ret >>> 0;
1014
+ WasmDualNumberFinalization.register(this, this.__wbg_ptr, this);
1015
+ return this;
1016
+ }
1017
+ /**
1018
+ * Power function
1019
+ * @param {number} exponent
1020
+ * @returns {WasmDualNumber}
1021
+ */
1022
+ pow(exponent) {
1023
+ const ret = wasm.wasmdualnumber_pow(this.__wbg_ptr, exponent);
1024
+ return WasmDualNumber.__wrap(ret);
1025
+ }
1026
+ /**
1027
+ * Sine function
1028
+ * @returns {WasmDualNumber}
1029
+ */
1030
+ sin() {
1031
+ const ret = wasm.wasmdualnumber_sin(this.__wbg_ptr);
1032
+ return WasmDualNumber.__wrap(ret);
1033
+ }
1034
+ /**
1035
+ * Subtraction
1036
+ * @param {WasmDualNumber} other
1037
+ * @returns {WasmDualNumber}
1038
+ */
1039
+ sub(other) {
1040
+ _assertClass(other, WasmDualNumber);
1041
+ const ret = wasm.wasmdualnumber_sub(this.__wbg_ptr, other.__wbg_ptr);
1042
+ return WasmDualNumber.__wrap(ret);
1043
+ }
1044
+ /**
1045
+ * Tangent function
1046
+ * @returns {WasmDualNumber}
1047
+ */
1048
+ tan() {
1049
+ const ret = wasm.wasmdualnumber_tan(this.__wbg_ptr);
1050
+ return WasmDualNumber.__wrap(ret);
1051
+ }
1052
+ /**
1053
+ * Hyperbolic cosine
1054
+ * @returns {WasmDualNumber}
1055
+ */
1056
+ cosh() {
1057
+ const ret = wasm.wasmdualnumber_cosh(this.__wbg_ptr);
1058
+ return WasmDualNumber.__wrap(ret);
1059
+ }
1060
+ /**
1061
+ * Integer power
1062
+ * @param {number} n
1063
+ * @returns {WasmDualNumber}
1064
+ */
1065
+ powi(n) {
1066
+ const ret = wasm.wasmdualnumber_powi(this.__wbg_ptr, n);
1067
+ return WasmDualNumber.__wrap(ret);
1068
+ }
1069
+ /**
1070
+ * ReLU activation function
1071
+ * @returns {WasmDualNumber}
1072
+ */
1073
+ relu() {
1074
+ const ret = wasm.wasmdualnumber_relu(this.__wbg_ptr);
1075
+ return WasmDualNumber.__wrap(ret);
1076
+ }
1077
+ /**
1078
+ * Hyperbolic sine
1079
+ * @returns {WasmDualNumber}
1080
+ */
1081
+ sinh() {
1082
+ const ret = wasm.wasmdualnumber_sinh(this.__wbg_ptr);
1083
+ return WasmDualNumber.__wrap(ret);
1084
+ }
1085
+ /**
1086
+ * Square root
1087
+ * @returns {WasmDualNumber}
1088
+ */
1089
+ sqrt() {
1090
+ const ret = wasm.wasmdualnumber_sqrt(this.__wbg_ptr);
1091
+ if (ret[2]) {
1092
+ throw takeFromExternrefTable0(ret[1]);
1093
+ }
1094
+ return WasmDualNumber.__wrap(ret[0]);
1095
+ }
1096
+ /**
1097
+ * Hyperbolic tangent
1098
+ * @returns {WasmDualNumber}
1099
+ */
1100
+ tanh() {
1101
+ const ret = wasm.wasmdualnumber_tanh(this.__wbg_ptr);
1102
+ return WasmDualNumber.__wrap(ret);
1103
+ }
1104
+ /**
1105
+ * Sigmoid activation function
1106
+ * @returns {WasmDualNumber}
1107
+ */
1108
+ sigmoid() {
1109
+ const ret = wasm.wasmdualnumber_sigmoid(this.__wbg_ptr);
1110
+ return WasmDualNumber.__wrap(ret);
1111
+ }
1112
+ /**
1113
+ * Create a constant (derivative = 0)
1114
+ * @param {number} value
1115
+ * @returns {WasmDualNumber}
1116
+ */
1117
+ static constant(value) {
1118
+ const ret = wasm.wasmdualnumber_constant(value);
1119
+ return WasmDualNumber.__wrap(ret);
1120
+ }
1121
+ /**
1122
+ * Get the dual part (derivative)
1123
+ * @returns {number}
1124
+ */
1125
+ getDual() {
1126
+ const ret = wasm.wasmdualnumber_getDual(this.__wbg_ptr);
1127
+ return ret;
1128
+ }
1129
+ /**
1130
+ * Get the real part (function value)
1131
+ * @returns {number}
1132
+ */
1133
+ getReal() {
1134
+ const ret = wasm.wasmdualnumber_getReal(this.__wbg_ptr);
1135
+ return ret;
1136
+ }
1137
+ /**
1138
+ * Softplus activation function
1139
+ * @returns {WasmDualNumber}
1140
+ */
1141
+ softplus() {
1142
+ const ret = wasm.wasmdualnumber_softplus(this.__wbg_ptr);
1143
+ return WasmDualNumber.__wrap(ret);
1144
+ }
1145
+ /**
1146
+ * Create a variable (derivative = 1)
1147
+ * @param {number} value
1148
+ * @returns {WasmDualNumber}
1149
+ */
1150
+ static variable(value) {
1151
+ const ret = wasm.wasmdualnumber_variable(value);
1152
+ return WasmDualNumber.__wrap(ret);
1153
+ }
1154
+ }
1155
+ if (Symbol.dispose) WasmDualNumber.prototype[Symbol.dispose] = WasmDualNumber.prototype.free;
1156
+
1157
+ const WasmFourVelocityFinalization = (typeof FinalizationRegistry === 'undefined')
1158
+ ? { register: () => {}, unregister: () => {} }
1159
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmfourvelocity_free(ptr >>> 0, 1));
1160
+ /**
1161
+ * WASM wrapper for four-velocity
1162
+ */
1163
+ export class WasmFourVelocity {
1164
+
1165
+ static __wrap(ptr) {
1166
+ ptr = ptr >>> 0;
1167
+ const obj = Object.create(WasmFourVelocity.prototype);
1168
+ obj.__wbg_ptr = ptr;
1169
+ WasmFourVelocityFinalization.register(obj, obj.__wbg_ptr, obj);
1170
+ return obj;
1171
+ }
1172
+
1173
+ __destroy_into_raw() {
1174
+ const ptr = this.__wbg_ptr;
1175
+ this.__wbg_ptr = 0;
1176
+ WasmFourVelocityFinalization.unregister(this);
1177
+ return ptr;
1178
+ }
1179
+
1180
+ free() {
1181
+ const ptr = this.__destroy_into_raw();
1182
+ wasm.__wbg_wasmfourvelocity_free(ptr, 0);
1183
+ }
1184
+ /**
1185
+ * Create four-velocity from 3-velocity components
1186
+ * @param {number} vx
1187
+ * @param {number} vy
1188
+ * @param {number} vz
1189
+ * @returns {WasmFourVelocity}
1190
+ */
1191
+ static from_velocity(vx, vy, vz) {
1192
+ const ret = wasm.wasmfourvelocity_from_velocity(vx, vy, vz);
1193
+ if (ret[2]) {
1194
+ throw takeFromExternrefTable0(ret[1]);
1195
+ }
1196
+ return WasmFourVelocity.__wrap(ret[0]);
1197
+ }
1198
+ /**
1199
+ * Check if normalized (u·u = c²)
1200
+ * @returns {boolean}
1201
+ */
1202
+ is_normalized() {
1203
+ const ret = wasm.wasmfourvelocity_is_normalized(this.__wbg_ptr);
1204
+ return ret !== 0;
1205
+ }
1206
+ /**
1207
+ * Get as spacetime vector
1208
+ * @returns {WasmSpacetimeVector}
1209
+ */
1210
+ as_spacetime_vector() {
1211
+ const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
1212
+ return WasmSpacetimeVector.__wrap(ret);
1213
+ }
1214
+ /**
1215
+ * Get spatial velocity magnitude
1216
+ * @returns {number}
1217
+ */
1218
+ spatial_velocity_magnitude() {
1219
+ const ret = wasm.wasmfourvelocity_spatial_velocity_magnitude(this.__wbg_ptr);
1220
+ return ret;
1221
+ }
1222
+ /**
1223
+ * Get Lorentz factor γ
1224
+ * @returns {number}
1225
+ */
1226
+ gamma() {
1227
+ const ret = wasm.wasmfourvelocity_gamma(this.__wbg_ptr);
1228
+ return ret;
1229
+ }
1230
+ /**
1231
+ * Get rapidity
1232
+ * @returns {number}
1233
+ */
1234
+ rapidity() {
1235
+ const ret = wasm.wasmfourvelocity_rapidity(this.__wbg_ptr);
1236
+ return ret;
1237
+ }
1238
+ /**
1239
+ * Get string representation
1240
+ * @returns {string}
1241
+ */
1242
+ to_string() {
1243
+ let deferred1_0;
1244
+ let deferred1_1;
1245
+ try {
1246
+ const ret = wasm.wasmfourvelocity_to_string(this.__wbg_ptr);
1247
+ deferred1_0 = ret[0];
1248
+ deferred1_1 = ret[1];
1249
+ return getStringFromWasm0(ret[0], ret[1]);
1250
+ } finally {
1251
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1252
+ }
1253
+ }
1254
+ }
1255
+ if (Symbol.dispose) WasmFourVelocity.prototype[Symbol.dispose] = WasmFourVelocity.prototype.free;
1256
+
1257
+ const WasmGeodesicIntegratorFinalization = (typeof FinalizationRegistry === 'undefined')
1258
+ ? { register: () => {}, unregister: () => {} }
1259
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgeodesicintegrator_free(ptr >>> 0, 1));
1260
+ /**
1261
+ * WASM wrapper for geodesic integration
1262
+ */
1263
+ export class WasmGeodesicIntegrator {
1264
+
1265
+ static __wrap(ptr) {
1266
+ ptr = ptr >>> 0;
1267
+ const obj = Object.create(WasmGeodesicIntegrator.prototype);
1268
+ obj.__wbg_ptr = ptr;
1269
+ WasmGeodesicIntegratorFinalization.register(obj, obj.__wbg_ptr, obj);
1270
+ return obj;
1271
+ }
1272
+
1273
+ __destroy_into_raw() {
1274
+ const ptr = this.__wbg_ptr;
1275
+ this.__wbg_ptr = 0;
1276
+ WasmGeodesicIntegratorFinalization.unregister(this);
1277
+ return ptr;
1278
+ }
1279
+
1280
+ free() {
1281
+ const ptr = this.__destroy_into_raw();
1282
+ wasm.__wbg_wasmgeodesicintegrator_free(ptr, 0);
1283
+ }
1284
+ /**
1285
+ * Propagate particle through spacetime
1286
+ * @param {WasmRelativisticParticle} particle
1287
+ * @param {number} integration_time
1288
+ * @param {number} time_step
1289
+ * @returns {Array<any>}
1290
+ */
1291
+ propagate_particle(particle, integration_time, time_step) {
1292
+ _assertClass(particle, WasmRelativisticParticle);
1293
+ const ret = wasm.wasmgeodesicintegrator_propagate_particle(this.__wbg_ptr, particle.__wbg_ptr, integration_time, time_step);
1294
+ if (ret[2]) {
1295
+ throw takeFromExternrefTable0(ret[1]);
1296
+ }
1297
+ return takeFromExternrefTable0(ret[0]);
1298
+ }
1299
+ /**
1300
+ * Create integrator with Schwarzschild metric
1301
+ * @param {WasmSchwarzschildMetric} metric
1302
+ * @returns {WasmGeodesicIntegrator}
1303
+ */
1304
+ static with_schwarzschild(metric) {
1305
+ _assertClass(metric, WasmSchwarzschildMetric);
1306
+ const ret = wasm.wasmgeodesicintegrator_with_schwarzschild(metric.__wbg_ptr);
1307
+ return WasmGeodesicIntegrator.__wrap(ret);
1308
+ }
1309
+ }
1310
+ if (Symbol.dispose) WasmGeodesicIntegrator.prototype[Symbol.dispose] = WasmGeodesicIntegrator.prototype.free;
1311
+
1312
+ const WasmGeometricNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
1313
+ ? { register: () => {}, unregister: () => {} }
1314
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricnetwork_free(ptr >>> 0, 1));
1315
+ /**
1316
+ * WASM wrapper for GeometricNetwork
1317
+ */
1318
+ export class WasmGeometricNetwork {
1319
+
1320
+ __destroy_into_raw() {
1321
+ const ptr = this.__wbg_ptr;
1322
+ this.__wbg_ptr = 0;
1323
+ WasmGeometricNetworkFinalization.unregister(this);
1324
+ return ptr;
1325
+ }
1326
+
1327
+ free() {
1328
+ const ptr = this.__destroy_into_raw();
1329
+ wasm.__wbg_wasmgeometricnetwork_free(ptr, 0);
1330
+ }
1331
+ /**
1332
+ * Get degree of a node
1333
+ * @param {number} node
1334
+ * @returns {number}
1335
+ */
1336
+ getDegree(node) {
1337
+ const ret = wasm.wasmgeometricnetwork_getDegree(this.__wbg_ptr, node);
1338
+ return ret >>> 0;
1339
+ }
1340
+ /**
1341
+ * Get neighbors of a node
1342
+ * @param {number} node
1343
+ * @returns {Uint32Array}
1344
+ */
1345
+ getNeighbors(node) {
1346
+ const ret = wasm.wasmgeometricnetwork_getNeighbors(this.__wbg_ptr, node);
1347
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1348
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1349
+ return v1;
1350
+ }
1351
+ /**
1352
+ * Find shortest path between two nodes
1353
+ * Returns the path as an array of node indices, or null if no path exists
1354
+ * @param {number} source
1355
+ * @param {number} target
1356
+ * @returns {Uint32Array | undefined}
1357
+ */
1358
+ shortestPath(source, target) {
1359
+ const ret = wasm.wasmgeometricnetwork_shortestPath(this.__wbg_ptr, source, target);
1360
+ if (ret[3]) {
1361
+ throw takeFromExternrefTable0(ret[2]);
1362
+ }
1363
+ let v1;
1364
+ if (ret[0] !== 0) {
1365
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1366
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1367
+ }
1368
+ return v1;
1369
+ }
1370
+ /**
1371
+ * Add a labeled node
1372
+ * @param {number} x
1373
+ * @param {number} y
1374
+ * @param {number} z
1375
+ * @param {string} label
1376
+ * @returns {number}
1377
+ */
1378
+ addLabeledNode(x, y, z, label) {
1379
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1380
+ const len0 = WASM_VECTOR_LEN;
1381
+ const ret = wasm.wasmgeometricnetwork_addLabeledNode(this.__wbg_ptr, x, y, z, ptr0, len0);
1382
+ return ret >>> 0;
1383
+ }
1384
+ /**
1385
+ * Find communities using geometric clustering
1386
+ * @param {number} num_communities
1387
+ * @returns {Uint32Array}
1388
+ */
1389
+ findCommunities(num_communities) {
1390
+ const ret = wasm.wasmgeometricnetwork_findCommunities(this.__wbg_ptr, num_communities);
1391
+ if (ret[3]) {
1392
+ throw takeFromExternrefTable0(ret[2]);
1393
+ }
1394
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1395
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1396
+ return v1;
1397
+ }
1398
+ /**
1399
+ * Get node position as [x, y, z]
1400
+ * @param {number} node
1401
+ * @returns {Float64Array | undefined}
1402
+ */
1403
+ getNodePosition(node) {
1404
+ const ret = wasm.wasmgeometricnetwork_getNodePosition(this.__wbg_ptr, node);
1405
+ let v1;
1406
+ if (ret[0] !== 0) {
1407
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1408
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1409
+ }
1410
+ return v1;
1411
+ }
1412
+ /**
1413
+ * Compute geometric distance between two nodes
1414
+ * @param {number} node1
1415
+ * @param {number} node2
1416
+ * @returns {number}
1417
+ */
1418
+ geometricDistance(node1, node2) {
1419
+ const ret = wasm.wasmgeometricnetwork_geometricDistance(this.__wbg_ptr, node1, node2);
1420
+ if (ret[2]) {
1421
+ throw takeFromExternrefTable0(ret[1]);
1422
+ }
1423
+ return ret[0];
1424
+ }
1425
+ /**
1426
+ * Add an undirected edge
1427
+ * @param {number} a
1428
+ * @param {number} b
1429
+ * @param {number} weight
1430
+ */
1431
+ addUndirectedEdge(a, b, weight) {
1432
+ const ret = wasm.wasmgeometricnetwork_addUndirectedEdge(this.__wbg_ptr, a, b, weight);
1433
+ if (ret[1]) {
1434
+ throw takeFromExternrefTable0(ret[0]);
1435
+ }
1436
+ }
1437
+ /**
1438
+ * Find shortest path with distance between two nodes
1439
+ * Returns an object with path and distance, or null if no path exists
1440
+ * @param {number} source
1441
+ * @param {number} target
1442
+ * @returns {any}
1443
+ */
1444
+ shortestPathWithDistance(source, target) {
1445
+ const ret = wasm.wasmgeometricnetwork_shortestPathWithDistance(this.__wbg_ptr, source, target);
1446
+ if (ret[2]) {
1447
+ throw takeFromExternrefTable0(ret[1]);
1448
+ }
1449
+ return takeFromExternrefTable0(ret[0]);
1450
+ }
1451
+ /**
1452
+ * Compute geometric centrality for all nodes
1453
+ * @returns {Float64Array}
1454
+ */
1455
+ computeGeometricCentrality() {
1456
+ const ret = wasm.wasmgeometricnetwork_computeGeometricCentrality(this.__wbg_ptr);
1457
+ if (ret[3]) {
1458
+ throw takeFromExternrefTable0(ret[2]);
1459
+ }
1460
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1461
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1462
+ return v1;
1463
+ }
1464
+ /**
1465
+ * Create a new geometric network
1466
+ */
1467
+ constructor() {
1468
+ const ret = wasm.wasmgeometricnetwork_new();
1469
+ this.__wbg_ptr = ret >>> 0;
1470
+ WasmGeometricNetworkFinalization.register(this, this.__wbg_ptr, this);
1471
+ return this;
1472
+ }
1473
+ /**
1474
+ * Add an edge between two nodes
1475
+ * @param {number} source
1476
+ * @param {number} target
1477
+ * @param {number} weight
1478
+ */
1479
+ addEdge(source, target, weight) {
1480
+ const ret = wasm.wasmgeometricnetwork_addEdge(this.__wbg_ptr, source, target, weight);
1481
+ if (ret[1]) {
1482
+ throw takeFromExternrefTable0(ret[0]);
1483
+ }
1484
+ }
1485
+ /**
1486
+ * Add a node at the given position
1487
+ * @param {number} x
1488
+ * @param {number} y
1489
+ * @param {number} z
1490
+ * @returns {number}
1491
+ */
1492
+ addNode(x, y, z) {
1493
+ const ret = wasm.wasmgeometricnetwork_addNode(this.__wbg_ptr, x, y, z);
1494
+ return ret >>> 0;
1495
+ }
1496
+ /**
1497
+ * Get number of edges
1498
+ * @returns {number}
1499
+ */
1500
+ numEdges() {
1501
+ const ret = wasm.wasmgeometricnetwork_numEdges(this.__wbg_ptr);
1502
+ return ret >>> 0;
1503
+ }
1504
+ /**
1505
+ * Get number of nodes
1506
+ * @returns {number}
1507
+ */
1508
+ numNodes() {
1509
+ const ret = wasm.wasmgeometricnetwork_numNodes(this.__wbg_ptr);
1510
+ return ret >>> 0;
1511
+ }
1512
+ }
1513
+ if (Symbol.dispose) WasmGeometricNetwork.prototype[Symbol.dispose] = WasmGeometricNetwork.prototype.free;
1514
+
1515
+ const WasmMultiDualNumberFinalization = (typeof FinalizationRegistry === 'undefined')
1516
+ ? { register: () => {}, unregister: () => {} }
1517
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultidualnumber_free(ptr >>> 0, 1));
1518
+ /**
1519
+ * WASM wrapper for multi-variable dual numbers
1520
+ */
1521
+ export class WasmMultiDualNumber {
1522
+
1523
+ static __wrap(ptr) {
1524
+ ptr = ptr >>> 0;
1525
+ const obj = Object.create(WasmMultiDualNumber.prototype);
1526
+ obj.__wbg_ptr = ptr;
1527
+ WasmMultiDualNumberFinalization.register(obj, obj.__wbg_ptr, obj);
1528
+ return obj;
1529
+ }
1530
+
1531
+ __destroy_into_raw() {
1532
+ const ptr = this.__wbg_ptr;
1533
+ this.__wbg_ptr = 0;
1534
+ WasmMultiDualNumberFinalization.unregister(this);
1535
+ return ptr;
1536
+ }
1537
+
1538
+ free() {
1539
+ const ptr = this.__destroy_into_raw();
1540
+ wasm.__wbg_wasmmultidualnumber_free(ptr, 0);
1541
+ }
1542
+ /**
1543
+ * Get a specific partial derivative
1544
+ * @param {number} index
1545
+ * @returns {number}
1546
+ */
1547
+ getPartial(index) {
1548
+ const ret = wasm.wasmmultidualnumber_getPartial(this.__wbg_ptr, index);
1549
+ if (ret[2]) {
1550
+ throw takeFromExternrefTable0(ret[1]);
1551
+ }
1552
+ return ret[0];
1553
+ }
1554
+ /**
1555
+ * Get the gradient (all partial derivatives)
1556
+ * @returns {Float64Array}
1557
+ */
1558
+ getGradient() {
1559
+ const ret = wasm.wasmmultidualnumber_getGradient(this.__wbg_ptr);
1560
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1561
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1562
+ return v1;
1563
+ }
1564
+ /**
1565
+ * Get number of variables
1566
+ * @returns {number}
1567
+ */
1568
+ getNumVars() {
1569
+ const ret = wasm.wasmmultidualnumber_getNumVars(this.__wbg_ptr);
1570
+ return ret >>> 0;
1571
+ }
1572
+ /**
1573
+ * Addition
1574
+ * @param {WasmMultiDualNumber} other
1575
+ * @returns {WasmMultiDualNumber}
1576
+ */
1577
+ add(other) {
1578
+ _assertClass(other, WasmMultiDualNumber);
1579
+ const ret = wasm.wasmmultidualnumber_add(this.__wbg_ptr, other.__wbg_ptr);
1580
+ if (ret[2]) {
1581
+ throw takeFromExternrefTable0(ret[1]);
1582
+ }
1583
+ return WasmMultiDualNumber.__wrap(ret[0]);
1584
+ }
1585
+ /**
1586
+ * Multiplication
1587
+ * @param {WasmMultiDualNumber} other
1588
+ * @returns {WasmMultiDualNumber}
1589
+ */
1590
+ mul(other) {
1591
+ _assertClass(other, WasmMultiDualNumber);
1592
+ const ret = wasm.wasmmultidualnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
1593
+ if (ret[2]) {
1594
+ throw takeFromExternrefTable0(ret[1]);
1595
+ }
1596
+ return WasmMultiDualNumber.__wrap(ret[0]);
1597
+ }
1598
+ /**
1599
+ * Create a new multi-dual number
1600
+ * @param {number} real
1601
+ * @param {Float64Array} duals
1602
+ */
1603
+ constructor(real, duals) {
1604
+ const ptr0 = passArrayF64ToWasm0(duals, wasm.__wbindgen_malloc);
1605
+ const len0 = WASM_VECTOR_LEN;
1606
+ const ret = wasm.wasmmultidualnumber_new(real, ptr0, len0);
1607
+ this.__wbg_ptr = ret >>> 0;
1608
+ WasmMultiDualNumberFinalization.register(this, this.__wbg_ptr, this);
1609
+ return this;
1610
+ }
1611
+ /**
1612
+ * Square root
1613
+ * @returns {WasmMultiDualNumber}
1614
+ */
1615
+ sqrt() {
1616
+ const ret = wasm.wasmmultidualnumber_sqrt(this.__wbg_ptr);
1617
+ if (ret[2]) {
1618
+ throw takeFromExternrefTable0(ret[1]);
1619
+ }
1620
+ return WasmMultiDualNumber.__wrap(ret[0]);
1621
+ }
1622
+ /**
1623
+ * Create a constant (all derivatives are zero)
1624
+ * @param {number} value
1625
+ * @param {number} num_vars
1626
+ * @returns {WasmMultiDualNumber}
1627
+ */
1628
+ static constant(value, num_vars) {
1629
+ const ret = wasm.wasmmultidualnumber_constant(value, num_vars);
1630
+ return WasmMultiDualNumber.__wrap(ret);
1631
+ }
1632
+ /**
1633
+ * Get the real part (function value)
1634
+ * @returns {number}
1635
+ */
1636
+ getReal() {
1637
+ const ret = wasm.wasmdualnumber_getReal(this.__wbg_ptr);
1638
+ return ret;
1639
+ }
1640
+ /**
1641
+ * Create a variable with derivative 1 at the specified index
1642
+ * @param {number} value
1643
+ * @param {number} num_vars
1644
+ * @param {number} var_index
1645
+ * @returns {WasmMultiDualNumber}
1646
+ */
1647
+ static variable(value, num_vars, var_index) {
1648
+ const ret = wasm.wasmmultidualnumber_variable(value, num_vars, var_index);
1649
+ return WasmMultiDualNumber.__wrap(ret);
1650
+ }
1651
+ }
1652
+ if (Symbol.dispose) WasmMultiDualNumber.prototype[Symbol.dispose] = WasmMultiDualNumber.prototype.free;
1653
+
1654
+ const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
1655
+ ? { register: () => {}, unregister: () => {} }
1656
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
1657
+ /**
1658
+ * WASM wrapper for Multivector with TypedArray support
1659
+ */
1660
+ export class WasmMultivector {
1661
+
1662
+ static __wrap(ptr) {
1663
+ ptr = ptr >>> 0;
1664
+ const obj = Object.create(WasmMultivector.prototype);
1665
+ obj.__wbg_ptr = ptr;
1666
+ WasmMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
1667
+ return obj;
1668
+ }
1669
+
1670
+ __destroy_into_raw() {
1671
+ const ptr = this.__wbg_ptr;
1672
+ this.__wbg_ptr = 0;
1673
+ WasmMultivectorFinalization.unregister(this);
1674
+ return ptr;
1675
+ }
1676
+
1677
+ free() {
1678
+ const ptr = this.__destroy_into_raw();
1679
+ wasm.__wbg_wasmmultivector_free(ptr, 0);
1680
+ }
1681
+ /**
1682
+ * Create a basis vector (0-indexed)
1683
+ * @param {number} index
1684
+ * @returns {WasmMultivector}
1685
+ */
1686
+ static basisVector(index) {
1687
+ const ret = wasm.wasmmultivector_basisVector(index);
1688
+ if (ret[2]) {
1689
+ throw takeFromExternrefTable0(ret[1]);
1690
+ }
1691
+ return WasmMultivector.__wrap(ret[0]);
1692
+ }
1693
+ /**
1694
+ * Inner product (dot product for vectors)
1695
+ * @param {WasmMultivector} other
1696
+ * @returns {WasmMultivector}
1697
+ */
1698
+ innerProduct(other) {
1699
+ _assertClass(other, WasmMultivector);
1700
+ const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
1701
+ return WasmMultivector.__wrap(ret);
1702
+ }
1703
+ /**
1704
+ * Outer product (wedge product)
1705
+ * @param {WasmMultivector} other
1706
+ * @returns {WasmMultivector}
1707
+ */
1708
+ outerProduct(other) {
1709
+ _assertClass(other, WasmMultivector);
1710
+ const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
1711
+ return WasmMultivector.__wrap(ret);
1712
+ }
1713
+ /**
1714
+ * Scalar product
1715
+ * @param {WasmMultivector} other
1716
+ * @returns {number}
1717
+ */
1718
+ scalarProduct(other) {
1719
+ _assertClass(other, WasmMultivector);
1720
+ const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
1721
+ return ret;
1722
+ }
1723
+ /**
1724
+ * Get a specific coefficient
1725
+ * @param {number} index
1726
+ * @returns {number}
1727
+ */
1728
+ getCoefficient(index) {
1729
+ const ret = wasm.wasmmultivector_getCoefficient(this.__wbg_ptr, index);
1730
+ return ret;
1731
+ }
1732
+ /**
1733
+ * Set a specific coefficient
1734
+ * @param {number} index
1735
+ * @param {number} value
1736
+ */
1737
+ setCoefficient(index, value) {
1738
+ wasm.wasmmultivector_setCoefficient(this.__wbg_ptr, index, value);
1739
+ }
1740
+ /**
1741
+ * Get coefficients as a Float64Array
1742
+ * @returns {Float64Array}
1743
+ */
1744
+ getCoefficients() {
1745
+ const ret = wasm.wasmmultivector_getCoefficients(this.__wbg_ptr);
1746
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1747
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1748
+ return v1;
1749
+ }
1750
+ /**
1751
+ * Grade projection
1752
+ * @param {number} grade
1753
+ * @returns {WasmMultivector}
1754
+ */
1755
+ gradeProjection(grade) {
1756
+ const ret = wasm.wasmmultivector_gradeProjection(this.__wbg_ptr, grade);
1757
+ return WasmMultivector.__wrap(ret);
1758
+ }
1759
+ /**
1760
+ * Create from a Float64Array of coefficients
1761
+ * @param {Float64Array} coefficients
1762
+ * @returns {WasmMultivector}
1763
+ */
1764
+ static fromCoefficients(coefficients) {
1765
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
1766
+ const len0 = WASM_VECTOR_LEN;
1767
+ const ret = wasm.wasmmultivector_fromCoefficients(ptr0, len0);
1768
+ if (ret[2]) {
1769
+ throw takeFromExternrefTable0(ret[1]);
1770
+ }
1771
+ return WasmMultivector.__wrap(ret[0]);
1772
+ }
1773
+ /**
1774
+ * Geometric product
1775
+ * @param {WasmMultivector} other
1776
+ * @returns {WasmMultivector}
1777
+ */
1778
+ geometricProduct(other) {
1779
+ _assertClass(other, WasmMultivector);
1780
+ const ret = wasm.wasmmultivector_geometricProduct(this.__wbg_ptr, other.__wbg_ptr);
1781
+ return WasmMultivector.__wrap(ret);
1782
+ }
1783
+ /**
1784
+ * Add two multivectors
1785
+ * @param {WasmMultivector} other
1786
+ * @returns {WasmMultivector}
1787
+ */
1788
+ add(other) {
1789
+ _assertClass(other, WasmMultivector);
1790
+ const ret = wasm.wasmmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
1791
+ return WasmMultivector.__wrap(ret);
1792
+ }
1793
+ /**
1794
+ * Exponential (for bivectors to create rotors)
1795
+ * @returns {WasmMultivector}
1796
+ */
1797
+ exp() {
1798
+ const ret = wasm.wasmmultivector_exp(this.__wbg_ptr);
1799
+ return WasmMultivector.__wrap(ret);
1800
+ }
1801
+ /**
1802
+ * Create a new zero multivector
1803
+ */
1804
+ constructor() {
1805
+ const ret = wasm.wasmmultivector_new();
1806
+ this.__wbg_ptr = ret >>> 0;
1807
+ WasmMultivectorFinalization.register(this, this.__wbg_ptr, this);
1808
+ return this;
1809
+ }
1810
+ /**
1811
+ * Subtract two multivectors
268
1812
  * @param {WasmMultivector} other
269
1813
  * @returns {WasmMultivector}
270
1814
  */
271
- outerProduct(other) {
272
- _assertClass(other, WasmMultivector);
273
- const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
1815
+ sub(other) {
1816
+ _assertClass(other, WasmMultivector);
1817
+ const ret = wasm.wasmmultivector_sub(this.__wbg_ptr, other.__wbg_ptr);
1818
+ return WasmMultivector.__wrap(ret);
1819
+ }
1820
+ /**
1821
+ * Compute norm (alias for magnitude, maintained for compatibility)
1822
+ * @returns {number}
1823
+ */
1824
+ norm() {
1825
+ const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
1826
+ return ret;
1827
+ }
1828
+ /**
1829
+ * Scale by a scalar
1830
+ * @param {number} scalar
1831
+ * @returns {WasmMultivector}
1832
+ */
1833
+ scale(scalar) {
1834
+ const ret = wasm.wasmmultivector_scale(this.__wbg_ptr, scalar);
1835
+ return WasmMultivector.__wrap(ret);
1836
+ }
1837
+ /**
1838
+ * Create a scalar multivector
1839
+ * @param {number} value
1840
+ * @returns {WasmMultivector}
1841
+ */
1842
+ static scalar(value) {
1843
+ const ret = wasm.wasmmultivector_scalar(value);
1844
+ return WasmMultivector.__wrap(ret);
1845
+ }
1846
+ /**
1847
+ * Compute inverse
1848
+ * @returns {WasmMultivector}
1849
+ */
1850
+ inverse() {
1851
+ const ret = wasm.wasmmultivector_inverse(this.__wbg_ptr);
1852
+ if (ret[2]) {
1853
+ throw takeFromExternrefTable0(ret[1]);
1854
+ }
1855
+ return WasmMultivector.__wrap(ret[0]);
1856
+ }
1857
+ /**
1858
+ * Reverse
1859
+ * @returns {WasmMultivector}
1860
+ */
1861
+ reverse() {
1862
+ const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
1863
+ return WasmMultivector.__wrap(ret);
1864
+ }
1865
+ /**
1866
+ * Compute magnitude
1867
+ * @returns {number}
1868
+ */
1869
+ magnitude() {
1870
+ const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
1871
+ return ret;
1872
+ }
1873
+ /**
1874
+ * Normalize
1875
+ * @returns {WasmMultivector}
1876
+ */
1877
+ normalize() {
1878
+ const ret = wasm.wasmmultivector_normalize(this.__wbg_ptr);
1879
+ if (ret[2]) {
1880
+ throw takeFromExternrefTable0(ret[1]);
1881
+ }
1882
+ return WasmMultivector.__wrap(ret[0]);
1883
+ }
1884
+ }
1885
+ if (Symbol.dispose) WasmMultivector.prototype[Symbol.dispose] = WasmMultivector.prototype.free;
1886
+
1887
+ const WasmRelativisticConstantsFinalization = (typeof FinalizationRegistry === 'undefined')
1888
+ ? { register: () => {}, unregister: () => {} }
1889
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrelativisticconstants_free(ptr >>> 0, 1));
1890
+ /**
1891
+ * Physical constants
1892
+ */
1893
+ export class WasmRelativisticConstants {
1894
+
1895
+ __destroy_into_raw() {
1896
+ const ptr = this.__wbg_ptr;
1897
+ this.__wbg_ptr = 0;
1898
+ WasmRelativisticConstantsFinalization.unregister(this);
1899
+ return ptr;
1900
+ }
1901
+
1902
+ free() {
1903
+ const ptr = this.__destroy_into_raw();
1904
+ wasm.__wbg_wasmrelativisticconstants_free(ptr, 0);
1905
+ }
1906
+ /**
1907
+ * Earth mass (kg)
1908
+ * @returns {number}
1909
+ */
1910
+ static get earth_mass() {
1911
+ const ret = wasm.wasmrelativisticconstants_earth_mass();
1912
+ return ret;
1913
+ }
1914
+ /**
1915
+ * Solar mass (kg)
1916
+ * @returns {number}
1917
+ */
1918
+ static get solar_mass() {
1919
+ const ret = wasm.wasmrelativisticconstants_solar_mass();
1920
+ return ret;
1921
+ }
1922
+ /**
1923
+ * Speed of light in vacuum (m/s)
1924
+ * @returns {number}
1925
+ */
1926
+ static get speed_of_light() {
1927
+ const ret = wasm.wasmrelativisticconstants_speed_of_light();
1928
+ return ret;
1929
+ }
1930
+ /**
1931
+ * Gravitational constant (m³/kg·s²)
1932
+ * @returns {number}
1933
+ */
1934
+ static get gravitational_constant() {
1935
+ const ret = wasm.wasmrelativisticconstants_gravitational_constant();
1936
+ return ret;
1937
+ }
1938
+ }
1939
+ if (Symbol.dispose) WasmRelativisticConstants.prototype[Symbol.dispose] = WasmRelativisticConstants.prototype.free;
1940
+
1941
+ const WasmRelativisticParticleFinalization = (typeof FinalizationRegistry === 'undefined')
1942
+ ? { register: () => {}, unregister: () => {} }
1943
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrelativisticparticle_free(ptr >>> 0, 1));
1944
+ /**
1945
+ * WASM wrapper for relativistic particles
1946
+ */
1947
+ export class WasmRelativisticParticle {
1948
+
1949
+ static __wrap(ptr) {
1950
+ ptr = ptr >>> 0;
1951
+ const obj = Object.create(WasmRelativisticParticle.prototype);
1952
+ obj.__wbg_ptr = ptr;
1953
+ WasmRelativisticParticleFinalization.register(obj, obj.__wbg_ptr, obj);
1954
+ return obj;
1955
+ }
1956
+
1957
+ __destroy_into_raw() {
1958
+ const ptr = this.__wbg_ptr;
1959
+ this.__wbg_ptr = 0;
1960
+ WasmRelativisticParticleFinalization.unregister(this);
1961
+ return ptr;
1962
+ }
1963
+
1964
+ free() {
1965
+ const ptr = this.__destroy_into_raw();
1966
+ wasm.__wbg_wasmrelativisticparticle_free(ptr, 0);
1967
+ }
1968
+ /**
1969
+ * Get 3D position components
1970
+ * @returns {Array<any>}
1971
+ */
1972
+ position_3d() {
1973
+ const ret = wasm.wasmrelativisticparticle_position_3d(this.__wbg_ptr);
1974
+ return ret;
1975
+ }
1976
+ /**
1977
+ * Get position as spacetime vector
1978
+ * @returns {WasmSpacetimeVector}
1979
+ */
1980
+ position_4d() {
1981
+ const ret = wasm.wasmrelativisticparticle_position_4d(this.__wbg_ptr);
1982
+ return WasmSpacetimeVector.__wrap(ret);
1983
+ }
1984
+ /**
1985
+ * Create particle with specified energy
1986
+ * @param {number} x
1987
+ * @param {number} y
1988
+ * @param {number} z
1989
+ * @param {number} direction_x
1990
+ * @param {number} direction_y
1991
+ * @param {number} direction_z
1992
+ * @param {number} kinetic_energy
1993
+ * @param {number} mass
1994
+ * @param {number} charge
1995
+ * @returns {WasmRelativisticParticle}
1996
+ */
1997
+ static with_energy(x, y, z, direction_x, direction_y, direction_z, kinetic_energy, mass, charge) {
1998
+ const ret = wasm.wasmrelativisticparticle_with_energy(x, y, z, direction_x, direction_y, direction_z, kinetic_energy, mass, charge);
1999
+ if (ret[2]) {
2000
+ throw takeFromExternrefTable0(ret[1]);
2001
+ }
2002
+ return WasmRelativisticParticle.__wrap(ret[0]);
2003
+ }
2004
+ /**
2005
+ * Get total energy
2006
+ * @returns {number}
2007
+ */
2008
+ total_energy() {
2009
+ const ret = wasm.wasmrelativisticparticle_total_energy(this.__wbg_ptr);
2010
+ return ret;
2011
+ }
2012
+ /**
2013
+ * Get four-velocity
2014
+ * @returns {WasmFourVelocity}
2015
+ */
2016
+ four_velocity() {
2017
+ const ret = wasm.wasmrelativisticparticle_four_velocity(this.__wbg_ptr);
2018
+ return WasmFourVelocity.__wrap(ret);
2019
+ }
2020
+ /**
2021
+ * Get kinetic energy
2022
+ * @returns {number}
2023
+ */
2024
+ kinetic_energy() {
2025
+ const ret = wasm.wasmrelativisticparticle_kinetic_energy(this.__wbg_ptr);
2026
+ return ret;
2027
+ }
2028
+ /**
2029
+ * Get momentum magnitude
2030
+ * @returns {number}
2031
+ */
2032
+ momentum_magnitude() {
2033
+ const ret = wasm.wasmrelativisticparticle_momentum_magnitude(this.__wbg_ptr);
2034
+ return ret;
2035
+ }
2036
+ /**
2037
+ * Create a new relativistic particle
2038
+ * @param {number} x
2039
+ * @param {number} y
2040
+ * @param {number} z
2041
+ * @param {number} vx
2042
+ * @param {number} vy
2043
+ * @param {number} vz
2044
+ * @param {number} spin
2045
+ * @param {number} mass
2046
+ * @param {number} charge
2047
+ */
2048
+ constructor(x, y, z, vx, vy, vz, spin, mass, charge) {
2049
+ const ret = wasm.wasmrelativisticparticle_new(x, y, z, vx, vy, vz, spin, mass, charge);
2050
+ if (ret[2]) {
2051
+ throw takeFromExternrefTable0(ret[1]);
2052
+ }
2053
+ this.__wbg_ptr = ret[0] >>> 0;
2054
+ WasmRelativisticParticleFinalization.register(this, this.__wbg_ptr, this);
2055
+ return this;
2056
+ }
2057
+ /**
2058
+ * Get rest mass
2059
+ * @returns {number}
2060
+ */
2061
+ mass() {
2062
+ const ret = wasm.wasmrelativisticparticle_mass(this.__wbg_ptr);
2063
+ return ret;
2064
+ }
2065
+ /**
2066
+ * Get electric charge
2067
+ * @returns {number}
2068
+ */
2069
+ charge() {
2070
+ const ret = wasm.wasmrelativisticparticle_charge(this.__wbg_ptr);
2071
+ return ret;
2072
+ }
2073
+ /**
2074
+ * Get string representation
2075
+ * @returns {string}
2076
+ */
2077
+ to_string() {
2078
+ let deferred1_0;
2079
+ let deferred1_1;
2080
+ try {
2081
+ const ret = wasm.wasmrelativisticparticle_to_string(this.__wbg_ptr);
2082
+ deferred1_0 = ret[0];
2083
+ deferred1_1 = ret[1];
2084
+ return getStringFromWasm0(ret[0], ret[1]);
2085
+ } finally {
2086
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2087
+ }
2088
+ }
2089
+ }
2090
+ if (Symbol.dispose) WasmRelativisticParticle.prototype[Symbol.dispose] = WasmRelativisticParticle.prototype.free;
2091
+
2092
+ const WasmRotorFinalization = (typeof FinalizationRegistry === 'undefined')
2093
+ ? { register: () => {}, unregister: () => {} }
2094
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrotor_free(ptr >>> 0, 1));
2095
+ /**
2096
+ * Rotor operations for WASM
2097
+ */
2098
+ export class WasmRotor {
2099
+
2100
+ static __wrap(ptr) {
2101
+ ptr = ptr >>> 0;
2102
+ const obj = Object.create(WasmRotor.prototype);
2103
+ obj.__wbg_ptr = ptr;
2104
+ WasmRotorFinalization.register(obj, obj.__wbg_ptr, obj);
2105
+ return obj;
2106
+ }
2107
+
2108
+ __destroy_into_raw() {
2109
+ const ptr = this.__wbg_ptr;
2110
+ this.__wbg_ptr = 0;
2111
+ WasmRotorFinalization.unregister(this);
2112
+ return ptr;
2113
+ }
2114
+
2115
+ free() {
2116
+ const ptr = this.__destroy_into_raw();
2117
+ wasm.__wbg_wasmrotor_free(ptr, 0);
2118
+ }
2119
+ /**
2120
+ * Create a rotor from a bivector and angle
2121
+ * @param {WasmMultivector} bivector
2122
+ * @param {number} angle
2123
+ * @returns {WasmRotor}
2124
+ */
2125
+ static fromBivector(bivector, angle) {
2126
+ _assertClass(bivector, WasmMultivector);
2127
+ const ret = wasm.wasmrotor_fromBivector(bivector.__wbg_ptr, angle);
2128
+ return WasmRotor.__wrap(ret);
2129
+ }
2130
+ /**
2131
+ * Apply rotor to a multivector
2132
+ * @param {WasmMultivector} mv
2133
+ * @returns {WasmMultivector}
2134
+ */
2135
+ apply(mv) {
2136
+ _assertClass(mv, WasmMultivector);
2137
+ const ret = wasm.wasmrotor_apply(this.__wbg_ptr, mv.__wbg_ptr);
274
2138
  return WasmMultivector.__wrap(ret);
275
2139
  }
276
2140
  /**
277
- * Scalar product
278
- * @param {WasmMultivector} other
279
- * @returns {number}
2141
+ * Compose two rotors
2142
+ * @param {WasmRotor} other
2143
+ * @returns {WasmRotor}
2144
+ */
2145
+ compose(other) {
2146
+ _assertClass(other, WasmRotor);
2147
+ const ret = wasm.wasmrotor_compose(this.__wbg_ptr, other.__wbg_ptr);
2148
+ return WasmRotor.__wrap(ret);
2149
+ }
2150
+ /**
2151
+ * Get inverse rotor
2152
+ * @returns {WasmRotor}
2153
+ */
2154
+ inverse() {
2155
+ const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
2156
+ return WasmRotor.__wrap(ret);
2157
+ }
2158
+ }
2159
+ if (Symbol.dispose) WasmRotor.prototype[Symbol.dispose] = WasmRotor.prototype.free;
2160
+
2161
+ const WasmSchwarzschildMetricFinalization = (typeof FinalizationRegistry === 'undefined')
2162
+ ? { register: () => {}, unregister: () => {} }
2163
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmschwarzschildmetric_free(ptr >>> 0, 1));
2164
+ /**
2165
+ * WASM wrapper for Schwarzschild metric
2166
+ */
2167
+ export class WasmSchwarzschildMetric {
2168
+
2169
+ static __wrap(ptr) {
2170
+ ptr = ptr >>> 0;
2171
+ const obj = Object.create(WasmSchwarzschildMetric.prototype);
2172
+ obj.__wbg_ptr = ptr;
2173
+ WasmSchwarzschildMetricFinalization.register(obj, obj.__wbg_ptr, obj);
2174
+ return obj;
2175
+ }
2176
+
2177
+ __destroy_into_raw() {
2178
+ const ptr = this.__wbg_ptr;
2179
+ this.__wbg_ptr = 0;
2180
+ WasmSchwarzschildMetricFinalization.unregister(this);
2181
+ return ptr;
2182
+ }
2183
+
2184
+ free() {
2185
+ const ptr = this.__destroy_into_raw();
2186
+ wasm.__wbg_wasmschwarzschildmetric_free(ptr, 0);
2187
+ }
2188
+ /**
2189
+ * Check for singularity at given position
2190
+ * @param {WasmSpacetimeVector} position
2191
+ * @returns {boolean}
2192
+ */
2193
+ has_singularity(position) {
2194
+ _assertClass(position, WasmSpacetimeVector);
2195
+ const ret = wasm.wasmschwarzschildmetric_has_singularity(this.__wbg_ptr, position.__wbg_ptr);
2196
+ return ret !== 0;
2197
+ }
2198
+ /**
2199
+ * Compute effective potential for circular orbits
2200
+ * @param {number} r
2201
+ * @param {number} angular_momentum
2202
+ * @returns {number}
2203
+ */
2204
+ effective_potential(r, angular_momentum) {
2205
+ const ret = wasm.wasmschwarzschildmetric_effective_potential(this.__wbg_ptr, r, angular_momentum);
2206
+ return ret;
2207
+ }
2208
+ /**
2209
+ * Get Schwarzschild radius
2210
+ * @returns {number}
2211
+ */
2212
+ schwarzschild_radius() {
2213
+ const ret = wasm.wasmschwarzschildmetric_schwarzschild_radius(this.__wbg_ptr);
2214
+ return ret;
2215
+ }
2216
+ /**
2217
+ * Create Schwarzschild metric for the Sun
2218
+ * @returns {WasmSchwarzschildMetric}
2219
+ */
2220
+ static sun() {
2221
+ const ret = wasm.wasmschwarzschildmetric_sun();
2222
+ return WasmSchwarzschildMetric.__wrap(ret);
2223
+ }
2224
+ /**
2225
+ * Get central mass
2226
+ * @returns {number}
2227
+ */
2228
+ mass() {
2229
+ const ret = wasm.wasmdualnumber_getReal(this.__wbg_ptr);
2230
+ return ret;
2231
+ }
2232
+ /**
2233
+ * Create Schwarzschild metric for Earth
2234
+ * @returns {WasmSchwarzschildMetric}
2235
+ */
2236
+ static earth() {
2237
+ const ret = wasm.wasmschwarzschildmetric_earth();
2238
+ return WasmSchwarzschildMetric.__wrap(ret);
2239
+ }
2240
+ /**
2241
+ * Create Schwarzschild metric for custom mass
2242
+ * @param {number} mass
2243
+ * @returns {WasmSchwarzschildMetric}
2244
+ */
2245
+ static from_mass(mass) {
2246
+ const ret = wasm.wasmschwarzschildmetric_from_mass(mass);
2247
+ return WasmSchwarzschildMetric.__wrap(ret);
2248
+ }
2249
+ }
2250
+ if (Symbol.dispose) WasmSchwarzschildMetric.prototype[Symbol.dispose] = WasmSchwarzschildMetric.prototype.free;
2251
+
2252
+ const WasmSpacetimeVectorFinalization = (typeof FinalizationRegistry === 'undefined')
2253
+ ? { register: () => {}, unregister: () => {} }
2254
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmspacetimevector_free(ptr >>> 0, 1));
2255
+ /**
2256
+ * WASM wrapper for spacetime vectors
2257
+ */
2258
+ export class WasmSpacetimeVector {
2259
+
2260
+ static __wrap(ptr) {
2261
+ ptr = ptr >>> 0;
2262
+ const obj = Object.create(WasmSpacetimeVector.prototype);
2263
+ obj.__wbg_ptr = ptr;
2264
+ WasmSpacetimeVectorFinalization.register(obj, obj.__wbg_ptr, obj);
2265
+ return obj;
2266
+ }
2267
+
2268
+ __destroy_into_raw() {
2269
+ const ptr = this.__wbg_ptr;
2270
+ this.__wbg_ptr = 0;
2271
+ WasmSpacetimeVectorFinalization.unregister(this);
2272
+ return ptr;
2273
+ }
2274
+
2275
+ free() {
2276
+ const ptr = this.__destroy_into_raw();
2277
+ wasm.__wbg_wasmspacetimevector_free(ptr, 0);
2278
+ }
2279
+ /**
2280
+ * Check if vector is timelike (massive particle)
2281
+ * @returns {boolean}
2282
+ */
2283
+ is_timelike() {
2284
+ const ret = wasm.wasmspacetimevector_is_timelike(this.__wbg_ptr);
2285
+ return ret !== 0;
2286
+ }
2287
+ /**
2288
+ * Check if vector is spacelike
2289
+ * @returns {boolean}
2290
+ */
2291
+ is_spacelike() {
2292
+ const ret = wasm.wasmspacetimevector_is_spacelike(this.__wbg_ptr);
2293
+ return ret !== 0;
2294
+ }
2295
+ /**
2296
+ * Compute Minkowski norm squared
2297
+ * @returns {number}
2298
+ */
2299
+ norm_squared() {
2300
+ const ret = wasm.wasmspacetimevector_norm_squared(this.__wbg_ptr);
2301
+ return ret;
2302
+ }
2303
+ /**
2304
+ * Compute Minkowski inner product with another spacetime vector
2305
+ * @param {WasmSpacetimeVector} other
2306
+ * @returns {number}
2307
+ */
2308
+ minkowski_dot(other) {
2309
+ _assertClass(other, WasmSpacetimeVector);
2310
+ const ret = wasm.wasmspacetimevector_minkowski_dot(this.__wbg_ptr, other.__wbg_ptr);
2311
+ return ret;
2312
+ }
2313
+ /**
2314
+ * Get temporal component
2315
+ * @returns {number}
2316
+ */
2317
+ get t() {
2318
+ const ret = wasm.wasmfourvelocity_gamma(this.__wbg_ptr);
2319
+ return ret;
2320
+ }
2321
+ /**
2322
+ * Get x component
2323
+ * @returns {number}
2324
+ */
2325
+ get x() {
2326
+ const ret = wasm.wasmdualnumber_getDual(this.__wbg_ptr);
2327
+ return ret;
2328
+ }
2329
+ /**
2330
+ * Get y component
2331
+ * @returns {number}
2332
+ */
2333
+ get y() {
2334
+ const ret = wasm.wasmspacetimevector_y(this.__wbg_ptr);
2335
+ return ret;
2336
+ }
2337
+ /**
2338
+ * Get z component
2339
+ * @returns {number}
2340
+ */
2341
+ get z() {
2342
+ const ret = wasm.wasmspacetimevector_z(this.__wbg_ptr);
2343
+ return ret;
2344
+ }
2345
+ /**
2346
+ * Create a new spacetime vector with components (ct, x, y, z)
2347
+ * @param {number} t
2348
+ * @param {number} x
2349
+ * @param {number} y
2350
+ * @param {number} z
2351
+ */
2352
+ constructor(t, x, y, z) {
2353
+ const ret = wasm.wasmspacetimevector_new(t, x, y, z);
2354
+ this.__wbg_ptr = ret >>> 0;
2355
+ WasmSpacetimeVectorFinalization.register(this, this.__wbg_ptr, this);
2356
+ return this;
2357
+ }
2358
+ /**
2359
+ * Check if vector is null (lightlike)
2360
+ * @returns {boolean}
2361
+ */
2362
+ is_null() {
2363
+ const ret = wasm.wasmspacetimevector_is_null(this.__wbg_ptr);
2364
+ return ret !== 0;
2365
+ }
2366
+ /**
2367
+ * Create a timelike vector
2368
+ * @param {number} t
2369
+ * @returns {WasmSpacetimeVector}
2370
+ */
2371
+ static timelike(t) {
2372
+ const ret = wasm.wasmspacetimevector_timelike(t);
2373
+ return WasmSpacetimeVector.__wrap(ret);
2374
+ }
2375
+ /**
2376
+ * Create a spacelike vector
2377
+ * @param {number} x
2378
+ * @param {number} y
2379
+ * @param {number} z
2380
+ * @returns {WasmSpacetimeVector}
2381
+ */
2382
+ static spacelike(x, y, z) {
2383
+ const ret = wasm.wasmspacetimevector_spacelike(x, y, z);
2384
+ return WasmSpacetimeVector.__wrap(ret);
2385
+ }
2386
+ /**
2387
+ * Get string representation
2388
+ * @returns {string}
2389
+ */
2390
+ to_string() {
2391
+ let deferred1_0;
2392
+ let deferred1_1;
2393
+ try {
2394
+ const ret = wasm.wasmspacetimevector_to_string(this.__wbg_ptr);
2395
+ deferred1_0 = ret[0];
2396
+ deferred1_1 = ret[1];
2397
+ return getStringFromWasm0(ret[0], ret[1]);
2398
+ } finally {
2399
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2400
+ }
2401
+ }
2402
+ }
2403
+ if (Symbol.dispose) WasmSpacetimeVector.prototype[Symbol.dispose] = WasmSpacetimeVector.prototype.free;
2404
+
2405
+ const WasmTrajectoryPointFinalization = (typeof FinalizationRegistry === 'undefined')
2406
+ ? { register: () => {}, unregister: () => {} }
2407
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtrajectorypoint_free(ptr >>> 0, 1));
2408
+ /**
2409
+ * Trajectory point for particle propagation
2410
+ */
2411
+ export class WasmTrajectoryPoint {
2412
+
2413
+ __destroy_into_raw() {
2414
+ const ptr = this.__wbg_ptr;
2415
+ this.__wbg_ptr = 0;
2416
+ WasmTrajectoryPointFinalization.unregister(this);
2417
+ return ptr;
2418
+ }
2419
+
2420
+ free() {
2421
+ const ptr = this.__destroy_into_raw();
2422
+ wasm.__wbg_wasmtrajectorypoint_free(ptr, 0);
2423
+ }
2424
+ /**
2425
+ * Get position
2426
+ * @returns {WasmSpacetimeVector}
280
2427
  */
281
- scalarProduct(other) {
282
- _assertClass(other, WasmMultivector);
283
- const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
284
- return ret;
2428
+ get position() {
2429
+ const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
2430
+ return WasmSpacetimeVector.__wrap(ret);
285
2431
  }
286
2432
  /**
287
- * Get a specific coefficient
288
- * @param {number} index
2433
+ * Time coordinate
289
2434
  * @returns {number}
290
2435
  */
291
- getCoefficient(index) {
292
- const ret = wasm.wasmmultivector_getCoefficient(this.__wbg_ptr, index);
2436
+ get time() {
2437
+ const ret = wasm.__wbg_get_wasmtrajectorypoint_time(this.__wbg_ptr);
293
2438
  return ret;
294
2439
  }
295
2440
  /**
296
- * Set a specific coefficient
297
- * @param {number} index
298
- * @param {number} value
2441
+ * Time coordinate
2442
+ * @param {number} arg0
299
2443
  */
300
- setCoefficient(index, value) {
301
- wasm.wasmmultivector_setCoefficient(this.__wbg_ptr, index, value);
2444
+ set time(arg0) {
2445
+ wasm.__wbg_set_wasmtrajectorypoint_time(this.__wbg_ptr, arg0);
2446
+ }
2447
+ }
2448
+ if (Symbol.dispose) WasmTrajectoryPoint.prototype[Symbol.dispose] = WasmTrajectoryPoint.prototype.free;
2449
+
2450
+ const WasmTropicalNumberFinalization = (typeof FinalizationRegistry === 'undefined')
2451
+ ? { register: () => {}, unregister: () => {} }
2452
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalnumber_free(ptr >>> 0, 1));
2453
+ /**
2454
+ * WASM wrapper for TropicalNumber
2455
+ */
2456
+ export class WasmTropicalNumber {
2457
+
2458
+ static __wrap(ptr) {
2459
+ ptr = ptr >>> 0;
2460
+ const obj = Object.create(WasmTropicalNumber.prototype);
2461
+ obj.__wbg_ptr = ptr;
2462
+ WasmTropicalNumberFinalization.register(obj, obj.__wbg_ptr, obj);
2463
+ return obj;
2464
+ }
2465
+
2466
+ __destroy_into_raw() {
2467
+ const ptr = this.__wbg_ptr;
2468
+ this.__wbg_ptr = 0;
2469
+ WasmTropicalNumberFinalization.unregister(this);
2470
+ return ptr;
2471
+ }
2472
+
2473
+ free() {
2474
+ const ptr = this.__destroy_into_raw();
2475
+ wasm.__wbg_wasmtropicalnumber_free(ptr, 0);
302
2476
  }
303
2477
  /**
304
- * Get coefficients as a Float64Array
305
- * @returns {Float64Array}
2478
+ * Check if this is infinite
2479
+ * @returns {boolean}
306
2480
  */
307
- getCoefficients() {
308
- const ret = wasm.wasmmultivector_getCoefficients(this.__wbg_ptr);
309
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
310
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
311
- return v1;
2481
+ isInfinity() {
2482
+ const ret = wasm.wasmtropicalnumber_isInfinity(this.__wbg_ptr);
2483
+ return ret !== 0;
312
2484
  }
313
2485
  /**
314
- * Grade projection
315
- * @param {number} grade
316
- * @returns {WasmMultivector}
2486
+ * Tropical addition (max operation)
2487
+ * @param {WasmTropicalNumber} other
2488
+ * @returns {WasmTropicalNumber}
317
2489
  */
318
- gradeProjection(grade) {
319
- const ret = wasm.wasmmultivector_gradeProjection(this.__wbg_ptr, grade);
320
- return WasmMultivector.__wrap(ret);
2490
+ tropicalAdd(other) {
2491
+ _assertClass(other, WasmTropicalNumber);
2492
+ const ret = wasm.wasmtropicalnumber_add(this.__wbg_ptr, other.__wbg_ptr);
2493
+ return WasmTropicalNumber.__wrap(ret);
321
2494
  }
322
2495
  /**
323
- * Create from a Float64Array of coefficients
324
- * @param {Float64Array} coefficients
325
- * @returns {WasmMultivector}
2496
+ * Tropical multiplication (addition)
2497
+ * @param {WasmTropicalNumber} other
2498
+ * @returns {WasmTropicalNumber}
326
2499
  */
327
- static fromCoefficients(coefficients) {
328
- const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
329
- const len0 = WASM_VECTOR_LEN;
330
- const ret = wasm.wasmmultivector_fromCoefficients(ptr0, len0);
331
- if (ret[2]) {
332
- throw takeFromExternrefTable0(ret[1]);
333
- }
334
- return WasmMultivector.__wrap(ret[0]);
2500
+ tropicalMul(other) {
2501
+ _assertClass(other, WasmTropicalNumber);
2502
+ const ret = wasm.wasmtropicalnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
2503
+ return WasmTropicalNumber.__wrap(ret);
335
2504
  }
336
2505
  /**
337
- * Geometric product
338
- * @param {WasmMultivector} other
339
- * @returns {WasmMultivector}
2506
+ * Tropical power (scalar multiplication)
2507
+ * @param {number} n
2508
+ * @returns {WasmTropicalNumber}
340
2509
  */
341
- geometricProduct(other) {
342
- _assertClass(other, WasmMultivector);
343
- const ret = wasm.wasmmultivector_geometricProduct(this.__wbg_ptr, other.__wbg_ptr);
344
- return WasmMultivector.__wrap(ret);
2510
+ tropicalPow(n) {
2511
+ const ret = wasm.wasmtropicalnumber_tropicalPow(this.__wbg_ptr, n);
2512
+ return WasmTropicalNumber.__wrap(ret);
345
2513
  }
346
2514
  /**
347
- * Add two multivectors
348
- * @param {WasmMultivector} other
349
- * @returns {WasmMultivector}
2515
+ * Create from log probability
2516
+ * @param {number} log_p
2517
+ * @returns {WasmTropicalNumber}
350
2518
  */
351
- add(other) {
352
- _assertClass(other, WasmMultivector);
353
- const ret = wasm.wasmmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
354
- return WasmMultivector.__wrap(ret);
2519
+ static fromLogProb(log_p) {
2520
+ const ret = wasm.wasmtropicalnumber_fromLogProb(log_p);
2521
+ return WasmTropicalNumber.__wrap(ret);
355
2522
  }
356
2523
  /**
357
- * Exponential (for bivectors to create rotors)
358
- * @returns {WasmMultivector}
2524
+ * Standard addition (for convenience)
2525
+ * @param {WasmTropicalNumber} other
2526
+ * @returns {WasmTropicalNumber}
359
2527
  */
360
- exp() {
361
- const ret = wasm.wasmmultivector_exp(this.__wbg_ptr);
362
- return WasmMultivector.__wrap(ret);
2528
+ add(other) {
2529
+ _assertClass(other, WasmTropicalNumber);
2530
+ const ret = wasm.wasmtropicalnumber_add(this.__wbg_ptr, other.__wbg_ptr);
2531
+ return WasmTropicalNumber.__wrap(ret);
363
2532
  }
364
2533
  /**
365
- * Create a new zero multivector
2534
+ * Standard multiplication (for convenience)
2535
+ * @param {WasmTropicalNumber} other
2536
+ * @returns {WasmTropicalNumber}
366
2537
  */
367
- constructor() {
368
- const ret = wasm.wasmmultivector_new();
369
- this.__wbg_ptr = ret >>> 0;
370
- WasmMultivectorFinalization.register(this, this.__wbg_ptr, this);
371
- return this;
2538
+ mul(other) {
2539
+ _assertClass(other, WasmTropicalNumber);
2540
+ const ret = wasm.wasmtropicalnumber_mul(this.__wbg_ptr, other.__wbg_ptr);
2541
+ return WasmTropicalNumber.__wrap(ret);
372
2542
  }
373
2543
  /**
374
- * Subtract two multivectors
375
- * @param {WasmMultivector} other
376
- * @returns {WasmMultivector}
2544
+ * Negation
2545
+ * @returns {WasmTropicalNumber}
377
2546
  */
378
- sub(other) {
379
- _assertClass(other, WasmMultivector);
380
- const ret = wasm.wasmmultivector_sub(this.__wbg_ptr, other.__wbg_ptr);
381
- return WasmMultivector.__wrap(ret);
2547
+ neg() {
2548
+ const ret = wasm.wasmtropicalnumber_neg(this.__wbg_ptr);
2549
+ return WasmTropicalNumber.__wrap(ret);
382
2550
  }
383
2551
  /**
384
- * Compute norm (alias for magnitude, maintained for compatibility)
385
- * @returns {number}
2552
+ * Create a new tropical number from a regular number
2553
+ * @param {number} value
386
2554
  */
387
- norm() {
388
- const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
389
- return ret;
2555
+ constructor(value) {
2556
+ const ret = wasm.wasmtropicalnumber_fromLogProb(value);
2557
+ this.__wbg_ptr = ret >>> 0;
2558
+ WasmTropicalNumberFinalization.register(this, this.__wbg_ptr, this);
2559
+ return this;
390
2560
  }
391
2561
  /**
392
- * Scale by a scalar
393
- * @param {number} scalar
394
- * @returns {WasmMultivector}
2562
+ * Create tropical one (regular zero)
2563
+ * @returns {WasmTropicalNumber}
395
2564
  */
396
- scale(scalar) {
397
- const ret = wasm.wasmmultivector_scale(this.__wbg_ptr, scalar);
398
- return WasmMultivector.__wrap(ret);
2565
+ static one() {
2566
+ const ret = wasm.wasmtropicalnumber_one();
2567
+ return WasmTropicalNumber.__wrap(ret);
399
2568
  }
400
2569
  /**
401
- * Create a scalar multivector
402
- * @param {number} value
403
- * @returns {WasmMultivector}
2570
+ * Create tropical zero (negative infinity)
2571
+ * @returns {WasmTropicalNumber}
404
2572
  */
405
- static scalar(value) {
406
- const ret = wasm.wasmmultivector_scalar(value);
407
- return WasmMultivector.__wrap(ret);
2573
+ static zero() {
2574
+ const ret = wasm.wasmtropicalnumber_zero();
2575
+ return WasmTropicalNumber.__wrap(ret);
408
2576
  }
409
2577
  /**
410
- * Compute inverse
411
- * @returns {WasmMultivector}
2578
+ * Check if this is tropical one (zero)
2579
+ * @returns {boolean}
412
2580
  */
413
- inverse() {
414
- const ret = wasm.wasmmultivector_inverse(this.__wbg_ptr);
415
- if (ret[2]) {
416
- throw takeFromExternrefTable0(ret[1]);
417
- }
418
- return WasmMultivector.__wrap(ret[0]);
2581
+ isOne() {
2582
+ const ret = wasm.wasmtropicalnumber_isOne(this.__wbg_ptr);
2583
+ return ret !== 0;
419
2584
  }
420
2585
  /**
421
- * Reverse
422
- * @returns {WasmMultivector}
2586
+ * Check if this is tropical zero (negative infinity)
2587
+ * @returns {boolean}
423
2588
  */
424
- reverse() {
425
- const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
426
- return WasmMultivector.__wrap(ret);
2589
+ isZero() {
2590
+ const ret = wasm.wasmtropicalnumber_isZero(this.__wbg_ptr);
2591
+ return ret !== 0;
427
2592
  }
428
2593
  /**
429
- * Compute magnitude
2594
+ * Convert to probability (via exp)
430
2595
  * @returns {number}
431
2596
  */
432
- magnitude() {
433
- const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
2597
+ toProb() {
2598
+ const ret = wasm.wasmtropicalnumber_toProb(this.__wbg_ptr);
434
2599
  return ret;
435
2600
  }
436
2601
  /**
437
- * Normalize
438
- * @returns {WasmMultivector}
2602
+ * Get the underlying value
2603
+ * @returns {number}
439
2604
  */
440
- normalize() {
441
- const ret = wasm.wasmmultivector_normalize(this.__wbg_ptr);
442
- if (ret[2]) {
443
- throw takeFromExternrefTable0(ret[1]);
444
- }
445
- return WasmMultivector.__wrap(ret[0]);
2605
+ getValue() {
2606
+ const ret = wasm.wasmdualnumber_getReal(this.__wbg_ptr);
2607
+ return ret;
446
2608
  }
447
2609
  }
448
- if (Symbol.dispose) WasmMultivector.prototype[Symbol.dispose] = WasmMultivector.prototype.free;
2610
+ if (Symbol.dispose) WasmTropicalNumber.prototype[Symbol.dispose] = WasmTropicalNumber.prototype.free;
449
2611
 
450
- const WasmRotorFinalization = (typeof FinalizationRegistry === 'undefined')
2612
+ const WasmTropicalPolynomialFinalization = (typeof FinalizationRegistry === 'undefined')
451
2613
  ? { register: () => {}, unregister: () => {} }
452
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmrotor_free(ptr >>> 0, 1));
2614
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalpolynomial_free(ptr >>> 0, 1));
453
2615
  /**
454
- * Rotor operations for WASM
2616
+ * WASM wrapper for TropicalPolynomial - polynomial operations in tropical algebra
455
2617
  */
456
- export class WasmRotor {
457
-
458
- static __wrap(ptr) {
459
- ptr = ptr >>> 0;
460
- const obj = Object.create(WasmRotor.prototype);
461
- obj.__wbg_ptr = ptr;
462
- WasmRotorFinalization.register(obj, obj.__wbg_ptr, obj);
463
- return obj;
464
- }
2618
+ export class WasmTropicalPolynomial {
465
2619
 
466
2620
  __destroy_into_raw() {
467
2621
  const ptr = this.__wbg_ptr;
468
2622
  this.__wbg_ptr = 0;
469
- WasmRotorFinalization.unregister(this);
2623
+ WasmTropicalPolynomialFinalization.unregister(this);
470
2624
  return ptr;
471
2625
  }
472
2626
 
473
2627
  free() {
474
2628
  const ptr = this.__destroy_into_raw();
475
- wasm.__wbg_wasmrotor_free(ptr, 0);
2629
+ wasm.__wbg_wasmtropicalpolynomial_free(ptr, 0);
476
2630
  }
477
2631
  /**
478
- * Create a rotor from a bivector and angle
479
- * @param {WasmMultivector} bivector
480
- * @param {number} angle
481
- * @returns {WasmRotor}
2632
+ * Find tropical roots of the polynomial
2633
+ * @returns {Array<any>}
482
2634
  */
483
- static fromBivector(bivector, angle) {
484
- _assertClass(bivector, WasmMultivector);
485
- const ret = wasm.wasmrotor_fromBivector(bivector.__wbg_ptr, angle);
486
- return WasmRotor.__wrap(ret);
2635
+ tropical_roots() {
2636
+ const ret = wasm.wasmtropicalpolynomial_tropical_roots(this.__wbg_ptr);
2637
+ return ret;
487
2638
  }
488
2639
  /**
489
- * Apply rotor to a multivector
490
- * @param {WasmMultivector} mv
491
- * @returns {WasmMultivector}
2640
+ * Get the number of coefficients
2641
+ * @returns {number}
492
2642
  */
493
- apply(mv) {
494
- _assertClass(mv, WasmMultivector);
495
- const ret = wasm.wasmrotor_apply(this.__wbg_ptr, mv.__wbg_ptr);
496
- return WasmMultivector.__wrap(ret);
2643
+ coefficients_count() {
2644
+ const ret = wasm.wasmtropicalpolynomial_coefficients_count(this.__wbg_ptr);
2645
+ return ret >>> 0;
497
2646
  }
498
2647
  /**
499
- * Compose two rotors
500
- * @param {WasmRotor} other
501
- * @returns {WasmRotor}
2648
+ * Create a new tropical polynomial from coefficients
2649
+ * @param {Float64Array} coefficients
502
2650
  */
503
- compose(other) {
504
- _assertClass(other, WasmRotor);
505
- const ret = wasm.wasmrotor_compose(this.__wbg_ptr, other.__wbg_ptr);
506
- return WasmRotor.__wrap(ret);
2651
+ constructor(coefficients) {
2652
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
2653
+ const len0 = WASM_VECTOR_LEN;
2654
+ const ret = wasm.wasmtropicalpolynomial_new(ptr0, len0);
2655
+ this.__wbg_ptr = ret >>> 0;
2656
+ WasmTropicalPolynomialFinalization.register(this, this.__wbg_ptr, this);
2657
+ return this;
507
2658
  }
508
2659
  /**
509
- * Get inverse rotor
510
- * @returns {WasmRotor}
2660
+ * Evaluate the polynomial at a given tropical number
2661
+ * @param {WasmTropicalNumber} x
2662
+ * @returns {WasmTropicalNumber}
511
2663
  */
512
- inverse() {
513
- const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
514
- return WasmRotor.__wrap(ret);
2664
+ evaluate(x) {
2665
+ _assertClass(x, WasmTropicalNumber);
2666
+ const ret = wasm.wasmtropicalpolynomial_evaluate(this.__wbg_ptr, x.__wbg_ptr);
2667
+ return WasmTropicalNumber.__wrap(ret);
515
2668
  }
516
2669
  }
517
- if (Symbol.dispose) WasmRotor.prototype[Symbol.dispose] = WasmRotor.prototype.free;
2670
+ if (Symbol.dispose) WasmTropicalPolynomial.prototype[Symbol.dispose] = WasmTropicalPolynomial.prototype.free;
2671
+
2672
+ const WasmTropicalViterbiFinalization = (typeof FinalizationRegistry === 'undefined')
2673
+ ? { register: () => {}, unregister: () => {} }
2674
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtropicalviterbi_free(ptr >>> 0, 1));
2675
+ /**
2676
+ * WASM wrapper for TropicalViterbi - Hidden Markov Model decoding
2677
+ */
2678
+ export class WasmTropicalViterbi {
2679
+
2680
+ __destroy_into_raw() {
2681
+ const ptr = this.__wbg_ptr;
2682
+ this.__wbg_ptr = 0;
2683
+ WasmTropicalViterbiFinalization.unregister(this);
2684
+ return ptr;
2685
+ }
2686
+
2687
+ free() {
2688
+ const ptr = this.__destroy_into_raw();
2689
+ wasm.__wbg_wasmtropicalviterbi_free(ptr, 0);
2690
+ }
2691
+ /**
2692
+ * Compute forward probabilities for all states
2693
+ * @param {Uint32Array} observations
2694
+ * @returns {Array<any>}
2695
+ */
2696
+ forward_probabilities(observations) {
2697
+ const ptr0 = passArray32ToWasm0(observations, wasm.__wbindgen_malloc);
2698
+ const len0 = WASM_VECTOR_LEN;
2699
+ const ret = wasm.wasmtropicalviterbi_forward_probabilities(this.__wbg_ptr, ptr0, len0);
2700
+ if (ret[2]) {
2701
+ throw takeFromExternrefTable0(ret[1]);
2702
+ }
2703
+ return takeFromExternrefTable0(ret[0]);
2704
+ }
2705
+ /**
2706
+ * Create a new Viterbi decoder
2707
+ *
2708
+ * # Arguments
2709
+ * * `transitions` - Transition probability matrix (2D array)
2710
+ * * `emissions` - Emission probability matrix (2D array)
2711
+ * @param {any} transitions
2712
+ * @param {any} emissions
2713
+ */
2714
+ constructor(transitions, emissions) {
2715
+ const ret = wasm.wasmtropicalviterbi_new(transitions, emissions);
2716
+ if (ret[2]) {
2717
+ throw takeFromExternrefTable0(ret[1]);
2718
+ }
2719
+ this.__wbg_ptr = ret[0] >>> 0;
2720
+ WasmTropicalViterbiFinalization.register(this, this.__wbg_ptr, this);
2721
+ return this;
2722
+ }
2723
+ /**
2724
+ * Decode the most likely state sequence for given observations
2725
+ *
2726
+ * Returns an object with `states` (array of state indices) and `probability` (log probability)
2727
+ * @param {Uint32Array} observations
2728
+ * @returns {any}
2729
+ */
2730
+ decode(observations) {
2731
+ const ptr0 = passArray32ToWasm0(observations, wasm.__wbindgen_malloc);
2732
+ const len0 = WASM_VECTOR_LEN;
2733
+ const ret = wasm.wasmtropicalviterbi_decode(this.__wbg_ptr, ptr0, len0);
2734
+ if (ret[2]) {
2735
+ throw takeFromExternrefTable0(ret[1]);
2736
+ }
2737
+ return takeFromExternrefTable0(ret[0]);
2738
+ }
2739
+ }
2740
+ if (Symbol.dispose) WasmTropicalViterbi.prototype[Symbol.dispose] = WasmTropicalViterbi.prototype.free;
518
2741
 
519
2742
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
520
2743
 
@@ -554,9 +2777,62 @@ async function __wbg_load(module, imports) {
554
2777
  function __wbg_get_imports() {
555
2778
  const imports = {};
556
2779
  imports.wbg = {};
557
- imports.wbg.__wbg_log_fb67a0d730fc146e = function(arg0, arg1) {
2780
+ imports.wbg.__wbg_apply_dc50eb58583d2a57 = function() { return handleError(function (arg0, arg1, arg2) {
2781
+ const ret = arg0.apply(arg1, arg2);
2782
+ return ret;
2783
+ }, arguments) };
2784
+ imports.wbg.__wbg_from_88bc52ce20ba6318 = function(arg0) {
2785
+ const ret = Array.from(arg0);
2786
+ return ret;
2787
+ };
2788
+ imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
2789
+ const ret = arg0[arg1 >>> 0];
2790
+ return ret;
2791
+ };
2792
+ imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
2793
+ const ret = arg0.length;
2794
+ return ret;
2795
+ };
2796
+ imports.wbg.__wbg_log_c123554c5b238740 = function(arg0, arg1) {
558
2797
  console.log(getStringFromWasm0(arg0, arg1));
559
2798
  };
2799
+ imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
2800
+ const ret = new Object();
2801
+ return ret;
2802
+ };
2803
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
2804
+ const ret = new Array();
2805
+ return ret;
2806
+ };
2807
+ imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
2808
+ const ret = arg0.push(arg1);
2809
+ return ret;
2810
+ };
2811
+ imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
2812
+ const ret = Reflect.set(arg0, arg1, arg2);
2813
+ return ret;
2814
+ }, arguments) };
2815
+ imports.wbg.__wbg_wasmspacetimevector_new = function(arg0) {
2816
+ const ret = WasmSpacetimeVector.__wrap(arg0);
2817
+ return ret;
2818
+ };
2819
+ imports.wbg.__wbg_wasmtropicalnumber_new = function(arg0) {
2820
+ const ret = WasmTropicalNumber.__wrap(arg0);
2821
+ return ret;
2822
+ };
2823
+ imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
2824
+ const ret = debugString(arg1);
2825
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2826
+ const len1 = WASM_VECTOR_LEN;
2827
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2828
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2829
+ };
2830
+ imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
2831
+ const obj = arg1;
2832
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2833
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2834
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2835
+ };
560
2836
  imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
561
2837
  throw new Error(getStringFromWasm0(arg0, arg1));
562
2838
  };
@@ -565,8 +2841,13 @@ function __wbg_get_imports() {
565
2841
  const ret = getStringFromWasm0(arg0, arg1);
566
2842
  return ret;
567
2843
  };
2844
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
2845
+ // Cast intrinsic for `F64 -> Externref`.
2846
+ const ret = arg0;
2847
+ return ret;
2848
+ };
568
2849
  imports.wbg.__wbindgen_init_externref_table = function() {
569
- const table = wasm.__wbindgen_export_0;
2850
+ const table = wasm.__wbindgen_export_2;
570
2851
  const offset = table.grow(4);
571
2852
  table.set(0, undefined);
572
2853
  table.set(offset + 0, undefined);
@@ -586,7 +2867,9 @@ function __wbg_init_memory(imports, memory) {
586
2867
  function __wbg_finalize_init(instance, module) {
587
2868
  wasm = instance.exports;
588
2869
  __wbg_init.__wbindgen_wasm_module = module;
2870
+ cachedDataViewMemory0 = null;
589
2871
  cachedFloat64ArrayMemory0 = null;
2872
+ cachedUint32ArrayMemory0 = null;
590
2873
  cachedUint8ArrayMemory0 = null;
591
2874
 
592
2875