@topolab/tda 0.3.0 → 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.
@@ -0,0 +1,93 @@
1
+ import type { PointCloud } from './check.js';
2
+ import type { DistanceMatrix } from './types.js';
3
+ import type { Bifiltration, Firep, Presentation } from './two_parameter.js';
4
+ /**
5
+ * One RIVET input data file as plain data. The kind of file decides which
6
+ * fields are present: `points` a cloud, `points_fn` values and a cloud,
7
+ * `metric` a distance matrix, `metric_fn` values and a distance matrix,
8
+ * `bifiltration` a bifiltration, `firep` a chain complex.
9
+ */
10
+ export interface RivetInput {
11
+ /** The kind of data, from `--datatype`; `points` when the flag is absent. */
12
+ datatype: 'points' | 'points_fn' | 'metric' | 'metric_fn' | 'bifiltration' | 'firep';
13
+ /** Every flag of the file: `--name value` as `name` -> value, a flag with no value as `true`. */
14
+ flags: Record<string, string | true>;
15
+ /** `points` and `points_fn`: the cloud. */
16
+ points?: PointCloud;
17
+ /** `metric` and `metric_fn`: the full `n x n` matrix, row-major (the upper-triangular form expanded). */
18
+ distances?: DistanceMatrix;
19
+ /** `points_fn` and `metric_fn`: the function values, one per point. */
20
+ values?: Float64Array;
21
+ /** `--maxdist` as a number; `Infinity` when the flag is absent. */
22
+ maxDistance: number;
23
+ /**
24
+ * `bifiltration`: the simplices as cells, in the file's order, every
25
+ * facet a cell of the file; `gradeOffsets` when any simplex has several
26
+ * grades. With `--xreverse` (`--yreverse`) the x (y) coordinate of every
27
+ * grade is negated, so that the result is an increasing bifiltration.
28
+ */
29
+ bifiltration?: Bifiltration;
30
+ /** `firep`: the chain complex `C2 -> C1 -> C0` over Z/2, both maps as CSR arrays. */
31
+ firep?: Firep;
32
+ }
33
+ /**
34
+ * Reads the text of a RIVET input data file into plain data, as
35
+ * {@link RivetInput}. The six kinds of file of RIVET 1.1 are read:
36
+ * `points`, `points_fn`, `metric`, `metric_fn`, `bifiltration`
37
+ * (multicritical allowed) and `firep`; `--datatype` selects the kind and
38
+ * `points` when the flag is absent. A distance matrix is read in either of
39
+ * the two forms the documentation gives, and the upper-triangular one is
40
+ * expanded to the full symmetric matrix. A bifiltration keeps the file's
41
+ * simplex order, and every facet must itself be listed as a simplex, on
42
+ * any line of the file; with `--xreverse` (`--yreverse`) the x (y)
43
+ * coordinate of every grade is negated, so that the result is an
44
+ * increasing bifiltration. The grades of a firep are as the file gives
45
+ * them; a firep's reverse flags are kept in `flags` only. The Rust crate
46
+ * reads the file (`parse_rivet_input`), so it needs the module.
47
+ */
48
+ export declare function parseRivetInput(text: string): RivetInput;
49
+ /** Options of {@link rivetPresentation}. */
50
+ export interface RivetPresentationOptions {
51
+ /** Homology degree, a non-negative integer (RIVET's `--homology`). Default 0, as in RIVET. */
52
+ degree?: number;
53
+ }
54
+ /**
55
+ * The minimal presentation of the module the RIVET input file `text`
56
+ * describes, in degree `degree`, built as RIVET 1.1 builds it (by the Rust
57
+ * crate's `rivet_presentation`):
58
+ *
59
+ * - A point cloud or a metric space with function values (`points_fn`,
60
+ * `metric_fn`) gives the function-Rips bifiltration
61
+ * (`functionRipsPresentation`); `--xreverse` filters by decreasing value
62
+ * (the values negated), and `--bifil degree` gives the degree-Rips
63
+ * bifiltration instead.
64
+ * - Without function values (`points`, `metric`) it is the degree-Rips
65
+ * bifiltration (`degreeRipsPresentation`, whose first coordinate is minus
66
+ * the degree); `--bifil function` gives the function-Rips bifiltration of
67
+ * `balldensity[]`, by decreasing value.
68
+ * - `--function balldensity[r]`, `gaussian[σ]` or `eccentricity[p]`
69
+ * computes the function on the points or the metric space (values in the
70
+ * file are not used) and gives its function-Rips bifiltration, whatever
71
+ * `--bifil` says: the ball density `C·#{y : d(x, y) <= r}`, the Gaussian
72
+ * density `C·Σ_y exp(−d(x, y)²/(2σ²))` (`C` makes the values sum to 1) and
73
+ * the eccentricity `(Σ_y d(x, y)^p / n)^(1/p)`. Empty brackets take
74
+ * RIVET's defaults: `r` and `σ` RIVET 1.1's 20th percentile of the
75
+ * distances (entry `⌊M/5⌋ − 1` of the distances of all `M` pairs in
76
+ * increasing order, coincident points' zeros counted; 0 when `M < 5`, and
77
+ * then a point's density counts the points that coincide with it), and
78
+ * `p = 1`. `p` may be any real number at least 1, as RIVET's documentation
79
+ * defines it (RIVET 1.1 truncates it to an integer). The filtration is by
80
+ * decreasing value, with or without `--xreverse`, as RIVET's documentation
81
+ * sets it.
82
+ * - A bifiltration gives `bifiltrationPresentation`, a FIRep
83
+ * `firepPresentation`.
84
+ *
85
+ * Rips bifiltrations go up to `--maxdist`. The file is refused as
86
+ * {@link parseRivetInput} refuses it; `--function user` on a file without
87
+ * function values, a `--function` of another form, `--yreverse` on a Rips
88
+ * bifiltration, a negative `--maxdist` on one and a negative distance are
89
+ * refused with a `RangeError`, as is what the builder refuses. To read the
90
+ * file's data, use {@link parseRivetInput}.
91
+ */
92
+ export declare function rivetPresentation(text: string, opts?: RivetPresentationOptions): Presentation;
93
+ //# sourceMappingURL=rivet_input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rivet_input.d.ts","sourceRoot":"","sources":["../src/rivet_input.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,6EAA6E;IAC7E,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,CAAC;IACrF,iGAAiG;IACjG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,2CAA2C;IAC3C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,yGAAyG;IACzG,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,uEAAuE;IACvE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,qFAAqF;IACrF,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAgED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAIxD;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,wBAAwB,GAAG,YAAY,CAM7F"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * RIVET input data files, the input format RIVET 1.1's documentation
3
+ * specifies, read into plain data, and the module a file describes. The
4
+ * Rust crate reads them (`parse_rivet_input` and `rivet_presentation` in
5
+ * `rust/tda-core/src/two_parameter/rivet.rs`); these functions check their
6
+ * arguments and shape the result. A file holds one of six kinds of data (a
7
+ * point cloud, a point cloud with a function, a metric space, a metric
8
+ * space with a function, a bifiltration or a short chain complex), with
9
+ * the flags that tell RIVET how to build a bifiltration from it.
10
+ *
11
+ * A line that starts with `#` is a comment and a blank line is ignored.
12
+ * A line that starts with `--` is a flag, `--name value`, the value the
13
+ * rest of the line (`true` when the flag has none); a repeated flag keeps
14
+ * its last line. Where the documentation allows commas, numbers are
15
+ * separated by spaces or commas; the bifiltration and firep formats
16
+ * separate their numbers by spaces only. Whitespace is JavaScript's (`\s`).
17
+ *
18
+ * A file that does not follow the documentation is refused with a
19
+ * `TypeError` (a value of the wrong kind, such as a token that is not a
20
+ * number) or a `RangeError` (a wrong count, an index out of range, an
21
+ * unknown `--datatype`), and every message names the 1-based line the
22
+ * error is on.
23
+ */
24
+ import { int, kind, options } from './check.js';
25
+ import { call, module } from './load.js';
26
+ import { presentationOf } from './two_parameter.js';
27
+ /** The file's text as the UTF-8 bytes the module reads (a lone surrogate as U+FFFD). */
28
+ const encoder = new TextEncoder();
29
+ function textOf(v) {
30
+ if (typeof v !== 'string')
31
+ throw new TypeError(`text must be a string, got ${kind(v)}`);
32
+ return encoder.encode(v);
33
+ }
34
+ /** The module's result as a {@link RivetInput}, its fields in the order of the kind. */
35
+ function inputOf(raw) {
36
+ const r = { datatype: raw.datatype, flags: Object.fromEntries(raw.flags) };
37
+ switch (raw.datatype) {
38
+ case 'points':
39
+ case 'points_fn':
40
+ r.points = { coords: raw.coords, d: raw.d };
41
+ break;
42
+ case 'metric':
43
+ case 'metric_fn':
44
+ r.distances = { distances: raw.distances };
45
+ break;
46
+ case 'bifiltration': {
47
+ const b = { dims: raw.dims, grades: raw.grades, offsets: raw.offsets, facets: raw.facets };
48
+ if (raw.gradeOffsets !== undefined)
49
+ b.gradeOffsets = raw.gradeOffsets;
50
+ r.bifiltration = b;
51
+ break;
52
+ }
53
+ case 'firep':
54
+ r.firep = {
55
+ high: { grades: raw.highGrades, offsets: raw.highOffsets, rows: raw.highRows },
56
+ low: { grades: raw.lowGrades, offsets: raw.lowOffsets, rows: raw.lowRows },
57
+ lowRank: raw.lowRank
58
+ };
59
+ break;
60
+ }
61
+ if (raw.values !== undefined)
62
+ r.values = raw.values;
63
+ r.maxDistance = raw.maxDistance;
64
+ return r;
65
+ }
66
+ /**
67
+ * Reads the text of a RIVET input data file into plain data, as
68
+ * {@link RivetInput}. The six kinds of file of RIVET 1.1 are read:
69
+ * `points`, `points_fn`, `metric`, `metric_fn`, `bifiltration`
70
+ * (multicritical allowed) and `firep`; `--datatype` selects the kind and
71
+ * `points` when the flag is absent. A distance matrix is read in either of
72
+ * the two forms the documentation gives, and the upper-triangular one is
73
+ * expanded to the full symmetric matrix. A bifiltration keeps the file's
74
+ * simplex order, and every facet must itself be listed as a simplex, on
75
+ * any line of the file; with `--xreverse` (`--yreverse`) the x (y)
76
+ * coordinate of every grade is negated, so that the result is an
77
+ * increasing bifiltration. The grades of a firep are as the file gives
78
+ * them; a firep's reverse flags are kept in `flags` only. The Rust crate
79
+ * reads the file (`parse_rivet_input`), so it needs the module.
80
+ */
81
+ export function parseRivetInput(text) {
82
+ module();
83
+ const bytes = textOf(text);
84
+ return call('parseRivetInput', (m) => inputOf(m.rivetInputFlat(bytes)));
85
+ }
86
+ const RIVET_PRESENTATION_KEYS = { degree: true };
87
+ /**
88
+ * The minimal presentation of the module the RIVET input file `text`
89
+ * describes, in degree `degree`, built as RIVET 1.1 builds it (by the Rust
90
+ * crate's `rivet_presentation`):
91
+ *
92
+ * - A point cloud or a metric space with function values (`points_fn`,
93
+ * `metric_fn`) gives the function-Rips bifiltration
94
+ * (`functionRipsPresentation`); `--xreverse` filters by decreasing value
95
+ * (the values negated), and `--bifil degree` gives the degree-Rips
96
+ * bifiltration instead.
97
+ * - Without function values (`points`, `metric`) it is the degree-Rips
98
+ * bifiltration (`degreeRipsPresentation`, whose first coordinate is minus
99
+ * the degree); `--bifil function` gives the function-Rips bifiltration of
100
+ * `balldensity[]`, by decreasing value.
101
+ * - `--function balldensity[r]`, `gaussian[σ]` or `eccentricity[p]`
102
+ * computes the function on the points or the metric space (values in the
103
+ * file are not used) and gives its function-Rips bifiltration, whatever
104
+ * `--bifil` says: the ball density `C·#{y : d(x, y) <= r}`, the Gaussian
105
+ * density `C·Σ_y exp(−d(x, y)²/(2σ²))` (`C` makes the values sum to 1) and
106
+ * the eccentricity `(Σ_y d(x, y)^p / n)^(1/p)`. Empty brackets take
107
+ * RIVET's defaults: `r` and `σ` RIVET 1.1's 20th percentile of the
108
+ * distances (entry `⌊M/5⌋ − 1` of the distances of all `M` pairs in
109
+ * increasing order, coincident points' zeros counted; 0 when `M < 5`, and
110
+ * then a point's density counts the points that coincide with it), and
111
+ * `p = 1`. `p` may be any real number at least 1, as RIVET's documentation
112
+ * defines it (RIVET 1.1 truncates it to an integer). The filtration is by
113
+ * decreasing value, with or without `--xreverse`, as RIVET's documentation
114
+ * sets it.
115
+ * - A bifiltration gives `bifiltrationPresentation`, a FIRep
116
+ * `firepPresentation`.
117
+ *
118
+ * Rips bifiltrations go up to `--maxdist`. The file is refused as
119
+ * {@link parseRivetInput} refuses it; `--function user` on a file without
120
+ * function values, a `--function` of another form, `--yreverse` on a Rips
121
+ * bifiltration, a negative `--maxdist` on one and a negative distance are
122
+ * refused with a `RangeError`, as is what the builder refuses. To read the
123
+ * file's data, use {@link parseRivetInput}.
124
+ */
125
+ export function rivetPresentation(text, opts) {
126
+ module();
127
+ const bytes = textOf(text);
128
+ const o = options(opts, 'rivetPresentation', RIVET_PRESENTATION_KEYS);
129
+ const degree = o.degree === undefined ? 0 : int(o.degree, 'degree', 0, 254);
130
+ return call('rivetPresentation', (m) => presentationOf(m.rivetPresentationFlat(bytes, degree), degree));
131
+ }
132
+ //# sourceMappingURL=rivet_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rivet_input.js","sourceRoot":"","sources":["../src/rivet_input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAwDpD,wFAAwF;AACxF,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,SAAS,MAAM,CAAC,CAAU;IACxB,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,wFAAwF;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ED
Binary file
@@ -0,0 +1,243 @@
1
+ import type { PointCloud } from './check.js';
2
+ import type { DistanceMatrix } from './types.js';
3
+ /**
4
+ * A minimal presentation of a two-parameter persistence module: generators
5
+ * and relations with grades `(x, y)`, and each relation as a sum of
6
+ * generators. Grades are stored as indices into the axes `xs` and `ys`.
7
+ * Relations are ordered by `y`, then `x`.
8
+ */
9
+ export interface Presentation {
10
+ /** The distinct first coordinates of the grades, increasing. */
11
+ xs: Float64Array;
12
+ /** The distinct second coordinates of the grades, increasing. */
13
+ ys: Float64Array;
14
+ /** `[x index, y index]` for each generator. */
15
+ generators: Uint32Array;
16
+ /** `[x index, y index]` for each relation. */
17
+ relations: Uint32Array;
18
+ /** Relation `j` is the sum of the generators `rows[offsets[j] .. offsets[j + 1]]`. */
19
+ offsets: Uint32Array;
20
+ /** Generator indices of the relations, increasing within a relation. */
21
+ rows: Uint32Array;
22
+ /** The homology degree the module is of. */
23
+ degree: number;
24
+ }
25
+ /** Options of {@link functionRipsPresentation}. */
26
+ export interface FunctionRipsPresentationOptions {
27
+ /** Homology degree, a non-negative integer. Default 1. */
28
+ degree?: number;
29
+ /** Largest edge kept, non-negative. Default `Infinity` (every pair). */
30
+ maxEdgeLength?: number;
31
+ }
32
+ /** The module's six arrays with the degree (internal: also used by src/rivet_input.ts). */
33
+ export declare function presentationOf(raw: Omit<Presentation, 'degree'>, degree: number): Presentation;
34
+ /**
35
+ * The minimal presentation of the degree-`degree` homology of the
36
+ * function-Rips bifiltration of a point cloud or a distance matrix: the
37
+ * simplex on a set of points is present at `(a, r)` when every point has
38
+ * function value `<= a` and every pair is at distance `<= r`. `values[i]` is
39
+ * the function at point `i` (for instance a codensity, so that dense
40
+ * regions come first). Degrees 0, 1 and 2 never build the complex (degrees 0
41
+ * and 1 take thousands of points, degree 2 hundreds); higher degrees build it
42
+ * up to dimension `degree + 1`.
43
+ */
44
+ export declare function functionRipsPresentation(points: PointCloud | DistanceMatrix, values: ArrayLike<number>, opts?: FunctionRipsPresentationOptions): Presentation;
45
+ /** Options of {@link degreeRipsPresentation}. */
46
+ export interface DegreeRipsPresentationOptions {
47
+ /** Homology degree, a non-negative integer. Default 1. */
48
+ degree?: number;
49
+ /** Largest edge kept, non-negative; degrees are counted among the edges kept. Default `Infinity`. */
50
+ maxEdgeLength?: number;
51
+ }
52
+ /**
53
+ * The minimal presentation of the degree-`degree` homology of the
54
+ * degree-Rips bifiltration of a point cloud or a distance matrix: at
55
+ * `(−k, r)`, the Rips complex at scale `r` on the points with at least `k`
56
+ * other points within `r`. The first coordinate is minus the degree, so that
57
+ * the complex grows along both axes; it needs no function on the points.
58
+ * Every simplex has one grade per degree its points reach, so the cost
59
+ * grows with the number of simplices times the number of points: for small
60
+ * clouds (about 60 points in degree 1 take a second).
61
+ */
62
+ export declare function degreeRipsPresentation(points: PointCloud | DistanceMatrix, opts?: DegreeRipsPresentationOptions): Presentation;
63
+ /**
64
+ * A bifiltered cell complex: cell `k` has dimension `dims[k]` and facets
65
+ * `facets[offsets[k] .. offsets[k + 1]]` (cell indices; none for a vertex).
66
+ * Without `gradeOffsets` each cell has one grade, `(grades[2k], grades[2k +
67
+ * 1])`, and every facet's grade must be at most its cell's in both
68
+ * coordinates. With `gradeOffsets` the bifiltration is multicritical: cell
69
+ * `k` is present from each of the grades number `gradeOffsets[k]` to
70
+ * `gradeOffsets[k + 1]` of `grades` on, and a facet must be present wherever
71
+ * its cell is.
72
+ */
73
+ export interface Bifiltration {
74
+ /** Dimension of each cell. */
75
+ dims: Uint8Array;
76
+ /** `[x, y]` for each grade: one per cell, or as `gradeOffsets` says. */
77
+ grades: Float64Array;
78
+ /** Multicritical only: offsets of the cells' grades (one more than the cells), counted in grades. */
79
+ gradeOffsets?: Uint32Array;
80
+ /** CSR offsets of the facets (one more than the cells). */
81
+ offsets: Uint32Array;
82
+ /** Facets as cell indices. */
83
+ facets: Uint32Array;
84
+ }
85
+ /** Options of {@link bifiltrationPresentation}. */
86
+ export interface BifiltrationPresentationOptions {
87
+ /** Homology degree, a non-negative integer. Default 1. */
88
+ degree?: number;
89
+ }
90
+ /**
91
+ * The minimal presentation of the degree-`degree` homology of any
92
+ * bifiltered cell complex, one grade a cell or several, over Z/2.
93
+ */
94
+ export declare function bifiltrationPresentation(bifiltration: Bifiltration, opts?: BifiltrationPresentationOptions): Presentation;
95
+ /** A presentation's arrays, checked for their kinds (internal: also used by src/arrangement.ts). */
96
+ export declare function checked(p: Presentation, name: string): Presentation;
97
+ /** The bigraded Betti numbers of a module and its Hilbert function. */
98
+ export interface BigradedBetti {
99
+ /** Grades `[x, y, …]` of the generators (ξ₀). */
100
+ b0: Float64Array;
101
+ /** Grades `[x, y, …]` of the relations (ξ₁). */
102
+ b1: Float64Array;
103
+ /** Grades `[x, y, …]` of the relations among the relations (ξ₂). */
104
+ b2: Float64Array;
105
+ /** The axes the Hilbert function is given on (the presentation's). */
106
+ xs: Float64Array;
107
+ /** See `xs`. */
108
+ ys: Float64Array;
109
+ /**
110
+ * The Hilbert function: `hilbert[iy · xs.length + ix]` is the dimension of
111
+ * the module at `(xs[ix], ys[iy])`, and at every point up to the next
112
+ * grid line on either axis. The module is zero below `xs[0]` or `ys[0]`.
113
+ */
114
+ hilbert: Uint32Array;
115
+ }
116
+ /**
117
+ * The bigraded Betti numbers ξ₀, ξ₁, ξ₂ of a presented module (the grades
118
+ * of the generators, the relations and the relations among relations, with
119
+ * multiplicity) and its Hilbert function, the dimension of the module at
120
+ * every point of the plane.
121
+ */
122
+ export declare function bigradedBetti(presentation: Presentation): BigradedBetti;
123
+ /**
124
+ * A line of non-negative slope: through `point`, along `direction` (both
125
+ * coordinates non-negative, not both zero) or at `angle` degrees from the
126
+ * first axis (0 to 90).
127
+ */
128
+ export type SliceLine = {
129
+ point: ArrayLike<number>;
130
+ direction: ArrayLike<number>;
131
+ } | {
132
+ point: ArrayLike<number>;
133
+ angle: number;
134
+ };
135
+ /** The barcode of a module along one line. */
136
+ export interface FiberedBarcode {
137
+ /**
138
+ * `[birth, death, …]` in the line's parameter `t`: the point of the line
139
+ * at `t` is `point + t · direction`. `death` is `Infinity` for a class
140
+ * that persists along the rest of the line. Sorted by birth, then death.
141
+ */
142
+ pairs: Float64Array;
143
+ /** The point of the line that `t = 0` is: the line's `point`. */
144
+ point: [number, number];
145
+ /** The unit direction of the line, as the module computed it from `direction` or `angle`. */
146
+ direction: [number, number];
147
+ }
148
+ /**
149
+ * The fibered barcode of a presented module: its barcode along each given
150
+ * line of non-negative slope. Restricted to such a line, a two-parameter
151
+ * module is a one-parameter module, and this is its barcode, in the line's
152
+ * parameter. One line gives one barcode; an array of lines an array of
153
+ * barcodes, in one call. The Rust core builds each line, as the crate's
154
+ * `Line::new` (a direction, normalised) or `Line::from_angle` (an angle: 0,
155
+ * 45 and 90 degrees exactly, others from the cosine and sine of the `libm`
156
+ * crate, a port of musl's) builds it, and returns it as the barcode's
157
+ * `point` and `direction`: the same bits in every JavaScript engine, in the
158
+ * Python package and from the crate.
159
+ */
160
+ export declare function fiberedBarcode(presentation: Presentation, line: SliceLine): FiberedBarcode;
161
+ export declare function fiberedBarcode(presentation: Presentation, lines: readonly SliceLine[]): FiberedBarcode[];
162
+ /**
163
+ * One line or an array of lines as the module reads them: `[px, py, a, b, …]`
164
+ * and one flag per line, 1 when the line is given by its angle (internal:
165
+ * also used by src/arrangement.ts).
166
+ */
167
+ export declare function linesOf(lines: SliceLine | readonly SliceLine[]): {
168
+ many: boolean;
169
+ flat: Float64Array;
170
+ angles: Uint8Array;
171
+ };
172
+ /**
173
+ * The barcodes of `{ pairs, offsets, lines }`, each with the line the module
174
+ * built (internal: also used by src/arrangement.ts).
175
+ */
176
+ export declare function barcodesOf(r: {
177
+ pairs: Float64Array;
178
+ offsets: Uint32Array;
179
+ lines: Float64Array;
180
+ }, many: boolean): FiberedBarcode | FiberedBarcode[];
181
+ /** One map of a {@link Firep}: a column per generator of its source, with that generator's grade and the indices of its non-zero rows. */
182
+ export interface FirepMatrix {
183
+ /** `[x, y]` for each column. */
184
+ grades: Float64Array;
185
+ /** Column `j` has the rows `rows[offsets[j] .. offsets[j + 1]]`. */
186
+ offsets: Uint32Array;
187
+ /** Row indices into the target's generators, from 0. */
188
+ rows: Uint32Array;
189
+ }
190
+ /**
191
+ * A chain complex of free bigraded modules `C2 → C1 → C0` over Z/2, RIVET's
192
+ * free implicit representation (FIRep): the module it presents is the
193
+ * homology at `C1`. Every row of a column of `high` must have a grade at most
194
+ * the column's, and the two maps must compose to zero.
195
+ */
196
+ export interface Firep {
197
+ /** `C2 → C1`: a column per generator of `C2`, rows indexing `C1`. */
198
+ high: FirepMatrix;
199
+ /** `C1 → C0`: a column per generator of `C1` (so its grades are those of `C1`), rows indexing `C0`. */
200
+ low: FirepMatrix;
201
+ /** The number of generators of `C0` (their grades are not needed). */
202
+ lowRank: number;
203
+ }
204
+ /** Options of {@link firepPresentation}. */
205
+ export interface FirepPresentationOptions {
206
+ /** The homology degree recorded in the result (the module is the homology at `C1` whatever it is). Default 1. */
207
+ degree?: number;
208
+ }
209
+ /**
210
+ * The minimal presentation of the homology of a chain complex of free
211
+ * bigraded modules at its middle (RIVET's FIRep input), over Z/2.
212
+ */
213
+ export declare function firepPresentation(firep: Firep, opts?: FirepPresentationOptions): Presentation;
214
+ /** Options of {@link coarsenPresentation}. */
215
+ export interface CoarsenPresentationOptions {
216
+ /**
217
+ * Bins on the first axis (RIVET's `--xbins`), a non-negative integer.
218
+ * Default 0: the axis as it is. So is an axis with at most this many
219
+ * distinct grades.
220
+ */
221
+ xbins?: number;
222
+ /** Bins on the second axis (RIVET's `--ybins`), as `xbins`. */
223
+ ybins?: number;
224
+ /**
225
+ * `[lo, hi]` covered by the bins of the first axis. Default: from the
226
+ * smallest to the largest first coordinate of the grades. `hi` must be at
227
+ * least the largest one.
228
+ */
229
+ xRange?: ArrayLike<number>;
230
+ /** `[lo, hi]` covered by the bins of the second axis, as `xRange`. */
231
+ yRange?: ArrayLike<number>;
232
+ }
233
+ /**
234
+ * The minimal presentation of the module coarsened onto a grid, as RIVET
235
+ * coarsens with `--xbins` and `--ybins`: `xbins` values evenly spaced over
236
+ * `xRange`, the last at its end (`lo + k (hi − lo) / xbins`, `k = 1 …
237
+ * xbins`), the same for `y`, and every grade rounded up to the grid. The
238
+ * coarsened module at a point is the module at the largest grid point below
239
+ * it, so fewer grades, fewer anchors and a smaller augmented arrangement,
240
+ * at the price of moving every interval's ends up to the grid.
241
+ */
242
+ export declare function coarsenPresentation(presentation: Presentation, opts?: CoarsenPresentationOptions): Presentation;
243
+ //# sourceMappingURL=two_parameter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"two_parameter.d.ts","sourceRoot":"","sources":["../src/two_parameter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,EAAE,EAAE,YAAY,CAAC;IACjB,iEAAiE;IACjE,EAAE,EAAE,YAAY,CAAC;IACjB,+CAA+C;IAC/C,UAAU,EAAE,WAAW,CAAC;IACxB,8CAA8C;IAC9C,SAAS,EAAE,WAAW,CAAC;IACvB,sFAAsF;IACtF,OAAO,EAAE,WAAW,CAAC;IACrB,wEAAwE;IACxE,IAAI,EAAE,WAAW,CAAC;IAClB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mDAAmD;AACnD,MAAM,WAAW,+BAA+B;IAC9C,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAU9F;AAED;;;;;;;;;GASG;AACH,wBAAgB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