@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.
Files changed (90) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/CITATION.cff +72 -0
  3. package/LICENSE +21 -0
  4. package/README.md +100 -2
  5. package/SECURITY.md +34 -0
  6. package/THIRD_PARTY_LICENSES.md +696 -0
  7. package/dist/build_info.json +12 -0
  8. package/dist/check.d.ts +118 -0
  9. package/dist/check.d.ts.map +1 -0
  10. package/dist/check.js +298 -0
  11. package/dist/check.js.map +1 -0
  12. package/dist/complex.d.ts +543 -0
  13. package/dist/complex.d.ts.map +1 -0
  14. package/dist/complex.js +712 -0
  15. package/dist/complex.js.map +1 -0
  16. package/dist/diagram.d.ts +116 -0
  17. package/dist/diagram.d.ts.map +1 -0
  18. package/dist/diagram.js +238 -0
  19. package/dist/diagram.js.map +1 -0
  20. package/dist/diagram_of.d.ts +17 -0
  21. package/dist/diagram_of.d.ts.map +1 -0
  22. package/dist/diagram_of.js +40 -0
  23. package/dist/diagram_of.js.map +1 -0
  24. package/dist/experimental.d.ts +14 -0
  25. package/dist/experimental.d.ts.map +1 -0
  26. package/dist/experimental.js +13 -0
  27. package/dist/experimental.js.map +1 -0
  28. package/dist/flat.d.ts +64 -0
  29. package/dist/flat.d.ts.map +1 -0
  30. package/dist/flat.js +158 -0
  31. package/dist/flat.js.map +1 -0
  32. package/dist/index.d.ts +38 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +29 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/ladder/tda_ladder.d.ts +223 -0
  37. package/dist/ladder/tda_ladder.js +1360 -0
  38. package/dist/ladder/tda_ladder_bg.wasm +0 -0
  39. package/dist/ladder/tda_ladder_bg.wasm.d.ts +43 -0
  40. package/dist/ladder.d.ts +306 -0
  41. package/dist/ladder.d.ts.map +1 -0
  42. package/dist/ladder.js +607 -0
  43. package/dist/ladder.js.map +1 -0
  44. package/dist/load.d.ts +53 -0
  45. package/dist/load.d.ts.map +1 -0
  46. package/dist/load.js +173 -0
  47. package/dist/load.js.map +1 -0
  48. package/dist/memory.d.ts +58 -0
  49. package/dist/memory.d.ts.map +1 -0
  50. package/dist/memory.js +2 -0
  51. package/dist/memory.js.map +1 -0
  52. package/dist/persistence.d.ts +349 -0
  53. package/dist/persistence.d.ts.map +1 -0
  54. package/dist/persistence.js +478 -0
  55. package/dist/persistence.js.map +1 -0
  56. package/dist/pkg/tda_wasm.d.ts +13 -0
  57. package/dist/pkg/tda_wasm.js +1900 -0
  58. package/dist/prepared.d.ts +62 -0
  59. package/dist/prepared.d.ts.map +1 -0
  60. package/dist/prepared.js +81 -0
  61. package/dist/prepared.js.map +1 -0
  62. package/dist/source.d.ts +43 -0
  63. package/dist/source.d.ts.map +1 -0
  64. package/dist/source.js +99 -0
  65. package/dist/source.js.map +1 -0
  66. package/dist/tda.wasm +0 -0
  67. package/dist/types.d.ts +146 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +2 -0
  70. package/dist/types.js.map +1 -0
  71. package/dist/vineyard.d.ts +278 -0
  72. package/dist/vineyard.d.ts.map +1 -0
  73. package/dist/vineyard.js +236 -0
  74. package/dist/vineyard.js.map +1 -0
  75. package/package.json +77 -4
  76. package/src/check.ts +338 -0
  77. package/src/complex.ts +1179 -0
  78. package/src/diagram.ts +299 -0
  79. package/src/diagram_of.ts +40 -0
  80. package/src/experimental.ts +13 -0
  81. package/src/flat.ts +204 -0
  82. package/src/index.ts +155 -0
  83. package/src/ladder.ts +903 -0
  84. package/src/load.ts +201 -0
  85. package/src/memory.ts +58 -0
  86. package/src/persistence.ts +752 -0
  87. package/src/prepared.ts +111 -0
  88. package/src/source.ts +132 -0
  89. package/src/types.ts +163 -0
  90. package/src/vineyard.ts +463 -0
package/dist/load.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { LoadSource } from './source.js';
2
+ export type { LoadSource };
3
+ /** The module's exports: called through {@link call}. */
4
+ type Engine = any;
5
+ /**
6
+ * Owners of experimental native handles; ordinary calls retain no state. A
7
+ * cleanup gets `trapped = true` when the instance trapped: it must then
8
+ * drop its handle without calling into the instance.
9
+ */
10
+ type Cleanup = (trapped: boolean) => void;
11
+ /** @internal Register a native owner's cleanup, returning its unregister function. */
12
+ export declare function onUnload(cleanup: Cleanup): () => void;
13
+ /**
14
+ * Load the module. Without `source` it is read from `tda.wasm` next to the
15
+ * package's code (`@topolab/tda/tda.wasm`): from the file in Node, by
16
+ * `fetch` in a browser, where bundlers that understand
17
+ * `new URL(…, import.meta.url)` resolve it. Nothing is written to
18
+ * `globalThis`.
19
+ *
20
+ * Once the module is loaded, `load` returns the same resolved promise and
21
+ * ignores `source`. While a load is in progress, a call with the same
22
+ * `source` (the same value, or none both times) shares that load and its
23
+ * outcome. A call with another `source` waits for the load in progress: if
24
+ * it succeeds, the call resolves too, without using its own `source` (the
25
+ * module is loaded once); if it fails, the call does not share that failure
26
+ * but loads from its own `source`. Two loads never instantiate at once. A
27
+ * failed load is not kept, so a later call can retry with a corrected
28
+ * source; {@link unload} rejects every load in progress.
29
+ */
30
+ export declare function load(source?: LoadSource): Promise<void>;
31
+ /**
32
+ * Drop the module, so that its memory (which wasm never shrinks) can be
33
+ * reclaimed once nothing else refers to it. Results already returned are
34
+ * copies and stay valid. Functions that need the module throw until
35
+ * {@link load} is called again; a load in progress rejects.
36
+ */
37
+ export declare function unload(): void;
38
+ /** Whether the module is loaded (a {@link load} has resolved and no {@link unload} followed). */
39
+ export declare function isLoaded(): boolean;
40
+ /** The package version the loaded module was built as (equal to the package's). */
41
+ export declare function version(): string;
42
+ /** @internal The loaded module; throws when none is. */
43
+ export declare function module(): Engine;
44
+ /**
45
+ * @internal Run `f` on the module for the API function `fn`. Every engine
46
+ * export handles traps and recovery in its generated glue; an engine
47
+ * refusal reaches the caller as the very error the module threw, its
48
+ * message naming `fn` where the engine names the Rust routine that refused.
49
+ */
50
+ export declare function call<T>(fn: string, f: (m: Engine) => T): T;
51
+ /** @internal Run `f` on the module, its errors as the module threw them. */
52
+ export declare function call<T>(f: (m: Engine) => T): T;
53
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,yDAAyD;AAEzD,KAAK,MAAM,GAAG,GAAG,CAAC;AAclB;;;;GAIG;AACH,KAAK,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAG1C,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,IAAI,CAGrD;AAsBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CvD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,IAAI,IAAI,CAE7B;AA4BD,iGAAiG;AACjG,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED,mFAAmF;AACnF,wBAAgB,OAAO,IAAI,MAAM,CAGhC;AAED,wDAAwD;AACxD,wBAAgB,MAAM,IAAI,MAAM,CAG/B;AAKD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5D,4EAA4E;AAC5E,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC"}
package/dist/load.js ADDED
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Loading and unloading the WebAssembly module, and the bridge every
3
+ * function calls it through (internal).
4
+ */
5
+ // @ts-ignore - the module's glue (wasm-bindgen --target web), built with the module
6
+ import { __tda_create } from '../dist/pkg/tda_wasm.js';
7
+ import { compileSource } from './source.js';
8
+ /** The load in progress or done, `null` when none is. */
9
+ let ready = null;
10
+ /** The `source` the load in {@link ready} was given (`undefined` for the default). */
11
+ let readySource;
12
+ /** Settles when the last load started has settled: a new load waits for it, so two never instantiate at once. */
13
+ let settled = Promise.resolve();
14
+ /** The loaded module, `undefined` when none is. */
15
+ let engine;
16
+ /** The loaded module's `version()`, read once at load (a string costs a UTF-8 decode per call). */
17
+ let engineVersion = '';
18
+ /** Incremented by every `unload()`, so a load it overtook drops its instance instead of keeping it. */
19
+ let generation = 0;
20
+ const unloadCleanups = new Set();
21
+ /** @internal Register a native owner's cleanup, returning its unregister function. */
22
+ export function onUnload(cleanup) {
23
+ unloadCleanups.add(cleanup);
24
+ return () => { unloadCleanups.delete(cleanup); };
25
+ }
26
+ /**
27
+ * Instantiates `module` with a glue instance of its own (`__tda_create`, a
28
+ * factory around wasm-bindgen's glue), so the glue
29
+ * reads no global (`fetch`, `Response`, `Request`) and every load has its own
30
+ * module object; a failure rejects the load.
31
+ */
32
+ async function instantiate(module) {
33
+ const glue = __tda_create();
34
+ const instance = await WebAssembly.instantiate(module, glue.imports());
35
+ glue.finalize(instance, module);
36
+ glue.exports.__oom_on_recover(() => {
37
+ const cleanups = [...unloadCleanups];
38
+ unloadCleanups.clear();
39
+ for (const cleanup of cleanups) {
40
+ try {
41
+ cleanup(true);
42
+ }
43
+ catch { /* Recovery must invalidate every owner. */ }
44
+ }
45
+ });
46
+ return glue.exports;
47
+ }
48
+ /**
49
+ * Load the module. Without `source` it is read from `tda.wasm` next to the
50
+ * package's code (`@topolab/tda/tda.wasm`): from the file in Node, by
51
+ * `fetch` in a browser, where bundlers that understand
52
+ * `new URL(…, import.meta.url)` resolve it. Nothing is written to
53
+ * `globalThis`.
54
+ *
55
+ * Once the module is loaded, `load` returns the same resolved promise and
56
+ * ignores `source`. While a load is in progress, a call with the same
57
+ * `source` (the same value, or none both times) shares that load and its
58
+ * outcome. A call with another `source` waits for the load in progress: if
59
+ * it succeeds, the call resolves too, without using its own `source` (the
60
+ * module is loaded once); if it fails, the call does not share that failure
61
+ * but loads from its own `source`. Two loads never instantiate at once. A
62
+ * failed load is not kept, so a later call can retry with a corrected
63
+ * source; {@link unload} rejects every load in progress.
64
+ */
65
+ export function load(source) {
66
+ if (ready && engine === undefined && !Object.is(source, readySource)) {
67
+ const mine = generation;
68
+ const overtaken = () => new Error('@topolab/tda: unload() was called while load() was in progress');
69
+ return ready.then(() => {
70
+ if (mine !== generation)
71
+ throw overtaken();
72
+ }, () => {
73
+ if (mine !== generation)
74
+ throw overtaken();
75
+ return load(source);
76
+ });
77
+ }
78
+ if (!ready) {
79
+ readySource = source;
80
+ const mine = generation;
81
+ const p = settled
82
+ .then(() => compileSource(source, () => new URL('./tda.wasm', import.meta.url), {
83
+ exports: ['version', 'persistenceFlat', '__oom_record'],
84
+ file: 'tda.wasm',
85
+ pkg: '@topolab/tda'
86
+ }))
87
+ .then(instantiate)
88
+ .then((m) => {
89
+ if (mine !== generation) {
90
+ // unload() ran while this load was in flight: it wins
91
+ throw new Error('@topolab/tda: unload() was called while load() was in progress');
92
+ }
93
+ engine = m;
94
+ engineVersion = m.version();
95
+ }, (e) => {
96
+ if (mine === generation)
97
+ ready = null;
98
+ throw e;
99
+ });
100
+ ready = p;
101
+ settled = p.catch(() => undefined);
102
+ }
103
+ return ready;
104
+ }
105
+ /**
106
+ * Drop the module, so that its memory (which wasm never shrinks) can be
107
+ * reclaimed once nothing else refers to it. Results already returned are
108
+ * copies and stay valid. Functions that need the module throw until
109
+ * {@link load} is called again; a load in progress rejects.
110
+ */
111
+ export function unload() {
112
+ drop(false);
113
+ }
114
+ /**
115
+ * Clears the loader's state first, so that nothing a cleanup does can leave
116
+ * the module loaded, then runs every cleanup; after a trap the cleanups are
117
+ * told not to call into the instance. Throws the first error a cleanup
118
+ * threw, once all have run, unless the instance trapped (then the trap is
119
+ * what the caller is told about).
120
+ */
121
+ function drop(trapped) {
122
+ generation++;
123
+ ready = null;
124
+ engine = undefined;
125
+ const cleanups = [...unloadCleanups];
126
+ unloadCleanups.clear();
127
+ let failed = false;
128
+ let first;
129
+ for (const cleanup of cleanups) {
130
+ try {
131
+ cleanup(trapped);
132
+ }
133
+ catch (error) {
134
+ if (!failed)
135
+ first = error;
136
+ failed = true;
137
+ }
138
+ }
139
+ if (failed && !trapped)
140
+ throw first;
141
+ }
142
+ /** Whether the module is loaded (a {@link load} has resolved and no {@link unload} followed). */
143
+ export function isLoaded() {
144
+ return engine !== undefined;
145
+ }
146
+ /** The package version the loaded module was built as (equal to the package's). */
147
+ export function version() {
148
+ module();
149
+ return engineVersion;
150
+ }
151
+ /** @internal The loaded module; throws when none is. */
152
+ export function module() {
153
+ if (engine === undefined)
154
+ throw new Error('@topolab/tda is not loaded: await load() first');
155
+ return engine;
156
+ }
157
+ /** An engine message's leading routine name (`cech_complex: `), after an optional `invalid input: ` or `input too large: `. */
158
+ const ROUTINE = /^((?:invalid input|input too large): )?[a-z][a-z0-9]*(?:_[a-z0-9]+)+: /;
159
+ export function call(a, b) {
160
+ if (typeof a !== 'string')
161
+ return a(module());
162
+ const m = module();
163
+ try {
164
+ return b(m);
165
+ }
166
+ catch (e) {
167
+ if (e instanceof Error && e.code === undefined && ROUTINE.test(e.message)) {
168
+ e.message = e.message.replace(ROUTINE, (_, head) => `${head ?? ''}${a}: `);
169
+ }
170
+ throw e;
171
+ }
172
+ }
173
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oFAAoF;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAS5C,yDAAyD;AACzD,IAAI,KAAK,GAAyB,IAAI,CA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,CAAC;IAC5F,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+HAA+H;AAC/H,MAAM,OAAO,GAAG,wEAAwE,CAAC;AAWzF,MAAM,UAAU,IAAI,CAAI,CAA8B,EAAE,CAAoB;IAC1E,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC;QACH,OAAO,CAAE,CAAC,CAAC,CAAC,CAAC;IACf,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,IAAK,CAAwB,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;YAClG,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,IAAwB,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACjG,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ /** A WebAssembly memory refusal; the next call needs no load(). */
2
+ export interface CapacityError extends RangeError {
3
+ readonly code: 'TOO_LARGE';
4
+ readonly details: CapacityDetails;
5
+ }
6
+ /** Numbers describe a failed buffer request and committed wasm memory. */
7
+ export interface CapacityDetails {
8
+ readonly function: string;
9
+ /** 'allocator' when the exact internal structure is unknown. */
10
+ readonly phase: string;
11
+ readonly requestedBytes: number;
12
+ /** Diagnostic, always `null`: committed pages include free allocator space, so the bytes in use are not known. */
13
+ readonly inUseBytes: null;
14
+ readonly memoryBytes: number;
15
+ readonly committedBytes: number;
16
+ /** Applicable ceiling: Rust Layout, reached wasm memory, module maximum, or documented JS conversion budget. */
17
+ readonly limitBytes: number;
18
+ /** Module maximum, even when the host refuses growth earlier. */
19
+ readonly declaredMaxBytes: number;
20
+ readonly allocationLimitBytes: number;
21
+ readonly input: Readonly<Record<string, number | readonly number[]>>;
22
+ readonly parameters: Readonly<Record<string, unknown>>;
23
+ /** True for a checked Rust Layout refusal before the allocator. */
24
+ readonly capacityOverflow?: boolean;
25
+ /** A conservative API budget for an extra JavaScript conversion buffer, not the host heap limit. */
26
+ readonly hostConversionBudgetBytes?: number;
27
+ readonly alignment?: number;
28
+ /** Diagnostic for bug reports (the module's internal function number); not part of the stable API and may change. */
29
+ readonly functionId?: number;
30
+ /** Diagnostic for bug reports (the module's internal phase number); not part of the stable API and may change. */
31
+ readonly phaseId?: number;
32
+ /** Diagnostic: how long the instance replacement took; not part of the stable API and may change. */
33
+ readonly recoveryMilliseconds?: number;
34
+ readonly elements?: number;
35
+ readonly elementBytes?: number;
36
+ /** Rounded down fresh-instance estimate, in estimateUnit; never an admission guarantee. */
37
+ readonly estimatedMaxInput?: number;
38
+ readonly estimatedInputShape?: readonly number[];
39
+ readonly estimateUnit?: string;
40
+ /** Growth law, failed-structure scaling, working-set model and limits, or omission reason. */
41
+ readonly estimateMethod?: string;
42
+ /** Measured capacity-benchmark success at the stated parameters, not a universal capacity. */
43
+ readonly capacityReference?: {
44
+ readonly size: number;
45
+ readonly limitBytes: number;
46
+ readonly unit: string;
47
+ readonly parameters: string;
48
+ };
49
+ readonly capacityEstimate?: {
50
+ /** A single-buffer ceiling, not a whole-input estimate. */
51
+ readonly maximumElements?: number;
52
+ /** Fresh-instance pairwise estimate at the original dimension. */
53
+ readonly maximumEqualSamples?: number;
54
+ readonly failingSamples?: number;
55
+ readonly method: string;
56
+ };
57
+ }
58
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,QAAQ,CAAC,IAAI,EAAE,WAAW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E,MAAM,CAAC;IAC/B,2FAA2F;IAC3F,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,8FAA8F;IAC9F,QAAQ,CAAC,iBAAiB,CAAC,EAAE;QAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,QAAQ,CAAC,gBAAgB,CAAC,EAAE;QAC1B,2DAA2D;QAC3D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAClC,kEAAkE;QAClE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
package/dist/memory.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":""}
@@ -0,0 +1,349 @@
1
+ import type { Keys, PointCloud } from './check.js';
2
+ import type { ComplexLike, Diagram, DistanceMatrix, Grid, Scale } from './types.js';
3
+ /**
4
+ * A complex argument as the typed arrays the engine reads: typed arrays of
5
+ * the right kind pass through, plain arrays (or other typed arrays) are
6
+ * checked (32-bit integer vertex ids, non-negative integer offsets, numbers)
7
+ * and converted. The rest (CSR shape, closure, monotonicity, NaN) the Rust
8
+ * core checks, naming the simplex.
9
+ */
10
+ export declare function complexArgs(v: unknown, name: string): {
11
+ vertices: Int32Array;
12
+ offsets: Uint32Array;
13
+ filtrations: Float64Array;
14
+ scale: Scale;
15
+ top: number;
16
+ };
17
+ /** @internal Whether checked complex arrays are the empty complex: no simplex, `offsets` `[0]`. */
18
+ export declare function isEmptyComplex(c: {
19
+ vertices: Int32Array;
20
+ offsets: Uint32Array;
21
+ filtrations: Float64Array;
22
+ }): boolean;
23
+ /** Options of {@link persistence}. */
24
+ export interface PersistenceOptions {
25
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
26
+ coeff?: number;
27
+ /**
28
+ * Leave out the finite pairs with `death − birth <= minPersistence`
29
+ * (GUDHI's `min_persistence`); essential pairs are always kept. A finite
30
+ * number `>= 0`. Default 0: only the pairs of length zero are left out.
31
+ * `1e-12` removes the bars one ulp long that rounding leaves on symmetric
32
+ * input such as a lattice.
33
+ */
34
+ minPersistence?: number;
35
+ }
36
+ /** @internal The option keys of {@link PersistenceOptions}. */
37
+ export declare const PERSISTENCE_KEYS: Keys<PersistenceOptions>;
38
+ /**
39
+ * The persistence diagram of a filtered simplicial complex: one a builder
40
+ * returned, or one the caller builds as `{ vertices, offsets, filtrations }`
41
+ * (`scale` is read when present, `'value'` otherwise).
42
+ *
43
+ * The complex must be closed (every face of every simplex listed, its
44
+ * vertices included) and monotone (no face valued above a coface); no
45
+ * simplex may be listed twice or list a vertex twice, and no value may be
46
+ * NaN (`Infinity`, `-Infinity` and `-0` are fine). Anything else is a
47
+ * `RangeError` naming the simplex. Vertex ids are any 32-bit integers;
48
+ * vertex order within a simplex and simplex order do not matter.
49
+ *
50
+ * The Rust core puts the simplices in the documented order and its reducer
51
+ * computes the pairs over `Z/coeff`, in
52
+ * every dimension up to the complex's top one (an empty complex has an
53
+ * empty diagram). Within a dimension the finite pairs come in the order of
54
+ * their death simplex, then the essential classes in the order of their
55
+ * birth simplex: an order that depends on the complex only.
56
+ */
57
+ export declare function persistence(complex: ComplexLike, opts?: PersistenceOptions): Diagram;
58
+ /** Which representatives {@link ripsPersistence} returns, and of which dimensions. */
59
+ export interface RepresentativesOptions {
60
+ /**
61
+ * `'cycles'` (default): for every finite pair a cycle (simplices with zero
62
+ * boundary, all present at the birth: for H₁ the edges of a loop), from a
63
+ * homology reduction over the death simplices. `'cocycles'`: for every
64
+ * pair, essential ones included, the reduction column of the cohomology
65
+ * pass (what ripser.py's `do_cocycles` returns).
66
+ */
67
+ kind?: 'cycles' | 'cocycles';
68
+ /** The homology dimensions to return representatives for. Default: every dimension up to `maxDim`; `[]` returns none. */
69
+ dims?: number[];
70
+ }
71
+ /** Options of {@link ripsPersistence}. */
72
+ export interface RipsPersistenceOptions {
73
+ /** The highest homology dimension, an integer from 0 to 9. Default 1. */
74
+ maxDim?: number;
75
+ /**
76
+ * Keep the simplices of diameter `<= maxEdgeLength`, non-negative.
77
+ * Default `Infinity`: the filtration is cut at the enclosing radius, past
78
+ * which every Rips complex is a cone, so no pair is lost.
79
+ */
80
+ maxEdgeLength?: number;
81
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
82
+ coeff?: number;
83
+ /**
84
+ * Also return a representative of every pair (`true` for the default
85
+ * {@link RepresentativesOptions}). Default `false`. The representatives of
86
+ * the pairs `minPersistence` leaves out are left out too.
87
+ */
88
+ representatives?: boolean | RepresentativesOptions;
89
+ /**
90
+ * Leave out the finite pairs with `death − birth <= minPersistence`
91
+ * (GUDHI's `min_persistence`); essential pairs are always kept. A finite
92
+ * number `>= 0`. Default 0: only the pairs of length zero are left out.
93
+ * `1e-12` removes the bars one ulp long that rounding leaves on symmetric
94
+ * input such as a lattice.
95
+ */
96
+ minPersistence?: number;
97
+ }
98
+ /**
99
+ * The representatives of the pairs of a Rips diagram, as typed arrays
100
+ * (`materialize()` builds the objects). Representative `i` stands for pair
101
+ * `pairIndex[i]` of dimension `dims[i]` (the pair `pairs[dims[i]][2p]`,
102
+ * `pairs[dims[i]][2p + 1]`); its simplices are `simplexOffsets[i] ..
103
+ * simplexOffsets[i + 1]`, with their coefficients at the same positions of
104
+ * `coefficients` and their vertex ids, `dims[i] + 1` per simplex, ascending
105
+ * within a simplex (a simplex is oriented by that order), in
106
+ * `vertices[vertexOffsets[i] .. vertexOffsets[i + 1]]`.
107
+ *
108
+ * What a representative is (the package's tests check every one against the
109
+ * input itself): a cycle has zero boundary, every simplex has
110
+ * diameter `<= birth` and one exactly `birth`, it is not a cycle created before
111
+ * `birth` plus a boundary before `death`, and it is a boundary at `death` up
112
+ * to cycles created before `birth`; a cocycle has zero coboundary on every
113
+ * simplex of diameter `< death`, non-zero coboundary on some simplex of
114
+ * diameter `death`, and every simplex has diameter in [`birth`, `death`].
115
+ * Representatives are not unique, nor the shortest.
116
+ */
117
+ export interface RipsRepresentatives {
118
+ /** The kind of representative. */
119
+ kind: 'cycles' | 'cocycles';
120
+ /** The homology dimension of each representative. */
121
+ dims: Uint8Array;
122
+ /** The index of each representative's pair within the pairs of its dimension. */
123
+ pairIndex: Uint32Array;
124
+ /** The birth of each representative's pair. */
125
+ births: Float64Array;
126
+ /** The death of each representative's pair. */
127
+ deaths: Float64Array;
128
+ /** Length `count + 1`: the simplices of representative `i`. */
129
+ simplexOffsets: Uint32Array;
130
+ /** Length `count + 1`: the vertex ids of representative `i`. */
131
+ vertexOffsets: Uint32Array;
132
+ /** Vertex ids (indices into the input), `dims[i] + 1` per simplex. */
133
+ vertices: Int32Array;
134
+ /** The coefficient of each simplex, in `(−coeff/2, coeff/2]`; always 1 over `Z/2`. */
135
+ coefficients: Int32Array;
136
+ }
137
+ /** A Rips diagram, with the representatives when asked for. */
138
+ export interface RipsPersistence extends Diagram {
139
+ /** Present only with `representatives`. */
140
+ representatives?: RipsRepresentatives;
141
+ }
142
+ /**
143
+ * The Vietoris–Rips persistence diagram of a point cloud or of a distance
144
+ * matrix, H₀ up to dimension `maxDim`, by the Rust core without building the complex
145
+ * (persistent cohomology with clearing, implicit coboundaries and
146
+ * apparent pairs, after Ripser ([reference](https://topolab.ai/tda/docs/references/#bauer-2021)); an edge collapse before H₂ and up).
147
+ * Distances are computed in double precision in GUDHI's order, so the
148
+ * diagram is GUDHI's, value for value, on dimensions 0 to `maxDim`; the
149
+ * classes a truncated complex reports in dimension `maxDim + 1` are not
150
+ * reported. A distance matrix is read in its strict lower triangle;
151
+ * `Infinity` entries are absent edges and no entry may be NaN or negative.
152
+ * A point cloud with two points whose squared distance overflows double
153
+ * precision is refused (a `RangeError`: rescale it). Within a dimension the pairs come in
154
+ * the engine's order. The Rips key holds the colex index of a simplex's
155
+ * vertices off its longest edge in 32 bits, so C(n, `maxDim`) must be below
156
+ * 2^32 for n points (at most 2,954 points at `maxDim` 3, 52 at 9); a larger
157
+ * input is refused with a `RangeError` whose message starts with
158
+ * `input too large:`.
159
+ *
160
+ * With `representatives`, the pairs (the same multiset, every value bit;
161
+ * the order within a dimension may differ) come with a representative cycle
162
+ * or cocycle each ({@link RipsRepresentatives}). Representatives are
163
+ * computed on the uncollapsed filtration, which is slower on dense
164
+ * filtrations in dimension 2 and up; past a working column of 256 MiB,
165
+ * cocycles are refused (a `RangeError`, `input too large:`) and cycles are computed on the collapsed
166
+ * filtration instead (still cycles of the Rips complex, of the same bars).
167
+ */
168
+ export declare function ripsPersistence(points: PointCloud | DistanceMatrix, opts?: RipsPersistenceOptions): RipsPersistence;
169
+ /** Options of {@link cubicalPersistence}. */
170
+ export interface CubicalPersistenceOptions {
171
+ /**
172
+ * `'T'` (default): each value sits on a top-dimensional cell (pixel,
173
+ * voxel) and every lower cell enters at the smallest value among the top
174
+ * cells containing it. `'V'` (2-D only): each value sits on a vertex and
175
+ * every cell enters at the largest value among its vertices. The names of
176
+ * Garin et al. 2020 and CubicalRipser.
177
+ */
178
+ construction?: 'T' | 'V';
179
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
180
+ coeff?: number;
181
+ /**
182
+ * Leave out the finite pairs with `death − birth <= minPersistence`
183
+ * (GUDHI's `min_persistence`); essential pairs are always kept. A finite
184
+ * number `>= 0`. Default 0: only the pairs of length zero are left out.
185
+ * `1e-12` removes the bars one ulp long that rounding leaves on symmetric
186
+ * input such as a lattice.
187
+ */
188
+ minPersistence?: number;
189
+ }
190
+ /**
191
+ * The sublevel-set persistence diagram of an image or a volume, homology up
192
+ * to the number of axes. 2-D and 3-D grids run the Rust core (union-find
193
+ * with Alexander duality; H₁ of volumes by a cohomology reduction over
194
+ * `Z/coeff`); other grids (up to 16 axes) run the Rust core's reducer over
195
+ * its cells. The T diagram
196
+ * is GUDHI's bitmap complex's in every case, up to the
197
+ * sign of a zero on input holding both -0 and +0; within a dimension the
198
+ * pairs come in the engine's order. In 2-D the field does not change the
199
+ * diagram.
200
+ */
201
+ export declare function cubicalPersistence(image: Grid, opts?: CubicalPersistenceOptions): Diagram;
202
+ /** An insertion of a cell into a zigzag (made by {@link insertOp}). */
203
+ export interface InsertOp {
204
+ type: 'insert';
205
+ /** The cell's id, a 32-bit integer. */
206
+ cell: number;
207
+ /** The ids of the cell's faces one dimension down, in the complex at that moment (empty for a vertex). */
208
+ boundary: number[];
209
+ /** The cell's dimension. */
210
+ dim: number;
211
+ /** The operation's value; when every operation has one, the diagram is on these values too. */
212
+ value?: number;
213
+ }
214
+ /** A removal of a cell from a zigzag (made by {@link removeOp}). */
215
+ export interface RemoveOp {
216
+ type: 'remove';
217
+ /** The cell's id. */
218
+ cell: number;
219
+ /** The operation's value; when every operation has one, the diagram is on these values too. */
220
+ value?: number;
221
+ }
222
+ /** One operation of a zigzag. */
223
+ export type ZigzagOp = InsertOp | RemoveOp;
224
+ /** Insert cell `cell` of dimension `dim` with faces `boundary`, at `value` if given. */
225
+ export declare function insertOp(cell: number, boundary: number[], dim: number, value?: number): InsertOp;
226
+ /** Remove cell `cell`, at `value` if given. */
227
+ export declare function removeOp(cell: number, value?: number): RemoveOp;
228
+ /** Packed zigzag operations, without one JavaScript object per operation.
229
+ * Each record is `[kind, cell, dim, value, boundaryLength, ...boundary]`.
230
+ * `kind` is 0 for insertion, 1 for removal; removals use dim=0 and no boundary.
231
+ * Set withValues when the value column supplies the monotone operation values.
232
+ * The engine validates the same cell-complex and value rules as object input.
233
+ */
234
+ export interface PackedZigzag {
235
+ records: Float64Array;
236
+ withValues?: boolean;
237
+ }
238
+ /** Options of {@link zigzagPersistence}. */
239
+ export interface ZigzagPersistenceOptions {
240
+ /**
241
+ * Leave out the finite bars with `death − birth <= minPersistence`,
242
+ * measured in the units the bars are reported in (GUDHI's
243
+ * `min_persistence`); bars that persist after the last operation are always
244
+ * kept. When every operation has a value, the bars of `pairs` are measured
245
+ * on those values and `indexPairs` keeps every bar; otherwise the bars of
246
+ * `indexPairs` are measured in operations (a bar is at least one operation
247
+ * long, so `1` leaves out the bars that last one operation). A finite
248
+ * number `>= 0`. Default 0: nothing more is left out.
249
+ */
250
+ minPersistence?: number;
251
+ }
252
+ /** The diagram of a zigzag. */
253
+ export interface ZigzagPersistence {
254
+ /**
255
+ * `indexPairs[k]`: the bars of Hₖ on operation indices,
256
+ * `[birth, death, …]`: the class exists after operation `birth` and no
257
+ * longer after operation `death`, `Infinity` when it persists after the
258
+ * last operation. In no particular order. Without values, the bars no
259
+ * longer than `minPersistence` operations are left out.
260
+ */
261
+ indexPairs: Float64Array[];
262
+ /**
263
+ * `pairs[k]`, present when every operation has a value: the bars of Hₖ
264
+ * on those values, each endpoint the value of its operation (copied
265
+ * through), `Infinity` for a class that persists after the last operation; on
266
+ * non-increasing values the two endpoints are swapped so that
267
+ * birth <= death, and a bar between two operations of one value (length
268
+ * zero) is left out, as is a bar no longer than `minPersistence`.
269
+ */
270
+ pairs?: Float64Array[];
271
+ /** Always `'value'`. */
272
+ scale: 'value';
273
+ /** Always 2: zigzag persistence is computed over Z/2. */
274
+ coeff: 2;
275
+ }
276
+ /**
277
+ * Zigzag persistence of a sequence of insertions and removals of cells,
278
+ * by the FastZigzag conversion ([reference](https://topolab.ai/tda/docs/references/#dey-and-hou-2022)): the zigzag becomes one ordinary
279
+ * filtration of the cone over a non-repetitive copy of it, reduced over Z/2
280
+ * and read back as zigzag intervals. Homology up to
281
+ * the highest cell dimension. Z/2 only; no representatives.
282
+ *
283
+ * The operations must describe a zigzag of cell complexes, or the call is
284
+ * refused with a `RangeError` naming the operation: every face of an
285
+ * inserted cell is in the complex at that moment and has one dimension
286
+ * less; a vertex has no face, an edge two; the faces of a cell of
287
+ * dimension 2 or more form a cycle (every cell two dimensions down is a face
288
+ * of an even number of them); a cell is not inserted while it
289
+ * is in the complex, nor removed while it is not or while a coface of it is.
290
+ * When the operations have values, the values must be monotone (all
291
+ * non-decreasing or all non-increasing) and not NaN; either every operation
292
+ * has a value or none has.
293
+ */
294
+ export declare function zigzagPersistence(ops: ZigzagOp[] | PackedZigzag, opts?: ZigzagPersistenceOptions): ZigzagPersistence;
295
+ /**
296
+ * Volume-optimal cycles as typed arrays (`materialize()` builds the
297
+ * objects). Result `r` is the pair `(births[r], deaths[r])` in dimension `dim`; its
298
+ * volume is the `(dim + 1)`-simplices in rows `volumeOffsets[r] ..
299
+ * volumeOffsets[r + 1]` of `volumeVertices` (`dim + 2` vertex ids a row,
300
+ * increasing), its boundary, the cycle, the `dim`-simplices in rows
301
+ * `boundaryOffsets[r] .. boundaryOffsets[r + 1]` of `boundaryVertices`
302
+ * (`dim + 1` ids a row, increasing),
303
+ * and the cycle's distinct vertices `cycleVertices[cycleVertexOffsets[r] ..
304
+ * cycleVertexOffsets[r + 1]]`, sorted. `found[r]` is 0 when the merge tree
305
+ * has no answer for the pair; its lists are then empty.
306
+ */
307
+ export interface VolumeOptimalCycles {
308
+ /** The homology dimension of every result (the ambient dimension minus one). */
309
+ dim: number;
310
+ births: Float64Array;
311
+ deaths: Float64Array;
312
+ found: Uint8Array;
313
+ /** Length `count + 1`, in rows (simplices). */
314
+ volumeOffsets: Uint32Array;
315
+ volumeVertices: Int32Array;
316
+ /** Length `count + 1`, in rows (simplices). */
317
+ boundaryOffsets: Uint32Array;
318
+ boundaryVertices: Int32Array;
319
+ /** Length `count + 1`. */
320
+ cycleVertexOffsets: Uint32Array;
321
+ cycleVertices: Int32Array;
322
+ }
323
+ /** Options of {@link volumeOptimalCycles}. */
324
+ export interface VolumeOptimalCyclesOptions {
325
+ /** The homology dimension `n − 1` of a triangulation of a convex domain in R^n, a non-negative integer. Required. */
326
+ dim: number;
327
+ /** One finite pair `[birth, death]`: find its cycle only. Default: every finite pair. */
328
+ pair?: [number, number];
329
+ /**
330
+ * Without `pair`, leave out the pairs with `death − birth <=
331
+ * minPersistence` and their cycles (GUDHI's `min_persistence`); `pair`
332
+ * itself is always answered. A finite number `>= 0`. Default 0.
333
+ */
334
+ minPersistence?: number;
335
+ }
336
+ /**
337
+ * Experimental: volume-optimal cycles in dimension `dim`, by the merge-tree /
338
+ * Alexander-duality method ([reference](https://topolab.ai/tda/docs/references/#obayashi-2018), §5).
339
+ * Meaningful for triangulations of convex
340
+ * domains in R^(dim + 1), such as alpha complexes. With `pair`, the cycle of
341
+ * that one finite pair (or the pair echoed with `found[0] === 0`); without,
342
+ * every finite pair's (longer than `minPersistence`), sorted by birth then
343
+ * death. The engine orders and checks the complex itself (closed, values
344
+ * non-decreasing from face to coface; a simplex's vertices in any order,
345
+ * none listed twice). The general L1 problem and stable volumes are not
346
+ * implemented.
347
+ */
348
+ export declare function volumeOptimalCycles(complex: ComplexLike, opts: VolumeOptimalCyclesOptions): VolumeOptimalCycles;
349
+ //# sourceMappingURL=persistence.d.ts.map