@danielsimonjr/mathts-functions 0.56.0 → 0.57.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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Halfspace intersection / vertex enumeration (2-D & 3-D) — completes the
|
|
3
|
+
* computational-geometry engine.
|
|
4
|
+
*
|
|
5
|
+
* Given a set of halfspaces `A·x + b ≤ 0` (SciPy's convention — see below) and
|
|
6
|
+
* a strictly **interior** point `x₀`, `halfspaceIntersection` returns the
|
|
7
|
+
* **vertices** of the bounded polytope `{x : A·x + b ≤ 0}`.
|
|
8
|
+
*
|
|
9
|
+
* ## Convention (matches `scipy.spatial.HalfspaceIntersection`)
|
|
10
|
+
*
|
|
11
|
+
* Each halfspace is a row `[a_1, …, a_d, b]` of length `d + 1` denoting the
|
|
12
|
+
* inequality
|
|
13
|
+
*
|
|
14
|
+
* ```text
|
|
15
|
+
* a·x + b ≤ 0 (i.e. a·x ≤ −b)
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* This is exactly SciPy's stacked `[A | b]` form (`Ax + b ≤ 0`). To feed a
|
|
19
|
+
* constraint written `a·x ≤ c`, pass the row `[a_1, …, a_d, −c]`.
|
|
20
|
+
*
|
|
21
|
+
* ## Method — the dual-hull route (SciPy's approach)
|
|
22
|
+
*
|
|
23
|
+
* With a strictly interior point `x₀` (every `aᵢ·x₀ + bᵢ < 0`), map each
|
|
24
|
+
* halfspace to a **dual point**
|
|
25
|
+
*
|
|
26
|
+
* ```text
|
|
27
|
+
* yᵢ = aᵢ / dᵢ , dᵢ = −(aᵢ·x₀ + bᵢ) > 0.
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The convex hull of `{yᵢ}` is the polar dual of the (recentred) polytope:
|
|
31
|
+
* **each facet of the dual hull corresponds to a vertex of the primal
|
|
32
|
+
* polytope**, and the primal vertex is the point where the `d` halfspaces
|
|
33
|
+
* spanning that facet meet — the solution of the `d × d` linear system
|
|
34
|
+
* `aᵢ·x = −bᵢ` over those `d` halfspaces. Redundant (non-hull) halfspaces map to
|
|
35
|
+
* interior dual points and contribute no vertex, exactly as SciPy discards them.
|
|
36
|
+
*
|
|
37
|
+
* **Boundedness.** The primal polytope is bounded iff the dual-space **origin**
|
|
38
|
+
* lies strictly inside `conv{yᵢ}` (equivalently, the halfspace normals `aᵢ`
|
|
39
|
+
* positively span `ℝᵈ`). This is checked against the oriented dual-hull facets;
|
|
40
|
+
* an unbounded polytope throws — mirroring SciPy's `QhullError`.
|
|
41
|
+
*
|
|
42
|
+
* ## Dimensions
|
|
43
|
+
*
|
|
44
|
+
* Implemented for **2-D and 3-D** by reusing the package's `convexHull`
|
|
45
|
+
* (monotone-chain / QuickHull). For `d > 3` a clear error is thrown: the
|
|
46
|
+
* general n-D case needs an n-D convex hull (QuickHull-n) or the
|
|
47
|
+
* **double-description method** (Motzkin — incrementally intersect halfspaces,
|
|
48
|
+
* maintaining the V-representation with an LP/adjacency feasibility step), which
|
|
49
|
+
* MathTS's hull does not yet provide. Not half-shipped.
|
|
50
|
+
*
|
|
51
|
+
* Pinned against `scipy.spatial.HalfspaceIntersection(halfspaces,
|
|
52
|
+
* interior_point).intersections` (the vertex set, order-independent to ~1e-9) in
|
|
53
|
+
* `functions/tests/geometry-halfspace-oracle.test.ts`.
|
|
54
|
+
*
|
|
55
|
+
* @packageDocumentation
|
|
56
|
+
*/
|
|
57
|
+
/** Structured halfspace-intersection result (mirrors SciPy's vertex output). */
|
|
58
|
+
export interface HalfspaceIntersectionResult {
|
|
59
|
+
/**
|
|
60
|
+
* Vertices of the bounded polytope `{x : A·x + b ≤ 0}` as coordinate arrays.
|
|
61
|
+
* In 2-D they are ordered counter-clockwise (a polygon traversal); in 3-D the
|
|
62
|
+
* order is unspecified (deduplicated).
|
|
63
|
+
*/
|
|
64
|
+
vertices: number[][];
|
|
65
|
+
/**
|
|
66
|
+
* Vertex–facet incidence: `incidences[k]` lists the indices (into the input
|
|
67
|
+
* `halfspaces`) of every halfspace that is **tight** (`a·v + b = 0`) at
|
|
68
|
+
* `vertices[k]`. A true polytope vertex is tight on at least `d` halfspaces.
|
|
69
|
+
*/
|
|
70
|
+
incidences: number[][];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Enumerate the vertices of the bounded polytope defined by a set of halfspaces.
|
|
74
|
+
*
|
|
75
|
+
* @param halfspaces - Rows `[a_1, …, a_d, b]` denoting `a·x + b ≤ 0`
|
|
76
|
+
* (SciPy's `Ax + b ≤ 0` convention). All rows must have length `d + 1`.
|
|
77
|
+
* @param interiorPoint - A point `x₀` of length `d` that is **strictly interior**
|
|
78
|
+
* to the polytope (every `aᵢ·x₀ + bᵢ < 0`).
|
|
79
|
+
* @returns A {@link HalfspaceIntersectionResult} (vertices + vertex-facet incidence).
|
|
80
|
+
* @throws When `d ∉ {2, 3}`; when a halfspace row is malformed; when
|
|
81
|
+
* `interiorPoint` is not strictly interior; or when the polytope is unbounded.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Unit square [0,1]² from its four edge halfspaces.
|
|
85
|
+
* halfspaceIntersection(
|
|
86
|
+
* [[-1, 0, 0], [1, 0, -1], [0, -1, 0], [0, 1, -1]],
|
|
87
|
+
* [0.5, 0.5]
|
|
88
|
+
* ).vertices; // the four corners (CCW)
|
|
89
|
+
*/
|
|
90
|
+
export declare function halfspaceIntersection(halfspaces: number[][], interiorPoint: number[]): HalfspaceIntersectionResult;
|
|
91
|
+
//# sourceMappingURL=halfspace-intersection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halfspace-intersection.d.ts","sourceRoot":"","sources":["../../src/geometry/halfspace-intersection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAIH,gFAAgF;AAChF,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;CACxB;AAmID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAAE,EAAE,EACtB,aAAa,EAAE,MAAM,EAAE,GACtB,2BAA2B,CAwI7B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,8 @@ export { alphaShape } from './geometry/alpha-shape.js';
|
|
|
108
108
|
export type { AlphaShapeResult } from './geometry/alpha-shape.js';
|
|
109
109
|
export { sphericalVoronoi } from './geometry/spherical-voronoi.js';
|
|
110
110
|
export type { SphericalVoronoiResult } from './geometry/spherical-voronoi.js';
|
|
111
|
+
export { halfspaceIntersection } from './geometry/halfspace-intersection.js';
|
|
112
|
+
export type { HalfspaceIntersectionResult } from './geometry/halfspace-intersection.js';
|
|
111
113
|
export { noncentralChi2CDF, noncentralFCDF, noncentralTCDF, circmean, circstd, circvar, vonMisesPDF, mcnemar, cochranQ, } from './stats/inference-extra2.js';
|
|
112
114
|
export type { CircularOptions, McNemarOptions, McNemarResult, CochranQResult, } from './stats/inference-extra2.js';
|
|
113
115
|
export { hyp0f1, hyp1f1, hyp2f1, pFq } from './special/hypergeometric.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,cAAc,kBAAkB,CAAC;AAKjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,E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a,EAAE,MAAM,kCAAkC,CAAC;AAChG,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13454,8 +13454,8 @@ function solveDAE(f, g, tspan, y0, z0, options = {}) {
|
|
|
13454
13454
|
for (let it = 0; it < 12; it++) {
|
|
13455
13455
|
const R0 = residual(wc);
|
|
13456
13456
|
const J = newtonMatrix(tNew, wc, c0, residual, R0);
|
|
13457
|
-
const
|
|
13458
|
-
const dw =
|
|
13457
|
+
const solve4 = _factorSolver(J, n);
|
|
13458
|
+
const dw = solve4(R0.map((v) => -v));
|
|
13459
13459
|
if (!dw.every((v) => Number.isFinite(v))) break;
|
|
13460
13460
|
for (let i = 0; i < n; i++) {
|
|
13461
13461
|
wc[i] += dw[i];
|
|
@@ -21938,8 +21938,8 @@ function nearlyEqual2(a, b, relTol = 1e-9, absTol = 0) {
|
|
|
21938
21938
|
}
|
|
21939
21939
|
const ax = x.abs();
|
|
21940
21940
|
const ay = y.abs();
|
|
21941
|
-
const
|
|
21942
|
-
const relBound =
|
|
21941
|
+
const maxAbs2 = ax.greaterThanOrEqual(ay) ? ax : ay;
|
|
21942
|
+
const relBound = maxAbs2.mul(relTol);
|
|
21943
21943
|
const diff2 = x.sub(y).abs();
|
|
21944
21944
|
return diff2.lessThanOrEqual(relBound) || diff2.lessThanOrEqual(absTol);
|
|
21945
21945
|
}
|
|
@@ -38328,17 +38328,17 @@ function createComplexEigs({
|
|
|
38328
38328
|
last2 = true;
|
|
38329
38329
|
for (let i = 0; i < N2; i++) {
|
|
38330
38330
|
let colNorm = realzero;
|
|
38331
|
-
let
|
|
38331
|
+
let rowNorm2 = realzero;
|
|
38332
38332
|
for (let j = 0; j < N2; j++) {
|
|
38333
38333
|
if (i === j) continue;
|
|
38334
38334
|
colNorm = addScalar2(colNorm, abs2(arr10[j][i]));
|
|
38335
|
-
|
|
38335
|
+
rowNorm2 = addScalar2(rowNorm2, abs2(arr10[i][j]));
|
|
38336
38336
|
}
|
|
38337
|
-
if (!equal2(colNorm, 0) && !equal2(
|
|
38337
|
+
if (!equal2(colNorm, 0) && !equal2(rowNorm2, 0)) {
|
|
38338
38338
|
let f = realone;
|
|
38339
38339
|
let c = colNorm;
|
|
38340
|
-
const rowDivRadix = divideScalar2(
|
|
38341
|
-
const rowMulRadix = multiplyScalar2(
|
|
38340
|
+
const rowDivRadix = divideScalar2(rowNorm2, radix);
|
|
38341
|
+
const rowMulRadix = multiplyScalar2(rowNorm2, radix);
|
|
38342
38342
|
while (smaller2(c, rowDivRadix)) {
|
|
38343
38343
|
c = multiplyScalar2(c, radixSq);
|
|
38344
38344
|
f = multiplyScalar2(f, radix);
|
|
@@ -38348,8 +38348,8 @@ function createComplexEigs({
|
|
|
38348
38348
|
f = divideScalar2(f, radix);
|
|
38349
38349
|
}
|
|
38350
38350
|
const condition = smaller2(
|
|
38351
|
-
divideScalar2(addScalar2(c,
|
|
38352
|
-
multiplyScalar2(addScalar2(colNorm,
|
|
38351
|
+
divideScalar2(addScalar2(c, rowNorm2), f),
|
|
38352
|
+
multiplyScalar2(addScalar2(colNorm, rowNorm2), 0.95)
|
|
38353
38353
|
);
|
|
38354
38354
|
if (condition) {
|
|
38355
38355
|
last2 = false;
|
|
@@ -47419,8 +47419,8 @@ function funm(A, f, fDerivs) {
|
|
|
47419
47419
|
return out;
|
|
47420
47420
|
}
|
|
47421
47421
|
const { values } = eig3(A, { computeVectors: false });
|
|
47422
|
-
const
|
|
47423
|
-
const tol = EIGENVALUE_DISTINCT_REL_TOL * Math.max(1,
|
|
47422
|
+
const maxAbs2 = values.reduce((m, v) => Math.max(m, cAbs(v)), 0);
|
|
47423
|
+
const tol = EIGENVALUE_DISTINCT_REL_TOL * Math.max(1, maxAbs2);
|
|
47424
47424
|
const clusters = clusterEigenvalues(values, tol);
|
|
47425
47425
|
if (clusters.length === n) {
|
|
47426
47426
|
const F2 = cZeros(n);
|
|
@@ -52068,6 +52068,177 @@ function sphericalVoronoi(points, radius = 1, center3 = [0, 0, 0]) {
|
|
|
52068
52068
|
return { vertices, regions, areas };
|
|
52069
52069
|
}
|
|
52070
52070
|
|
|
52071
|
+
// src/geometry/halfspace-intersection.ts
|
|
52072
|
+
var STRICT_INTERIOR_REL = 1e-12;
|
|
52073
|
+
var BOUNDED_REL = 1e-9;
|
|
52074
|
+
var TIGHT_REL = 1e-9;
|
|
52075
|
+
var DEDUP_SIG = 9;
|
|
52076
|
+
var SINGULAR_REL = 1e-12;
|
|
52077
|
+
function maxAbs(points) {
|
|
52078
|
+
let m = 0;
|
|
52079
|
+
for (const p of points) {
|
|
52080
|
+
for (const x of p) {
|
|
52081
|
+
const a = Math.abs(x);
|
|
52082
|
+
if (a > m) m = a;
|
|
52083
|
+
}
|
|
52084
|
+
}
|
|
52085
|
+
return m;
|
|
52086
|
+
}
|
|
52087
|
+
function rowNorm(row2) {
|
|
52088
|
+
let s = 0;
|
|
52089
|
+
for (const x of row2) s += x * x;
|
|
52090
|
+
return Math.sqrt(s);
|
|
52091
|
+
}
|
|
52092
|
+
function isSingular(det2, a) {
|
|
52093
|
+
let bound = 1;
|
|
52094
|
+
for (const row2 of a) bound *= rowNorm(row2);
|
|
52095
|
+
return bound === 0 || Math.abs(det2) <= SINGULAR_REL * bound;
|
|
52096
|
+
}
|
|
52097
|
+
function solve2(a, c) {
|
|
52098
|
+
const det2 = a[0][0] * a[1][1] - a[0][1] * a[1][0];
|
|
52099
|
+
if (isSingular(det2, a)) return null;
|
|
52100
|
+
return [(c[0] * a[1][1] - c[1] * a[0][1]) / det2, (a[0][0] * c[1] - a[1][0] * c[0]) / det2];
|
|
52101
|
+
}
|
|
52102
|
+
function solve3(a, c) {
|
|
52103
|
+
const det2 = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
|
|
52104
|
+
if (isSingular(det2, a)) return null;
|
|
52105
|
+
const detFor = (col) => {
|
|
52106
|
+
const m = a.map((row2, i) => row2.map((v, j) => j === col ? c[i] : v));
|
|
52107
|
+
return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
|
52108
|
+
};
|
|
52109
|
+
return [detFor(0) / det2, detFor(1) / det2, detFor(2) / det2];
|
|
52110
|
+
}
|
|
52111
|
+
function originStrictlyInside(dual, hull, dim) {
|
|
52112
|
+
for (const simplex of hull.simplices) {
|
|
52113
|
+
const p0 = dual[simplex[0]];
|
|
52114
|
+
if (dim === 2) {
|
|
52115
|
+
const p1 = dual[simplex[1]];
|
|
52116
|
+
const ex = p1[0] - p0[0];
|
|
52117
|
+
const ey = p1[1] - p0[1];
|
|
52118
|
+
const edgeLen = Math.hypot(ex, ey);
|
|
52119
|
+
if (edgeLen === 0) continue;
|
|
52120
|
+
const dist = (ex * (0 - p0[1]) - ey * (0 - p0[0])) / edgeLen;
|
|
52121
|
+
if (dist <= BOUNDED_REL) return false;
|
|
52122
|
+
} else {
|
|
52123
|
+
const p1 = dual[simplex[1]];
|
|
52124
|
+
const p2 = dual[simplex[2]];
|
|
52125
|
+
const ux = p1[0] - p0[0];
|
|
52126
|
+
const uy = p1[1] - p0[1];
|
|
52127
|
+
const uz = p1[2] - p0[2];
|
|
52128
|
+
const vx = p2[0] - p0[0];
|
|
52129
|
+
const vy = p2[1] - p0[1];
|
|
52130
|
+
const vz = p2[2] - p0[2];
|
|
52131
|
+
const nx = uy * vz - uz * vy;
|
|
52132
|
+
const ny = uz * vx - ux * vz;
|
|
52133
|
+
const nz = ux * vy - uy * vx;
|
|
52134
|
+
const nLen = Math.hypot(nx, ny, nz);
|
|
52135
|
+
if (nLen === 0) continue;
|
|
52136
|
+
const dist = -(p0[0] * nx + p0[1] * ny + p0[2] * nz) / nLen;
|
|
52137
|
+
if (dist >= -BOUNDED_REL) return false;
|
|
52138
|
+
}
|
|
52139
|
+
}
|
|
52140
|
+
return true;
|
|
52141
|
+
}
|
|
52142
|
+
function halfspaceIntersection(halfspaces, interiorPoint) {
|
|
52143
|
+
if (!Array.isArray(halfspaces) || halfspaces.length === 0) {
|
|
52144
|
+
throw new Error("halfspaceIntersection: requires a non-empty array of halfspaces");
|
|
52145
|
+
}
|
|
52146
|
+
if (!Array.isArray(interiorPoint)) {
|
|
52147
|
+
throw new Error("halfspaceIntersection: interiorPoint must be a coordinate array");
|
|
52148
|
+
}
|
|
52149
|
+
const dim = interiorPoint.length;
|
|
52150
|
+
if (dim !== 2 && dim !== 3) {
|
|
52151
|
+
throw new Error(
|
|
52152
|
+
`halfspaceIntersection: only 2-D and 3-D polytopes are supported (got dimension ${dim}). The general n-D case requires an n-D convex hull or the double-description method, which is not yet implemented.`
|
|
52153
|
+
);
|
|
52154
|
+
}
|
|
52155
|
+
for (const hs of halfspaces) {
|
|
52156
|
+
if (!Array.isArray(hs) || hs.length !== dim + 1) {
|
|
52157
|
+
throw new Error(
|
|
52158
|
+
`halfspaceIntersection: each halfspace must be a row [a_1..a_${dim}, b] of length ${dim + 1}`
|
|
52159
|
+
);
|
|
52160
|
+
}
|
|
52161
|
+
}
|
|
52162
|
+
if (halfspaces.length < dim + 1) {
|
|
52163
|
+
throw new Error(
|
|
52164
|
+
`halfspaceIntersection: the polytope is unbounded \u2014 a bounded ${dim}-D polytope needs at least ${dim + 1} halfspaces (got ${halfspaces.length}); fewer cannot enclose a bounded region`
|
|
52165
|
+
);
|
|
52166
|
+
}
|
|
52167
|
+
const offsets = [];
|
|
52168
|
+
const offsetScales = [];
|
|
52169
|
+
for (const hs of halfspaces) {
|
|
52170
|
+
let s = hs[dim];
|
|
52171
|
+
let mag = Math.abs(hs[dim]);
|
|
52172
|
+
for (let j = 0; j < dim; j++) {
|
|
52173
|
+
const term = hs[j] * interiorPoint[j];
|
|
52174
|
+
s += term;
|
|
52175
|
+
mag += Math.abs(term);
|
|
52176
|
+
}
|
|
52177
|
+
offsets.push(s);
|
|
52178
|
+
offsetScales.push(mag);
|
|
52179
|
+
}
|
|
52180
|
+
for (let i = 0; i < offsets.length; i++) {
|
|
52181
|
+
if (offsets[i] >= -STRICT_INTERIOR_REL * offsetScales[i]) {
|
|
52182
|
+
throw new Error(
|
|
52183
|
+
`halfspaceIntersection: interiorPoint is not strictly interior \u2014 halfspace ${i} gives a\xB7x\u2080 + b = ${offsets[i]} (must be < 0)`
|
|
52184
|
+
);
|
|
52185
|
+
}
|
|
52186
|
+
}
|
|
52187
|
+
const dual = halfspaces.map((hs, i) => {
|
|
52188
|
+
const d = -offsets[i];
|
|
52189
|
+
const y = new Array(dim);
|
|
52190
|
+
for (let j = 0; j < dim; j++) y[j] = hs[j] / d;
|
|
52191
|
+
return y;
|
|
52192
|
+
});
|
|
52193
|
+
const dualScale = maxAbs(dual);
|
|
52194
|
+
const dualN = dualScale > 0 && Number.isFinite(dualScale) ? dual.map((y) => y.map((x) => x / dualScale)) : dual;
|
|
52195
|
+
const hull = convexHull(dualN);
|
|
52196
|
+
if (!originStrictlyInside(dualN, hull, dim)) {
|
|
52197
|
+
throw new Error(
|
|
52198
|
+
"halfspaceIntersection: the polytope is unbounded (the halfspace normals do not positively span the space); vertex enumeration requires a bounded polytope"
|
|
52199
|
+
);
|
|
52200
|
+
}
|
|
52201
|
+
const candidates = [];
|
|
52202
|
+
for (const simplex of hull.simplices) {
|
|
52203
|
+
const aRows = simplex.map((idx) => halfspaces[idx].slice(0, dim));
|
|
52204
|
+
const cVals = simplex.map((idx) => -halfspaces[idx][dim]);
|
|
52205
|
+
const v = dim === 2 ? solve2(aRows, cVals) : solve3(aRows, cVals);
|
|
52206
|
+
if (v === null) continue;
|
|
52207
|
+
if (!v.every((x) => Number.isFinite(x))) continue;
|
|
52208
|
+
candidates.push(v);
|
|
52209
|
+
}
|
|
52210
|
+
const vertScale = maxAbs(candidates);
|
|
52211
|
+
const quantum = vertScale > 0 ? vertScale * Math.pow(10, -DEDUP_SIG) : 0;
|
|
52212
|
+
const vertices = [];
|
|
52213
|
+
const seen = /* @__PURE__ */ new Set();
|
|
52214
|
+
for (const v of candidates) {
|
|
52215
|
+
const key = quantum > 0 ? v.map((x) => Math.round(x / quantum)).join(",") : v.join(",");
|
|
52216
|
+
if (seen.has(key)) continue;
|
|
52217
|
+
seen.add(key);
|
|
52218
|
+
vertices.push(v);
|
|
52219
|
+
}
|
|
52220
|
+
if (dim === 2 && vertices.length > 2) {
|
|
52221
|
+
const cx = vertices.reduce((s, v) => s + v[0], 0) / vertices.length;
|
|
52222
|
+
const cy = vertices.reduce((s, v) => s + v[1], 0) / vertices.length;
|
|
52223
|
+
vertices.sort((p, q) => Math.atan2(p[1] - cy, p[0] - cx) - Math.atan2(q[1] - cy, q[0] - cx));
|
|
52224
|
+
}
|
|
52225
|
+
const incidences = vertices.map((v) => {
|
|
52226
|
+
const tight = [];
|
|
52227
|
+
for (let i = 0; i < halfspaces.length; i++) {
|
|
52228
|
+
let s = halfspaces[i][dim];
|
|
52229
|
+
let mag = Math.abs(halfspaces[i][dim]);
|
|
52230
|
+
for (let j = 0; j < dim; j++) {
|
|
52231
|
+
const term = halfspaces[i][j] * v[j];
|
|
52232
|
+
s += term;
|
|
52233
|
+
mag += Math.abs(term);
|
|
52234
|
+
}
|
|
52235
|
+
if (Math.abs(s) <= TIGHT_REL * mag) tight.push(i);
|
|
52236
|
+
}
|
|
52237
|
+
return tight;
|
|
52238
|
+
});
|
|
52239
|
+
return { vertices, incidences };
|
|
52240
|
+
}
|
|
52241
|
+
|
|
52071
52242
|
// src/stats/inference-extra2.ts
|
|
52072
52243
|
var TWO_PI = 2 * Math.PI;
|
|
52073
52244
|
function noncentralChi2CDF(x, df, nc) {
|
|
@@ -53243,8 +53414,8 @@ var Interval = class {
|
|
|
53243
53414
|
if (this.hi <= 0) {
|
|
53244
53415
|
return outward(this.hi ** n, this.lo ** n);
|
|
53245
53416
|
}
|
|
53246
|
-
const
|
|
53247
|
-
return outward(0,
|
|
53417
|
+
const maxAbs2 = Math.max(Math.abs(this.lo), Math.abs(this.hi));
|
|
53418
|
+
return outward(0, maxAbs2 ** n);
|
|
53248
53419
|
}
|
|
53249
53420
|
};
|
|
53250
53421
|
function interval(lo, hi) {
|
|
@@ -54446,6 +54617,7 @@ export {
|
|
|
54446
54617
|
groebnerBasis,
|
|
54447
54618
|
groupDelay,
|
|
54448
54619
|
gumbelDist,
|
|
54620
|
+
halfspaceIntersection,
|
|
54449
54621
|
halley,
|
|
54450
54622
|
harmonicCentrality,
|
|
54451
54623
|
harmonicNumber,
|
package/package.json
CHANGED