@topolab/tda 0.0.0-stage → 0.4.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 (105) hide show
  1. package/CHANGELOG.md +106 -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 +697 -0
  7. package/dist/arrangement.d.ts +50 -0
  8. package/dist/arrangement.d.ts.map +1 -0
  9. package/dist/arrangement.js +63 -0
  10. package/dist/arrangement.js.map +1 -0
  11. package/dist/build_info.json +12 -0
  12. package/dist/check.d.ts +118 -0
  13. package/dist/check.d.ts.map +1 -0
  14. package/dist/check.js +298 -0
  15. package/dist/check.js.map +1 -0
  16. package/dist/complex.d.ts +543 -0
  17. package/dist/complex.d.ts.map +1 -0
  18. package/dist/complex.js +712 -0
  19. package/dist/complex.js.map +1 -0
  20. package/dist/diagram.d.ts +116 -0
  21. package/dist/diagram.d.ts.map +1 -0
  22. package/dist/diagram.js +238 -0
  23. package/dist/diagram.js.map +1 -0
  24. package/dist/diagram_of.d.ts +17 -0
  25. package/dist/diagram_of.d.ts.map +1 -0
  26. package/dist/diagram_of.js +40 -0
  27. package/dist/diagram_of.js.map +1 -0
  28. package/dist/experimental.d.ts +18 -0
  29. package/dist/experimental.d.ts.map +1 -0
  30. package/dist/experimental.js +16 -0
  31. package/dist/experimental.js.map +1 -0
  32. package/dist/flat.d.ts +64 -0
  33. package/dist/flat.d.ts.map +1 -0
  34. package/dist/flat.js +158 -0
  35. package/dist/flat.js.map +1 -0
  36. package/dist/index.d.ts +42 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +31 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/ladder/tda_ladder.d.ts +223 -0
  41. package/dist/ladder/tda_ladder.js +1360 -0
  42. package/dist/ladder/tda_ladder_bg.wasm +0 -0
  43. package/dist/ladder/tda_ladder_bg.wasm.d.ts +43 -0
  44. package/dist/ladder.d.ts +306 -0
  45. package/dist/ladder.d.ts.map +1 -0
  46. package/dist/ladder.js +607 -0
  47. package/dist/ladder.js.map +1 -0
  48. package/dist/load.d.ts +53 -0
  49. package/dist/load.d.ts.map +1 -0
  50. package/dist/load.js +173 -0
  51. package/dist/load.js.map +1 -0
  52. package/dist/memory.d.ts +58 -0
  53. package/dist/memory.d.ts.map +1 -0
  54. package/dist/memory.js +2 -0
  55. package/dist/memory.js.map +1 -0
  56. package/dist/persistence.d.ts +349 -0
  57. package/dist/persistence.d.ts.map +1 -0
  58. package/dist/persistence.js +478 -0
  59. package/dist/persistence.js.map +1 -0
  60. package/dist/pkg/tda_wasm.d.ts +13 -0
  61. package/dist/pkg/tda_wasm.js +2528 -0
  62. package/dist/prepared.d.ts +62 -0
  63. package/dist/prepared.d.ts.map +1 -0
  64. package/dist/prepared.js +81 -0
  65. package/dist/prepared.js.map +1 -0
  66. package/dist/rivet_input.d.ts +93 -0
  67. package/dist/rivet_input.d.ts.map +1 -0
  68. package/dist/rivet_input.js +132 -0
  69. package/dist/rivet_input.js.map +1 -0
  70. package/dist/source.d.ts +43 -0
  71. package/dist/source.d.ts.map +1 -0
  72. package/dist/source.js +99 -0
  73. package/dist/source.js.map +1 -0
  74. package/dist/tda.wasm +0 -0
  75. package/dist/two_parameter.d.ts +243 -0
  76. package/dist/two_parameter.d.ts.map +1 -0
  77. package/dist/two_parameter.js +275 -0
  78. package/dist/two_parameter.js.map +1 -0
  79. package/dist/types.d.ts +146 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/types.js +2 -0
  82. package/dist/types.js.map +1 -0
  83. package/dist/vineyard.d.ts +278 -0
  84. package/dist/vineyard.d.ts.map +1 -0
  85. package/dist/vineyard.js +236 -0
  86. package/dist/vineyard.js.map +1 -0
  87. package/package.json +77 -4
  88. package/src/arrangement.ts +96 -0
  89. package/src/check.ts +338 -0
  90. package/src/complex.ts +1179 -0
  91. package/src/diagram.ts +299 -0
  92. package/src/diagram_of.ts +40 -0
  93. package/src/experimental.ts +17 -0
  94. package/src/flat.ts +204 -0
  95. package/src/index.ts +181 -0
  96. package/src/ladder.ts +903 -0
  97. package/src/load.ts +201 -0
  98. package/src/memory.ts +58 -0
  99. package/src/persistence.ts +752 -0
  100. package/src/prepared.ts +111 -0
  101. package/src/rivet_input.ts +195 -0
  102. package/src/source.ts +132 -0
  103. package/src/two_parameter.ts +480 -0
  104. package/src/types.ts +163 -0
  105. package/src/vineyard.ts +463 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The plain data the package takes and returns. Every result is a plain
3
+ * object of typed arrays, numbers, strings, booleans and arrays of them, so
4
+ * it survives `postMessage` and `structuredClone` whole; no result has
5
+ * methods.
6
+ */
7
+ import type { PointCloud } from './check.js';
8
+ export type { PointCloud };
9
+ /**
10
+ * The quantity a filtration's values measure, carried by every complex and
11
+ * diagram.
12
+ *
13
+ * - `'edgeLength'`: an edge length, twice a ball radius (Rips, ellipsoid
14
+ * Rips; cutoff `maxEdgeLength`);
15
+ * - `'radius'`: the radius of a ball (Čech, Delaunay–Čech, ellipsoid Čech;
16
+ * cutoff `maxRadius`);
17
+ * - `'squaredRadius'`: a squared radius, negative at weighted vertices
18
+ * (alpha, coupled alpha, k-fold cover; cutoff `maxSquaredRadius`);
19
+ * - `'squaredRelaxation'`: the relaxation of the witness complex, a squared
20
+ * length (cutoff `maxSquaredRelaxation`);
21
+ * - `'epsilon'`: the wing length ε (wing complex; cutoff `maxEpsilon`);
22
+ * - `'growthRadius'`: the ℓ∞ radius `j · stepSize` within which the boxes of
23
+ * the box filtration grow (cutoffs `stepSize`, `maxSteps`);
24
+ * - `'value'`: the caller's own values (cubical complexes, a complex the
25
+ * caller builds, zigzag operations).
26
+ */
27
+ export type Scale = 'edgeLength' | 'radius' | 'squaredRadius' | 'squaredRelaxation' | 'epsilon' | 'growthRadius' | 'value';
28
+ /** A dense `n × n` distance matrix, row-major; only the strict lower triangle (`distances[i·n + j]`, `i > j`) is read, and no entry may be NaN or negative. */
29
+ export interface DistanceMatrix {
30
+ /** The `n²` distances, row-major. */
31
+ distances: Float64Array;
32
+ }
33
+ /**
34
+ * An image or a volume: `values` row-major in NumPy's order, the last axis
35
+ * fastest. A `height × width` image is `shape: [height, width]`, its pixel
36
+ * `(row, column)` at `values[row · width + column]`, as in `ImageData`.
37
+ */
38
+ export interface Grid {
39
+ /** The values, row-major (length the product of `shape`). */
40
+ values: Float64Array;
41
+ /** The extent of each axis, slowest first. */
42
+ shape: number[];
43
+ }
44
+ /**
45
+ * A filtered simplicial complex as three typed arrays (CSR): simplex `i` is
46
+ * `vertices[offsets[i] .. offsets[i + 1])`, its vertex ids in increasing
47
+ * order, entered at `filtrations[i]`.
48
+ *
49
+ * Every builder lists its simplices in one documented order: by value
50
+ * (`-0` equal to `+0`), then by dimension, then lexicographically on the
51
+ * increasing vertex lists (as Python sorts lists). Values never decrease,
52
+ * and every face comes before its cofaces. (Where the input's ties are not
53
+ * exact in double precision, the full Čech builder raises a coface to its
54
+ * faces' values; see `cechComplex`.)
55
+ *
56
+ * A function that takes simplices (`persistence`, `volumeOptimalCycles`,
57
+ * `flatten`, the ladder filtrations) accepts each simplex's vertices in any
58
+ * order and sorts them; a vertex listed twice in one simplex is refused with
59
+ * a `RangeError`.
60
+ */
61
+ export interface Complex {
62
+ /** Concatenated vertex ids of every simplex (increasing within a simplex). */
63
+ vertices: Int32Array;
64
+ /** Length `count + 1`; simplex `i` is `vertices[offsets[i] .. offsets[i + 1])`. */
65
+ offsets: Uint32Array;
66
+ /** The value at which simplex `i` enters. */
67
+ filtrations: Float64Array;
68
+ /** The quantity the values measure. */
69
+ scale: Scale;
70
+ }
71
+ /**
72
+ * What the functions that take a complex accept: a {@link Complex}, or the
73
+ * same three arrays as number arrays (converted, with integer checks), with
74
+ * or without `scale`.
75
+ */
76
+ export interface ComplexLike {
77
+ vertices: ArrayLike<number>;
78
+ offsets: ArrayLike<number>;
79
+ filtrations: ArrayLike<number>;
80
+ scale?: Scale;
81
+ }
82
+ /** One simplex as an object (what {@link materialize} builds from a {@link Complex}). */
83
+ export interface Simplex {
84
+ /** Vertex ids, increasing in what the package returns; any order in what it takes. */
85
+ vertices: number[];
86
+ /** The value at which the simplex enters. */
87
+ filtration: number;
88
+ }
89
+ /**
90
+ * Every cell of a T-construction cubical complex, in the order (value, then
91
+ * cell dimension, then bitmap position).
92
+ */
93
+ export interface CubicalComplex {
94
+ /** The grid's shape (the input's, slowest axis first). */
95
+ shape: number[];
96
+ /**
97
+ * Position of each cell in the bitmap, the grid of `2 · shape[i] + 1`
98
+ * positions along axis `i`, numbered row-major (the last axis fastest): a
99
+ * cell's coordinate is odd along the axes it spans, and the pixel at
100
+ * `(p0, p1, …)` is the cell at `(2 p0 + 1, 2 p1 + 1, …)`.
101
+ */
102
+ cells: Uint32Array;
103
+ /** The dimension of each cell (the number of its odd coordinates). */
104
+ dims: Uint8Array;
105
+ /** The value of each cell: the smallest value of the pixels containing it. */
106
+ filtrations: Float64Array;
107
+ /** Always `'value'`: the image's own values. */
108
+ scale: 'value';
109
+ }
110
+ /**
111
+ * A persistence diagram. `pairs[k]` lists the classes of Hₖ as
112
+ * `[birth, death, birth, death, …]`, essential classes with
113
+ * `death = Infinity`, one array per homology dimension from 0 to the highest
114
+ * the call computes (empty arrays included). Pairs of length zero are left
115
+ * out, and with the `minPersistence` option every finite pair with
116
+ * `death − birth <= minPersistence`.
117
+ */
118
+ export interface Diagram {
119
+ /** `pairs[k]`: the pairs of Hₖ, `[birth, death, …]`. */
120
+ pairs: Float64Array[];
121
+ /** The quantity the values measure. */
122
+ scale: Scale;
123
+ /** The coefficient field `Z/coeff` the diagram was computed over. */
124
+ coeff: number;
125
+ }
126
+ /** The result of a builder's `…Persistence` function: the diagram, and with `complex: true` the complex it was computed from. */
127
+ export interface BuilderPersistence<C extends Complex = Complex> extends Diagram {
128
+ /** The complex, as the builder returns it; present only with `complex: true`. */
129
+ complex?: C;
130
+ }
131
+ /** Options every builder's `…Persistence` function takes beside the builder's own. */
132
+ export interface BuilderPersistenceOptions {
133
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
134
+ coeff?: number;
135
+ /** Also return the complex, as the builder returns it. Default `false`. */
136
+ complex?: boolean;
137
+ /**
138
+ * Leave out the finite pairs with `death − birth <= minPersistence`
139
+ * (GUDHI's `min_persistence`); essential pairs are always kept. A finite
140
+ * number `>= 0`. Default 0: only the pairs of length zero are left out.
141
+ * `1e-12` removes the bars one ulp long that rounding leaves on symmetric
142
+ * input such as a lattice.
143
+ */
144
+ minPersistence?: number;
145
+ }
146
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,KAAK,GACb,YAAY,GACZ,QAAQ,GACR,eAAe,GACf,mBAAmB,GACnB,SAAS,GACT,cAAc,GACd,OAAO,CAAC;AAEZ,+JAA+J;AAC/J,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,SAAS,EAAE,YAAY,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,6DAA6D;IAC7D,MAAM,EAAE,YAAY,CAAC;IACrB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,OAAO;IACtB,8EAA8E;IAC9E,QAAQ,EAAE,UAAU,CAAC;IACrB,mFAAmF;IACnF,OAAO,EAAE,WAAW,CAAC;IACrB,6CAA6C;IAC7C,WAAW,EAAE,YAAY,CAAC;IAC1B,uCAAuC;IACvC,KAAK,EAAE,KAAK,CAAC;CACd;A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//# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,278 @@
1
+ import type { PointCloud, Vec } from './check.js';
2
+ import type { Complex, ComplexLike, Grid, Scale } from './types.js';
3
+ /** Which representative cycles a vineyard function returns. */
4
+ export interface VineyardRepresentativesOptions {
5
+ /**
6
+ * Times at which to extract representative cycles, each a finite number in
7
+ * `[0, number of frames − 1]`. Representatives are returned in this order.
8
+ * Every transposition with crossing time `<= t` is applied before the
9
+ * snapshot at `t` is taken (in particular, at `t = 0` on a multi-frame
10
+ * input, tied cells whose order reverses in frame 1 transpose before the
11
+ * `t = 0` snapshot, whereas a 1-frame input has no transpositions).
12
+ */
13
+ times: Vec;
14
+ /**
15
+ * Homology dimensions to return representatives for. Default: all
16
+ * dimensions present in the vineyard; `[]` returns none.
17
+ */
18
+ dims?: number[];
19
+ }
20
+ /**
21
+ * Representative cycles of a vineyard at requested times, as typed arrays.
22
+ * Representative `r` stands for vine `vines[r]` at time `times[r]` (with
23
+ * homology dimension `dims[r]`, birth `births[r]` and death `deaths[r]` at
24
+ * that time); its cycle is the linear combination of
25
+ * `cells[offsets[r] .. offsets[r + 1]]` with coefficients
26
+ * `coefficients[offsets[r] .. offsets[r + 1]]` in `(−coeff/2, coeff/2]`
27
+ * (all 1 over `Z/2`).
28
+ *
29
+ * Ordered by requested time, then by vine index.
30
+ */
31
+ export interface VineyardRepresentatives {
32
+ /** Requested time of each representative. */
33
+ times: Float64Array;
34
+ /** Vine index (`0 .. dims.length − 1` of the enclosing vineyard) of each representative. */
35
+ vines: Uint32Array;
36
+ /** Homology dimension of each representative. */
37
+ dims: Uint8Array;
38
+ /** Birth of the vine at `times[r]`. */
39
+ births: Float64Array;
40
+ /** Death of the vine at `times[r]`, `Infinity` for an essential class. */
41
+ deaths: Float64Array;
42
+ /** Length `count + 1`: representative `r` owns `offsets[r] .. offsets[r + 1]` of `cells` and `coefficients`. */
43
+ offsets: Uint32Array;
44
+ /**
45
+ * Cell indices of each cycle: simplex indices into the input complex for
46
+ * {@link vineyard}, bitmap positions for {@link cubicalVineyard}, simplex
47
+ * indices into the returned `complex` for {@link ripsVineyard}.
48
+ */
49
+ cells: Uint32Array;
50
+ /** Coefficient of each cell in `(−coeff/2, coeff/2]`; all 1 over `Z/2`. */
51
+ coefficients: Int32Array;
52
+ }
53
+ /** Options of {@link vineyard} and {@link cubicalVineyard}. */
54
+ export interface VineyardOptions {
55
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
56
+ coeff?: number;
57
+ /**
58
+ * Leave out the vines whose `death − birth` is at most `minPersistence` at
59
+ * every knot; essential vines are always kept. A finite number `>= 0`.
60
+ * Default 0: only the vines that never leave the diagonal are left out.
61
+ */
62
+ minPersistence?: number;
63
+ /**
64
+ * Also return one representative cycle per kept vine persisting at each
65
+ * requested time (`death > birth` at that time, or essential) in the
66
+ * requested dimensions. Every transposition at crossing time `<= t` is
67
+ * applied before the snapshot at `t` is taken.
68
+ */
69
+ representatives?: VineyardRepresentativesOptions;
70
+ }
71
+ /**
72
+ * The vines of a homotopy, as typed arrays. Vine `v` is one class followed
73
+ * through time: its knots are the entries `offsets[v] .. offsets[v + 1]` of
74
+ * `times`, `births`, `deaths`, `birthSimplices` and `deathSimplices`, in
75
+ * time order: its state at time 0, at every switch of the pairing that
76
+ * involves it, and at every frame. Between two consecutive knots its birth
77
+ * and death are linear in time, so the knots are the whole vine. The times
78
+ * of a vine's knots are non-decreasing, not strictly increasing: two knots
79
+ * share a time when a switch happens at time 0 or at a frame (where values
80
+ * are tied), and when two crossings are equal within rounding.
81
+ *
82
+ * The vines come by dimension, and within a dimension in the order of
83
+ * `persistence(complex)` at time 0 (the classes with a death by their death
84
+ * simplex, then the essential classes by their birth simplex).
85
+ */
86
+ export interface Vineyard {
87
+ /** The homology dimension of each vine (constant along it). */
88
+ dims: Uint8Array;
89
+ /** Length `count + 1`; vine `v` owns the knots `offsets[v] .. offsets[v + 1]`. */
90
+ offsets: Uint32Array;
91
+ /** The time of each knot: frame `m` is at time `m`. Non-decreasing along a vine; two knots may share a time. */
92
+ times: Float64Array;
93
+ /** The birth at each knot. */
94
+ births: Float64Array;
95
+ /** The death at each knot, `Infinity` for an essential class. */
96
+ deaths: Float64Array;
97
+ /** The simplex (an index into the input complex) that creates the class from each knot to the next. */
98
+ birthSimplices: Uint32Array;
99
+ /** The simplex that destroys it from each knot to the next, `-1` for an essential class. */
100
+ deathSimplices: Int32Array;
101
+ /** The number of transpositions of adjacent simplices the homotopy made. */
102
+ transpositions: number;
103
+ /** How many of them switched the pairing (each adds a knot to two vines). */
104
+ switches: number;
105
+ /** The quantity the values measure (the complex's `scale`, `'value'` when it has none). */
106
+ scale: Scale;
107
+ /** The prime `p` of the coefficient field `Z/p`. */
108
+ coeff: number;
109
+ /** Present only when `representatives` was requested. */
110
+ representatives?: VineyardRepresentatives;
111
+ }
112
+ /**
113
+ * The persistence vineyard of a filtered simplicial complex whose values
114
+ * change: `complex.filtrations` are the values at time 0, and `frames[m]`
115
+ * (one value per simplex, in the complex's order) those at time `m + 1`.
116
+ * Between two frames every value moves on a straight line, and the result
117
+ * follows every class of the persistence diagram through that homotopy over
118
+ * `Z/coeff`.
119
+ *
120
+ * The algorithm is the linear-time transposition update ([reference](https://topolab.ai/tda/docs/references/#cohen-steiner-edelsbrunner-and-morozov-2006)): the
121
+ * matrix decomposition behind `persistence` is computed once, at time 0,
122
+ * and repaired in time linear in the number of simplices each time two
123
+ * simplices adjacent in the filtration order exchange their places, instead
124
+ * of being recomputed.
125
+ *
126
+ * The complex must be closed, and monotone at time 0 and at every frame (no
127
+ * face valued above a coface); every value must be finite. Anything else is
128
+ * a `RangeError` naming the simplex. Simplices of equal value keep their
129
+ * order, which at time 0 is the documented order of {@link Complex}: at a
130
+ * frame the vines' points with `death > birth` are the pairs of
131
+ * `persistence` of the complex with that frame's values (over the same
132
+ * `coeff`), and at any time in between those of the interpolated values.
133
+ *
134
+ * Memory bounds a vineyard before its size limits do: the decomposition
135
+ * keeps U, every column addition of the reduction at time 0 (on tied or
136
+ * evenly spread values many times the number of simplices), and
137
+ * transpositions fill it in further. A vineyard that does not fit throws
138
+ * `TOO_LARGE` (phase `'boundary matrix'`). The same holds for
139
+ * {@link cubicalVineyard} and {@link ripsVineyard}.
140
+ */
141
+ export declare function vineyard(complex: ComplexLike, frames: ArrayLike<Vec>, opts?: VineyardOptions): Vineyard;
142
+ /**
143
+ * Persistence vineyard of a sequence of images or volumes
144
+ * ({@link cubicalVineyard}), stored as typed arrays. Has the fields of
145
+ * {@link Vineyard}, with cubical complex cells in place of simplices.
146
+ */
147
+ export interface CubicalVineyard {
148
+ /** Homology dimension of each vine (constant along the vine). */
149
+ dims: Uint8Array;
150
+ /**
151
+ * Offsets into the knot arrays, of length `count + 1`; vine `v` owns knots
152
+ * `offsets[v] .. offsets[v + 1]`.
153
+ */
154
+ offsets: Uint32Array;
155
+ /** Time coordinate of each knot; image `m` is at time `m`. Non-decreasing along a vine; two knots may share a time (see {@link Vineyard}). */
156
+ times: Float64Array;
157
+ /** The `birth` coordinate at each knot. */
158
+ births: Float64Array;
159
+ /**
160
+ * The `death` coordinate at each knot, or `Infinity` for an essential
161
+ * class.
162
+ */
163
+ deaths: Float64Array;
164
+ /**
165
+ * Cell that creates the class from each knot to the next, given as a
166
+ * bitmap position (numbered as in {@link CubicalComplex}`.cells`:
167
+ * `2 · shape[i] + 1` positions along axis `i`, row-major, so the pixel at
168
+ * `(p0, p1, …)` is the cell at `(2 p0 + 1, 2 p1 + 1, …)`).
169
+ */
170
+ birthCells: Uint32Array;
171
+ /**
172
+ * Cell that destroys the class from each knot to the next, given as a
173
+ * bitmap position, or `-1` for an essential class.
174
+ */
175
+ deathCells: Int32Array;
176
+ /** Number of adjacent-cell transpositions performed along the homotopy. */
177
+ transpositions: number;
178
+ /**
179
+ * Number of transpositions that switched the persistence pairing (each
180
+ * switch adds a knot to two vines).
181
+ */
182
+ switches: number;
183
+ /** Common shape of the input images, slowest axis first. */
184
+ shape: number[];
185
+ /** Filtration scale; always `'value'` (the images' own values). */
186
+ scale: 'value';
187
+ /** The prime `p` of the coefficient field `Z/p`. */
188
+ coeff: number;
189
+ /** Present only when `representatives` was requested. */
190
+ representatives?: VineyardRepresentatives;
191
+ }
192
+ /**
193
+ * Compute the persistence vineyard of a sequence of images or volumes of the
194
+ * same shape, following the classes of the sublevel-set persistence diagram
195
+ * (T-construction, as in {@link cubicalPersistence}) across frames over
196
+ * `Z/coeff`.
197
+ *
198
+ * Each image assigns values to the cells of one shared cubical complex, the
199
+ * T-construction complex of the grid: each top-dimensional cell (pixel or
200
+ * voxel) takes its own value, and each lower-dimensional cell takes the
201
+ * minimum value among the top-dimensional cells containing it. Between
202
+ * consecutive images, each cell's value moves linearly, and the vines follow
203
+ * that homotopy using the transposition updates of {@link vineyard}. At
204
+ * image `m`, the vine points with `death > birth` are the pairs of
205
+ * `cubicalPersistence(images[m], { coeff })`. Cell values are interpolated
206
+ * between images rather than pixel values: a lower-dimensional cell takes the
207
+ * linear interpolation of its two cell values, which can lie below the
208
+ * T-construction value of the interpolated image.
209
+ *
210
+ * Every image must be a {@link Grid} with the same shape as `images[0]` and
211
+ * finite values.
212
+ */
213
+ export declare function cubicalVineyard(images: ArrayLike<Grid>, opts?: VineyardOptions): CubicalVineyard;
214
+ /** Options for {@link ripsVineyard}. */
215
+ export interface RipsVineyardOptions {
216
+ /** Maximum homology dimension, an integer from 0 to 9. Default 1. */
217
+ maxDim?: number;
218
+ /**
219
+ * Non-negative edge-length threshold. Keep only simplices whose edges each
220
+ * have length at most `maxEdgeLength` in at least one cloud (the cloud may
221
+ * differ from edge to edge). Default `Infinity`: include every simplex up
222
+ * to dimension `maxDim + 1`, so every vine is exact.
223
+ */
224
+ maxEdgeLength?: number;
225
+ /** The prime `p` of the coefficient field `Z/p`, from 2 to `2^31 − 1`. Default 2. */
226
+ coeff?: number;
227
+ /**
228
+ * Minimum persistence threshold, a finite number `>= 0`. Omit vines whose
229
+ * `death − birth` is at most `minPersistence` at every knot; essential
230
+ * vines are always kept. Default 0: omit only vines that never leave the
231
+ * diagonal.
232
+ */
233
+ minPersistence?: number;
234
+ /**
235
+ * Also return one representative cycle per kept vine persisting at each
236
+ * requested time (`death > birth` at that time, or essential) in the
237
+ * requested dimensions (up to `maxDim`). Every transposition at crossing
238
+ * time `<= t` is applied before the snapshot at `t` is taken.
239
+ */
240
+ representatives?: VineyardRepresentativesOptions;
241
+ }
242
+ /** Result of {@link ripsVineyard}: the vineyard and its shared complex. */
243
+ export interface RipsVineyard extends Vineyard {
244
+ /**
245
+ * Shared complex across all clouds, carrying its values from `clouds[0]`
246
+ * in the documented order of a {@link Complex}. Indexed by `birthSimplices`
247
+ * and `deathSimplices`; its vertices are point indices.
248
+ */
249
+ complex: Complex;
250
+ }
251
+ /**
252
+ * Compute the persistence vineyard of a moving point cloud, following the
253
+ * classes of the Vietoris–Rips persistence diagram across frames over
254
+ * `Z/coeff`. `clouds[m]` holds the same points in the same order at time `m`.
255
+ *
256
+ * One shared complex serves all clouds: every simplex up to dimension
257
+ * `maxDim + 1` whose edges each have length at most `maxEdgeLength` in at
258
+ * least one cloud (all such simplices by default). Cloud `m` assigns each
259
+ * simplex the length of its longest edge there, as {@link ripsComplex} does,
260
+ * and between consecutive clouds each simplex's value moves linearly; the
261
+ * vines follow that homotopy using the transposition updates of
262
+ * {@link vineyard}. Simplex values are interpolated rather than point
263
+ * coordinates: between two clouds, a simplex takes the linear interpolation
264
+ * of its two lengths, not its length in the interpolated cloud.
265
+ *
266
+ * At cloud `m`, the vine points with `death > birth` are the pairs of
267
+ * `ripsPersistence(clouds[m], { maxDim, coeff })`. With a finite
268
+ * `maxEdgeLength`, every vine is exact while `death` is below
269
+ * `maxEdgeLength`: at each cloud and at every time between consecutive
270
+ * clouds, the complex contains every simplex of value at most
271
+ * `maxEdgeLength` at its exact value. A death at or above `maxEdgeLength`
272
+ * indicates only that the class persists until at least `maxEdgeLength`.
273
+ *
274
+ * Every cloud must have the same number of points and `d` as `clouds[0]`,
275
+ * with finite coordinates.
276
+ */
277
+ export declare function ripsVineyard(clouds: ArrayLike<PointCloud>, opts?: RipsVineyardOptions): RipsVineyard;
278
+ //# sourceMappingURL=vineyard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vineyard.d.ts","sourceRoot":"","sources":["../src/vineyard.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAQ,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpE,+DAA+D;AAC/D,MAAM,WAAW,8BAA8B;IAC7C;;;;;;;OAOG;IACH,KAAK,EAAE,GAAG,CAAC;IACX;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAID;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACtC,6CAA6C;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,4FAA4F;IAC5F,KAAK,EAAE,WAAW,CAAC;IACnB,iDAAiD;IACjD,IAAI,EAAE,UAAU,CAAC;IACjB,uCAAuC;IACvC,MAAM,EAAE,YAAY,CAAC;IACrB,0EAA0E;IAC1E,MAAM,EAAE,YAAY,CAAC;IACrB,gHAAgH;IAChH,OAAO,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,KAAK,EAAE,WAAW,CAAC;IACnB,2EAA2E;IAC3E,YAAY,EAAE,UAAU,CAAC;CAC1B;AA4BD,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,8BAA8B,CAAC;CAClD;AAID;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