@justinelliottcobb/amari-wasm 0.9.0 → 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.d.ts +479 -60
- package/amari_wasm.js +1326 -182
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +1 -1
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));
|
|
@@ -152,175 +410,464 @@ export class PerformanceOperations {
|
|
|
152
410
|
wasm.__wbg_performanceoperations_free(ptr, 0);
|
|
153
411
|
}
|
|
154
412
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {Float64Array}
|
|
157
|
-
* @param {
|
|
413
|
+
* Batch normalize vectors for efficiency
|
|
414
|
+
* @param {Float64Array} vectors
|
|
415
|
+
* @param {number} vector_size
|
|
158
416
|
* @returns {Float64Array}
|
|
159
417
|
*/
|
|
160
|
-
static
|
|
161
|
-
const ptr0 = passArrayF64ToWasm0(
|
|
418
|
+
static batchNormalize(vectors, vector_size) {
|
|
419
|
+
const ptr0 = passArrayF64ToWasm0(vectors, wasm.__wbindgen_malloc);
|
|
162
420
|
const len0 = WASM_VECTOR_LEN;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
|
|
166
|
-
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
421
|
+
const ret = wasm.performanceoperations_batchNormalize(ptr0, len0, vector_size);
|
|
422
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
167
423
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
168
|
-
return
|
|
424
|
+
return v2;
|
|
169
425
|
}
|
|
170
426
|
/**
|
|
171
|
-
* Optimized vector
|
|
427
|
+
* Optimized vector dot product
|
|
172
428
|
* @param {Float64Array} v1
|
|
173
429
|
* @param {Float64Array} v2
|
|
174
|
-
* @returns {
|
|
430
|
+
* @returns {number}
|
|
175
431
|
*/
|
|
176
|
-
static
|
|
432
|
+
static vectorDotProduct(v1, v2) {
|
|
177
433
|
const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
|
|
178
434
|
const len0 = WASM_VECTOR_LEN;
|
|
179
435
|
const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
|
|
180
436
|
const len1 = WASM_VECTOR_LEN;
|
|
181
|
-
const ret = wasm.
|
|
182
|
-
|
|
183
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
184
|
-
return v3;
|
|
437
|
+
const ret = wasm.performanceoperations_vectorDotProduct(ptr0, len0, ptr1, len1);
|
|
438
|
+
return ret;
|
|
185
439
|
}
|
|
186
440
|
/**
|
|
187
|
-
* Optimized vector
|
|
441
|
+
* Optimized vector operations for 3D space
|
|
188
442
|
* @param {Float64Array} v1
|
|
189
443
|
* @param {Float64Array} v2
|
|
190
|
-
* @returns {
|
|
444
|
+
* @returns {Float64Array}
|
|
191
445
|
*/
|
|
192
|
-
static
|
|
446
|
+
static vectorCrossProduct(v1, v2) {
|
|
193
447
|
const ptr0 = passArrayF64ToWasm0(v1, wasm.__wbindgen_malloc);
|
|
194
448
|
const len0 = WASM_VECTOR_LEN;
|
|
195
449
|
const ptr1 = passArrayF64ToWasm0(v2, wasm.__wbindgen_malloc);
|
|
196
450
|
const len1 = WASM_VECTOR_LEN;
|
|
197
|
-
const ret = wasm.
|
|
198
|
-
|
|
451
|
+
const ret = wasm.performanceoperations_vectorCrossProduct(ptr0, len0, ptr1, len1);
|
|
452
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
453
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
454
|
+
return v3;
|
|
199
455
|
}
|
|
200
456
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param {Float64Array}
|
|
203
|
-
* @param {
|
|
457
|
+
* Fast geometric product for hot paths with memory pooling
|
|
458
|
+
* @param {Float64Array} lhs
|
|
459
|
+
* @param {Float64Array} rhs
|
|
204
460
|
* @returns {Float64Array}
|
|
205
461
|
*/
|
|
206
|
-
static
|
|
207
|
-
const ptr0 = passArrayF64ToWasm0(
|
|
462
|
+
static fastGeometricProduct(lhs, rhs) {
|
|
463
|
+
const ptr0 = passArrayF64ToWasm0(lhs, wasm.__wbindgen_malloc);
|
|
208
464
|
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
const
|
|
210
|
-
|
|
465
|
+
const ptr1 = passArrayF64ToWasm0(rhs, wasm.__wbindgen_malloc);
|
|
466
|
+
const len1 = WASM_VECTOR_LEN;
|
|
467
|
+
const ret = wasm.performanceoperations_fastGeometricProduct(ptr0, len0, ptr1, len1);
|
|
468
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
211
469
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
212
|
-
return
|
|
470
|
+
return v3;
|
|
213
471
|
}
|
|
214
472
|
}
|
|
215
473
|
if (Symbol.dispose) PerformanceOperations.prototype[Symbol.dispose] = PerformanceOperations.prototype.free;
|
|
216
474
|
|
|
217
|
-
const
|
|
475
|
+
const WasmFourVelocityFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
218
476
|
? { register: () => {}, unregister: () => {} }
|
|
219
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
477
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfourvelocity_free(ptr >>> 0, 1));
|
|
220
478
|
/**
|
|
221
|
-
* WASM wrapper for
|
|
479
|
+
* WASM wrapper for four-velocity
|
|
222
480
|
*/
|
|
223
|
-
export class
|
|
481
|
+
export class WasmFourVelocity {
|
|
224
482
|
|
|
225
483
|
static __wrap(ptr) {
|
|
226
484
|
ptr = ptr >>> 0;
|
|
227
|
-
const obj = Object.create(
|
|
485
|
+
const obj = Object.create(WasmFourVelocity.prototype);
|
|
228
486
|
obj.__wbg_ptr = ptr;
|
|
229
|
-
|
|
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
|
-
|
|
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.
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Create a new zero multivector
|
|
246
|
-
*/
|
|
247
|
-
constructor() {
|
|
248
|
-
const ret = wasm.wasmmultivector_new();
|
|
249
|
-
this.__wbg_ptr = ret >>> 0;
|
|
250
|
-
WasmMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
251
|
-
return this;
|
|
500
|
+
wasm.__wbg_wasmfourvelocity_free(ptr, 0);
|
|
252
501
|
}
|
|
253
502
|
/**
|
|
254
|
-
* Create from
|
|
255
|
-
* @param {
|
|
256
|
-
* @
|
|
503
|
+
* Create four-velocity from 3-velocity components
|
|
504
|
+
* @param {number} vx
|
|
505
|
+
* @param {number} vy
|
|
506
|
+
* @param {number} vz
|
|
507
|
+
* @returns {WasmFourVelocity}
|
|
257
508
|
*/
|
|
258
|
-
static
|
|
259
|
-
const
|
|
260
|
-
const len0 = WASM_VECTOR_LEN;
|
|
261
|
-
const ret = wasm.wasmmultivector_fromCoefficients(ptr0, len0);
|
|
509
|
+
static from_velocity(vx, vy, vz) {
|
|
510
|
+
const ret = wasm.wasmfourvelocity_from_velocity(vx, vy, vz);
|
|
262
511
|
if (ret[2]) {
|
|
263
512
|
throw takeFromExternrefTable0(ret[1]);
|
|
264
513
|
}
|
|
265
|
-
return
|
|
514
|
+
return WasmFourVelocity.__wrap(ret[0]);
|
|
266
515
|
}
|
|
267
516
|
/**
|
|
268
|
-
*
|
|
269
|
-
* @
|
|
270
|
-
* @returns {WasmMultivector}
|
|
517
|
+
* Check if normalized (u·u = c²)
|
|
518
|
+
* @returns {boolean}
|
|
271
519
|
*/
|
|
272
|
-
|
|
273
|
-
const ret = wasm.
|
|
274
|
-
return
|
|
520
|
+
is_normalized() {
|
|
521
|
+
const ret = wasm.wasmfourvelocity_is_normalized(this.__wbg_ptr);
|
|
522
|
+
return ret !== 0;
|
|
275
523
|
}
|
|
276
524
|
/**
|
|
277
|
-
*
|
|
278
|
-
* @
|
|
279
|
-
* @returns {WasmMultivector}
|
|
525
|
+
* Get as spacetime vector
|
|
526
|
+
* @returns {WasmSpacetimeVector}
|
|
280
527
|
*/
|
|
281
|
-
|
|
282
|
-
const ret = wasm.
|
|
283
|
-
|
|
284
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
285
|
-
}
|
|
286
|
-
return WasmMultivector.__wrap(ret[0]);
|
|
528
|
+
as_spacetime_vector() {
|
|
529
|
+
const ret = wasm.wasmfourvelocity_as_spacetime_vector(this.__wbg_ptr);
|
|
530
|
+
return WasmSpacetimeVector.__wrap(ret);
|
|
287
531
|
}
|
|
288
532
|
/**
|
|
289
|
-
* Get
|
|
290
|
-
* @returns {
|
|
533
|
+
* Get spatial velocity magnitude
|
|
534
|
+
* @returns {number}
|
|
291
535
|
*/
|
|
292
|
-
|
|
293
|
-
const ret = wasm.
|
|
294
|
-
|
|
295
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
296
|
-
return v1;
|
|
536
|
+
spatial_velocity_magnitude() {
|
|
537
|
+
const ret = wasm.wasmfourvelocity_spatial_velocity_magnitude(this.__wbg_ptr);
|
|
538
|
+
return ret;
|
|
297
539
|
}
|
|
298
540
|
/**
|
|
299
|
-
* Get
|
|
300
|
-
* @param {number} index
|
|
541
|
+
* Get Lorentz factor γ
|
|
301
542
|
* @returns {number}
|
|
302
543
|
*/
|
|
303
|
-
|
|
304
|
-
const ret = wasm.
|
|
544
|
+
gamma() {
|
|
545
|
+
const ret = wasm.wasmfourvelocity_gamma(this.__wbg_ptr);
|
|
305
546
|
return ret;
|
|
306
547
|
}
|
|
307
548
|
/**
|
|
308
|
-
*
|
|
309
|
-
* @
|
|
310
|
-
* @param {number} value
|
|
549
|
+
* Get rapidity
|
|
550
|
+
* @returns {number}
|
|
311
551
|
*/
|
|
312
|
-
|
|
313
|
-
wasm.
|
|
552
|
+
rapidity() {
|
|
553
|
+
const ret = wasm.wasmfourvelocity_rapidity(this.__wbg_ptr);
|
|
554
|
+
return ret;
|
|
314
555
|
}
|
|
315
556
|
/**
|
|
316
|
-
*
|
|
317
|
-
* @
|
|
318
|
-
* @returns {WasmMultivector}
|
|
557
|
+
* Get string representation
|
|
558
|
+
* @returns {string}
|
|
319
559
|
*/
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
+
}
|
|
571
|
+
}
|
|
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);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Propagate particle through spacetime
|
|
604
|
+
* @param {WasmRelativisticParticle} particle
|
|
605
|
+
* @param {number} integration_time
|
|
606
|
+
* @param {number} time_step
|
|
607
|
+
* @returns {Array<any>}
|
|
608
|
+
*/
|
|
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);
|
|
612
|
+
if (ret[2]) {
|
|
613
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
614
|
+
}
|
|
615
|
+
return takeFromExternrefTable0(ret[0]);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Create integrator with Schwarzschild metric
|
|
619
|
+
* @param {WasmSchwarzschildMetric} metric
|
|
620
|
+
* @returns {WasmGeodesicIntegrator}
|
|
621
|
+
*/
|
|
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);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Get degree of a node
|
|
651
|
+
* @param {number} node
|
|
652
|
+
* @returns {number}
|
|
653
|
+
*/
|
|
654
|
+
getDegree(node) {
|
|
655
|
+
const ret = wasm.wasmgeometricnetwork_getDegree(this.__wbg_ptr, node);
|
|
656
|
+
return ret >>> 0;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Get neighbors of a node
|
|
660
|
+
* @param {number} node
|
|
661
|
+
* @returns {Uint32Array}
|
|
662
|
+
*/
|
|
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;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
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]);
|
|
324
871
|
}
|
|
325
872
|
/**
|
|
326
873
|
* Inner product (dot product for vectors)
|
|
@@ -332,120 +879,394 @@ export class WasmMultivector {
|
|
|
332
879
|
const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
333
880
|
return WasmMultivector.__wrap(ret);
|
|
334
881
|
}
|
|
335
|
-
/**
|
|
336
|
-
* Outer product (wedge product)
|
|
337
|
-
* @param {WasmMultivector} other
|
|
338
|
-
* @returns {WasmMultivector}
|
|
339
|
-
*/
|
|
340
|
-
outerProduct(other) {
|
|
341
|
-
_assertClass(other, WasmMultivector);
|
|
342
|
-
const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
343
|
-
return WasmMultivector.__wrap(ret);
|
|
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
|
|
982
|
+
*/
|
|
983
|
+
constructor() {
|
|
984
|
+
const ret = wasm.wasmmultivector_new();
|
|
985
|
+
this.__wbg_ptr = ret >>> 0;
|
|
986
|
+
WasmMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
987
|
+
return this;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Subtract two multivectors
|
|
991
|
+
* @param {WasmMultivector} other
|
|
992
|
+
* @returns {WasmMultivector}
|
|
993
|
+
*/
|
|
994
|
+
sub(other) {
|
|
995
|
+
_assertClass(other, WasmMultivector);
|
|
996
|
+
const ret = wasm.wasmmultivector_sub(this.__wbg_ptr, other.__wbg_ptr);
|
|
997
|
+
return WasmMultivector.__wrap(ret);
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Compute norm (alias for magnitude, maintained for compatibility)
|
|
1001
|
+
* @returns {number}
|
|
1002
|
+
*/
|
|
1003
|
+
norm() {
|
|
1004
|
+
const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
|
|
1005
|
+
return ret;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Scale by a scalar
|
|
1009
|
+
* @param {number} scalar
|
|
1010
|
+
* @returns {WasmMultivector}
|
|
1011
|
+
*/
|
|
1012
|
+
scale(scalar) {
|
|
1013
|
+
const ret = wasm.wasmmultivector_scale(this.__wbg_ptr, scalar);
|
|
1014
|
+
return WasmMultivector.__wrap(ret);
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Create a scalar multivector
|
|
1018
|
+
* @param {number} value
|
|
1019
|
+
* @returns {WasmMultivector}
|
|
1020
|
+
*/
|
|
1021
|
+
static scalar(value) {
|
|
1022
|
+
const ret = wasm.wasmmultivector_scalar(value);
|
|
1023
|
+
return WasmMultivector.__wrap(ret);
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Compute inverse
|
|
1027
|
+
* @returns {WasmMultivector}
|
|
1028
|
+
*/
|
|
1029
|
+
inverse() {
|
|
1030
|
+
const ret = wasm.wasmmultivector_inverse(this.__wbg_ptr);
|
|
1031
|
+
if (ret[2]) {
|
|
1032
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1033
|
+
}
|
|
1034
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Reverse
|
|
1038
|
+
* @returns {WasmMultivector}
|
|
1039
|
+
*/
|
|
1040
|
+
reverse() {
|
|
1041
|
+
const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
|
|
1042
|
+
return WasmMultivector.__wrap(ret);
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Compute magnitude
|
|
1046
|
+
* @returns {number}
|
|
1047
|
+
*/
|
|
1048
|
+
magnitude() {
|
|
1049
|
+
const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
|
|
1050
|
+
return ret;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Normalize
|
|
1054
|
+
* @returns {WasmMultivector}
|
|
1055
|
+
*/
|
|
1056
|
+
normalize() {
|
|
1057
|
+
const ret = wasm.wasmmultivector_normalize(this.__wbg_ptr);
|
|
1058
|
+
if (ret[2]) {
|
|
1059
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1060
|
+
}
|
|
1061
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
if (Symbol.dispose) WasmMultivector.prototype[Symbol.dispose] = WasmMultivector.prototype.free;
|
|
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);
|
|
344
1146
|
}
|
|
345
1147
|
/**
|
|
346
|
-
*
|
|
347
|
-
* @
|
|
348
|
-
* @returns {number}
|
|
1148
|
+
* Get 3D position components
|
|
1149
|
+
* @returns {Array<any>}
|
|
349
1150
|
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
1151
|
+
position_3d() {
|
|
1152
|
+
const ret = wasm.wasmrelativisticparticle_position_3d(this.__wbg_ptr);
|
|
353
1153
|
return ret;
|
|
354
1154
|
}
|
|
355
1155
|
/**
|
|
356
|
-
*
|
|
357
|
-
* @returns {
|
|
1156
|
+
* Get position as spacetime vector
|
|
1157
|
+
* @returns {WasmSpacetimeVector}
|
|
358
1158
|
*/
|
|
359
|
-
|
|
360
|
-
const ret = wasm.
|
|
361
|
-
return
|
|
1159
|
+
position_4d() {
|
|
1160
|
+
const ret = wasm.wasmrelativisticparticle_position_4d(this.__wbg_ptr);
|
|
1161
|
+
return WasmSpacetimeVector.__wrap(ret);
|
|
362
1162
|
}
|
|
363
1163
|
/**
|
|
364
|
-
*
|
|
365
|
-
* @param {number}
|
|
366
|
-
* @
|
|
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}
|
|
367
1175
|
*/
|
|
368
|
-
|
|
369
|
-
const ret = wasm.
|
|
370
|
-
|
|
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]);
|
|
371
1182
|
}
|
|
372
1183
|
/**
|
|
373
|
-
*
|
|
374
|
-
* @returns {
|
|
1184
|
+
* Get total energy
|
|
1185
|
+
* @returns {number}
|
|
375
1186
|
*/
|
|
376
|
-
|
|
377
|
-
const ret = wasm.
|
|
378
|
-
return
|
|
1187
|
+
total_energy() {
|
|
1188
|
+
const ret = wasm.wasmrelativisticparticle_total_energy(this.__wbg_ptr);
|
|
1189
|
+
return ret;
|
|
379
1190
|
}
|
|
380
1191
|
/**
|
|
381
|
-
*
|
|
382
|
-
* @returns {
|
|
1192
|
+
* Get four-velocity
|
|
1193
|
+
* @returns {WasmFourVelocity}
|
|
383
1194
|
*/
|
|
384
|
-
|
|
385
|
-
const ret = wasm.
|
|
386
|
-
return ret;
|
|
1195
|
+
four_velocity() {
|
|
1196
|
+
const ret = wasm.wasmrelativisticparticle_four_velocity(this.__wbg_ptr);
|
|
1197
|
+
return WasmFourVelocity.__wrap(ret);
|
|
387
1198
|
}
|
|
388
1199
|
/**
|
|
389
|
-
*
|
|
1200
|
+
* Get kinetic energy
|
|
390
1201
|
* @returns {number}
|
|
391
1202
|
*/
|
|
392
|
-
|
|
393
|
-
const ret = wasm.
|
|
1203
|
+
kinetic_energy() {
|
|
1204
|
+
const ret = wasm.wasmrelativisticparticle_kinetic_energy(this.__wbg_ptr);
|
|
394
1205
|
return ret;
|
|
395
1206
|
}
|
|
396
1207
|
/**
|
|
397
|
-
*
|
|
398
|
-
* @returns {
|
|
1208
|
+
* Get momentum magnitude
|
|
1209
|
+
* @returns {number}
|
|
399
1210
|
*/
|
|
400
|
-
|
|
401
|
-
const ret = wasm.
|
|
402
|
-
|
|
403
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
404
|
-
}
|
|
405
|
-
return WasmMultivector.__wrap(ret[0]);
|
|
1211
|
+
momentum_magnitude() {
|
|
1212
|
+
const ret = wasm.wasmrelativisticparticle_momentum_magnitude(this.__wbg_ptr);
|
|
1213
|
+
return ret;
|
|
406
1214
|
}
|
|
407
1215
|
/**
|
|
408
|
-
*
|
|
409
|
-
* @
|
|
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
|
|
410
1226
|
*/
|
|
411
|
-
|
|
412
|
-
const ret = wasm.
|
|
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);
|
|
413
1229
|
if (ret[2]) {
|
|
414
1230
|
throw takeFromExternrefTable0(ret[1]);
|
|
415
1231
|
}
|
|
416
|
-
|
|
1232
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1233
|
+
WasmRelativisticParticleFinalization.register(this, this.__wbg_ptr, this);
|
|
1234
|
+
return this;
|
|
417
1235
|
}
|
|
418
1236
|
/**
|
|
419
|
-
*
|
|
420
|
-
* @
|
|
421
|
-
* @returns {WasmMultivector}
|
|
1237
|
+
* Get rest mass
|
|
1238
|
+
* @returns {number}
|
|
422
1239
|
*/
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
return WasmMultivector.__wrap(ret);
|
|
1240
|
+
mass() {
|
|
1241
|
+
const ret = wasm.wasmrelativisticparticle_mass(this.__wbg_ptr);
|
|
1242
|
+
return ret;
|
|
427
1243
|
}
|
|
428
1244
|
/**
|
|
429
|
-
*
|
|
430
|
-
* @
|
|
431
|
-
* @returns {WasmMultivector}
|
|
1245
|
+
* Get electric charge
|
|
1246
|
+
* @returns {number}
|
|
432
1247
|
*/
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return WasmMultivector.__wrap(ret);
|
|
1248
|
+
charge() {
|
|
1249
|
+
const ret = wasm.wasmrelativisticparticle_charge(this.__wbg_ptr);
|
|
1250
|
+
return ret;
|
|
437
1251
|
}
|
|
438
1252
|
/**
|
|
439
|
-
*
|
|
440
|
-
* @
|
|
441
|
-
* @returns {WasmMultivector}
|
|
1253
|
+
* Get string representation
|
|
1254
|
+
* @returns {string}
|
|
442
1255
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
+
}
|
|
446
1267
|
}
|
|
447
1268
|
}
|
|
448
|
-
if (Symbol.dispose)
|
|
1269
|
+
if (Symbol.dispose) WasmRelativisticParticle.prototype[Symbol.dispose] = WasmRelativisticParticle.prototype.free;
|
|
449
1270
|
|
|
450
1271
|
const WasmRotorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
451
1272
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -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.
|
|
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.
|
|
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
|
|