@justinelliottcobb/amari-wasm 0.9.1 → 0.9.2

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
@@ -30,6 +30,206 @@ function getStringFromWasm0(ptr, len) {
30
30
  return decodeText(ptr, len);
31
31
  }
32
32
 
33
+ function addToExternrefTable0(obj) {
34
+ const idx = wasm.__externref_table_alloc();
35
+ wasm.__wbindgen_export_2.set(idx, obj);
36
+ return idx;
37
+ }
38
+
39
+ function handleError(f, args) {
40
+ try {
41
+ return f.apply(this, args);
42
+ } catch (e) {
43
+ const idx = addToExternrefTable0(e);
44
+ wasm.__wbindgen_exn_store(idx);
45
+ }
46
+ }
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 takeFromExternrefTable0(idx) {
177
+ const value = wasm.__wbindgen_export_2.get(idx);
178
+ wasm.__externref_table_dealloc(idx);
179
+ return value;
180
+ }
181
+
182
+ function _assertClass(instance, klass) {
183
+ if (!(instance instanceof klass)) {
184
+ throw new Error(`expected instance of ${klass.name}`);
185
+ }
186
+ }
187
+ /**
188
+ * Convert Lorentz factor to velocity
189
+ * @param {number} gamma
190
+ * @returns {number}
191
+ */
192
+ export function gamma_to_velocity(gamma) {
193
+ const ret = wasm.gamma_to_velocity(gamma);
194
+ if (ret[2]) {
195
+ throw takeFromExternrefTable0(ret[1]);
196
+ }
197
+ return ret[0];
198
+ }
199
+
200
+ /**
201
+ * Convert velocity to Lorentz factor
202
+ * @param {number} velocity_magnitude
203
+ * @returns {number}
204
+ */
205
+ export function velocity_to_gamma(velocity_magnitude) {
206
+ const ret = wasm.velocity_to_gamma(velocity_magnitude);
207
+ if (ret[2]) {
208
+ throw takeFromExternrefTable0(ret[1]);
209
+ }
210
+ return ret[0];
211
+ }
212
+
213
+ /**
214
+ * Calculate light deflection angle for photon grazing massive object
215
+ * @param {number} impact_parameter
216
+ * @param {number} mass
217
+ * @returns {number}
218
+ */
219
+ export function light_deflection_angle(impact_parameter, mass) {
220
+ const ret = wasm.light_deflection_angle(impact_parameter, mass);
221
+ return ret;
222
+ }
223
+
224
+ /**
225
+ * Validate that this module loaded correctly
226
+ * @returns {boolean}
227
+ */
228
+ export function validate_relativistic_module() {
229
+ const ret = wasm.validate_relativistic_module();
230
+ return ret !== 0;
231
+ }
232
+
33
233
  let cachedFloat64ArrayMemory0 = null;
34
234
 
35
235
  function getFloat64ArrayMemory0() {
@@ -39,8 +239,6 @@ function getFloat64ArrayMemory0() {
39
239
  return cachedFloat64ArrayMemory0;
40
240
  }
41
241
 
42
- let WASM_VECTOR_LEN = 0;
43
-
44
242
  function passArrayF64ToWasm0(arg, malloc) {
45
243
  const ptr = malloc(arg.length * 8, 8) >>> 0;
46
244
  getFloat64ArrayMemory0().set(arg, ptr / 8);
@@ -48,22 +246,10 @@ function passArrayF64ToWasm0(arg, malloc) {
48
246
  return ptr;
49
247
  }
50
248
 
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
249
  function getArrayF64FromWasm0(ptr, len) {
58
250
  ptr = ptr >>> 0;
59
251
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
60
252
  }
61
-
62
- function _assertClass(instance, klass) {
63
- if (!(instance instanceof klass)) {
64
- throw new Error(`expected instance of ${klass.name}`);
65
- }
66
- }
67
253
  /**
68
254
  * Initialize the WASM module
69
255
  */
@@ -71,6 +257,20 @@ export function init() {
71
257
  wasm.init();
72
258
  }
73
259
 
260
+ let cachedUint32ArrayMemory0 = null;
261
+
262
+ function getUint32ArrayMemory0() {
263
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
264
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
265
+ }
266
+ return cachedUint32ArrayMemory0;
267
+ }
268
+
269
+ function getArrayU32FromWasm0(ptr, len) {
270
+ ptr = ptr >>> 0;
271
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
272
+ }
273
+
74
274
  const BatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
75
275
  ? { register: () => {}, unregister: () => {} }
76
276
  : new FinalizationRegistry(ptr => wasm.__wbg_batchoperations_free(ptr >>> 0, 1));
@@ -132,6 +332,64 @@ export class BatchOperations {
132
332
  }
133
333
  if (Symbol.dispose) BatchOperations.prototype[Symbol.dispose] = BatchOperations.prototype.free;
134
334
 
335
+ const NetworkBatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
336
+ ? { register: () => {}, unregister: () => {} }
337
+ : new FinalizationRegistry(ptr => wasm.__wbg_networkbatchoperations_free(ptr >>> 0, 1));
338
+ /**
339
+ * Batch network operations for performance
340
+ */
341
+ export class NetworkBatchOperations {
342
+
343
+ __destroy_into_raw() {
344
+ const ptr = this.__wbg_ptr;
345
+ this.__wbg_ptr = 0;
346
+ NetworkBatchOperationsFinalization.unregister(this);
347
+ return ptr;
348
+ }
349
+
350
+ free() {
351
+ const ptr = this.__destroy_into_raw();
352
+ wasm.__wbg_networkbatchoperations_free(ptr, 0);
353
+ }
354
+ /**
355
+ * Fast geometric clustering using k-means in 3D space
356
+ * @param {Float64Array} positions
357
+ * @param {number} num_nodes
358
+ * @param {number} k
359
+ * @param {number} max_iterations
360
+ * @returns {Uint32Array}
361
+ */
362
+ static geometricKMeansClustering(positions, num_nodes, k, max_iterations) {
363
+ const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
364
+ const len0 = WASM_VECTOR_LEN;
365
+ const ret = wasm.networkbatchoperations_geometricKMeansClustering(ptr0, len0, num_nodes, k, max_iterations);
366
+ if (ret[3]) {
367
+ throw takeFromExternrefTable0(ret[2]);
368
+ }
369
+ var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
370
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
371
+ return v2;
372
+ }
373
+ /**
374
+ * Compute all pairwise distances in a network
375
+ * @param {Float64Array} positions
376
+ * @param {number} num_nodes
377
+ * @returns {Float64Array}
378
+ */
379
+ static computeAllPairwiseDistances(positions, num_nodes) {
380
+ const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
381
+ const len0 = WASM_VECTOR_LEN;
382
+ const ret = wasm.networkbatchoperations_computeAllPairwiseDistances(ptr0, len0, num_nodes);
383
+ if (ret[3]) {
384
+ throw takeFromExternrefTable0(ret[2]);
385
+ }
386
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
387
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
388
+ return v2;
389
+ }
390
+ }
391
+ if (Symbol.dispose) NetworkBatchOperations.prototype[Symbol.dispose] = NetworkBatchOperations.prototype.free;
392
+
135
393
  const PerformanceOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
136
394
  ? { register: () => {}, unregister: () => {} }
137
395
  : new FinalizationRegistry(ptr => wasm.__wbg_performanceoperations_free(ptr >>> 0, 1));
@@ -214,155 +472,513 @@ export class PerformanceOperations {
214
472
  }
215
473
  if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
216
474
 
217
- const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
475
+ const WasmFourVelocityFinalization = (typeof FinalizationRegistry === 'undefined')
218
476
  ? { register: () => {}, unregister: () => {} }
219
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
477
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmfourvelocity_free(ptr >>> 0, 1));
220
478
  /**
221
- * WASM wrapper for Multivector with TypedArray support
479
+ * WASM wrapper for four-velocity
222
480
  */
223
- export class WasmMultivector {
481
+ export class WasmFourVelocity {
224
482
 
225
483
  static __wrap(ptr) {
226
484
  ptr = ptr >>> 0;
227
- const obj = Object.create(WasmMultivector.prototype);
485
+ const obj = Object.create(WasmFourVelocity.prototype);
228
486
  obj.__wbg_ptr = ptr;
229
- WasmMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
487
+ WasmFourVelocityFinalization.register(obj, obj.__wbg_ptr, obj);
230
488
  return obj;
231
489
  }
232
490
 
233
491
  __destroy_into_raw() {
234
492
  const ptr = this.__wbg_ptr;
235
493
  this.__wbg_ptr = 0;
236
- WasmMultivectorFinalization.unregister(this);
494
+ WasmFourVelocityFinalization.unregister(this);
237
495
  return ptr;
238
496
  }
239
497
 
240
498
  free() {
241
499
  const ptr = this.__destroy_into_raw();
242
- wasm.__wbg_wasmmultivector_free(ptr, 0);
500
+ wasm.__wbg_wasmfourvelocity_free(ptr, 0);
243
501
  }
244
502
  /**
245
- * Create a basis vector (0-indexed)
246
- * @param {number} index
247
- * @returns {WasmMultivector}
503
+ * Create four-velocity from 3-velocity components
504
+ * @param {number} vx
505
+ * @param {number} vy
506
+ * @param {number} vz
507
+ * @returns {WasmFourVelocity}
248
508
  */
249
- static basisVector(index) {
250
- const ret = wasm.wasmmultivector_basisVector(index);
509
+ static from_velocity(vx, vy, vz) {
510
+ const ret = wasm.wasmfourvelocity_from_velocity(vx, vy, vz);
251
511
  if (ret[2]) {
252
512
  throw takeFromExternrefTable0(ret[1]);
253
513
  }
254
- return WasmMultivector.__wrap(ret[0]);
514
+ return WasmFourVelocity.__wrap(ret[0]);
255
515
  }
256
516
  /**
257
- * Inner product (dot product for vectors)
258
- * @param {WasmMultivector} other
259
- * @returns {WasmMultivector}
517
+ * Check if normalized (u·u = )
518
+ * @returns {boolean}
260
519
  */
261
- innerProduct(other) {
262
- _assertClass(other, WasmMultivector);
263
- const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
264
- return WasmMultivector.__wrap(ret);
520
+ is_normalized() {
521
+ const ret = wasm.wasmfourvelocity_is_normalized(this.__wbg_ptr);
522
+ return ret !== 0;
265
523
  }
266
524
  /**
267
- * Outer product (wedge product)
268
- * @param {WasmMultivector} other
269
- * @returns {WasmMultivector}
525
+ * Get as spacetime vector
526
+ * @returns {WasmSpacetimeVector}
270
527
  */
271
- outerProduct(other) {
272
- _assertClass(other, WasmMultivector);
273
- const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
274
- return WasmMultivector.__wrap(ret);
528
+ as_spacetime_vector() {
529
+ const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
530
+ return WasmSpacetimeVector.__wrap(ret);
275
531
  }
276
532
  /**
277
- * Scalar product
278
- * @param {WasmMultivector} other
533
+ * Get spatial velocity magnitude
279
534
  * @returns {number}
280
535
  */
281
- scalarProduct(other) {
282
- _assertClass(other, WasmMultivector);
283
- const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
536
+ spatial_velocity_magnitude() {
537
+ const ret = wasm.wasmfourvelocity_spatial_velocity_magnitude(this.__wbg_ptr);
284
538
  return ret;
285
539
  }
286
540
  /**
287
- * Get a specific coefficient
288
- * @param {number} index
541
+ * Get Lorentz factor γ
289
542
  * @returns {number}
290
543
  */
291
- getCoefficient(index) {
292
- const ret = wasm.wasmmultivector_getCoefficient(this.__wbg_ptr, index);
544
+ gamma() {
545
+ const ret = wasm.wasmfourvelocity_gamma(this.__wbg_ptr);
293
546
  return ret;
294
547
  }
295
548
  /**
296
- * Set a specific coefficient
297
- * @param {number} index
298
- * @param {number} value
549
+ * Get rapidity
550
+ * @returns {number}
299
551
  */
300
- setCoefficient(index, value) {
301
- wasm.wasmmultivector_setCoefficient(this.__wbg_ptr, index, value);
552
+ rapidity() {
553
+ const ret = wasm.wasmfourvelocity_rapidity(this.__wbg_ptr);
554
+ return ret;
302
555
  }
303
556
  /**
304
- * Get coefficients as a Float64Array
305
- * @returns {Float64Array}
557
+ * Get string representation
558
+ * @returns {string}
306
559
  */
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;
560
+ to_string() {
561
+ let deferred1_0;
562
+ let deferred1_1;
563
+ try {
564
+ const ret = wasm.wasmfourvelocity_to_string(this.__wbg_ptr);
565
+ deferred1_0 = ret[0];
566
+ deferred1_1 = ret[1];
567
+ return getStringFromWasm0(ret[0], ret[1]);
568
+ } finally {
569
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
570
+ }
312
571
  }
313
- /**
314
- * Grade projection
315
- * @param {number} grade
316
- * @returns {WasmMultivector}
317
- */
318
- gradeProjection(grade) {
319
- const ret = wasm.wasmmultivector_gradeProjection(this.__wbg_ptr, grade);
320
- return WasmMultivector.__wrap(ret);
572
+ }
573
+ if (Symbol.dispose) WasmFourVelocity.prototype[Symbol.dispose] = WasmFourVelocity.prototype.free;
574
+
575
+ const WasmGeodesicIntegratorFinalization = (typeof FinalizationRegistry === 'undefined')
576
+ ? { register: () => {}, unregister: () => {} }
577
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgeodesicintegrator_free(ptr >>> 0, 1));
578
+ /**
579
+ * WASM wrapper for geodesic integration
580
+ */
581
+ export class WasmGeodesicIntegrator {
582
+
583
+ static __wrap(ptr) {
584
+ ptr = ptr >>> 0;
585
+ const obj = Object.create(WasmGeodesicIntegrator.prototype);
586
+ obj.__wbg_ptr = ptr;
587
+ WasmGeodesicIntegratorFinalization.register(obj, obj.__wbg_ptr, obj);
588
+ return obj;
589
+ }
590
+
591
+ __destroy_into_raw() {
592
+ const ptr = this.__wbg_ptr;
593
+ this.__wbg_ptr = 0;
594
+ WasmGeodesicIntegratorFinalization.unregister(this);
595
+ return ptr;
596
+ }
597
+
598
+ free() {
599
+ const ptr = this.__destroy_into_raw();
600
+ wasm.__wbg_wasmgeodesicintegrator_free(ptr, 0);
321
601
  }
322
602
  /**
323
- * Create from a Float64Array of coefficients
324
- * @param {Float64Array} coefficients
325
- * @returns {WasmMultivector}
603
+ * Propagate particle through spacetime
604
+ * @param {WasmRelativisticParticle} particle
605
+ * @param {number} integration_time
606
+ * @param {number} time_step
607
+ * @returns {Array<any>}
326
608
  */
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);
609
+ propagate_particle(particle, integration_time, time_step) {
610
+ _assertClass(particle, WasmRelativisticParticle);
611
+ const ret = wasm.wasmgeodesicintegrator_propagate_particle(this.__wbg_ptr, particle.__wbg_ptr, integration_time, time_step);
331
612
  if (ret[2]) {
332
613
  throw takeFromExternrefTable0(ret[1]);
333
614
  }
334
- return WasmMultivector.__wrap(ret[0]);
615
+ return takeFromExternrefTable0(ret[0]);
335
616
  }
336
617
  /**
337
- * Geometric product
338
- * @param {WasmMultivector} other
339
- * @returns {WasmMultivector}
618
+ * Create integrator with Schwarzschild metric
619
+ * @param {WasmSchwarzschildMetric} metric
620
+ * @returns {WasmGeodesicIntegrator}
340
621
  */
341
- geometricProduct(other) {
342
- _assertClass(other, WasmMultivector);
343
- const ret = wasm.wasmmultivector_geometricProduct(this.__wbg_ptr, other.__wbg_ptr);
344
- return WasmMultivector.__wrap(ret);
622
+ static with_schwarzschild(metric) {
623
+ _assertClass(metric, WasmSchwarzschildMetric);
624
+ const ret = wasm.wasmgeodesicintegrator_with_schwarzschild(metric.__wbg_ptr);
625
+ return WasmGeodesicIntegrator.__wrap(ret);
626
+ }
627
+ }
628
+ if (Symbol.dispose) WasmGeodesicIntegrator.prototype[Symbol.dispose] = WasmGeodesicIntegrator.prototype.free;
629
+
630
+ const WasmGeometricNetworkFinalization = (typeof FinalizationRegistry === 'undefined')
631
+ ? { register: () => {}, unregister: () => {} }
632
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgeometricnetwork_free(ptr >>> 0, 1));
633
+ /**
634
+ * WASM wrapper for GeometricNetwork
635
+ */
636
+ export class WasmGeometricNetwork {
637
+
638
+ __destroy_into_raw() {
639
+ const ptr = this.__wbg_ptr;
640
+ this.__wbg_ptr = 0;
641
+ WasmGeometricNetworkFinalization.unregister(this);
642
+ return ptr;
643
+ }
644
+
645
+ free() {
646
+ const ptr = this.__destroy_into_raw();
647
+ wasm.__wbg_wasmgeometricnetwork_free(ptr, 0);
345
648
  }
346
649
  /**
347
- * Add two multivectors
348
- * @param {WasmMultivector} other
349
- * @returns {WasmMultivector}
650
+ * Get degree of a node
651
+ * @param {number} node
652
+ * @returns {number}
350
653
  */
351
- add(other) {
352
- _assertClass(other, WasmMultivector);
353
- const ret = wasm.wasmmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
354
- return WasmMultivector.__wrap(ret);
654
+ getDegree(node) {
655
+ const ret = wasm.wasmgeometricnetwork_getDegree(this.__wbg_ptr, node);
656
+ return ret >>> 0;
355
657
  }
356
658
  /**
357
- * Exponential (for bivectors to create rotors)
358
- * @returns {WasmMultivector}
659
+ * Get neighbors of a node
660
+ * @param {number} node
661
+ * @returns {Uint32Array}
359
662
  */
360
- exp() {
361
- const ret = wasm.wasmmultivector_exp(this.__wbg_ptr);
362
- return WasmMultivector.__wrap(ret);
663
+ getNeighbors(node) {
664
+ const ret = wasm.wasmgeometricnetwork_getNeighbors(this.__wbg_ptr, node);
665
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
666
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
667
+ return v1;
363
668
  }
364
669
  /**
365
- * Create a new zero multivector
670
+ * Find shortest path between two nodes
671
+ * Returns the path as an array of node indices, or null if no path exists
672
+ * @param {number} source
673
+ * @param {number} target
674
+ * @returns {Uint32Array | undefined}
675
+ */
676
+ shortestPath(source, target) {
677
+ const ret = wasm.wasmgeometricnetwork_shortestPath(this.__wbg_ptr, source, target);
678
+ if (ret[3]) {
679
+ throw takeFromExternrefTable0(ret[2]);
680
+ }
681
+ let v1;
682
+ if (ret[0] !== 0) {
683
+ v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
684
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
685
+ }
686
+ return v1;
687
+ }
688
+ /**
689
+ * Add a labeled node
690
+ * @param {number} x
691
+ * @param {number} y
692
+ * @param {number} z
693
+ * @param {string} label
694
+ * @returns {number}
695
+ */
696
+ addLabeledNode(x, y, z, label) {
697
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
698
+ const len0 = WASM_VECTOR_LEN;
699
+ const ret = wasm.wasmgeometricnetwork_addLabeledNode(this.__wbg_ptr, x, y, z, ptr0, len0);
700
+ return ret >>> 0;
701
+ }
702
+ /**
703
+ * Find communities using geometric clustering
704
+ * @param {number} num_communities
705
+ * @returns {Uint32Array}
706
+ */
707
+ findCommunities(num_communities) {
708
+ const ret = wasm.wasmgeometricnetwork_findCommunities(this.__wbg_ptr, num_communities);
709
+ if (ret[3]) {
710
+ throw takeFromExternrefTable0(ret[2]);
711
+ }
712
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
713
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
714
+ return v1;
715
+ }
716
+ /**
717
+ * Get node position as [x, y, z]
718
+ * @param {number} node
719
+ * @returns {Float64Array | undefined}
720
+ */
721
+ getNodePosition(node) {
722
+ const ret = wasm.wasmgeometricnetwork_getNodePosition(this.__wbg_ptr, node);
723
+ let v1;
724
+ if (ret[0] !== 0) {
725
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
726
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
727
+ }
728
+ return v1;
729
+ }
730
+ /**
731
+ * Compute geometric distance between two nodes
732
+ * @param {number} node1
733
+ * @param {number} node2
734
+ * @returns {number}
735
+ */
736
+ geometricDistance(node1, node2) {
737
+ const ret = wasm.wasmgeometricnetwork_geometricDistance(this.__wbg_ptr, node1, node2);
738
+ if (ret[2]) {
739
+ throw takeFromExternrefTable0(ret[1]);
740
+ }
741
+ return ret[0];
742
+ }
743
+ /**
744
+ * Add an undirected edge
745
+ * @param {number} a
746
+ * @param {number} b
747
+ * @param {number} weight
748
+ */
749
+ addUndirectedEdge(a, b, weight) {
750
+ const ret = wasm.wasmgeometricnetwork_addUndirectedEdge(this.__wbg_ptr, a, b, weight);
751
+ if (ret[1]) {
752
+ throw takeFromExternrefTable0(ret[0]);
753
+ }
754
+ }
755
+ /**
756
+ * Find shortest path with distance between two nodes
757
+ * Returns an object with path and distance, or null if no path exists
758
+ * @param {number} source
759
+ * @param {number} target
760
+ * @returns {any}
761
+ */
762
+ shortestPathWithDistance(source, target) {
763
+ const ret = wasm.wasmgeometricnetwork_shortestPathWithDistance(this.__wbg_ptr, source, target);
764
+ if (ret[2]) {
765
+ throw takeFromExternrefTable0(ret[1]);
766
+ }
767
+ return takeFromExternrefTable0(ret[0]);
768
+ }
769
+ /**
770
+ * Compute geometric centrality for all nodes
771
+ * @returns {Float64Array}
772
+ */
773
+ computeGeometricCentrality() {
774
+ const ret = wasm.wasmgeometricnetwork_computeGeometricCentrality(this.__wbg_ptr);
775
+ if (ret[3]) {
776
+ throw takeFromExternrefTable0(ret[2]);
777
+ }
778
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
779
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
780
+ return v1;
781
+ }
782
+ /**
783
+ * Create a new geometric network
784
+ */
785
+ constructor() {
786
+ const ret = wasm.wasmgeometricnetwork_new();
787
+ this.__wbg_ptr = ret >>> 0;
788
+ WasmGeometricNetworkFinalization.register(this, this.__wbg_ptr, this);
789
+ return this;
790
+ }
791
+ /**
792
+ * Add an edge between two nodes
793
+ * @param {number} source
794
+ * @param {number} target
795
+ * @param {number} weight
796
+ */
797
+ addEdge(source, target, weight) {
798
+ const ret = wasm.wasmgeometricnetwork_addEdge(this.__wbg_ptr, source, target, weight);
799
+ if (ret[1]) {
800
+ throw takeFromExternrefTable0(ret[0]);
801
+ }
802
+ }
803
+ /**
804
+ * Add a node at the given position
805
+ * @param {number} x
806
+ * @param {number} y
807
+ * @param {number} z
808
+ * @returns {number}
809
+ */
810
+ addNode(x, y, z) {
811
+ const ret = wasm.wasmgeometricnetwork_addNode(this.__wbg_ptr, x, y, z);
812
+ return ret >>> 0;
813
+ }
814
+ /**
815
+ * Get number of edges
816
+ * @returns {number}
817
+ */
818
+ numEdges() {
819
+ const ret = wasm.wasmgeometricnetwork_numEdges(this.__wbg_ptr);
820
+ return ret >>> 0;
821
+ }
822
+ /**
823
+ * Get number of nodes
824
+ * @returns {number}
825
+ */
826
+ numNodes() {
827
+ const ret = wasm.wasmgeometricnetwork_numNodes(this.__wbg_ptr);
828
+ return ret >>> 0;
829
+ }
830
+ }
831
+ if (Symbol.dispose) WasmGeometricNetwork.prototype[Symbol.dispose] = WasmGeometricNetwork.prototype.free;
832
+
833
+ const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
834
+ ? { register: () => {}, unregister: () => {} }
835
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
836
+ /**
837
+ * WASM wrapper for Multivector with TypedArray support
838
+ */
839
+ export class WasmMultivector {
840
+
841
+ static __wrap(ptr) {
842
+ ptr = ptr >>> 0;
843
+ const obj = Object.create(WasmMultivector.prototype);
844
+ obj.__wbg_ptr = ptr;
845
+ WasmMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
846
+ return obj;
847
+ }
848
+
849
+ __destroy_into_raw() {
850
+ const ptr = this.__wbg_ptr;
851
+ this.__wbg_ptr = 0;
852
+ WasmMultivectorFinalization.unregister(this);
853
+ return ptr;
854
+ }
855
+
856
+ free() {
857
+ const ptr = this.__destroy_into_raw();
858
+ wasm.__wbg_wasmmultivector_free(ptr, 0);
859
+ }
860
+ /**
861
+ * Create a basis vector (0-indexed)
862
+ * @param {number} index
863
+ * @returns {WasmMultivector}
864
+ */
865
+ static basisVector(index) {
866
+ const ret = wasm.wasmmultivector_basisVector(index);
867
+ if (ret[2]) {
868
+ throw takeFromExternrefTable0(ret[1]);
869
+ }
870
+ return WasmMultivector.__wrap(ret[0]);
871
+ }
872
+ /**
873
+ * Inner product (dot product for vectors)
874
+ * @param {WasmMultivector} other
875
+ * @returns {WasmMultivector}
876
+ */
877
+ innerProduct(other) {
878
+ _assertClass(other, WasmMultivector);
879
+ const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
880
+ return WasmMultivector.__wrap(ret);
881
+ }
882
+ /**
883
+ * Outer product (wedge product)
884
+ * @param {WasmMultivector} other
885
+ * @returns {WasmMultivector}
886
+ */
887
+ outerProduct(other) {
888
+ _assertClass(other, WasmMultivector);
889
+ const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
890
+ return WasmMultivector.__wrap(ret);
891
+ }
892
+ /**
893
+ * Scalar product
894
+ * @param {WasmMultivector} other
895
+ * @returns {number}
896
+ */
897
+ scalarProduct(other) {
898
+ _assertClass(other, WasmMultivector);
899
+ const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
900
+ return ret;
901
+ }
902
+ /**
903
+ * Get a specific coefficient
904
+ * @param {number} index
905
+ * @returns {number}
906
+ */
907
+ getCoefficient(index) {
908
+ const ret = wasm.wasmmultivector_getCoefficient(this.__wbg_ptr, index);
909
+ return ret;
910
+ }
911
+ /**
912
+ * Set a specific coefficient
913
+ * @param {number} index
914
+ * @param {number} value
915
+ */
916
+ setCoefficient(index, value) {
917
+ wasm.wasmmultivector_setCoefficient(this.__wbg_ptr, index, value);
918
+ }
919
+ /**
920
+ * Get coefficients as a Float64Array
921
+ * @returns {Float64Array}
922
+ */
923
+ getCoefficients() {
924
+ const ret = wasm.wasmmultivector_getCoefficients(this.__wbg_ptr);
925
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
926
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
927
+ return v1;
928
+ }
929
+ /**
930
+ * Grade projection
931
+ * @param {number} grade
932
+ * @returns {WasmMultivector}
933
+ */
934
+ gradeProjection(grade) {
935
+ const ret = wasm.wasmmultivector_gradeProjection(this.__wbg_ptr, grade);
936
+ return WasmMultivector.__wrap(ret);
937
+ }
938
+ /**
939
+ * Create from a Float64Array of coefficients
940
+ * @param {Float64Array} coefficients
941
+ * @returns {WasmMultivector}
942
+ */
943
+ static fromCoefficients(coefficients) {
944
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
945
+ const len0 = WASM_VECTOR_LEN;
946
+ const ret = wasm.wasmmultivector_fromCoefficients(ptr0, len0);
947
+ if (ret[2]) {
948
+ throw takeFromExternrefTable0(ret[1]);
949
+ }
950
+ return WasmMultivector.__wrap(ret[0]);
951
+ }
952
+ /**
953
+ * Geometric product
954
+ * @param {WasmMultivector} other
955
+ * @returns {WasmMultivector}
956
+ */
957
+ geometricProduct(other) {
958
+ _assertClass(other, WasmMultivector);
959
+ const ret = wasm.wasmmultivector_geometricProduct(this.__wbg_ptr, other.__wbg_ptr);
960
+ return WasmMultivector.__wrap(ret);
961
+ }
962
+ /**
963
+ * Add two multivectors
964
+ * @param {WasmMultivector} other
965
+ * @returns {WasmMultivector}
966
+ */
967
+ add(other) {
968
+ _assertClass(other, WasmMultivector);
969
+ const ret = wasm.wasmmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
970
+ return WasmMultivector.__wrap(ret);
971
+ }
972
+ /**
973
+ * Exponential (for bivectors to create rotors)
974
+ * @returns {WasmMultivector}
975
+ */
976
+ exp() {
977
+ const ret = wasm.wasmmultivector_exp(this.__wbg_ptr);
978
+ return WasmMultivector.__wrap(ret);
979
+ }
980
+ /**
981
+ * Create a new zero multivector
366
982
  */
367
983
  constructor() {
368
984
  const ret = wasm.wasmmultivector_new();
@@ -447,6 +1063,211 @@ export class WasmMultivector {
447
1063
  }
448
1064
  if (Symbol.dispose) WasmMultivector.prototype[Symbol.dispose] = WasmMultivector.prototype.free;
449
1065
 
1066
+ const WasmRelativisticConstantsFinalization = (typeof FinalizationRegistry === 'undefined')
1067
+ ? { register: () => {}, unregister: () => {} }
1068
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrelativisticconstants_free(ptr >>> 0, 1));
1069
+ /**
1070
+ * Physical constants
1071
+ */
1072
+ export class WasmRelativisticConstants {
1073
+
1074
+ __destroy_into_raw() {
1075
+ const ptr = this.__wbg_ptr;
1076
+ this.__wbg_ptr = 0;
1077
+ WasmRelativisticConstantsFinalization.unregister(this);
1078
+ return ptr;
1079
+ }
1080
+
1081
+ free() {
1082
+ const ptr = this.__destroy_into_raw();
1083
+ wasm.__wbg_wasmrelativisticconstants_free(ptr, 0);
1084
+ }
1085
+ /**
1086
+ * Earth mass (kg)
1087
+ * @returns {number}
1088
+ */
1089
+ static get earth_mass() {
1090
+ const ret = wasm.wasmrelativisticconstants_earth_mass();
1091
+ return ret;
1092
+ }
1093
+ /**
1094
+ * Solar mass (kg)
1095
+ * @returns {number}
1096
+ */
1097
+ static get solar_mass() {
1098
+ const ret = wasm.wasmrelativisticconstants_solar_mass();
1099
+ return ret;
1100
+ }
1101
+ /**
1102
+ * Speed of light in vacuum (m/s)
1103
+ * @returns {number}
1104
+ */
1105
+ static get speed_of_light() {
1106
+ const ret = wasm.wasmrelativisticconstants_speed_of_light();
1107
+ return ret;
1108
+ }
1109
+ /**
1110
+ * Gravitational constant (m³/kg·s²)
1111
+ * @returns {number}
1112
+ */
1113
+ static get gravitational_constant() {
1114
+ const ret = wasm.wasmrelativisticconstants_gravitational_constant();
1115
+ return ret;
1116
+ }
1117
+ }
1118
+ if (Symbol.dispose) WasmRelativisticConstants.prototype[Symbol.dispose] = WasmRelativisticConstants.prototype.free;
1119
+
1120
+ const WasmRelativisticParticleFinalization = (typeof FinalizationRegistry === 'undefined')
1121
+ ? { register: () => {}, unregister: () => {} }
1122
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrelativisticparticle_free(ptr >>> 0, 1));
1123
+ /**
1124
+ * WASM wrapper for relativistic particles
1125
+ */
1126
+ export class WasmRelativisticParticle {
1127
+
1128
+ static __wrap(ptr) {
1129
+ ptr = ptr >>> 0;
1130
+ const obj = Object.create(WasmRelativisticParticle.prototype);
1131
+ obj.__wbg_ptr = ptr;
1132
+ WasmRelativisticParticleFinalization.register(obj, obj.__wbg_ptr, obj);
1133
+ return obj;
1134
+ }
1135
+
1136
+ __destroy_into_raw() {
1137
+ const ptr = this.__wbg_ptr;
1138
+ this.__wbg_ptr = 0;
1139
+ WasmRelativisticParticleFinalization.unregister(this);
1140
+ return ptr;
1141
+ }
1142
+
1143
+ free() {
1144
+ const ptr = this.__destroy_into_raw();
1145
+ wasm.__wbg_wasmrelativisticparticle_free(ptr, 0);
1146
+ }
1147
+ /**
1148
+ * Get 3D position components
1149
+ * @returns {Array<any>}
1150
+ */
1151
+ position_3d() {
1152
+ const ret = wasm.wasmrelativisticparticle_position_3d(this.__wbg_ptr);
1153
+ return ret;
1154
+ }
1155
+ /**
1156
+ * Get position as spacetime vector
1157
+ * @returns {WasmSpacetimeVector}
1158
+ */
1159
+ position_4d() {
1160
+ const ret = wasm.wasmrelativisticparticle_position_4d(this.__wbg_ptr);
1161
+ return WasmSpacetimeVector.__wrap(ret);
1162
+ }
1163
+ /**
1164
+ * Create particle with specified energy
1165
+ * @param {number} x
1166
+ * @param {number} y
1167
+ * @param {number} z
1168
+ * @param {number} direction_x
1169
+ * @param {number} direction_y
1170
+ * @param {number} direction_z
1171
+ * @param {number} kinetic_energy
1172
+ * @param {number} mass
1173
+ * @param {number} charge
1174
+ * @returns {WasmRelativisticParticle}
1175
+ */
1176
+ static with_energy(x, y, z, direction_x, direction_y, direction_z, kinetic_energy, mass, charge) {
1177
+ const ret = wasm.wasmrelativisticparticle_with_energy(x, y, z, direction_x, direction_y, direction_z, kinetic_energy, mass, charge);
1178
+ if (ret[2]) {
1179
+ throw takeFromExternrefTable0(ret[1]);
1180
+ }
1181
+ return WasmRelativisticParticle.__wrap(ret[0]);
1182
+ }
1183
+ /**
1184
+ * Get total energy
1185
+ * @returns {number}
1186
+ */
1187
+ total_energy() {
1188
+ const ret = wasm.wasmrelativisticparticle_total_energy(this.__wbg_ptr);
1189
+ return ret;
1190
+ }
1191
+ /**
1192
+ * Get four-velocity
1193
+ * @returns {WasmFourVelocity}
1194
+ */
1195
+ four_velocity() {
1196
+ const ret = wasm.wasmrelativisticparticle_four_velocity(this.__wbg_ptr);
1197
+ return WasmFourVelocity.__wrap(ret);
1198
+ }
1199
+ /**
1200
+ * Get kinetic energy
1201
+ * @returns {number}
1202
+ */
1203
+ kinetic_energy() {
1204
+ const ret = wasm.wasmrelativisticparticle_kinetic_energy(this.__wbg_ptr);
1205
+ return ret;
1206
+ }
1207
+ /**
1208
+ * Get momentum magnitude
1209
+ * @returns {number}
1210
+ */
1211
+ momentum_magnitude() {
1212
+ const ret = wasm.wasmrelativisticparticle_momentum_magnitude(this.__wbg_ptr);
1213
+ return ret;
1214
+ }
1215
+ /**
1216
+ * Create a new relativistic particle
1217
+ * @param {number} x
1218
+ * @param {number} y
1219
+ * @param {number} z
1220
+ * @param {number} vx
1221
+ * @param {number} vy
1222
+ * @param {number} vz
1223
+ * @param {number} spin
1224
+ * @param {number} mass
1225
+ * @param {number} charge
1226
+ */
1227
+ constructor(x, y, z, vx, vy, vz, spin, mass, charge) {
1228
+ const ret = wasm.wasmrelativisticparticle_new(x, y, z, vx, vy, vz, spin, mass, charge);
1229
+ if (ret[2]) {
1230
+ throw takeFromExternrefTable0(ret[1]);
1231
+ }
1232
+ this.__wbg_ptr = ret[0] >>> 0;
1233
+ WasmRelativisticParticleFinalization.register(this, this.__wbg_ptr, this);
1234
+ return this;
1235
+ }
1236
+ /**
1237
+ * Get rest mass
1238
+ * @returns {number}
1239
+ */
1240
+ mass() {
1241
+ const ret = wasm.wasmrelativisticparticle_mass(this.__wbg_ptr);
1242
+ return ret;
1243
+ }
1244
+ /**
1245
+ * Get electric charge
1246
+ * @returns {number}
1247
+ */
1248
+ charge() {
1249
+ const ret = wasm.wasmrelativisticparticle_charge(this.__wbg_ptr);
1250
+ return ret;
1251
+ }
1252
+ /**
1253
+ * Get string representation
1254
+ * @returns {string}
1255
+ */
1256
+ to_string() {
1257
+ let deferred1_0;
1258
+ let deferred1_1;
1259
+ try {
1260
+ const ret = wasm.wasmrelativisticparticle_to_string(this.__wbg_ptr);
1261
+ deferred1_0 = ret[0];
1262
+ deferred1_1 = ret[1];
1263
+ return getStringFromWasm0(ret[0], ret[1]);
1264
+ } finally {
1265
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1266
+ }
1267
+ }
1268
+ }
1269
+ if (Symbol.dispose) WasmRelativisticParticle.prototype[Symbol.dispose] = WasmRelativisticParticle.prototype.free;
1270
+
450
1271
  const WasmRotorFinalization = (typeof FinalizationRegistry === 'undefined')
451
1272
  ? { register: () => {}, unregister: () => {} }
452
1273
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmrotor_free(ptr >>> 0, 1));
@@ -516,6 +1337,295 @@ export class WasmRotor {
516
1337
  }
517
1338
  if (Symbol.dispose) WasmRotor.prototype[Symbol.dispose] = WasmRotor.prototype.free;
518
1339
 
1340
+ const WasmSchwarzschildMetricFinalization = (typeof FinalizationRegistry === 'undefined')
1341
+ ? { register: () => {}, unregister: () => {} }
1342
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmschwarzschildmetric_free(ptr >>> 0, 1));
1343
+ /**
1344
+ * WASM wrapper for Schwarzschild metric
1345
+ */
1346
+ export class WasmSchwarzschildMetric {
1347
+
1348
+ static __wrap(ptr) {
1349
+ ptr = ptr >>> 0;
1350
+ const obj = Object.create(WasmSchwarzschildMetric.prototype);
1351
+ obj.__wbg_ptr = ptr;
1352
+ WasmSchwarzschildMetricFinalization.register(obj, obj.__wbg_ptr, obj);
1353
+ return obj;
1354
+ }
1355
+
1356
+ __destroy_into_raw() {
1357
+ const ptr = this.__wbg_ptr;
1358
+ this.__wbg_ptr = 0;
1359
+ WasmSchwarzschildMetricFinalization.unregister(this);
1360
+ return ptr;
1361
+ }
1362
+
1363
+ free() {
1364
+ const ptr = this.__destroy_into_raw();
1365
+ wasm.__wbg_wasmschwarzschildmetric_free(ptr, 0);
1366
+ }
1367
+ /**
1368
+ * Check for singularity at given position
1369
+ * @param {WasmSpacetimeVector} position
1370
+ * @returns {boolean}
1371
+ */
1372
+ has_singularity(position) {
1373
+ _assertClass(position, WasmSpacetimeVector);
1374
+ const ret = wasm.wasmschwarzschildmetric_has_singularity(this.__wbg_ptr, position.__wbg_ptr);
1375
+ return ret !== 0;
1376
+ }
1377
+ /**
1378
+ * Compute effective potential for circular orbits
1379
+ * @param {number} r
1380
+ * @param {number} angular_momentum
1381
+ * @returns {number}
1382
+ */
1383
+ effective_potential(r, angular_momentum) {
1384
+ const ret = wasm.wasmschwarzschildmetric_effective_potential(this.__wbg_ptr, r, angular_momentum);
1385
+ return ret;
1386
+ }
1387
+ /**
1388
+ * Get Schwarzschild radius
1389
+ * @returns {number}
1390
+ */
1391
+ schwarzschild_radius() {
1392
+ const ret = wasm.wasmschwarzschildmetric_schwarzschild_radius(this.__wbg_ptr);
1393
+ return ret;
1394
+ }
1395
+ /**
1396
+ * Create Schwarzschild metric for the Sun
1397
+ * @returns {WasmSchwarzschildMetric}
1398
+ */
1399
+ static sun() {
1400
+ const ret = wasm.wasmschwarzschildmetric_sun();
1401
+ return WasmSchwarzschildMetric.__wrap(ret);
1402
+ }
1403
+ /**
1404
+ * Get central mass
1405
+ * @returns {number}
1406
+ */
1407
+ mass() {
1408
+ const ret = wasm.wasmschwarzschildmetric_mass(this.__wbg_ptr);
1409
+ return ret;
1410
+ }
1411
+ /**
1412
+ * Create Schwarzschild metric for Earth
1413
+ * @returns {WasmSchwarzschildMetric}
1414
+ */
1415
+ static earth() {
1416
+ const ret = wasm.wasmschwarzschildmetric_earth();
1417
+ return WasmSchwarzschildMetric.__wrap(ret);
1418
+ }
1419
+ /**
1420
+ * Create Schwarzschild metric for custom mass
1421
+ * @param {number} mass
1422
+ * @returns {WasmSchwarzschildMetric}
1423
+ */
1424
+ static from_mass(mass) {
1425
+ const ret = wasm.wasmschwarzschildmetric_from_mass(mass);
1426
+ return WasmSchwarzschildMetric.__wrap(ret);
1427
+ }
1428
+ }
1429
+ if (Symbol.dispose) WasmSchwarzschildMetric.prototype[Symbol.dispose] = WasmSchwarzschildMetric.prototype.free;
1430
+
1431
+ const WasmSpacetimeVectorFinalization = (typeof FinalizationRegistry === 'undefined')
1432
+ ? { register: () => {}, unregister: () => {} }
1433
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmspacetimevector_free(ptr >>> 0, 1));
1434
+ /**
1435
+ * WASM wrapper for spacetime vectors
1436
+ */
1437
+ export class WasmSpacetimeVector {
1438
+
1439
+ static __wrap(ptr) {
1440
+ ptr = ptr >>> 0;
1441
+ const obj = Object.create(WasmSpacetimeVector.prototype);
1442
+ obj.__wbg_ptr = ptr;
1443
+ WasmSpacetimeVectorFinalization.register(obj, obj.__wbg_ptr, obj);
1444
+ return obj;
1445
+ }
1446
+
1447
+ __destroy_into_raw() {
1448
+ const ptr = this.__wbg_ptr;
1449
+ this.__wbg_ptr = 0;
1450
+ WasmSpacetimeVectorFinalization.unregister(this);
1451
+ return ptr;
1452
+ }
1453
+
1454
+ free() {
1455
+ const ptr = this.__destroy_into_raw();
1456
+ wasm.__wbg_wasmspacetimevector_free(ptr, 0);
1457
+ }
1458
+ /**
1459
+ * Check if vector is timelike (massive particle)
1460
+ * @returns {boolean}
1461
+ */
1462
+ is_timelike() {
1463
+ const ret = wasm.wasmspacetimevector_is_timelike(this.__wbg_ptr);
1464
+ return ret !== 0;
1465
+ }
1466
+ /**
1467
+ * Check if vector is spacelike
1468
+ * @returns {boolean}
1469
+ */
1470
+ is_spacelike() {
1471
+ const ret = wasm.wasmspacetimevector_is_spacelike(this.__wbg_ptr);
1472
+ return ret !== 0;
1473
+ }
1474
+ /**
1475
+ * Compute Minkowski norm squared
1476
+ * @returns {number}
1477
+ */
1478
+ norm_squared() {
1479
+ const ret = wasm.wasmspacetimevector_norm_squared(this.__wbg_ptr);
1480
+ return ret;
1481
+ }
1482
+ /**
1483
+ * Compute Minkowski inner product with another spacetime vector
1484
+ * @param {WasmSpacetimeVector} other
1485
+ * @returns {number}
1486
+ */
1487
+ minkowski_dot(other) {
1488
+ _assertClass(other, WasmSpacetimeVector);
1489
+ const ret = wasm.wasmspacetimevector_minkowski_dot(this.__wbg_ptr, other.__wbg_ptr);
1490
+ return ret;
1491
+ }
1492
+ /**
1493
+ * Get temporal component
1494
+ * @returns {number}
1495
+ */
1496
+ get t() {
1497
+ const ret = wasm.wasmfourvelocity_gamma(this.__wbg_ptr);
1498
+ return ret;
1499
+ }
1500
+ /**
1501
+ * Get x component
1502
+ * @returns {number}
1503
+ */
1504
+ get x() {
1505
+ const ret = wasm.wasmspacetimevector_x(this.__wbg_ptr);
1506
+ return ret;
1507
+ }
1508
+ /**
1509
+ * Get y component
1510
+ * @returns {number}
1511
+ */
1512
+ get y() {
1513
+ const ret = wasm.wasmspacetimevector_y(this.__wbg_ptr);
1514
+ return ret;
1515
+ }
1516
+ /**
1517
+ * Get z component
1518
+ * @returns {number}
1519
+ */
1520
+ get z() {
1521
+ const ret = wasm.wasmspacetimevector_z(this.__wbg_ptr);
1522
+ return ret;
1523
+ }
1524
+ /**
1525
+ * Create a new spacetime vector with components (ct, x, y, z)
1526
+ * @param {number} t
1527
+ * @param {number} x
1528
+ * @param {number} y
1529
+ * @param {number} z
1530
+ */
1531
+ constructor(t, x, y, z) {
1532
+ const ret = wasm.wasmspacetimevector_new(t, x, y, z);
1533
+ this.__wbg_ptr = ret >>> 0;
1534
+ WasmSpacetimeVectorFinalization.register(this, this.__wbg_ptr, this);
1535
+ return this;
1536
+ }
1537
+ /**
1538
+ * Check if vector is null (lightlike)
1539
+ * @returns {boolean}
1540
+ */
1541
+ is_null() {
1542
+ const ret = wasm.wasmspacetimevector_is_null(this.__wbg_ptr);
1543
+ return ret !== 0;
1544
+ }
1545
+ /**
1546
+ * Create a timelike vector
1547
+ * @param {number} t
1548
+ * @returns {WasmSpacetimeVector}
1549
+ */
1550
+ static timelike(t) {
1551
+ const ret = wasm.wasmspacetimevector_timelike(t);
1552
+ return WasmSpacetimeVector.__wrap(ret);
1553
+ }
1554
+ /**
1555
+ * Create a spacelike vector
1556
+ * @param {number} x
1557
+ * @param {number} y
1558
+ * @param {number} z
1559
+ * @returns {WasmSpacetimeVector}
1560
+ */
1561
+ static spacelike(x, y, z) {
1562
+ const ret = wasm.wasmspacetimevector_spacelike(x, y, z);
1563
+ return WasmSpacetimeVector.__wrap(ret);
1564
+ }
1565
+ /**
1566
+ * Get string representation
1567
+ * @returns {string}
1568
+ */
1569
+ to_string() {
1570
+ let deferred1_0;
1571
+ let deferred1_1;
1572
+ try {
1573
+ const ret = wasm.wasmspacetimevector_to_string(this.__wbg_ptr);
1574
+ deferred1_0 = ret[0];
1575
+ deferred1_1 = ret[1];
1576
+ return getStringFromWasm0(ret[0], ret[1]);
1577
+ } finally {
1578
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1579
+ }
1580
+ }
1581
+ }
1582
+ if (Symbol.dispose) WasmSpacetimeVector.prototype[Symbol.dispose] = WasmSpacetimeVector.prototype.free;
1583
+
1584
+ const WasmTrajectoryPointFinalization = (typeof FinalizationRegistry === 'undefined')
1585
+ ? { register: () => {}, unregister: () => {} }
1586
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmtrajectorypoint_free(ptr >>> 0, 1));
1587
+ /**
1588
+ * Trajectory point for particle propagation
1589
+ */
1590
+ export class WasmTrajectoryPoint {
1591
+
1592
+ __destroy_into_raw() {
1593
+ const ptr = this.__wbg_ptr;
1594
+ this.__wbg_ptr = 0;
1595
+ WasmTrajectoryPointFinalization.unregister(this);
1596
+ return ptr;
1597
+ }
1598
+
1599
+ free() {
1600
+ const ptr = this.__destroy_into_raw();
1601
+ wasm.__wbg_wasmtrajectorypoint_free(ptr, 0);
1602
+ }
1603
+ /**
1604
+ * Get position
1605
+ * @returns {WasmSpacetimeVector}
1606
+ */
1607
+ get position() {
1608
+ const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
1609
+ return WasmSpacetimeVector.__wrap(ret);
1610
+ }
1611
+ /**
1612
+ * Time coordinate
1613
+ * @returns {number}
1614
+ */
1615
+ get time() {
1616
+ const ret = wasm.__wbg_get_wasmtrajectorypoint_time(this.__wbg_ptr);
1617
+ return ret;
1618
+ }
1619
+ /**
1620
+ * Time coordinate
1621
+ * @param {number} arg0
1622
+ */
1623
+ set time(arg0) {
1624
+ wasm.__wbg_set_wasmtrajectorypoint_time(this.__wbg_ptr, arg0);
1625
+ }
1626
+ }
1627
+ if (Symbol.dispose) WasmTrajectoryPoint.prototype[Symbol.dispose] = WasmTrajectoryPoint.prototype.free;
1628
+
519
1629
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
520
1630
 
521
1631
  async function __wbg_load(module, imports) {
@@ -554,9 +1664,36 @@ async function __wbg_load(module, imports) {
554
1664
  function __wbg_get_imports() {
555
1665
  const imports = {};
556
1666
  imports.wbg = {};
557
- imports.wbg.__wbg_log_fb67a0d730fc146e = function(arg0, arg1) {
1667
+ imports.wbg.__wbg_log_92e4f1a348990392 = function(arg0, arg1) {
558
1668
  console.log(getStringFromWasm0(arg0, arg1));
559
1669
  };
1670
+ imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
1671
+ const ret = new Object();
1672
+ return ret;
1673
+ };
1674
+ imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
1675
+ const ret = new Array();
1676
+ return ret;
1677
+ };
1678
+ imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
1679
+ const ret = arg0.push(arg1);
1680
+ return ret;
1681
+ };
1682
+ imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
1683
+ const ret = Reflect.set(arg0, arg1, arg2);
1684
+ return ret;
1685
+ }, arguments) };
1686
+ imports.wbg.__wbg_wasmspacetimevector_new = function(arg0) {
1687
+ const ret = WasmSpacetimeVector.__wrap(arg0);
1688
+ return ret;
1689
+ };
1690
+ imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
1691
+ const ret = debugString(arg1);
1692
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1693
+ const len1 = WASM_VECTOR_LEN;
1694
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1695
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1696
+ };
560
1697
  imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
561
1698
  throw new Error(getStringFromWasm0(arg0, arg1));
562
1699
  };
@@ -565,8 +1702,13 @@ function __wbg_get_imports() {
565
1702
  const ret = getStringFromWasm0(arg0, arg1);
566
1703
  return ret;
567
1704
  };
1705
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1706
+ // Cast intrinsic for `F64 -> Externref`.
1707
+ const ret = arg0;
1708
+ return ret;
1709
+ };
568
1710
  imports.wbg.__wbindgen_init_externref_table = function() {
569
- const table = wasm.__wbindgen_export_0;
1711
+ const table = wasm.__wbindgen_export_2;
570
1712
  const offset = table.grow(4);
571
1713
  table.set(0, undefined);
572
1714
  table.set(offset + 0, undefined);
@@ -586,7 +1728,9 @@ function __wbg_init_memory(imports, memory) {
586
1728
  function __wbg_finalize_init(instance, module) {
587
1729
  wasm = instance.exports;
588
1730
  __wbg_init.__wbindgen_wasm_module = module;
1731
+ cachedDataViewMemory0 = null;
589
1732
  cachedFloat64ArrayMemory0 = null;
1733
+ cachedUint32ArrayMemory0 = null;
590
1734
  cachedUint8ArrayMemory0 = null;
591
1735
 
592
1736