@topolab/tda 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/CITATION.cff +72 -0
- package/LICENSE +21 -0
- package/README.md +100 -2
- package/SECURITY.md +34 -0
- package/THIRD_PARTY_LICENSES.md +696 -0
- package/dist/build_info.json +12 -0
- package/dist/check.d.ts +118 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +298 -0
- package/dist/check.js.map +1 -0
- package/dist/complex.d.ts +543 -0
- package/dist/complex.d.ts.map +1 -0
- package/dist/complex.js +712 -0
- package/dist/complex.js.map +1 -0
- package/dist/diagram.d.ts +116 -0
- package/dist/diagram.d.ts.map +1 -0
- package/dist/diagram.js +238 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diagram_of.d.ts +17 -0
- package/dist/diagram_of.d.ts.map +1 -0
- package/dist/diagram_of.js +40 -0
- package/dist/diagram_of.js.map +1 -0
- package/dist/experimental.d.ts +14 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +13 -0
- package/dist/experimental.js.map +1 -0
- package/dist/flat.d.ts +64 -0
- package/dist/flat.d.ts.map +1 -0
- package/dist/flat.js +158 -0
- package/dist/flat.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/ladder/tda_ladder.d.ts +223 -0
- package/dist/ladder/tda_ladder.js +1360 -0
- package/dist/ladder/tda_ladder_bg.wasm +0 -0
- package/dist/ladder/tda_ladder_bg.wasm.d.ts +43 -0
- package/dist/ladder.d.ts +306 -0
- package/dist/ladder.d.ts.map +1 -0
- package/dist/ladder.js +607 -0
- package/dist/ladder.js.map +1 -0
- package/dist/load.d.ts +53 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +173 -0
- package/dist/load.js.map +1 -0
- package/dist/memory.d.ts +58 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +2 -0
- package/dist/memory.js.map +1 -0
- package/dist/persistence.d.ts +349 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +478 -0
- package/dist/persistence.js.map +1 -0
- package/dist/pkg/tda_wasm.d.ts +13 -0
- package/dist/pkg/tda_wasm.js +1900 -0
- package/dist/prepared.d.ts +62 -0
- package/dist/prepared.d.ts.map +1 -0
- package/dist/prepared.js +81 -0
- package/dist/prepared.js.map +1 -0
- package/dist/source.d.ts +43 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +99 -0
- package/dist/source.js.map +1 -0
- package/dist/tda.wasm +0 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vineyard.d.ts +278 -0
- package/dist/vineyard.d.ts.map +1 -0
- package/dist/vineyard.js +236 -0
- package/dist/vineyard.js.map +1 -0
- package/package.json +77 -4
- package/src/check.ts +338 -0
- package/src/complex.ts +1179 -0
- package/src/diagram.ts +299 -0
- package/src/diagram_of.ts +40 -0
- package/src/experimental.ts +13 -0
- package/src/flat.ts +204 -0
- package/src/index.ts +155 -0
- package/src/ladder.ts +903 -0
- package/src/load.ts +201 -0
- package/src/memory.ts +58 -0
- package/src/persistence.ts +752 -0
- package/src/prepared.ts +111 -0
- package/src/source.ts +132 -0
- package/src/types.ts +163 -0
- package/src/vineyard.ts +463 -0
|
@@ -0,0 +1,1900 @@
|
|
|
1
|
+
/* @ts-self-types="./tda_wasm.d.ts" */
|
|
2
|
+
/**
|
|
3
|
+
* wasm-bindgen's glue (--target web) for tda.wasm, wrapped in a
|
|
4
|
+
* factory: each __tda_create() holds the
|
|
5
|
+
* state of one instance, so that every load() has a module object of its
|
|
6
|
+
* own. instantiate the module with imports(), then call finalize(instance,
|
|
7
|
+
* module); exports are the bound functions and classes.
|
|
8
|
+
*/
|
|
9
|
+
export function __tda_create() {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The native snapshot behind `prepareComplex` (src/prepared.ts). `delete()`
|
|
13
|
+
* frees it;
|
|
14
|
+
* wasm-bindgen's `free()` does too.
|
|
15
|
+
*/
|
|
16
|
+
class PreparedComplex {
|
|
17
|
+
__destroy_into_raw() {
|
|
18
|
+
const ptr = this.__wbg_ptr;
|
|
19
|
+
this.__wbg_ptr = 0;
|
|
20
|
+
PreparedComplexFinalization.unregister(this);
|
|
21
|
+
return ptr;
|
|
22
|
+
}
|
|
23
|
+
free() {
|
|
24
|
+
if (this.__oomEpoch !== undefined && this.__oomEpoch !== __oomEpoch) throw new Error("wasm handle is invalid after instance recovery or unload");
|
|
25
|
+
const context = { function: "free", input: {...this.__oomContext?.input,}, parameters: {} };
|
|
26
|
+
const copies = [];
|
|
27
|
+
__oomBegin();
|
|
28
|
+
try {
|
|
29
|
+
const ptr = this.__destroy_into_raw();
|
|
30
|
+
wasm.__wbg_preparedcomplex_free(ptr, 0);
|
|
31
|
+
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
34
|
+
throw __oomNormalize(error, context);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Frees the object, as src/prepared.ts calls it.
|
|
39
|
+
*/
|
|
40
|
+
delete() {
|
|
41
|
+
if (this.__oomEpoch !== undefined && this.__oomEpoch !== __oomEpoch) throw new Error("wasm handle is invalid after instance recovery or unload");
|
|
42
|
+
const context = { function: "delete", input: {...this.__oomContext?.input,}, parameters: {} };
|
|
43
|
+
const copies = [];
|
|
44
|
+
__oomBegin();
|
|
45
|
+
try {
|
|
46
|
+
const ptr = this.__destroy_into_raw();
|
|
47
|
+
wasm.preparedcomplex_delete(ptr);
|
|
48
|
+
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
51
|
+
throw __oomNormalize(error, context);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @returns {number}
|
|
56
|
+
*/
|
|
57
|
+
static liveCount() {
|
|
58
|
+
const context = { function: "liveCount", input: {...this.__oomContext?.input,}, parameters: {} };
|
|
59
|
+
const copies = [];
|
|
60
|
+
__oomBegin();
|
|
61
|
+
try {
|
|
62
|
+
copies.length = 0;
|
|
63
|
+
|
|
64
|
+
const ret = wasm.preparedcomplex_liveCount();
|
|
65
|
+
return ret >>> 0;
|
|
66
|
+
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
69
|
+
throw __oomNormalize(error, context);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @param {Int32Array} vertices
|
|
74
|
+
* @param {Uint32Array} offsets
|
|
75
|
+
* @param {Float64Array} filtrations
|
|
76
|
+
*/
|
|
77
|
+
constructor(vertices, offsets, filtrations) {
|
|
78
|
+
const context = { function: "prepareComplex", input: {...this.__oomContext?.input,"vertices": vertices.length,"offsets": offsets.length,"filtrations": filtrations.length}, parameters: {} };
|
|
79
|
+
const copies = [];
|
|
80
|
+
__oomBegin();
|
|
81
|
+
try {
|
|
82
|
+
const ptr0 = passArray32ToWasm0(vertices, (size, align) => __oomAllocate(size, align, copies, context));
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
const ptr1 = passArray32ToWasm0(offsets, (size, align) => __oomAllocate(size, align, copies, context));
|
|
85
|
+
const len1 = WASM_VECTOR_LEN;
|
|
86
|
+
const ptr2 = passArrayF64ToWasm0(filtrations, (size, align) => __oomAllocate(size, align, copies, context));
|
|
87
|
+
const len2 = WASM_VECTOR_LEN;
|
|
88
|
+
copies.length = 0;
|
|
89
|
+
const ret = wasm.preparedcomplex_new(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
90
|
+
if (ret[2]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
92
|
+
}
|
|
93
|
+
this.__wbg_ptr = ret[0];
|
|
94
|
+
this.__oomEpoch = __oomEpoch;
|
|
95
|
+
this.__oomContext = context;
|
|
96
|
+
PreparedComplexFinalization.register(this, {ptr:this.__wbg_ptr, epoch:__oomEpoch}, this);
|
|
97
|
+
return this;
|
|
98
|
+
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
101
|
+
throw __oomNormalize(error, context);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @param {number} coeff_field
|
|
106
|
+
* @returns {Float64Array}
|
|
107
|
+
*/
|
|
108
|
+
persistence(coeff_field) {
|
|
109
|
+
if (this.__oomEpoch !== undefined && this.__oomEpoch !== __oomEpoch) throw new Error("wasm handle is invalid after instance recovery or unload");
|
|
110
|
+
const context = { function: "persistence", input: {...this.__oomContext?.input,}, parameters: {"coeff": coeff_field} };
|
|
111
|
+
const copies = [];
|
|
112
|
+
__oomBegin();
|
|
113
|
+
try {
|
|
114
|
+
copies.length = 0;
|
|
115
|
+
|
|
116
|
+
const ret = wasm.preparedcomplex_persistence(this.__wbg_ptr, coeff_field);
|
|
117
|
+
if (ret[3]) {
|
|
118
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
119
|
+
}
|
|
120
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
121
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
122
|
+
throw error;
|
|
123
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
124
|
+
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
127
|
+
throw __oomNormalize(error, context);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (Symbol.dispose) PreparedComplex.prototype[Symbol.dispose] = PreparedComplex.prototype.free;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {Float64Array} diagram
|
|
135
|
+
* @param {Float64Array} grid
|
|
136
|
+
* @returns {Float64Array}
|
|
137
|
+
*/
|
|
138
|
+
function bettiCurveFlat(diagram, grid) {
|
|
139
|
+
const context = { function: "bettiCurve", input: {"diagram": diagram.length,"grid": grid.length}, parameters: {} };
|
|
140
|
+
const copies = [];
|
|
141
|
+
__oomBegin();
|
|
142
|
+
try {
|
|
143
|
+
const ptr0 = passArrayF64ToWasm0(diagram, (size, align) => __oomAllocate(size, align, copies, context));
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr1 = passArrayF64ToWasm0(grid, (size, align) => __oomAllocate(size, align, copies, context));
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
copies.length = 0;
|
|
148
|
+
const ret = wasm.bettiCurveFlat(ptr0, len0, ptr1, len1);
|
|
149
|
+
if (ret[3]) {
|
|
150
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
151
|
+
}
|
|
152
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
153
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
154
|
+
throw error;
|
|
155
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
156
|
+
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
159
|
+
throw __oomNormalize(error, context);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @param {Float64Array} diagram
|
|
165
|
+
* @param {number} t
|
|
166
|
+
* @returns {Float64Array}
|
|
167
|
+
*/
|
|
168
|
+
function bettiNumbersFlat(diagram, t) {
|
|
169
|
+
const context = { function: "bettiNumbers", input: {"diagram": diagram.length}, parameters: {"t": t} };
|
|
170
|
+
const copies = [];
|
|
171
|
+
__oomBegin();
|
|
172
|
+
try {
|
|
173
|
+
const ptr0 = passArrayF64ToWasm0(diagram, (size, align) => __oomAllocate(size, align, copies, context));
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
copies.length = 0;
|
|
176
|
+
const ret = wasm.bettiNumbersFlat(ptr0, len0, t);
|
|
177
|
+
if (ret[3]) {
|
|
178
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
179
|
+
}
|
|
180
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
181
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
182
|
+
throw error;
|
|
183
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
184
|
+
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
187
|
+
throw __oomNormalize(error, context);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @param {Float64Array} points
|
|
193
|
+
* @param {number} dimension
|
|
194
|
+
* @param {number} step_size
|
|
195
|
+
* @param {number} alpha
|
|
196
|
+
* @param {number} max_steps
|
|
197
|
+
* @param {number} max_simplex_dim
|
|
198
|
+
* @param {any} include_box_extents
|
|
199
|
+
* @returns {any}
|
|
200
|
+
*/
|
|
201
|
+
function boxFiltrationFlat(points, dimension, step_size, alpha, max_steps, max_simplex_dim, include_box_extents) {
|
|
202
|
+
const context = { function: "boxFiltration", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"step_size": step_size,"alpha": alpha,"max_steps": max_steps,"maxDim": max_simplex_dim,"include_box_extents": include_box_extents} };
|
|
203
|
+
const copies = [];
|
|
204
|
+
__oomBegin();
|
|
205
|
+
try {
|
|
206
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
207
|
+
const len0 = WASM_VECTOR_LEN;
|
|
208
|
+
copies.length = 0;
|
|
209
|
+
const ret = wasm.boxFiltrationFlat(ptr0, len0, dimension, step_size, alpha, max_steps, max_simplex_dim, include_box_extents);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
217
|
+
throw __oomNormalize(error, context);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @param {Float64Array} points
|
|
223
|
+
* @param {number} dimension
|
|
224
|
+
* @param {number} step_size
|
|
225
|
+
* @param {number} alpha
|
|
226
|
+
* @param {number} max_steps
|
|
227
|
+
* @param {number} max_simplex_dim
|
|
228
|
+
* @param {any} include_box_extents
|
|
229
|
+
* @param {number} coeff_field
|
|
230
|
+
* @param {any} with_simplices
|
|
231
|
+
* @returns {any}
|
|
232
|
+
*/
|
|
233
|
+
function boxFiltrationPipeline(points, dimension, step_size, alpha, max_steps, max_simplex_dim, include_box_extents, coeff_field, with_simplices) {
|
|
234
|
+
const context = { function: "boxFiltrationPersistence", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"step_size": step_size,"alpha": alpha,"max_steps": max_steps,"maxDim": max_simplex_dim,"include_box_extents": include_box_extents,"coeff": coeff_field,"complex": with_simplices} };
|
|
235
|
+
const copies = [];
|
|
236
|
+
__oomBegin();
|
|
237
|
+
try {
|
|
238
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
copies.length = 0;
|
|
241
|
+
const ret = wasm.boxFiltrationPipeline(ptr0, len0, dimension, step_size, alpha, max_steps, max_simplex_dim, include_box_extents, coeff_field, with_simplices);
|
|
242
|
+
if (ret[2]) {
|
|
243
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
244
|
+
}
|
|
245
|
+
return takeFromExternrefTable0(ret[0]);
|
|
246
|
+
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
249
|
+
throw __oomNormalize(error, context);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {Float64Array} points
|
|
255
|
+
* @param {number} dimension
|
|
256
|
+
* @param {number} max_radius
|
|
257
|
+
* @param {number} max_simplex_dimension
|
|
258
|
+
* @returns {any}
|
|
259
|
+
*/
|
|
260
|
+
function cechComplexFlat(points, dimension, max_radius, max_simplex_dimension) {
|
|
261
|
+
const context = { function: "cechComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxRadius": max_radius,"maxDim": max_simplex_dimension} };
|
|
262
|
+
const copies = [];
|
|
263
|
+
__oomBegin();
|
|
264
|
+
try {
|
|
265
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
copies.length = 0;
|
|
268
|
+
const ret = wasm.cechComplexFlat(ptr0, len0, dimension, max_radius, max_simplex_dimension);
|
|
269
|
+
if (ret[2]) {
|
|
270
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
271
|
+
}
|
|
272
|
+
return takeFromExternrefTable0(ret[0]);
|
|
273
|
+
|
|
274
|
+
} catch (error) {
|
|
275
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
276
|
+
throw __oomNormalize(error, context);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* `{ simplices?, pairs }` or `{ simplices?, empty: true }`, as the glue's
|
|
282
|
+
* `pipelineResult`; for points in dimension 1 to 3 its
|
|
283
|
+
* `bulkPipelineResult` of the Delaunay–Čech complex (the same shape).
|
|
284
|
+
* @param {Float64Array} points
|
|
285
|
+
* @param {number} dimension
|
|
286
|
+
* @param {number} max_radius
|
|
287
|
+
* @param {number} max_simplex_dimension
|
|
288
|
+
* @param {number} coeff_field
|
|
289
|
+
* @param {any} with_simplices
|
|
290
|
+
* @returns {any}
|
|
291
|
+
*/
|
|
292
|
+
function cechPipeline(points, dimension, max_radius, max_simplex_dimension, coeff_field, with_simplices) {
|
|
293
|
+
const context = { function: "cechPersistence", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxRadius": max_radius,"maxDim": max_simplex_dimension,"coeff": coeff_field,"complex": with_simplices} };
|
|
294
|
+
const copies = [];
|
|
295
|
+
__oomBegin();
|
|
296
|
+
try {
|
|
297
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
298
|
+
const len0 = WASM_VECTOR_LEN;
|
|
299
|
+
copies.length = 0;
|
|
300
|
+
const ret = wasm.cechPipeline(ptr0, len0, dimension, max_radius, max_simplex_dimension, coeff_field, with_simplices);
|
|
301
|
+
if (ret[2]) {
|
|
302
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
303
|
+
}
|
|
304
|
+
return takeFromExternrefTable0(ret[0]);
|
|
305
|
+
|
|
306
|
+
} catch (error) {
|
|
307
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
308
|
+
throw __oomNormalize(error, context);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @param {Float64Array} points
|
|
314
|
+
* @param {number} dimension
|
|
315
|
+
* @param {number} neighborhood_size
|
|
316
|
+
* @param {number} axes_ratio
|
|
317
|
+
* @returns {Float64Array}
|
|
318
|
+
*/
|
|
319
|
+
function computeEllipsoidGeometry(points, dimension, neighborhood_size, axes_ratio) {
|
|
320
|
+
const context = { function: "ellipsoids", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"neighborhood_size": neighborhood_size,"axes_ratio": axes_ratio} };
|
|
321
|
+
const copies = [];
|
|
322
|
+
__oomBegin();
|
|
323
|
+
try {
|
|
324
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
325
|
+
const len0 = WASM_VECTOR_LEN;
|
|
326
|
+
copies.length = 0;
|
|
327
|
+
const ret = wasm.computeEllipsoidGeometry(ptr0, len0, dimension, neighborhood_size, axes_ratio);
|
|
328
|
+
if (ret[3]) {
|
|
329
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
330
|
+
}
|
|
331
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
332
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
333
|
+
throw error;
|
|
334
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
335
|
+
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
338
|
+
throw __oomNormalize(error, context);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @param {Float64Array} points
|
|
344
|
+
* @param {number} q
|
|
345
|
+
* @param {number} theta
|
|
346
|
+
* @param {Float64Array} normals_or_k
|
|
347
|
+
* @returns {Float64Array}
|
|
348
|
+
*/
|
|
349
|
+
function computeWingGeometry(points, q, theta, normals_or_k) {
|
|
350
|
+
const context = { function: "wings", input: {"points": points.length,"normals_or_k": normals_or_k.length}, parameters: {"q": q,"theta": theta} };
|
|
351
|
+
const copies = [];
|
|
352
|
+
__oomBegin();
|
|
353
|
+
try {
|
|
354
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
355
|
+
const len0 = WASM_VECTOR_LEN;
|
|
356
|
+
const ptr1 = passArrayF64ToWasm0(normals_or_k, (size, align) => __oomAllocate(size, align, copies, context));
|
|
357
|
+
const len1 = WASM_VECTOR_LEN;
|
|
358
|
+
copies.length = 0;
|
|
359
|
+
const ret = wasm.computeWingGeometry(ptr0, len0, q, theta, ptr1, len1);
|
|
360
|
+
if (ret[3]) {
|
|
361
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
362
|
+
}
|
|
363
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
364
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
365
|
+
throw error;
|
|
366
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
367
|
+
|
|
368
|
+
} catch (error) {
|
|
369
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
370
|
+
throw __oomNormalize(error, context);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* @param {Float64Array} points
|
|
376
|
+
* @param {Float64Array} colors
|
|
377
|
+
* @param {number} max_squared_radius
|
|
378
|
+
* @param {number} max_simplex_dimension
|
|
379
|
+
* @returns {any}
|
|
380
|
+
*/
|
|
381
|
+
function coupledAlphaComplex2DFlat(points, colors, max_squared_radius, max_simplex_dimension) {
|
|
382
|
+
const context = { function: "coupledAlphaComplex", input: {"points": points.length,"colors": colors.length}, parameters: {"maxSquaredRadius": max_squared_radius,"maxDim": max_simplex_dimension} };
|
|
383
|
+
const copies = [];
|
|
384
|
+
__oomBegin();
|
|
385
|
+
try {
|
|
386
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
387
|
+
const len0 = WASM_VECTOR_LEN;
|
|
388
|
+
const ptr1 = passArrayF64ToWasm0(colors, (size, align) => __oomAllocate(size, align, copies, context));
|
|
389
|
+
const len1 = WASM_VECTOR_LEN;
|
|
390
|
+
copies.length = 0;
|
|
391
|
+
const ret = wasm.coupledAlphaComplex2DFlat(ptr0, len0, ptr1, len1, max_squared_radius, max_simplex_dimension);
|
|
392
|
+
if (ret[2]) {
|
|
393
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
394
|
+
}
|
|
395
|
+
return takeFromExternrefTable0(ret[0]);
|
|
396
|
+
|
|
397
|
+
} catch (error) {
|
|
398
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
399
|
+
throw __oomNormalize(error, context);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @param {Uint32Array} dimensions
|
|
405
|
+
* @param {Float64Array} values
|
|
406
|
+
* @returns {any}
|
|
407
|
+
*/
|
|
408
|
+
function cubicalComplexFlat(dimensions, values) {
|
|
409
|
+
const context = { function: "cubicalComplex", input: {shape: Array.from(dimensions), cells: values.length}, parameters: {} };
|
|
410
|
+
const copies = [];
|
|
411
|
+
__oomBegin();
|
|
412
|
+
try {
|
|
413
|
+
const ptr0 = passArray32ToWasm0(dimensions, (size, align) => __oomAllocate(size, align, copies, context));
|
|
414
|
+
const len0 = WASM_VECTOR_LEN;
|
|
415
|
+
const ptr1 = passArrayF64ToWasm0(values, (size, align) => __oomAllocate(size, align, copies, context));
|
|
416
|
+
const len1 = WASM_VECTOR_LEN;
|
|
417
|
+
copies.length = 0;
|
|
418
|
+
const ret = wasm.cubicalComplexFlat(ptr0, len0, ptr1, len1);
|
|
419
|
+
if (ret[2]) {
|
|
420
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
421
|
+
}
|
|
422
|
+
return takeFromExternrefTable0(ret[0]);
|
|
423
|
+
|
|
424
|
+
} catch (error) {
|
|
425
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
426
|
+
throw __oomNormalize(error, context);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @param {Uint32Array} dimensions
|
|
432
|
+
* @param {Float64Array} values
|
|
433
|
+
* @param {number} coeff_field
|
|
434
|
+
* @returns {Float64Array}
|
|
435
|
+
*/
|
|
436
|
+
function cubicalPersistenceFlat(dimensions, values, coeff_field) {
|
|
437
|
+
const context = { function: "cubicalPersistence", input: {shape: Array.from(dimensions), cells: values.length}, parameters: {"coeff": coeff_field} };
|
|
438
|
+
const copies = [];
|
|
439
|
+
__oomBegin();
|
|
440
|
+
try {
|
|
441
|
+
const ptr0 = passArray32ToWasm0(dimensions, (size, align) => __oomAllocate(size, align, copies, context));
|
|
442
|
+
const len0 = WASM_VECTOR_LEN;
|
|
443
|
+
const ptr1 = passArrayF64ToWasm0(values, (size, align) => __oomAllocate(size, align, copies, context));
|
|
444
|
+
const len1 = WASM_VECTOR_LEN;
|
|
445
|
+
copies.length = 0;
|
|
446
|
+
const ret = wasm.cubicalPersistenceFlat(ptr0, len0, ptr1, len1, coeff_field);
|
|
447
|
+
if (ret[3]) {
|
|
448
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
449
|
+
}
|
|
450
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
451
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
452
|
+
throw error;
|
|
453
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
454
|
+
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
457
|
+
throw __oomNormalize(error, context);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @param {Float64Array} values
|
|
463
|
+
* @param {number} width
|
|
464
|
+
* @param {number} height
|
|
465
|
+
* @returns {Float64Array}
|
|
466
|
+
*/
|
|
467
|
+
function cubicalVertexPersistenceFlat(values, width, height) {
|
|
468
|
+
const context = { function: "cubicalPersistence", input: {shape:[width,height], cells:values.length}, parameters: {coeff:2,construction:"V"} };
|
|
469
|
+
const copies = [];
|
|
470
|
+
__oomBegin();
|
|
471
|
+
try {
|
|
472
|
+
const ptr0 = passArrayF64ToWasm0(values, (size, align) => __oomAllocate(size, align, copies, context));
|
|
473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
474
|
+
copies.length = 0;
|
|
475
|
+
const ret = wasm.cubicalVertexPersistenceFlat(ptr0, len0, width, height);
|
|
476
|
+
if (ret[3]) {
|
|
477
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
478
|
+
}
|
|
479
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
480
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
481
|
+
throw error;
|
|
482
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
483
|
+
|
|
484
|
+
} catch (error) {
|
|
485
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
486
|
+
throw __oomNormalize(error, context);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @param {Uint32Array} dimensions
|
|
492
|
+
* @param {Float64Array} frames
|
|
493
|
+
* @param {number} frame_count
|
|
494
|
+
* @param {number} min_persistence
|
|
495
|
+
* @param {number} coeff_field
|
|
496
|
+
* @param {Float64Array} rep_times
|
|
497
|
+
* @param {any} with_reps
|
|
498
|
+
* @param {Uint32Array} rep_dims
|
|
499
|
+
* @param {any} filter_dims
|
|
500
|
+
* @returns {any}
|
|
501
|
+
*/
|
|
502
|
+
function cubicalVineyardFlat(dimensions, frames, frame_count, min_persistence, coeff_field, rep_times, with_reps, rep_dims, filter_dims) {
|
|
503
|
+
const context = { function: "cubicalVineyard", input: {shape: Array.from(dimensions), images: frame_count, values: frames.length}, parameters: {"frame_count": frame_count,"minPersistence": min_persistence,"coeff": coeff_field,"with_reps": with_reps,"filter_dims": filter_dims} };
|
|
504
|
+
const copies = [];
|
|
505
|
+
__oomBegin();
|
|
506
|
+
try {
|
|
507
|
+
const ptr0 = passArray32ToWasm0(dimensions, (size, align) => __oomAllocate(size, align, copies, context));
|
|
508
|
+
const len0 = WASM_VECTOR_LEN;
|
|
509
|
+
const ptr1 = passArrayF64ToWasm0(frames, (size, align) => __oomAllocate(size, align, copies, context));
|
|
510
|
+
const len1 = WASM_VECTOR_LEN;
|
|
511
|
+
const ptr2 = passArrayF64ToWasm0(rep_times, (size, align) => __oomAllocate(size, align, copies, context));
|
|
512
|
+
const len2 = WASM_VECTOR_LEN;
|
|
513
|
+
const ptr3 = passArray32ToWasm0(rep_dims, (size, align) => __oomAllocate(size, align, copies, context));
|
|
514
|
+
const len3 = WASM_VECTOR_LEN;
|
|
515
|
+
copies.length = 0;
|
|
516
|
+
const ret = wasm.cubicalVineyardFlat(ptr0, len0, ptr1, len1, frame_count, min_persistence, coeff_field, ptr2, len2, with_reps, ptr3, len3, filter_dims);
|
|
517
|
+
if (ret[2]) {
|
|
518
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
519
|
+
}
|
|
520
|
+
return takeFromExternrefTable0(ret[0]);
|
|
521
|
+
|
|
522
|
+
} catch (error) {
|
|
523
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
524
|
+
throw __oomNormalize(error, context);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* @param {Float64Array} points
|
|
530
|
+
* @param {number} dimension
|
|
531
|
+
* @param {number} max_radius
|
|
532
|
+
* @param {number} max_simplex_dimension
|
|
533
|
+
* @param {number} flat_tolerance
|
|
534
|
+
* @returns {any}
|
|
535
|
+
*/
|
|
536
|
+
function delaunayCechComplexFlat(points, dimension, max_radius, max_simplex_dimension, flat_tolerance) {
|
|
537
|
+
const context = { function: "delaunayCechComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxRadius": max_radius,"maxDim": max_simplex_dimension,"flatTolerance": (Number.isNaN(flat_tolerance) ? undefined : flat_tolerance)} };
|
|
538
|
+
const copies = [];
|
|
539
|
+
__oomBegin();
|
|
540
|
+
try {
|
|
541
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
542
|
+
const len0 = WASM_VECTOR_LEN;
|
|
543
|
+
copies.length = 0;
|
|
544
|
+
const ret = wasm.delaunayCechComplexFlat(ptr0, len0, dimension, max_radius, max_simplex_dimension, flat_tolerance);
|
|
545
|
+
if (ret[2]) {
|
|
546
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
547
|
+
}
|
|
548
|
+
return takeFromExternrefTable0(ret[0]);
|
|
549
|
+
|
|
550
|
+
} catch (error) {
|
|
551
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
552
|
+
throw __oomNormalize(error, context);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* @param {Float64Array} d
|
|
558
|
+
* @param {Float64Array} e
|
|
559
|
+
* @returns {Float64Array}
|
|
560
|
+
*/
|
|
561
|
+
function diagramBottleneckFlat(d, e) {
|
|
562
|
+
const context = { function: "diagramBottleneck", input: {n:d.length/2,m:e.length/2}, parameters: {} };
|
|
563
|
+
const copies = [];
|
|
564
|
+
__oomBegin();
|
|
565
|
+
try {
|
|
566
|
+
const ptr0 = passArrayF64ToWasm0(d, (size, align) => __oomAllocate(size, align, copies, context));
|
|
567
|
+
const len0 = WASM_VECTOR_LEN;
|
|
568
|
+
const ptr1 = passArrayF64ToWasm0(e, (size, align) => __oomAllocate(size, align, copies, context));
|
|
569
|
+
const len1 = WASM_VECTOR_LEN;
|
|
570
|
+
copies.length = 0;
|
|
571
|
+
const ret = wasm.diagramBottleneckFlat(ptr0, len0, ptr1, len1);
|
|
572
|
+
if (ret[3]) {
|
|
573
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
574
|
+
}
|
|
575
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
576
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
577
|
+
throw error;
|
|
578
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
579
|
+
|
|
580
|
+
} catch (error) {
|
|
581
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
582
|
+
throw __oomNormalize(error, context);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @param {Float64Array} d
|
|
588
|
+
* @param {Float64Array} e
|
|
589
|
+
* @param {number} order
|
|
590
|
+
* @param {number} internal_p
|
|
591
|
+
* @returns {Float64Array}
|
|
592
|
+
*/
|
|
593
|
+
function diagramWassersteinFlat(d, e, order, internal_p) {
|
|
594
|
+
const context = { function: "diagramWasserstein", input: {n:d.length/2,m:e.length/2}, parameters: {"order": order,"internal_p": internal_p} };
|
|
595
|
+
const copies = [];
|
|
596
|
+
__oomBegin();
|
|
597
|
+
try {
|
|
598
|
+
const ptr0 = passArrayF64ToWasm0(d, (size, align) => __oomAllocate(size, align, copies, context));
|
|
599
|
+
const len0 = WASM_VECTOR_LEN;
|
|
600
|
+
const ptr1 = passArrayF64ToWasm0(e, (size, align) => __oomAllocate(size, align, copies, context));
|
|
601
|
+
const len1 = WASM_VECTOR_LEN;
|
|
602
|
+
copies.length = 0;
|
|
603
|
+
const ret = wasm.diagramWassersteinFlat(ptr0, len0, ptr1, len1, order, internal_p);
|
|
604
|
+
if (ret[3]) {
|
|
605
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
606
|
+
}
|
|
607
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
608
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
609
|
+
throw error;
|
|
610
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
611
|
+
|
|
612
|
+
} catch (error) {
|
|
613
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
614
|
+
throw __oomNormalize(error, context);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* @param {Float64Array} points
|
|
620
|
+
* @param {number} dimension
|
|
621
|
+
* @param {number} neighborhood_size
|
|
622
|
+
* @param {number} axes_ratio
|
|
623
|
+
* @param {number} max_simplex_dimension
|
|
624
|
+
* @param {number} max_radius
|
|
625
|
+
* @returns {any}
|
|
626
|
+
*/
|
|
627
|
+
function ellipsoidCechComplexFlat(points, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_radius) {
|
|
628
|
+
const context = { function: "ellipsoidCechComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"neighborhood_size": neighborhood_size,"axes_ratio": axes_ratio,"maxDim": max_simplex_dimension,"maxRadius": max_radius} };
|
|
629
|
+
const copies = [];
|
|
630
|
+
__oomBegin();
|
|
631
|
+
try {
|
|
632
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
633
|
+
const len0 = WASM_VECTOR_LEN;
|
|
634
|
+
copies.length = 0;
|
|
635
|
+
const ret = wasm.ellipsoidCechComplexFlat(ptr0, len0, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_radius);
|
|
636
|
+
if (ret[2]) {
|
|
637
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
638
|
+
}
|
|
639
|
+
return takeFromExternrefTable0(ret[0]);
|
|
640
|
+
|
|
641
|
+
} catch (error) {
|
|
642
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
643
|
+
throw __oomNormalize(error, context);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @param {Float64Array} points
|
|
649
|
+
* @param {number} dimension
|
|
650
|
+
* @param {number} neighborhood_size
|
|
651
|
+
* @param {number} axes_ratio
|
|
652
|
+
* @param {number} max_simplex_dimension
|
|
653
|
+
* @param {number} max_radius
|
|
654
|
+
* @param {number} coeff_field
|
|
655
|
+
* @param {any} with_simplices
|
|
656
|
+
* @returns {any}
|
|
657
|
+
*/
|
|
658
|
+
function ellipsoidCechPipeline(points, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_radius, coeff_field, with_simplices) {
|
|
659
|
+
const context = { function: "ellipsoidCechPersistence", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"neighborhood_size": neighborhood_size,"axes_ratio": axes_ratio,"maxDim": max_simplex_dimension,"maxRadius": max_radius,"coeff": coeff_field,"complex": with_simplices} };
|
|
660
|
+
const copies = [];
|
|
661
|
+
__oomBegin();
|
|
662
|
+
try {
|
|
663
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
664
|
+
const len0 = WASM_VECTOR_LEN;
|
|
665
|
+
copies.length = 0;
|
|
666
|
+
const ret = wasm.ellipsoidCechPipeline(ptr0, len0, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_radius, coeff_field, with_simplices);
|
|
667
|
+
if (ret[2]) {
|
|
668
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
669
|
+
}
|
|
670
|
+
return takeFromExternrefTable0(ret[0]);
|
|
671
|
+
|
|
672
|
+
} catch (error) {
|
|
673
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
674
|
+
throw __oomNormalize(error, context);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* @param {Float64Array} points
|
|
680
|
+
* @param {number} dimension
|
|
681
|
+
* @param {number} neighborhood_size
|
|
682
|
+
* @param {number} axes_ratio
|
|
683
|
+
* @param {number} max_simplex_dimension
|
|
684
|
+
* @param {number} max_filtration
|
|
685
|
+
* @returns {any}
|
|
686
|
+
*/
|
|
687
|
+
function ellipsoidRipsComplexFlat(points, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_filtration) {
|
|
688
|
+
const context = { function: "ellipsoidRipsComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"neighborhood_size": neighborhood_size,"axes_ratio": axes_ratio,"maxDim": max_simplex_dimension,"max_filtration": max_filtration} };
|
|
689
|
+
const copies = [];
|
|
690
|
+
__oomBegin();
|
|
691
|
+
try {
|
|
692
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
693
|
+
const len0 = WASM_VECTOR_LEN;
|
|
694
|
+
copies.length = 0;
|
|
695
|
+
const ret = wasm.ellipsoidRipsComplexFlat(ptr0, len0, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_filtration);
|
|
696
|
+
if (ret[2]) {
|
|
697
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
698
|
+
}
|
|
699
|
+
return takeFromExternrefTable0(ret[0]);
|
|
700
|
+
|
|
701
|
+
} catch (error) {
|
|
702
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
703
|
+
throw __oomNormalize(error, context);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* @param {Float64Array} points
|
|
709
|
+
* @param {number} dimension
|
|
710
|
+
* @param {number} neighborhood_size
|
|
711
|
+
* @param {number} axes_ratio
|
|
712
|
+
* @param {number} max_simplex_dimension
|
|
713
|
+
* @param {number} max_filtration
|
|
714
|
+
* @param {number} coeff_field
|
|
715
|
+
* @param {any} with_simplices
|
|
716
|
+
* @returns {any}
|
|
717
|
+
*/
|
|
718
|
+
function ellipsoidRipsPipeline(points, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_filtration, coeff_field, with_simplices) {
|
|
719
|
+
const context = { function: "ellipsoidRipsPersistence", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"neighborhood_size": neighborhood_size,"axes_ratio": axes_ratio,"maxDim": max_simplex_dimension,"max_filtration": max_filtration,"coeff": coeff_field,"complex": with_simplices} };
|
|
720
|
+
const copies = [];
|
|
721
|
+
__oomBegin();
|
|
722
|
+
try {
|
|
723
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
724
|
+
const len0 = WASM_VECTOR_LEN;
|
|
725
|
+
copies.length = 0;
|
|
726
|
+
const ret = wasm.ellipsoidRipsPipeline(ptr0, len0, dimension, neighborhood_size, axes_ratio, max_simplex_dimension, max_filtration, coeff_field, with_simplices);
|
|
727
|
+
if (ret[2]) {
|
|
728
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
729
|
+
}
|
|
730
|
+
return takeFromExternrefTable0(ret[0]);
|
|
731
|
+
|
|
732
|
+
} catch (error) {
|
|
733
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
734
|
+
throw __oomNormalize(error, context);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* @param {Float64Array} points
|
|
740
|
+
* @param {number} dimension
|
|
741
|
+
* @param {number} num_landmarks
|
|
742
|
+
* @param {number} max_alpha_square
|
|
743
|
+
* @param {number} max_simplex_dimension
|
|
744
|
+
* @returns {any}
|
|
745
|
+
*/
|
|
746
|
+
function euclideanWitnessComplexFlat(points, dimension, num_landmarks, max_alpha_square, max_simplex_dimension) {
|
|
747
|
+
const context = { function: "witnessComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"num_landmarks": num_landmarks,"max_alpha_square": max_alpha_square,"maxDim": max_simplex_dimension} };
|
|
748
|
+
const copies = [];
|
|
749
|
+
__oomBegin();
|
|
750
|
+
try {
|
|
751
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
752
|
+
const len0 = WASM_VECTOR_LEN;
|
|
753
|
+
copies.length = 0;
|
|
754
|
+
const ret = wasm.euclideanWitnessComplexFlat(ptr0, len0, dimension, num_landmarks, max_alpha_square, max_simplex_dimension);
|
|
755
|
+
if (ret[2]) {
|
|
756
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
757
|
+
}
|
|
758
|
+
return takeFromExternrefTable0(ret[0]);
|
|
759
|
+
|
|
760
|
+
} catch (error) {
|
|
761
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
762
|
+
throw __oomNormalize(error, context);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* The test hook: `{ pairs, simplexOffsets, vertices }`.
|
|
768
|
+
* @param {Int32Array} vertices
|
|
769
|
+
* @param {Uint32Array} offsets
|
|
770
|
+
* @param {Float64Array} filtrations
|
|
771
|
+
* @param {number} coeff_field
|
|
772
|
+
* @returns {any}
|
|
773
|
+
*/
|
|
774
|
+
function getPersistentPairs(vertices, offsets, filtrations, coeff_field) {
|
|
775
|
+
const context = { function: "getPersistentPairs", input: {"vertices": vertices.length,"offsets": offsets.length,"filtrations": filtrations.length}, parameters: {"coeff": coeff_field} };
|
|
776
|
+
const copies = [];
|
|
777
|
+
__oomBegin();
|
|
778
|
+
try {
|
|
779
|
+
const ptr0 = passArray32ToWasm0(vertices, (size, align) => __oomAllocate(size, align, copies, context));
|
|
780
|
+
const len0 = WASM_VECTOR_LEN;
|
|
781
|
+
const ptr1 = passArray32ToWasm0(offsets, (size, align) => __oomAllocate(size, align, copies, context));
|
|
782
|
+
const len1 = WASM_VECTOR_LEN;
|
|
783
|
+
const ptr2 = passArrayF64ToWasm0(filtrations, (size, align) => __oomAllocate(size, align, copies, context));
|
|
784
|
+
const len2 = WASM_VECTOR_LEN;
|
|
785
|
+
copies.length = 0;
|
|
786
|
+
const ret = wasm.getPersistentPairs(ptr0, len0, ptr1, len1, ptr2, len2, coeff_field);
|
|
787
|
+
if (ret[2]) {
|
|
788
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
789
|
+
}
|
|
790
|
+
return takeFromExternrefTable0(ret[0]);
|
|
791
|
+
|
|
792
|
+
} catch (error) {
|
|
793
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
794
|
+
throw __oomNormalize(error, context);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* @param {Float64Array} points
|
|
800
|
+
* @param {number} k
|
|
801
|
+
* @param {number} max_squared_radius
|
|
802
|
+
* @param {number} max_simplex_dim
|
|
803
|
+
* @returns {any}
|
|
804
|
+
*/
|
|
805
|
+
function kFoldCoverComplexFlat(points, k, max_squared_radius, max_simplex_dim) {
|
|
806
|
+
const context = { function: "kFoldCoverComplex", input: {points: points.length / 3, dimension:3, coordinateElements:points.length}, parameters: {"k": k,"maxSquaredRadius": (max_squared_radius === 0 ? Infinity : max_squared_radius),"maxDim": max_simplex_dim} };
|
|
807
|
+
const copies = [];
|
|
808
|
+
__oomBegin();
|
|
809
|
+
try {
|
|
810
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
811
|
+
const len0 = WASM_VECTOR_LEN;
|
|
812
|
+
copies.length = 0;
|
|
813
|
+
const ret = wasm.kFoldCoverComplexFlat(ptr0, len0, k, max_squared_radius, max_simplex_dim);
|
|
814
|
+
if (ret[2]) {
|
|
815
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
816
|
+
}
|
|
817
|
+
return takeFromExternrefTable0(ret[0]);
|
|
818
|
+
|
|
819
|
+
} catch (error) {
|
|
820
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
821
|
+
throw __oomNormalize(error, context);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* @param {Float64Array} points
|
|
827
|
+
* @param {number} k
|
|
828
|
+
* @param {number} max_squared_radius
|
|
829
|
+
* @param {number} max_simplex_dim
|
|
830
|
+
* @param {number} coeff_field
|
|
831
|
+
* @param {any} with_simplices
|
|
832
|
+
* @returns {any}
|
|
833
|
+
*/
|
|
834
|
+
function kFoldCoverPipeline(points, k, max_squared_radius, max_simplex_dim, coeff_field, with_simplices) {
|
|
835
|
+
const context = { function: "kFoldCoverPersistence", input: {points: points.length / 3, dimension:3, coordinateElements:points.length}, parameters: {"k": k,"maxSquaredRadius": (max_squared_radius === 0 ? Infinity : max_squared_radius),"maxDim": max_simplex_dim,"coeff": coeff_field,"complex": with_simplices} };
|
|
836
|
+
const copies = [];
|
|
837
|
+
__oomBegin();
|
|
838
|
+
try {
|
|
839
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
840
|
+
const len0 = WASM_VECTOR_LEN;
|
|
841
|
+
copies.length = 0;
|
|
842
|
+
const ret = wasm.kFoldCoverPipeline(ptr0, len0, k, max_squared_radius, max_simplex_dim, coeff_field, with_simplices);
|
|
843
|
+
if (ret[2]) {
|
|
844
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
845
|
+
}
|
|
846
|
+
return takeFromExternrefTable0(ret[0]);
|
|
847
|
+
|
|
848
|
+
} catch (error) {
|
|
849
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
850
|
+
throw __oomNormalize(error, context);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* @param {Float64Array} flat
|
|
856
|
+
* @param {number} min_persistence
|
|
857
|
+
* @returns {Float64Array}
|
|
858
|
+
*/
|
|
859
|
+
function longPairsFlat(flat, min_persistence) {
|
|
860
|
+
const context = { function: "longPairs", input: {"flat": flat.length}, parameters: {"minPersistence": min_persistence} };
|
|
861
|
+
const copies = [];
|
|
862
|
+
__oomBegin();
|
|
863
|
+
try {
|
|
864
|
+
const ptr0 = passArrayF64ToWasm0(flat, (size, align) => __oomAllocate(size, align, copies, context));
|
|
865
|
+
const len0 = WASM_VECTOR_LEN;
|
|
866
|
+
copies.length = 0;
|
|
867
|
+
const ret = wasm.longPairsFlat(ptr0, len0, min_persistence);
|
|
868
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
869
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
870
|
+
throw error;
|
|
871
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
872
|
+
|
|
873
|
+
} catch (error) {
|
|
874
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
875
|
+
throw __oomNormalize(error, context);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* @param {Int32Array} vertices
|
|
881
|
+
* @param {Uint32Array} offsets
|
|
882
|
+
* @param {Float64Array} filtrations
|
|
883
|
+
* @param {number} coeff_field
|
|
884
|
+
* @returns {Float64Array}
|
|
885
|
+
*/
|
|
886
|
+
function persistenceFlat(vertices, offsets, filtrations, coeff_field) {
|
|
887
|
+
const context = { function: "persistence", input: {"vertices": vertices.length,"offsets": offsets.length,"filtrations": filtrations.length}, parameters: {"coeff": coeff_field} };
|
|
888
|
+
const copies = [];
|
|
889
|
+
__oomBegin();
|
|
890
|
+
try {
|
|
891
|
+
const ptr0 = passArray32ToWasm0(vertices, (size, align) => __oomAllocate(size, align, copies, context));
|
|
892
|
+
const len0 = WASM_VECTOR_LEN;
|
|
893
|
+
const ptr1 = passArray32ToWasm0(offsets, (size, align) => __oomAllocate(size, align, copies, context));
|
|
894
|
+
const len1 = WASM_VECTOR_LEN;
|
|
895
|
+
const ptr2 = passArrayF64ToWasm0(filtrations, (size, align) => __oomAllocate(size, align, copies, context));
|
|
896
|
+
const len2 = WASM_VECTOR_LEN;
|
|
897
|
+
copies.length = 0;
|
|
898
|
+
const ret = wasm.persistenceFlat(ptr0, len0, ptr1, len1, ptr2, len2, coeff_field);
|
|
899
|
+
if (ret[3]) {
|
|
900
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
901
|
+
}
|
|
902
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
903
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
904
|
+
throw error;
|
|
905
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
906
|
+
|
|
907
|
+
} catch (error) {
|
|
908
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
909
|
+
throw __oomNormalize(error, context);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* @param {Float64Array} pairs
|
|
915
|
+
* @param {number} rows
|
|
916
|
+
* @param {number} cols
|
|
917
|
+
* @param {any} auto_bounds
|
|
918
|
+
* @param {number} birth_min
|
|
919
|
+
* @param {number} birth_max
|
|
920
|
+
* @param {number} pers_min
|
|
921
|
+
* @param {number} pers_max
|
|
922
|
+
* @param {number} sigma
|
|
923
|
+
* @param {number} weight_power
|
|
924
|
+
* @returns {Float64Array}
|
|
925
|
+
*/
|
|
926
|
+
function persistenceImageFlat(pairs, rows, cols, auto_bounds, birth_min, birth_max, pers_min, pers_max, sigma, weight_power) {
|
|
927
|
+
const context = { function: "persistenceImage", input: {shape:[rows,cols], cells:rows*cols, pairElements:pairs.length}, parameters: {"rows": rows,"cols": cols,"auto_bounds": auto_bounds,"birth_min": birth_min,"birth_max": birth_max,"pers_min": pers_min,"pers_max": pers_max,"sigma": sigma,"weight_power": weight_power} };
|
|
928
|
+
const copies = [];
|
|
929
|
+
__oomBegin();
|
|
930
|
+
try {
|
|
931
|
+
const ptr0 = passArrayF64ToWasm0(pairs, (size, align) => __oomAllocate(size, align, copies, context));
|
|
932
|
+
const len0 = WASM_VECTOR_LEN;
|
|
933
|
+
copies.length = 0;
|
|
934
|
+
const ret = wasm.persistenceImageFlat(ptr0, len0, rows, cols, auto_bounds, birth_min, birth_max, pers_min, pers_max, sigma, weight_power);
|
|
935
|
+
if (ret[3]) {
|
|
936
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
937
|
+
}
|
|
938
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
939
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
940
|
+
throw error;
|
|
941
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
942
|
+
|
|
943
|
+
} catch (error) {
|
|
944
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
945
|
+
throw __oomNormalize(error, context);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* @param {Float64Array} pairs
|
|
951
|
+
* @param {number} first
|
|
952
|
+
* @param {number} last
|
|
953
|
+
* @param {Float64Array} grid
|
|
954
|
+
* @returns {Float64Array}
|
|
955
|
+
*/
|
|
956
|
+
function persistenceLandscapeFlat(pairs, first, last, grid) {
|
|
957
|
+
const context = { function: "persistenceLandscape", input: {gridPoints:grid.length, pairElements:pairs.length}, parameters: {"first": first,"last": last} };
|
|
958
|
+
const copies = [];
|
|
959
|
+
__oomBegin();
|
|
960
|
+
try {
|
|
961
|
+
const ptr0 = passArrayF64ToWasm0(pairs, (size, align) => __oomAllocate(size, align, copies, context));
|
|
962
|
+
const len0 = WASM_VECTOR_LEN;
|
|
963
|
+
const ptr1 = passArrayF64ToWasm0(grid, (size, align) => __oomAllocate(size, align, copies, context));
|
|
964
|
+
const len1 = WASM_VECTOR_LEN;
|
|
965
|
+
copies.length = 0;
|
|
966
|
+
const ret = wasm.persistenceLandscapeFlat(ptr0, len0, first, last, ptr1, len1);
|
|
967
|
+
if (ret[3]) {
|
|
968
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
969
|
+
}
|
|
970
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
971
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
972
|
+
throw error;
|
|
973
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
974
|
+
|
|
975
|
+
} catch (error) {
|
|
976
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
977
|
+
throw __oomNormalize(error, context);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* @param {Float64Array} points
|
|
983
|
+
* @param {number} dimension
|
|
984
|
+
* @param {number} max_edge_length
|
|
985
|
+
* @param {number} max_simplex_dimension
|
|
986
|
+
* @returns {any}
|
|
987
|
+
*/
|
|
988
|
+
function ripsComplexFlat(points, dimension, max_edge_length, max_simplex_dimension) {
|
|
989
|
+
const context = { function: "ripsComplex", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxEdgeLength": max_edge_length,"maxDim": max_simplex_dimension} };
|
|
990
|
+
const copies = [];
|
|
991
|
+
__oomBegin();
|
|
992
|
+
try {
|
|
993
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
994
|
+
const len0 = WASM_VECTOR_LEN;
|
|
995
|
+
copies.length = 0;
|
|
996
|
+
const ret = wasm.ripsComplexFlat(ptr0, len0, dimension, max_edge_length, max_simplex_dimension);
|
|
997
|
+
if (ret[2]) {
|
|
998
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
999
|
+
}
|
|
1000
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1001
|
+
|
|
1002
|
+
} catch (error) {
|
|
1003
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1004
|
+
throw __oomNormalize(error, context);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* @param {Float64Array} matrix
|
|
1010
|
+
* @param {number} num_points
|
|
1011
|
+
* @param {number} max_edge_length
|
|
1012
|
+
* @param {number} max_simplex_dimension
|
|
1013
|
+
* @returns {any}
|
|
1014
|
+
*/
|
|
1015
|
+
function ripsComplexFromMatrixFlat(matrix, num_points, max_edge_length, max_simplex_dimension) {
|
|
1016
|
+
const context = { function: "ripsComplex", input: {rows: num_points, columns: num_points, entries: matrix.length}, parameters: {"num_points": num_points,"maxEdgeLength": max_edge_length,"maxDim": max_simplex_dimension} };
|
|
1017
|
+
const copies = [];
|
|
1018
|
+
__oomBegin();
|
|
1019
|
+
try {
|
|
1020
|
+
const ptr0 = passArrayF64ToWasm0(matrix, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1021
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1022
|
+
copies.length = 0;
|
|
1023
|
+
const ret = wasm.ripsComplexFromMatrixFlat(ptr0, len0, num_points, max_edge_length, max_simplex_dimension);
|
|
1024
|
+
if (ret[2]) {
|
|
1025
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1026
|
+
}
|
|
1027
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1028
|
+
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1031
|
+
throw __oomNormalize(error, context);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* @param {Float64Array} points
|
|
1037
|
+
* @param {number} dimension
|
|
1038
|
+
* @param {number} max_dim
|
|
1039
|
+
* @param {number} threshold
|
|
1040
|
+
* @param {number} modulus
|
|
1041
|
+
* @returns {Float64Array}
|
|
1042
|
+
*/
|
|
1043
|
+
function ripsPersistenceFlat(points, dimension, max_dim, threshold, modulus) {
|
|
1044
|
+
const context = { function: "ripsPersistence", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxDim": max_dim,"maxEdgeLength": threshold,"coeff": modulus} };
|
|
1045
|
+
const copies = [];
|
|
1046
|
+
__oomBegin();
|
|
1047
|
+
try {
|
|
1048
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1049
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1050
|
+
copies.length = 0;
|
|
1051
|
+
const ret = wasm.ripsPersistenceFlat(ptr0, len0, dimension, max_dim, threshold, modulus);
|
|
1052
|
+
if (ret[3]) {
|
|
1053
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1054
|
+
}
|
|
1055
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
1056
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
1057
|
+
throw error;
|
|
1058
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
1059
|
+
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1062
|
+
throw __oomNormalize(error, context);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* @param {Float64Array} matrix
|
|
1068
|
+
* @param {number} num_points
|
|
1069
|
+
* @param {number} max_dim
|
|
1070
|
+
* @param {number} threshold
|
|
1071
|
+
* @param {number} modulus
|
|
1072
|
+
* @returns {Float64Array}
|
|
1073
|
+
*/
|
|
1074
|
+
function ripsPersistenceFromDistanceMatrixFlat(matrix, num_points, max_dim, threshold, modulus) {
|
|
1075
|
+
const context = { function: "ripsPersistence", input: {rows: num_points, columns: num_points, entries: matrix.length}, parameters: {"num_points": num_points,"maxDim": max_dim,"maxEdgeLength": threshold,"coeff": modulus} };
|
|
1076
|
+
const copies = [];
|
|
1077
|
+
__oomBegin();
|
|
1078
|
+
try {
|
|
1079
|
+
const ptr0 = passArrayF64ToWasm0(matrix, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1080
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1081
|
+
copies.length = 0;
|
|
1082
|
+
const ret = wasm.ripsPersistenceFromDistanceMatrixFlat(ptr0, len0, num_points, max_dim, threshold, modulus);
|
|
1083
|
+
if (ret[3]) {
|
|
1084
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1085
|
+
}
|
|
1086
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
1087
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
1088
|
+
throw error;
|
|
1089
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
1090
|
+
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1093
|
+
throw __oomNormalize(error, context);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* @param {Float64Array} points
|
|
1099
|
+
* @param {number} dimension
|
|
1100
|
+
* @param {number} max_dim
|
|
1101
|
+
* @param {number} threshold
|
|
1102
|
+
* @param {number} modulus
|
|
1103
|
+
* @param {number} kind
|
|
1104
|
+
* @param {number} dims_mask
|
|
1105
|
+
* @param {number} min_persistence
|
|
1106
|
+
* @returns {any}
|
|
1107
|
+
*/
|
|
1108
|
+
function ripsRepresentativesFlat(points, dimension, max_dim, threshold, modulus, kind, dims_mask, min_persistence) {
|
|
1109
|
+
const context = { function: "ripsRepresentatives", input: {points: points.length / dimension, dimension, coordinateElements: points.length}, parameters: {"dimension": dimension,"maxDim": max_dim,"maxEdgeLength": threshold,"coeff": modulus,"kind": kind,"dims_mask": dims_mask,"minPersistence": min_persistence} };
|
|
1110
|
+
const copies = [];
|
|
1111
|
+
__oomBegin();
|
|
1112
|
+
try {
|
|
1113
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1115
|
+
copies.length = 0;
|
|
1116
|
+
const ret = wasm.ripsRepresentativesFlat(ptr0, len0, dimension, max_dim, threshold, modulus, kind, dims_mask, min_persistence);
|
|
1117
|
+
if (ret[2]) {
|
|
1118
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1119
|
+
}
|
|
1120
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1121
|
+
|
|
1122
|
+
} catch (error) {
|
|
1123
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1124
|
+
throw __oomNormalize(error, context);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* @param {Float64Array} matrix
|
|
1130
|
+
* @param {number} num_points
|
|
1131
|
+
* @param {number} max_dim
|
|
1132
|
+
* @param {number} threshold
|
|
1133
|
+
* @param {number} modulus
|
|
1134
|
+
* @param {number} kind
|
|
1135
|
+
* @param {number} dims_mask
|
|
1136
|
+
* @param {number} min_persistence
|
|
1137
|
+
* @returns {any}
|
|
1138
|
+
*/
|
|
1139
|
+
function ripsRepresentativesFromDistanceMatrixFlat(matrix, num_points, max_dim, threshold, modulus, kind, dims_mask, min_persistence) {
|
|
1140
|
+
const context = { function: "ripsRepresentativesFromDistanceMatrix", input: {rows: num_points, columns: num_points, entries: matrix.length}, parameters: {"num_points": num_points,"maxDim": max_dim,"maxEdgeLength": threshold,"coeff": modulus,"kind": kind,"dims_mask": dims_mask,"minPersistence": min_persistence} };
|
|
1141
|
+
const copies = [];
|
|
1142
|
+
__oomBegin();
|
|
1143
|
+
try {
|
|
1144
|
+
const ptr0 = passArrayF64ToWasm0(matrix, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1146
|
+
copies.length = 0;
|
|
1147
|
+
const ret = wasm.ripsRepresentativesFromDistanceMatrixFlat(ptr0, len0, num_points, max_dim, threshold, modulus, kind, dims_mask, min_persistence);
|
|
1148
|
+
if (ret[2]) {
|
|
1149
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1150
|
+
}
|
|
1151
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1152
|
+
|
|
1153
|
+
} catch (error) {
|
|
1154
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1155
|
+
throw __oomNormalize(error, context);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* @param {Float64Array} clouds
|
|
1161
|
+
* @param {number} dimension
|
|
1162
|
+
* @param {number} frame_count
|
|
1163
|
+
* @param {number} max_edge_length
|
|
1164
|
+
* @param {number} max_dim
|
|
1165
|
+
* @param {number} min_persistence
|
|
1166
|
+
* @param {number} coeff_field
|
|
1167
|
+
* @param {Float64Array} rep_times
|
|
1168
|
+
* @param {any} with_reps
|
|
1169
|
+
* @param {Uint32Array} rep_dims
|
|
1170
|
+
* @param {any} filter_dims
|
|
1171
|
+
* @returns {any}
|
|
1172
|
+
*/
|
|
1173
|
+
function ripsVineyardFlat(clouds, dimension, frame_count, max_edge_length, max_dim, min_persistence, coeff_field, rep_times, with_reps, rep_dims, filter_dims) {
|
|
1174
|
+
const context = { function: "ripsVineyard", input: {points: clouds.length / (dimension * frame_count), dimension, clouds: frame_count, coordinateElements: clouds.length}, parameters: {"dimension": dimension,"frame_count": frame_count,"maxEdgeLength": max_edge_length,"maxDim": max_dim,"minPersistence": min_persistence,"coeff": coeff_field,"with_reps": with_reps,"filter_dims": filter_dims} };
|
|
1175
|
+
const copies = [];
|
|
1176
|
+
__oomBegin();
|
|
1177
|
+
try {
|
|
1178
|
+
const ptr0 = passArrayF64ToWasm0(clouds, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1180
|
+
const ptr1 = passArrayF64ToWasm0(rep_times, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1181
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1182
|
+
const ptr2 = passArray32ToWasm0(rep_dims, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1183
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1184
|
+
copies.length = 0;
|
|
1185
|
+
const ret = wasm.ripsVineyardFlat(ptr0, len0, dimension, frame_count, max_edge_length, max_dim, min_persistence, coeff_field, ptr1, len1, with_reps, ptr2, len2, filter_dims);
|
|
1186
|
+
if (ret[2]) {
|
|
1187
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1188
|
+
}
|
|
1189
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1190
|
+
|
|
1191
|
+
} catch (error) {
|
|
1192
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1193
|
+
throw __oomNormalize(error, context);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* The package version this module was built as (package.json's).
|
|
1199
|
+
* @returns {string}
|
|
1200
|
+
*/
|
|
1201
|
+
function version() {
|
|
1202
|
+
const context = { function: "version", input: {}, parameters: {} };
|
|
1203
|
+
const copies = [];
|
|
1204
|
+
__oomBegin();
|
|
1205
|
+
try {
|
|
1206
|
+
let deferred1_0;
|
|
1207
|
+
let deferred1_1;
|
|
1208
|
+
try {
|
|
1209
|
+
copies.length = 0;
|
|
1210
|
+
const ret = wasm.version();
|
|
1211
|
+
deferred1_0 = ret[0];
|
|
1212
|
+
deferred1_1 = ret[1];
|
|
1213
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1214
|
+
} finally {
|
|
1215
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1220
|
+
throw __oomNormalize(error, context);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* @param {Int32Array} vertices
|
|
1226
|
+
* @param {Uint32Array} offsets
|
|
1227
|
+
* @param {Float64Array} frames
|
|
1228
|
+
* @param {number} frame_count
|
|
1229
|
+
* @param {number} min_persistence
|
|
1230
|
+
* @param {number} coeff_field
|
|
1231
|
+
* @param {Float64Array} rep_times
|
|
1232
|
+
* @param {any} with_reps
|
|
1233
|
+
* @param {Uint32Array} rep_dims
|
|
1234
|
+
* @param {any} filter_dims
|
|
1235
|
+
* @returns {any}
|
|
1236
|
+
*/
|
|
1237
|
+
function vineyardFlat(vertices, offsets, frames, frame_count, min_persistence, coeff_field, rep_times, with_reps, rep_dims, filter_dims) {
|
|
1238
|
+
const context = { function: "vineyard", input: {"vertices": vertices.length,"offsets": offsets.length,"frames": frames.length,"rep_times": rep_times.length,"rep_dims": rep_dims.length}, parameters: {"frame_count": frame_count,"minPersistence": min_persistence,"coeff": coeff_field,"with_reps": with_reps,"filter_dims": filter_dims} };
|
|
1239
|
+
const copies = [];
|
|
1240
|
+
__oomBegin();
|
|
1241
|
+
try {
|
|
1242
|
+
const ptr0 = passArray32ToWasm0(vertices, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1244
|
+
const ptr1 = passArray32ToWasm0(offsets, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1245
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1246
|
+
const ptr2 = passArrayF64ToWasm0(frames, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1247
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1248
|
+
const ptr3 = passArrayF64ToWasm0(rep_times, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1249
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1250
|
+
const ptr4 = passArray32ToWasm0(rep_dims, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1251
|
+
const len4 = WASM_VECTOR_LEN;
|
|
1252
|
+
copies.length = 0;
|
|
1253
|
+
const ret = wasm.vineyardFlat(ptr0, len0, ptr1, len1, ptr2, len2, frame_count, min_persistence, coeff_field, ptr3, len3, with_reps, ptr4, len4, filter_dims);
|
|
1254
|
+
if (ret[2]) {
|
|
1255
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1256
|
+
}
|
|
1257
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1258
|
+
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1261
|
+
throw __oomNormalize(error, context);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* @param {Int32Array} vertices
|
|
1267
|
+
* @param {Uint32Array} offsets
|
|
1268
|
+
* @param {Float64Array} filtrations
|
|
1269
|
+
* @param {number} ambient_dim
|
|
1270
|
+
* @param {any} single
|
|
1271
|
+
* @param {number} birth
|
|
1272
|
+
* @param {number} death
|
|
1273
|
+
* @param {number} min_persistence
|
|
1274
|
+
* @returns {Float64Array}
|
|
1275
|
+
*/
|
|
1276
|
+
function volumeOptimalCyclesFlat(vertices, offsets, filtrations, ambient_dim, single, birth, death, min_persistence) {
|
|
1277
|
+
const context = { function: "volumeOptimalCycles", input: {"vertices": vertices.length,"offsets": offsets.length,"filtrations": filtrations.length}, parameters: {"ambient_dim": ambient_dim,"single": single,"birth": birth,"death": death,"minPersistence": min_persistence} };
|
|
1278
|
+
const copies = [];
|
|
1279
|
+
__oomBegin();
|
|
1280
|
+
try {
|
|
1281
|
+
const ptr0 = passArray32ToWasm0(vertices, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1283
|
+
const ptr1 = passArray32ToWasm0(offsets, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1284
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1285
|
+
const ptr2 = passArrayF64ToWasm0(filtrations, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1286
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1287
|
+
copies.length = 0;
|
|
1288
|
+
const ret = wasm.volumeOptimalCyclesFlat(ptr0, len0, ptr1, len1, ptr2, len2, ambient_dim, single, birth, death, min_persistence);
|
|
1289
|
+
if (ret[3]) {
|
|
1290
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1291
|
+
}
|
|
1292
|
+
try { return new Float64Array(getArrayF64FromWasm0(ret[0], ret[1])); } catch (error) {
|
|
1293
|
+
if (error instanceof RangeError) throw __oomCapacity(context, 'output-copy', ret[1] * 8, {elementBytes:8, elements:ret[1]});
|
|
1294
|
+
throw error;
|
|
1295
|
+
} finally { wasm.__wbindgen_free(ret[0], ret[1] * 8, 8); }
|
|
1296
|
+
|
|
1297
|
+
} catch (error) {
|
|
1298
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1299
|
+
throw __oomNormalize(error, context);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* `flat_tolerance`: NaN (or an omitted argument) is off.
|
|
1305
|
+
* @param {Float64Array} coords
|
|
1306
|
+
* @param {number} max_squared_radius
|
|
1307
|
+
* @param {number} flat_tolerance
|
|
1308
|
+
* @returns {any}
|
|
1309
|
+
*/
|
|
1310
|
+
function weightedAlphaComplexFlat(coords, max_squared_radius, flat_tolerance) {
|
|
1311
|
+
const context = { function: "alphaComplex", input: {points: coords.length / 4, storedCoordinatesPerPoint: 4}, parameters: {"maxSquaredRadius": (max_squared_radius === 0 ? Infinity : max_squared_radius),"flatTolerance": (Number.isNaN(flat_tolerance) ? undefined : flat_tolerance)} };
|
|
1312
|
+
const copies = [];
|
|
1313
|
+
__oomBegin();
|
|
1314
|
+
try {
|
|
1315
|
+
const ptr0 = passArrayF64ToWasm0(coords, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1317
|
+
copies.length = 0;
|
|
1318
|
+
const ret = wasm.weightedAlphaComplexFlat(ptr0, len0, max_squared_radius, flat_tolerance);
|
|
1319
|
+
if (ret[2]) {
|
|
1320
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1321
|
+
}
|
|
1322
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1323
|
+
|
|
1324
|
+
} catch (error) {
|
|
1325
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1326
|
+
throw __oomNormalize(error, context);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* @param {Float64Array} coords
|
|
1332
|
+
* @param {number} max_squared_radius
|
|
1333
|
+
* @param {number} coeff_field
|
|
1334
|
+
* @param {any} with_simplices
|
|
1335
|
+
* @param {number} flat_tolerance
|
|
1336
|
+
* @returns {any}
|
|
1337
|
+
*/
|
|
1338
|
+
function weightedAlphaPipeline(coords, max_squared_radius, coeff_field, with_simplices, flat_tolerance) {
|
|
1339
|
+
const context = { function: "alphaPersistence", input: {points: coords.length / 4, storedCoordinatesPerPoint: 4}, parameters: {"maxSquaredRadius": (max_squared_radius === 0 ? Infinity : max_squared_radius),"coeff": coeff_field,"complex": with_simplices,"flatTolerance": (Number.isNaN(flat_tolerance) ? undefined : flat_tolerance)} };
|
|
1340
|
+
const copies = [];
|
|
1341
|
+
__oomBegin();
|
|
1342
|
+
try {
|
|
1343
|
+
const ptr0 = passArrayF64ToWasm0(coords, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1344
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1345
|
+
copies.length = 0;
|
|
1346
|
+
const ret = wasm.weightedAlphaPipeline(ptr0, len0, max_squared_radius, coeff_field, with_simplices, flat_tolerance);
|
|
1347
|
+
if (ret[2]) {
|
|
1348
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1349
|
+
}
|
|
1350
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1351
|
+
|
|
1352
|
+
} catch (error) {
|
|
1353
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1354
|
+
throw __oomNormalize(error, context);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* @param {Float64Array} points
|
|
1360
|
+
* @param {number} q
|
|
1361
|
+
* @param {number} theta
|
|
1362
|
+
* @param {Float64Array} normals_or_k
|
|
1363
|
+
* @param {number} max_simplex_dimension
|
|
1364
|
+
* @param {number} max_eps
|
|
1365
|
+
* @returns {any}
|
|
1366
|
+
*/
|
|
1367
|
+
function wingComplexFlat(points, q, theta, normals_or_k, max_simplex_dimension, max_eps) {
|
|
1368
|
+
const context = { function: "wingComplex", input: {"points": points.length,"normals_or_k": normals_or_k.length}, parameters: {"q": q,"theta": theta,"maxDim": max_simplex_dimension,"max_eps": max_eps} };
|
|
1369
|
+
const copies = [];
|
|
1370
|
+
__oomBegin();
|
|
1371
|
+
try {
|
|
1372
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1373
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1374
|
+
const ptr1 = passArrayF64ToWasm0(normals_or_k, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1375
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1376
|
+
copies.length = 0;
|
|
1377
|
+
const ret = wasm.wingComplexFlat(ptr0, len0, q, theta, ptr1, len1, max_simplex_dimension, max_eps);
|
|
1378
|
+
if (ret[2]) {
|
|
1379
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1380
|
+
}
|
|
1381
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1382
|
+
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1385
|
+
throw __oomNormalize(error, context);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* @param {Float64Array} points
|
|
1391
|
+
* @param {number} q
|
|
1392
|
+
* @param {number} theta
|
|
1393
|
+
* @param {Float64Array} normals_or_k
|
|
1394
|
+
* @param {number} max_simplex_dimension
|
|
1395
|
+
* @param {number} max_eps
|
|
1396
|
+
* @param {number} coeff_field
|
|
1397
|
+
* @param {any} with_simplices
|
|
1398
|
+
* @returns {any}
|
|
1399
|
+
*/
|
|
1400
|
+
function wingPipeline(points, q, theta, normals_or_k, max_simplex_dimension, max_eps, coeff_field, with_simplices) {
|
|
1401
|
+
const context = { function: "wingPersistence", input: {"points": points.length,"normals_or_k": normals_or_k.length}, parameters: {"q": q,"theta": theta,"maxDim": max_simplex_dimension,"max_eps": max_eps,"coeff": coeff_field,"complex": with_simplices} };
|
|
1402
|
+
const copies = [];
|
|
1403
|
+
__oomBegin();
|
|
1404
|
+
try {
|
|
1405
|
+
const ptr0 = passArrayF64ToWasm0(points, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1406
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1407
|
+
const ptr1 = passArrayF64ToWasm0(normals_or_k, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1408
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1409
|
+
copies.length = 0;
|
|
1410
|
+
const ret = wasm.wingPipeline(ptr0, len0, q, theta, ptr1, len1, max_simplex_dimension, max_eps, coeff_field, with_simplices);
|
|
1411
|
+
if (ret[2]) {
|
|
1412
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1413
|
+
}
|
|
1414
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1415
|
+
|
|
1416
|
+
} catch (error) {
|
|
1417
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1418
|
+
throw __oomNormalize(error, context);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* @param {Float64Array} records
|
|
1424
|
+
* @param {any} with_values
|
|
1425
|
+
* @returns {any}
|
|
1426
|
+
*/
|
|
1427
|
+
function zigzagPersistenceFlat(records, with_values) {
|
|
1428
|
+
const context = { function: "zigzagPersistence", input: {"records": records.length}, parameters: {"with_values": with_values} };
|
|
1429
|
+
const copies = [];
|
|
1430
|
+
__oomBegin();
|
|
1431
|
+
try {
|
|
1432
|
+
const ptr0 = passArrayF64ToWasm0(records, (size, align) => __oomAllocate(size, align, copies, context));
|
|
1433
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1434
|
+
copies.length = 0;
|
|
1435
|
+
const ret = wasm.zigzagPersistenceFlat(ptr0, len0, with_values);
|
|
1436
|
+
if (ret[2]) {
|
|
1437
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1438
|
+
}
|
|
1439
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1440
|
+
|
|
1441
|
+
} catch (error) {
|
|
1442
|
+
if (!__oomPoisoned) for (const [ptr, size, align] of copies) wasm.__wbindgen_free(ptr, size, align);
|
|
1443
|
+
throw __oomNormalize(error, context);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function __wbg_get_imports() {
|
|
1447
|
+
const import0 = {
|
|
1448
|
+
__proto__: null,
|
|
1449
|
+
__wbg___wbindgen_is_falsy_16bd49b68658263e: function(arg0) {
|
|
1450
|
+
const ret = !arg0;
|
|
1451
|
+
return ret;
|
|
1452
|
+
},
|
|
1453
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
1454
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1455
|
+
},
|
|
1456
|
+
__wbg_instanceof_RangeError_62996e9dbf747e67: function(arg0) {
|
|
1457
|
+
let result;
|
|
1458
|
+
try {
|
|
1459
|
+
result = arg0 instanceof RangeError;
|
|
1460
|
+
} catch (_) {
|
|
1461
|
+
result = false;
|
|
1462
|
+
}
|
|
1463
|
+
const ret = result;
|
|
1464
|
+
return ret;
|
|
1465
|
+
},
|
|
1466
|
+
__wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
|
|
1467
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
1468
|
+
return ret;
|
|
1469
|
+
},
|
|
1470
|
+
__wbg_new_511b7d84dfb30888: function() { return handleError(function (arg0, arg1) {
|
|
1471
|
+
const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
|
|
1472
|
+
return ret;
|
|
1473
|
+
}, arguments); },
|
|
1474
|
+
__wbg_new_55ed41becb58cd16: function() { return handleError(function (arg0, arg1) {
|
|
1475
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
1476
|
+
return ret;
|
|
1477
|
+
}, arguments); },
|
|
1478
|
+
__wbg_new_617a8cdb8bb1130e: function() {
|
|
1479
|
+
const ret = new Object();
|
|
1480
|
+
return ret;
|
|
1481
|
+
},
|
|
1482
|
+
__wbg_new_6ab88fbe741af6b5: function(arg0, arg1) {
|
|
1483
|
+
const ret = new RangeError(getStringFromWasm0(arg0, arg1));
|
|
1484
|
+
return ret;
|
|
1485
|
+
},
|
|
1486
|
+
__wbg_new_81d0c780bd13b3c8: function() { return handleError(function (arg0, arg1) {
|
|
1487
|
+
const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
|
|
1488
|
+
return ret;
|
|
1489
|
+
}, arguments); },
|
|
1490
|
+
__wbg_new_bc524849b21af6ee: function() { return handleError(function (arg0, arg1) {
|
|
1491
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1492
|
+
return ret;
|
|
1493
|
+
}, arguments); },
|
|
1494
|
+
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1495
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1496
|
+
return ret;
|
|
1497
|
+
}, arguments); },
|
|
1498
|
+
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
1499
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1500
|
+
const ret = arg0;
|
|
1501
|
+
return ret;
|
|
1502
|
+
},
|
|
1503
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1504
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1505
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1506
|
+
return ret;
|
|
1507
|
+
},
|
|
1508
|
+
__wbindgen_init_externref_table: function() {
|
|
1509
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1510
|
+
const offset = table.grow(4);
|
|
1511
|
+
table.set(0, undefined);
|
|
1512
|
+
table.set(offset + 0, undefined);
|
|
1513
|
+
table.set(offset + 1, null);
|
|
1514
|
+
table.set(offset + 2, true);
|
|
1515
|
+
table.set(offset + 3, false);
|
|
1516
|
+
},
|
|
1517
|
+
};
|
|
1518
|
+
return {
|
|
1519
|
+
__proto__: null,
|
|
1520
|
+
"./tda_wasm_bg.js": import0,
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
const PreparedComplexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1525
|
+
? { register: () => {}, unregister: () => {} }
|
|
1526
|
+
: new FinalizationRegistry(({ptr,epoch}) => { if (epoch === __oomEpoch) wasm.__wbg_preparedcomplex_free(ptr, 1); });
|
|
1527
|
+
|
|
1528
|
+
function addToExternrefTable0(obj) {
|
|
1529
|
+
const idx = wasm.__externref_table_alloc();
|
|
1530
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1531
|
+
return idx;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
1535
|
+
ptr = ptr >>> 0;
|
|
1536
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
1540
|
+
ptr = ptr >>> 0;
|
|
1541
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
1545
|
+
ptr = ptr >>> 0;
|
|
1546
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1550
|
+
ptr = ptr >>> 0;
|
|
1551
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
1555
|
+
function getFloat64ArrayMemory0() {
|
|
1556
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
1557
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
1558
|
+
}
|
|
1559
|
+
return cachedFloat64ArrayMemory0;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
let cachedInt32ArrayMemory0 = null;
|
|
1563
|
+
function getInt32ArrayMemory0() {
|
|
1564
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
1565
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
1566
|
+
}
|
|
1567
|
+
return cachedInt32ArrayMemory0;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
function getStringFromWasm0(ptr, len) {
|
|
1571
|
+
return decodeText(ptr >>> 0, len);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
let cachedUint32ArrayMemory0 = null;
|
|
1575
|
+
function getUint32ArrayMemory0() {
|
|
1576
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
1577
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
1578
|
+
}
|
|
1579
|
+
return cachedUint32ArrayMemory0;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1583
|
+
function getUint8ArrayMemory0() {
|
|
1584
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1585
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1586
|
+
}
|
|
1587
|
+
return cachedUint8ArrayMemory0;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
function handleError(f, args) {
|
|
1591
|
+
try {
|
|
1592
|
+
return f.apply(this, args);
|
|
1593
|
+
} catch (e) {
|
|
1594
|
+
const idx = addToExternrefTable0(e);
|
|
1595
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
1600
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1601
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
1602
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1603
|
+
return ptr;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
1607
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
1608
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
1609
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1610
|
+
return ptr;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
function takeFromExternrefTable0(idx) {
|
|
1614
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1615
|
+
wasm.__externref_table_dealloc(idx);
|
|
1616
|
+
return value;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1620
|
+
cachedTextDecoder.decode();
|
|
1621
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1622
|
+
let numBytesDecoded = 0;
|
|
1623
|
+
function decodeText(ptr, len) {
|
|
1624
|
+
numBytesDecoded += len;
|
|
1625
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1626
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1627
|
+
cachedTextDecoder.decode();
|
|
1628
|
+
numBytesDecoded = len;
|
|
1629
|
+
}
|
|
1630
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
let WASM_VECTOR_LEN = 0;
|
|
1634
|
+
|
|
1635
|
+
let wasmModule, wasmInstance, wasm;
|
|
1636
|
+
function __wbg_finalize_init(instance, module) {
|
|
1637
|
+
const limits = WebAssembly.Module.customSections(module, 'topolab.memory-limit');
|
|
1638
|
+
if (limits.length) __oomLimit = Number(new TextDecoder().decode(limits[limits.length - 1]));
|
|
1639
|
+
wasmInstance = instance;
|
|
1640
|
+
wasm = __oomExports(instance.exports);
|
|
1641
|
+
__oomEpoch++;
|
|
1642
|
+
__oomInitialBytes = wasm.memory.buffer.byteLength;
|
|
1643
|
+
__oomRecordAddress = wasm.__oom_record();
|
|
1644
|
+
__capacityRecordAddress = wasm.__capacity_record();
|
|
1645
|
+
wasmModule = module;
|
|
1646
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1647
|
+
cachedInt32ArrayMemory0 = null;
|
|
1648
|
+
cachedUint32ArrayMemory0 = null;
|
|
1649
|
+
cachedUint8ArrayMemory0 = null;
|
|
1650
|
+
wasm.__wbindgen_start();
|
|
1651
|
+
return wasm;
|
|
1652
|
+
}
|
|
1653
|
+
// Only evaluated on refusal. Sizes describe a fresh instance with retained
|
|
1654
|
+
// handles discarded; this is an estimate, never an admission check.
|
|
1655
|
+
const __oomPhases = ['allocator','edge list','adjacency matrix','edge collapse',
|
|
1656
|
+
'coboundary columns','Delaunay triangulation','filtration','boundary matrix',
|
|
1657
|
+
'cubical cells','cost matrix','transport plan','transport solver',
|
|
1658
|
+
'sorted samples','projections','directions','result','input validation',
|
|
1659
|
+
'geometric neighborhoods','zigzag interval state','volume optimization',
|
|
1660
|
+
'representation grid','ladder matrices','(unused)','catalogue'];
|
|
1661
|
+
function __oomSize(bytes) {
|
|
1662
|
+
const units=['bytes','KiB','MiB','GiB'];
|
|
1663
|
+
let u=0; while(bytes>=1024 && u<3) {bytes/=1024;u++;}
|
|
1664
|
+
return bytes.toFixed(2)+' '+units[u];
|
|
1665
|
+
}
|
|
1666
|
+
function __oomEstimate(details) {
|
|
1667
|
+
const {function:fn,input:i,parameters:p,requestedBytes:r}=details;
|
|
1668
|
+
const headroom=Math.max(0,details.limitBytes-__oomInitialBytes);
|
|
1669
|
+
// Committed pages are NOT live usage. Their sum with the failed request
|
|
1670
|
+
// is a conservative pressure observation, not an exact peak calculation.
|
|
1671
|
+
const pressure=details.memoryBytes+r;
|
|
1672
|
+
const budget=0.5*headroom;
|
|
1673
|
+
const limits=details.allocationLimitBytes;
|
|
1674
|
+
let n,m,degree=2,working,unit='points per side',law,reference;
|
|
1675
|
+
if(fn==='ripsPersistence' && (p.maxDim??1)<=1 && (p.maxEdgeLength===Infinity) && p.coeff===2) {
|
|
1676
|
+
n=i.points??i.rows;
|
|
1677
|
+
// Infinity bounds edges by n*(n-1)/2; the enclosing-radius shortcut
|
|
1678
|
+
// can remove some. Radix staging and reduction also occupy memory.
|
|
1679
|
+
working=x=>(i.rows?56:48)*x*x+8*(i.dimension??0)*x;
|
|
1680
|
+
unit='points';law='Rips edge storage O(n^2), at most n*(n-1)/2 edges; same maxDim<=1, Infinity and coeff=2. Reduction is data dependent.';
|
|
1681
|
+
if(p.maxDim===1&&((i.dimension===3)||i.rows)) reference={size:i.rows?4096:8192,limitBytes:2147483648,unit:'points',parameters:'uniform unit-cube cloud, maxDim=1, Infinity, coeff=2; dense Euclidean matrix when applicable'};
|
|
1682
|
+
} else if((fn==='cubicalComplex'||fn==='cubicalPersistence') && i.shape?.length>=1 && i.shape.length<=3 && (fn==='cubicalComplex'||p.coeff===2)) {
|
|
1683
|
+
const d=i.shape.length; n=i.cells;degree=1;
|
|
1684
|
+
working=x=>32*3**d*x;
|
|
1685
|
+
unit='grid cells';law='Cubical cell count O(3^d * voxels), fixed dimension and aspect ratio, coeff=2. Reduction fill depends on values; conservative structural model.';
|
|
1686
|
+
if(fn==='cubicalPersistence'&&p.construction!=='V'&&d>=2&&i.shape.every(x=>x===i.shape[0])) reference={size:(d===2?4096**2:128**3),limitBytes:2147483648,unit:'grid cells',parameters:'uniform values, construction T, coeff=2, equal grid sides'};
|
|
1687
|
+
} else if(fn==='ripsComplex' && p.maxEdgeLength===Infinity && p.maxDim>=0 && p.maxDim<=3) {
|
|
1688
|
+
n=i.points??i.rows;degree=Math.max(i.rows?2:1,p.maxDim+1);
|
|
1689
|
+
working=x=>{let cells=0,choose=1;for(let k=1;k<=p.maxDim+1;k++){choose*=Math.max(0,x-k+1)/k;cells+=choose;}return 64*cells+(i.rows?8*x*x:8*x*(i.dimension??1));};
|
|
1690
|
+
unit='points';law='Full Rips complex bounded by sum(k=1..maxDim+1) binomial(n,k) simplices, plus graph and input, at Infinity; fixed maxDim<=3.';
|
|
1691
|
+
} else if(fn==='diagramWasserstein' && i.n>0 && i.m>0) {
|
|
1692
|
+
n=i.n;m=i.m;const ratio=m/n;
|
|
1693
|
+
working=x=>(x+1)*(ratio*x+1)>16777216?Infinity:64*(x+1)*(ratio*x+1)+512*(1+ratio)*x;
|
|
1694
|
+
unit='pairs per source diagram';law='Diagram Wasserstein O((n+1)*(m+1)), finite-pair counts bounded by total pairs, fixed ratio; includes cost matrix, diagonal node and simplex scratch. Existing 16777216-entry cap still applies.';
|
|
1695
|
+
if(n===m&&p.order===2&&p.internal_p===Infinity) reference={size:2048,limitBytes:2147483648,unit:'pairs per diagram',parameters:'finite uniform births/lifetimes, order=2, internalP=Infinity'};
|
|
1696
|
+
} else if(fn==='persistenceLandscape' && i.gridPoints>0 && p.first>=1 && p.last>=p.first) {
|
|
1697
|
+
n=i.gridPoints;degree=1;
|
|
1698
|
+
working=x=>8*x*(p.last-p.first+1+2*Math.min(p.last,16)+8)+64*i.pairElements;
|
|
1699
|
+
unit='grid points';law='Landscape memory O(gridPoints*levels+pairs), fixed first/last levels and same pairs. Includes output, per-grid work and sort buffers.';
|
|
1700
|
+
} else if(fn==='persistenceImage' && i.shape?.every(x=>x>0)) {
|
|
1701
|
+
n=i.cells;degree=1;
|
|
1702
|
+
working=x=>32*x+64*i.pairElements;
|
|
1703
|
+
unit='pixels';law='Persistence image memory O(rows*cols+pairs), fixed aspect ratio and same pairs. Output and per-axis work; double output allowance.';
|
|
1704
|
+
}
|
|
1705
|
+
if(!working || !(n>0) || !Number.isFinite(r) || !(r>0)) {
|
|
1706
|
+
details.estimateMethod='Omitted: data-dependent output size or reduction fill, or missing input dimensions, prevent a whole-input estimate. Input-copy and result-copy ceilings alone do not predict pipeline capacity.';
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
// Invert both the full working-set model and the failed structure's
|
|
1710
|
+
// measured pressure under its known degree. Round down, never up.
|
|
1711
|
+
const structural=n*Math.min(1,(budget/Math.max(pressure,1))**(1/degree), (limits/r)**(1/degree));
|
|
1712
|
+
let lo=0,hi=Math.min(n,structural);
|
|
1713
|
+
for(let k=0;k<48;k++) {const mid=(lo+hi)/2;if(working(mid)<=budget)lo=mid;else hi=mid;}
|
|
1714
|
+
let fit=Math.floor(lo);
|
|
1715
|
+
if(reference) {
|
|
1716
|
+
// Cross-check against the same-parameter capacity-benchmark doubling ladder.
|
|
1717
|
+
// A measured largest success is a conservative ceiling, not the true
|
|
1718
|
+
// maximum. Scaling that reference is still only a model at 64 MiB.
|
|
1719
|
+
fit=Math.min(fit,Math.floor(reference.size*(details.limitBytes/reference.limitBytes)**(1/degree)));
|
|
1720
|
+
details.capacityReference=reference;
|
|
1721
|
+
}
|
|
1722
|
+
if(fit<1) {details.estimateMethod=law+' Omitted: fixed inputs or the modeled working set leave no positive retry size.';return;}
|
|
1723
|
+
if(i.shape) {
|
|
1724
|
+
const factor=(fit/n)**(1/i.shape.length);
|
|
1725
|
+
const shape=i.shape.map(x=>Math.max(1,Math.floor(x*factor)));
|
|
1726
|
+
fit=shape.reduce((a,b)=>a*b,1);details.estimatedInputShape=shape;
|
|
1727
|
+
} else if(m) details.estimatedInputShape=[fit,Math.floor(fit*m/n)];
|
|
1728
|
+
if(fit<1 || (details.estimatedInputShape?.some(x=>x<1))) return;
|
|
1729
|
+
details.estimatedMaxInput=fit;
|
|
1730
|
+
details.estimateUnit=unit;
|
|
1731
|
+
details.estimateMethod=law+' Invert requestedBytes and committedBytes pressure with growth degree '+degree+'; take the smaller of that and the full working-set model using 50% of fresh-instance headroom, bounded by the single-buffer ceiling'+(reference?' and cross-checked against the 2026-10-17 capacity benchmark at the stated parameters':'')+'. Round down. Discard retained handles first; fragmentation, data-dependent fill and later stages can reduce capacity. Estimate, not a guarantee.';
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// Embedded inside each generated glue instance by patch_memory_glue.mjs.
|
|
1735
|
+
let __oomLimit = 4294967296;
|
|
1736
|
+
let __oomEpoch = 0, __oomPoisoned = false, __oomInitialBytes = 0;
|
|
1737
|
+
let __oomRecovery = () => {};
|
|
1738
|
+
let __oomCallDepth = 0, __oomFailureContext;
|
|
1739
|
+
function __oom_on_recover(callback) { __oomRecovery = callback; }
|
|
1740
|
+
function __oom_status() { return {memory:wasm.memory, epoch:__oomEpoch, limitBytes:__oomLimit}; }
|
|
1741
|
+
function __oomExports(raw) {
|
|
1742
|
+
const exports = {...raw};
|
|
1743
|
+
for (const [name, fn] of Object.entries(raw)) {
|
|
1744
|
+
if (typeof fn !== 'function') continue;
|
|
1745
|
+
exports[name] = (...args) => {
|
|
1746
|
+
if (__oomPoisoned) {
|
|
1747
|
+
if (/free|dealloc/.test(name)) return;
|
|
1748
|
+
throw new WebAssembly.RuntimeError('instance already trapped');
|
|
1749
|
+
}
|
|
1750
|
+
__oomCallDepth++;
|
|
1751
|
+
try {
|
|
1752
|
+
const result=fn(...args);
|
|
1753
|
+
if (__oomPoisoned) throw new WebAssembly.RuntimeError('nested engine call trapped');
|
|
1754
|
+
return result;
|
|
1755
|
+
}
|
|
1756
|
+
catch (error) {
|
|
1757
|
+
if (error instanceof WebAssembly.RuntimeError) __oomPoisoned = true;
|
|
1758
|
+
throw error;
|
|
1759
|
+
} finally { __oomCallDepth--; }
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
return exports;
|
|
1763
|
+
}
|
|
1764
|
+
function __oomBegin() {
|
|
1765
|
+
if (__oomPoisoned) throw new WebAssembly.RuntimeError('instance already trapped');
|
|
1766
|
+
// A previous fallible reservation may have returned an ordinary error.
|
|
1767
|
+
// Clear only the failure marker; Rust exports set their own function id.
|
|
1768
|
+
new Uint32Array(wasm.memory.buffer, __oomRecordAddress, 5)[0] = 0;
|
|
1769
|
+
new Uint32Array(wasm.memory.buffer, __capacityRecordAddress, 5).fill(0);
|
|
1770
|
+
}
|
|
1771
|
+
function __oomCapacity(context, phase, requestedBytes, extra = {}) {
|
|
1772
|
+
const memoryBytes = extra.memoryBytes ?? wasm.memory.buffer.byteLength;
|
|
1773
|
+
// A recorded allocator failure whose request still fits the declared
|
|
1774
|
+
// remaining address space means the host refused growth before that max.
|
|
1775
|
+
// The reached pages are a conservative retry budget, not a discovered
|
|
1776
|
+
// permanent browser ceiling. Never infer this from a Layout/JS-copy error.
|
|
1777
|
+
const record = new Uint32Array(wasm.memory.buffer, __oomRecordAddress, 5);
|
|
1778
|
+
const capacityOverflow = extra.capacityOverflow === true || (phase === 'input-copy' && requestedBytes > 2147483647);
|
|
1779
|
+
const growthRefused = !capacityOverflow && phase !== 'output-copy' && record[0] > 0
|
|
1780
|
+
&& memoryBytes < __oomLimit && requestedBytes <= __oomLimit - memoryBytes;
|
|
1781
|
+
const limitBytes = capacityOverflow ? Math.min(__oomLimit,2147483647) : growthRefused ? memoryBytes : __oomLimit;
|
|
1782
|
+
const details = {...context, phase, requestedBytes, inUseBytes:null,
|
|
1783
|
+
memoryBytes, committedBytes:memoryBytes, limitBytes, declaredMaxBytes:__oomLimit,
|
|
1784
|
+
allocationLimitBytes:Math.min(limitBytes,2147483647), ...extra};
|
|
1785
|
+
if (extra.elementBytes > 0) details.capacityEstimate = {
|
|
1786
|
+
maximumElements: Math.floor(details.allocationLimitBytes / extra.elementBytes),
|
|
1787
|
+
method:'Absolute ceiling for this buffer alone; other allocations and fragmentation reduce it. Not a largest-fitting whole-input estimate.'
|
|
1788
|
+
};
|
|
1789
|
+
__oomEstimate(details);
|
|
1790
|
+
const describe = value => JSON.stringify(value,(_key,x)=>typeof x==='number' && !Number.isFinite(x)?String(x):x);
|
|
1791
|
+
const remedy = __oomRemedies[context.function] ?? 'Use a smaller input.';
|
|
1792
|
+
const ceiling = requestedBytes > 2147483647 ? '; exceeds the wasm32 per-allocation ceiling (just below 2 GiB)' : '';
|
|
1793
|
+
// A growth the standard library refused before its size was checked
|
|
1794
|
+
// (the panic hook's record, alignment 0): only a lower bound is known.
|
|
1795
|
+
const atLeast = capacityOverflow && extra.alignment === 0 ? 'at least ' : '';
|
|
1796
|
+
const growth = growthRefused ? '; this browser refused to grow WebAssembly memory beyond '+__oomSize(limitBytes)+' (declared maximum '+__oomSize(__oomLimit)+')' : '';
|
|
1797
|
+
const fit = details.estimatedMaxInput;
|
|
1798
|
+
const estimate = fit ? '. About '+fit.toLocaleString('en-US')+' '+details.estimateUnit+' should fit with these parameters'+(details.estimatedInputShape ? ' (shape '+details.estimatedInputShape.join(' × ')+')' : '')+' in a fresh instance; estimate, not a guarantee' : '. No whole-input fit estimate is available for this stage';
|
|
1799
|
+
const error = new RangeError(context.function+': input too large for WebAssembly memory while building '+phase+'; '+atLeast+__oomSize(requestedBytes)+' requested'+ceiling+'; '+__oomSize(details.memoryBytes)+' committed (live usage unknown) of a '+__oomSize(__oomLimit)+' maximum'+growth+'; input '+describe(context.input)+'; parameters '+describe(context.parameters)+estimate+'. '+remedy);
|
|
1800
|
+
error.code='TOO_LARGE'; error.details=details;
|
|
1801
|
+
return error;
|
|
1802
|
+
}
|
|
1803
|
+
function __oomAllocate(size, align, copies, context) {
|
|
1804
|
+
const ptr=Number.isSafeInteger(size) && size>=0 && size<=Math.min(__oomLimit,2147483647) ? wasm.oom_reserve(size/align,align)>>>0 : 0;
|
|
1805
|
+
if (!ptr) throw __oomCapacity(context,'input-copy',size,{elements:size/align,elementBytes:align});
|
|
1806
|
+
copies.push([ptr,size,align]);
|
|
1807
|
+
return ptr;
|
|
1808
|
+
}
|
|
1809
|
+
function __oomNormalize(error, context) {
|
|
1810
|
+
if (error instanceof WebAssembly.RuntimeError) {
|
|
1811
|
+
// A nested user callback may catch a trap while an outer Rust call
|
|
1812
|
+
// is still on the stack. Recover only after all old wasm frames exit.
|
|
1813
|
+
__oomFailureContext ??= context;
|
|
1814
|
+
if (__oomCallDepth) throw error;
|
|
1815
|
+
context=__oomFailureContext;
|
|
1816
|
+
__oomFailureContext=undefined;
|
|
1817
|
+
// Read the poisoned instance before replacing any glue state. Do not
|
|
1818
|
+
// call back into it: even the record's address is cached at finalize.
|
|
1819
|
+
const record=Array.from(new Uint32Array(wasm.memory.buffer,__oomRecordAddress,5));
|
|
1820
|
+
const capacity=Array.from(new Uint32Array(wasm.memory.buffer,__capacityRecordAddress,5));
|
|
1821
|
+
const failure=(capacity[0] || capacity[1]) ? __oomCapacity(context,__oomPhases[capacity[3]]??'allocator',capacity[0]+4294967296*capacity[1],{
|
|
1822
|
+
capacityOverflow:true,alignment:capacity[2],functionId:record[2],phaseId:capacity[3],memoryBytes:capacity[4]*65536
|
|
1823
|
+
}) : record[0] ? __oomCapacity(context,__oomPhases[record[3]]??'allocator',record[0],{
|
|
1824
|
+
alignment:record[1],functionId:record[2],phaseId:record[3],memoryBytes:record[4]*65536
|
|
1825
|
+
}) : new Error(context.function+': internal WebAssembly trap ('+error.message+'); instance recovered',{cause:error});
|
|
1826
|
+
const compiled=wasmModule;
|
|
1827
|
+
const start=performance.now();
|
|
1828
|
+
__oomPoisoned=false;
|
|
1829
|
+
try {
|
|
1830
|
+
__wbg_finalize_init(new WebAssembly.Instance(compiled,__wbg_get_imports()),compiled);
|
|
1831
|
+
} catch (recoveryError) {
|
|
1832
|
+
__oomPoisoned=true;
|
|
1833
|
+
throw new Error(context.function+': WebAssembly instance recovery failed',{cause:recoveryError});
|
|
1834
|
+
}
|
|
1835
|
+
if (failure.details) failure.details.recoveryMilliseconds=performance.now()-start;
|
|
1836
|
+
// Memory views, scratch addresses and handles are invalidated before
|
|
1837
|
+
// control returns to the caller, including for an internal trap.
|
|
1838
|
+
__oomRecovery(wasm.memory);
|
|
1839
|
+
throw failure;
|
|
1840
|
+
}
|
|
1841
|
+
if (error && error.code==='TOO_LARGE') return error.details?.function ? error : __oomCapacity(context,error.details.phase,error.details.requestedBytes,error.details);
|
|
1842
|
+
// Existing allocation Result errors are retained only where already free.
|
|
1843
|
+
const match=/out of memory allocating (\d+) elements/.exec(error?.message);
|
|
1844
|
+
if (match) {
|
|
1845
|
+
const record=new Uint32Array(wasm.memory.buffer,__oomRecordAddress,5);
|
|
1846
|
+
if(record[0]) return __oomCapacity(context,__oomPhases[record[3]]??'allocator',record[0],{alignment:record[1],functionId:record[2],phaseId:record[3],memoryBytes:record[4]*65536});
|
|
1847
|
+
}
|
|
1848
|
+
return error;
|
|
1849
|
+
}
|
|
1850
|
+
let __oomRecordAddress=0, __capacityRecordAddress=0;
|
|
1851
|
+
// What a caller of each function can make smaller, in the API's own names.
|
|
1852
|
+
const __oomRemedies = {
|
|
1853
|
+
ripsPersistence:'Use fewer points, a smaller maxEdgeLength or a smaller maxDim.',
|
|
1854
|
+
ripsComplex:'Use fewer points, a smaller maxEdgeLength or a smaller maxSimplexDim.',
|
|
1855
|
+
ripsVineyard:'Use fewer points or clouds, a smaller maxEdgeLength or a smaller maxDim.',
|
|
1856
|
+
cechComplex:'Use fewer points, a smaller maxRadius or a smaller maxSimplexDim.',
|
|
1857
|
+
cechPersistence:'Use fewer points, a smaller maxRadius or a smaller maxSimplexDim.',
|
|
1858
|
+
delaunayCechComplex:'Use fewer points or a smaller maxRadius.',
|
|
1859
|
+
alphaComplex:'Use fewer points or a smaller maxSquaredRadius.',
|
|
1860
|
+
alphaPersistence:'Use fewer points or a smaller maxSquaredRadius.',
|
|
1861
|
+
coupledAlphaComplex:'Use a smaller maxSquaredRadius or a smaller maxSimplexDim.',
|
|
1862
|
+
kFoldCoverComplex:'Use fewer points, a smaller k, a smaller maxSquaredRadius or a smaller maxSimplexDim.',
|
|
1863
|
+
kFoldCoverPersistence:'Use fewer points, a smaller k, a smaller maxSquaredRadius or a smaller maxSimplexDim.',
|
|
1864
|
+
witnessComplex:'Use fewer points or landmarks, a smaller maxSquaredRelaxation or a smaller maxSimplexDim.',
|
|
1865
|
+
ellipsoids:'Use fewer points or a smaller neighbors.',
|
|
1866
|
+
ellipsoidRipsComplex:'Use fewer points, a smaller maxEdgeLength or a smaller maxSimplexDim.',
|
|
1867
|
+
ellipsoidRipsPersistence:'Use fewer points, a smaller maxEdgeLength or a smaller maxSimplexDim.',
|
|
1868
|
+
ellipsoidCechComplex:'Use fewer points, a smaller maxRadius or a smaller maxSimplexDim.',
|
|
1869
|
+
ellipsoidCechPersistence:'Use fewer points, a smaller maxRadius or a smaller maxSimplexDim.',
|
|
1870
|
+
wings:'Use fewer points.',
|
|
1871
|
+
wingComplex:'Use fewer points, a smaller maxEpsilon or a smaller maxSimplexDim.',
|
|
1872
|
+
wingPersistence:'Use fewer points, a smaller maxEpsilon or a smaller maxSimplexDim.',
|
|
1873
|
+
boxFiltration:'Use fewer points, a smaller maxSteps or a smaller maxSimplexDim.',
|
|
1874
|
+
boxFiltrationPersistence:'Use fewer points, a smaller maxSteps or a smaller maxSimplexDim.',
|
|
1875
|
+
cubicalComplex:'Use a smaller image or volume.',
|
|
1876
|
+
cubicalPersistence:'Use a smaller image or volume.',
|
|
1877
|
+
cubicalVineyard:'Use fewer or smaller images.',
|
|
1878
|
+
persistence:'Use a smaller complex.',
|
|
1879
|
+
prepareComplex:'Use a smaller complex.',
|
|
1880
|
+
vineyard:'Use a smaller complex or fewer frames.',
|
|
1881
|
+
zigzagPersistence:'Use fewer operations.',
|
|
1882
|
+
volumeOptimalCycles:'Use a smaller complex.',
|
|
1883
|
+
longPairs:'Use a smaller diagram.',
|
|
1884
|
+
bettiNumbers:'Use a smaller diagram.',
|
|
1885
|
+
bettiCurve:'Use a smaller diagram or grid.',
|
|
1886
|
+
persistenceLandscape:'Use a smaller diagram, a smaller grid or fewer layers.',
|
|
1887
|
+
persistenceImage:'Use a smaller diagram or resolution.',
|
|
1888
|
+
diagramWasserstein:'Use smaller diagrams.',
|
|
1889
|
+
diagramBottleneck:'Use smaller diagrams.',
|
|
1890
|
+
intervalApproximation:'Use a shorter ladder (a smaller n) or a smaller filtration.',
|
|
1891
|
+
decomposeCL4:'Use a smaller filtration.',
|
|
1892
|
+
courseRank:'Use a smaller filtration or a shorter course.',
|
|
1893
|
+
ripsThinningLadder:'Use fewer points, fewer edgeLengths or a smaller maxSimplexDim.'
|
|
1894
|
+
};
|
|
1895
|
+
return {
|
|
1896
|
+
exports: { PreparedComplex, bettiCurveFlat, bettiNumbersFlat, boxFiltrationFlat, boxFiltrationPipeline, cechComplexFlat, cechPipeline, computeEllipsoidGeometry, computeWingGeometry, coupledAlphaComplex2DFlat, cubicalComplexFlat, cubicalPersistenceFlat, cubicalVertexPersistenceFlat, cubicalVineyardFlat, delaunayCechComplexFlat, diagramBottleneckFlat, diagramWassersteinFlat, ellipsoidCechComplexFlat, ellipsoidCechPipeline, ellipsoidRipsComplexFlat, ellipsoidRipsPipeline, euclideanWitnessComplexFlat, getPersistentPairs, kFoldCoverComplexFlat, kFoldCoverPipeline, longPairsFlat, persistenceFlat, persistenceImageFlat, persistenceLandscapeFlat, ripsComplexFlat, ripsComplexFromMatrixFlat, ripsPersistenceFlat, ripsPersistenceFromDistanceMatrixFlat, ripsRepresentativesFlat, ripsRepresentativesFromDistanceMatrixFlat, ripsVineyardFlat, version, vineyardFlat, volumeOptimalCyclesFlat, weightedAlphaComplexFlat, weightedAlphaPipeline, wingComplexFlat, wingPipeline, zigzagPersistenceFlat, __oom_on_recover, __oom_status },
|
|
1897
|
+
imports: __wbg_get_imports,
|
|
1898
|
+
finalize: __wbg_finalize_init,
|
|
1899
|
+
};
|
|
1900
|
+
}
|