@danielsimonjr/mathts-functions 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +597 -135
- package/dist/typed/algebra.d.ts +14 -6
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/factorization/index.d.ts +25 -0
- package/dist/typed/factorization/index.d.ts.map +1 -1
- package/dist/typed/factorization/kronecker-factor.d.ts +48 -0
- package/dist/typed/factorization/kronecker-factor.d.ts.map +1 -0
- package/dist/typed/factorization/kronecker.d.ts +65 -0
- package/dist/typed/factorization/kronecker.d.ts.map +1 -0
- package/dist/typed/factorization/multi-poly.d.ts +107 -0
- package/dist/typed/factorization/multi-poly.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -454,7 +454,7 @@ __export(typed_exports, {
|
|
|
454
454
|
studentTTest: () => studentTTest,
|
|
455
455
|
studentTTestPaired: () => studentTTestPaired,
|
|
456
456
|
subfactorial: () => subfactorial,
|
|
457
|
-
substitute: () =>
|
|
457
|
+
substitute: () => substitute2,
|
|
458
458
|
subtract: () => subtract,
|
|
459
459
|
sum: () => sum,
|
|
460
460
|
symbolicPartialDerivative: () => symbolicPartialDerivative,
|
|
@@ -3341,8 +3341,8 @@ function resetGpuFft() {
|
|
|
3341
3341
|
resources = null;
|
|
3342
3342
|
}
|
|
3343
3343
|
function stageUniformsFor(res, n, inverse) {
|
|
3344
|
-
const
|
|
3345
|
-
const cached = res.stageUniforms.get(
|
|
3344
|
+
const key2 = `${n}:${inverse ? 1 : 0}`;
|
|
3345
|
+
const cached = res.stageUniforms.get(key2);
|
|
3346
3346
|
if (cached) return cached;
|
|
3347
3347
|
const stages = Math.log2(n);
|
|
3348
3348
|
const bufs = [];
|
|
@@ -3355,7 +3355,7 @@ function stageUniformsFor(res, n, inverse) {
|
|
|
3355
3355
|
res.device.queue.writeBuffer(u, 0, new Uint32Array([n, ns, inverse ? 1 : 0, 0]));
|
|
3356
3356
|
bufs.push(u);
|
|
3357
3357
|
}
|
|
3358
|
-
res.stageUniforms.set(
|
|
3358
|
+
res.stageUniforms.set(key2, bufs);
|
|
3359
3359
|
return bufs;
|
|
3360
3360
|
}
|
|
3361
3361
|
var isPowerOf2 = (n) => n > 0 && (n & n - 1) === 0;
|
|
@@ -8957,14 +8957,14 @@ function voronoiDiagram(points, bounds) {
|
|
|
8957
8957
|
const uy = ((a[0] * a[0] + a[1] * a[1]) * (c[0] - b[0]) + (b[0] * b[0] + b[1] * b[1]) * (a[0] - c[0]) + (c[0] * c[0] + c[1] * c[1]) * (b[0] - a[0])) / D;
|
|
8958
8958
|
const cx = Math.max(bounds[0], Math.min(bounds[2], ux));
|
|
8959
8959
|
const cy = Math.max(bounds[1], Math.min(bounds[3], uy));
|
|
8960
|
-
const
|
|
8961
|
-
triCircumcenters.set(
|
|
8960
|
+
const key2 = tri.slice().sort().join(",");
|
|
8961
|
+
triCircumcenters.set(key2, vertices.length);
|
|
8962
8962
|
vertices.push([cx, cy]);
|
|
8963
8963
|
}
|
|
8964
8964
|
const regions = Array.from({ length: points.length }, () => []);
|
|
8965
8965
|
for (const tri of triangles) {
|
|
8966
|
-
const
|
|
8967
|
-
const vIdx = triCircumcenters.get(
|
|
8966
|
+
const key2 = tri.slice().sort().join(",");
|
|
8967
|
+
const vIdx = triCircumcenters.get(key2);
|
|
8968
8968
|
if (vIdx !== void 0) {
|
|
8969
8969
|
for (const pIdx of tri) {
|
|
8970
8970
|
if (!regions[pIdx].includes(vIdx)) {
|
|
@@ -9582,10 +9582,10 @@ function cmpPowers(a, b) {
|
|
|
9582
9582
|
function normalize(p) {
|
|
9583
9583
|
const byKey = /* @__PURE__ */ new Map();
|
|
9584
9584
|
for (const t of p) {
|
|
9585
|
-
const
|
|
9586
|
-
const existing = byKey.get(
|
|
9585
|
+
const key2 = t.powers.join(",");
|
|
9586
|
+
const existing = byKey.get(key2);
|
|
9587
9587
|
if (existing) existing.coeff += t.coeff;
|
|
9588
|
-
else byKey.set(
|
|
9588
|
+
else byKey.set(key2, { coeff: t.coeff, powers: [...t.powers] });
|
|
9589
9589
|
}
|
|
9590
9590
|
return [...byKey.values()].filter((t) => Math.abs(t.coeff) > EPS).sort((a, b) => cmpPowers(b.powers, a.powers));
|
|
9591
9591
|
}
|
|
@@ -10573,6 +10573,441 @@ function factorUnivariateZ(f) {
|
|
|
10573
10573
|
return { constant, factors };
|
|
10574
10574
|
}
|
|
10575
10575
|
|
|
10576
|
+
// src/typed/factorization/multi-poly.ts
|
|
10577
|
+
function key(exps) {
|
|
10578
|
+
return exps.join(",");
|
|
10579
|
+
}
|
|
10580
|
+
function unkey(k) {
|
|
10581
|
+
if (k === "") {
|
|
10582
|
+
return [];
|
|
10583
|
+
}
|
|
10584
|
+
return k.split(",").map((s) => Number(s));
|
|
10585
|
+
}
|
|
10586
|
+
function fromTerms(vars, entries) {
|
|
10587
|
+
const terms = /* @__PURE__ */ new Map();
|
|
10588
|
+
for (const [exps, coeff] of entries) {
|
|
10589
|
+
if (exps.length !== vars.length) {
|
|
10590
|
+
throw new RangeError("fromTerms: exponent vector length must match vars.length");
|
|
10591
|
+
}
|
|
10592
|
+
const k = key(exps);
|
|
10593
|
+
const prev = terms.get(k) ?? 0n;
|
|
10594
|
+
const next = prev + coeff;
|
|
10595
|
+
if (next === 0n) {
|
|
10596
|
+
terms.delete(k);
|
|
10597
|
+
} else {
|
|
10598
|
+
terms.set(k, next);
|
|
10599
|
+
}
|
|
10600
|
+
}
|
|
10601
|
+
return { vars: vars.slice(), terms };
|
|
10602
|
+
}
|
|
10603
|
+
function degreeIn(p, varIndex) {
|
|
10604
|
+
let d = -1;
|
|
10605
|
+
for (const k of p.terms.keys()) {
|
|
10606
|
+
const exps = unkey(k);
|
|
10607
|
+
if (exps[varIndex] > d) {
|
|
10608
|
+
d = exps[varIndex];
|
|
10609
|
+
}
|
|
10610
|
+
}
|
|
10611
|
+
return d;
|
|
10612
|
+
}
|
|
10613
|
+
function totalDegree(p) {
|
|
10614
|
+
let d = -1;
|
|
10615
|
+
for (const k of p.terms.keys()) {
|
|
10616
|
+
const exps = unkey(k);
|
|
10617
|
+
const s = exps.reduce((a, b) => a + b, 0);
|
|
10618
|
+
if (s > d) {
|
|
10619
|
+
d = s;
|
|
10620
|
+
}
|
|
10621
|
+
}
|
|
10622
|
+
return d;
|
|
10623
|
+
}
|
|
10624
|
+
function isZero2(p) {
|
|
10625
|
+
return p.terms.size === 0;
|
|
10626
|
+
}
|
|
10627
|
+
function equals(a, b) {
|
|
10628
|
+
if (a.vars.length !== b.vars.length) return false;
|
|
10629
|
+
for (let i = 0; i < a.vars.length; i += 1) {
|
|
10630
|
+
if (a.vars[i] !== b.vars[i]) return false;
|
|
10631
|
+
}
|
|
10632
|
+
if (a.terms.size !== b.terms.size) return false;
|
|
10633
|
+
for (const [k, v] of a.terms) {
|
|
10634
|
+
if (b.terms.get(k) !== v) return false;
|
|
10635
|
+
}
|
|
10636
|
+
return true;
|
|
10637
|
+
}
|
|
10638
|
+
function addMP(a, b) {
|
|
10639
|
+
const terms = new Map(a.terms);
|
|
10640
|
+
for (const [k, v] of b.terms) {
|
|
10641
|
+
const next = (terms.get(k) ?? 0n) + v;
|
|
10642
|
+
if (next === 0n) {
|
|
10643
|
+
terms.delete(k);
|
|
10644
|
+
} else {
|
|
10645
|
+
terms.set(k, next);
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10648
|
+
return { vars: a.vars.slice(), terms };
|
|
10649
|
+
}
|
|
10650
|
+
function subMP(a, b) {
|
|
10651
|
+
return addMP(a, negMP(b));
|
|
10652
|
+
}
|
|
10653
|
+
function mulMP(a, b) {
|
|
10654
|
+
const n = a.vars.length;
|
|
10655
|
+
const terms = /* @__PURE__ */ new Map();
|
|
10656
|
+
for (const [ka, ca] of a.terms) {
|
|
10657
|
+
const ea = unkey(ka);
|
|
10658
|
+
for (const [kb, cb] of b.terms) {
|
|
10659
|
+
const eb = unkey(kb);
|
|
10660
|
+
const exps = new Array(n);
|
|
10661
|
+
for (let i = 0; i < n; i += 1) {
|
|
10662
|
+
exps[i] = ea[i] + eb[i];
|
|
10663
|
+
}
|
|
10664
|
+
const k = key(exps);
|
|
10665
|
+
const next = (terms.get(k) ?? 0n) + ca * cb;
|
|
10666
|
+
if (next === 0n) {
|
|
10667
|
+
terms.delete(k);
|
|
10668
|
+
} else {
|
|
10669
|
+
terms.set(k, next);
|
|
10670
|
+
}
|
|
10671
|
+
}
|
|
10672
|
+
}
|
|
10673
|
+
return { vars: a.vars.slice(), terms };
|
|
10674
|
+
}
|
|
10675
|
+
function negMP(p) {
|
|
10676
|
+
const terms = /* @__PURE__ */ new Map();
|
|
10677
|
+
for (const [k, v] of p.terms) {
|
|
10678
|
+
terms.set(k, -v);
|
|
10679
|
+
}
|
|
10680
|
+
return { vars: p.vars.slice(), terms };
|
|
10681
|
+
}
|
|
10682
|
+
function canonicalCompare(expsA, expsB) {
|
|
10683
|
+
const da = expsA.reduce((a, b) => a + b, 0);
|
|
10684
|
+
const db = expsB.reduce((a, b) => a + b, 0);
|
|
10685
|
+
if (da !== db) {
|
|
10686
|
+
return db - da;
|
|
10687
|
+
}
|
|
10688
|
+
for (let i = 0; i < expsA.length; i += 1) {
|
|
10689
|
+
if (expsA[i] !== expsB[i]) {
|
|
10690
|
+
return expsB[i] - expsA[i];
|
|
10691
|
+
}
|
|
10692
|
+
}
|
|
10693
|
+
return 0;
|
|
10694
|
+
}
|
|
10695
|
+
function leadingTerm(p) {
|
|
10696
|
+
let best = null;
|
|
10697
|
+
for (const [k, v] of p.terms) {
|
|
10698
|
+
const exps = unkey(k);
|
|
10699
|
+
if (best === null || canonicalCompare(exps, best.exps) < 0) {
|
|
10700
|
+
best = { exps, coeff: v };
|
|
10701
|
+
}
|
|
10702
|
+
}
|
|
10703
|
+
return best;
|
|
10704
|
+
}
|
|
10705
|
+
function integerContentMP(p) {
|
|
10706
|
+
let g = 0n;
|
|
10707
|
+
for (const v of p.terms.values()) {
|
|
10708
|
+
g = bigintGcd(g, v);
|
|
10709
|
+
}
|
|
10710
|
+
return g;
|
|
10711
|
+
}
|
|
10712
|
+
function primitivePartMP(p) {
|
|
10713
|
+
if (isZero2(p)) {
|
|
10714
|
+
return { vars: p.vars.slice(), terms: /* @__PURE__ */ new Map() };
|
|
10715
|
+
}
|
|
10716
|
+
const g = integerContentMP(p);
|
|
10717
|
+
const terms = /* @__PURE__ */ new Map();
|
|
10718
|
+
for (const [k, v] of p.terms) {
|
|
10719
|
+
terms.set(k, g === 0n ? v : v / g);
|
|
10720
|
+
}
|
|
10721
|
+
const divided = { vars: p.vars.slice(), terms };
|
|
10722
|
+
const lead = leadingTerm(divided);
|
|
10723
|
+
if (lead !== null && lead.coeff < 0n) {
|
|
10724
|
+
return negMP(divided);
|
|
10725
|
+
}
|
|
10726
|
+
return divided;
|
|
10727
|
+
}
|
|
10728
|
+
function multiExactDivide(a, b) {
|
|
10729
|
+
const bLead = leadingTerm(b);
|
|
10730
|
+
if (bLead === null) {
|
|
10731
|
+
return null;
|
|
10732
|
+
}
|
|
10733
|
+
const n = a.vars.length;
|
|
10734
|
+
let remainder = a;
|
|
10735
|
+
const quotientEntries = [];
|
|
10736
|
+
while (!isZero2(remainder)) {
|
|
10737
|
+
const rLead = leadingTerm(remainder);
|
|
10738
|
+
if (rLead === null) {
|
|
10739
|
+
break;
|
|
10740
|
+
}
|
|
10741
|
+
const qExps = new Array(n);
|
|
10742
|
+
for (let i = 0; i < n; i += 1) {
|
|
10743
|
+
const diff2 = rLead.exps[i] - bLead.exps[i];
|
|
10744
|
+
if (diff2 < 0) {
|
|
10745
|
+
return null;
|
|
10746
|
+
}
|
|
10747
|
+
qExps[i] = diff2;
|
|
10748
|
+
}
|
|
10749
|
+
if (rLead.coeff % bLead.coeff !== 0n) {
|
|
10750
|
+
return null;
|
|
10751
|
+
}
|
|
10752
|
+
const qCoeff = rLead.coeff / bLead.coeff;
|
|
10753
|
+
quotientEntries.push([qExps, qCoeff]);
|
|
10754
|
+
const qTerm = fromTerms(a.vars, [[qExps, qCoeff]]);
|
|
10755
|
+
remainder = subMP(remainder, mulMP(qTerm, b));
|
|
10756
|
+
}
|
|
10757
|
+
return fromTerms(a.vars, quotientEntries);
|
|
10758
|
+
}
|
|
10759
|
+
function fromAlgebraExpr(expr, vars) {
|
|
10760
|
+
try {
|
|
10761
|
+
const parsed = polyFromExpression(expr, vars);
|
|
10762
|
+
const entries = [];
|
|
10763
|
+
for (const term of parsed) {
|
|
10764
|
+
if (!Number.isInteger(term.coeff)) {
|
|
10765
|
+
return null;
|
|
10766
|
+
}
|
|
10767
|
+
entries.push([term.powers, BigInt(term.coeff)]);
|
|
10768
|
+
}
|
|
10769
|
+
return fromTerms(vars, entries);
|
|
10770
|
+
} catch {
|
|
10771
|
+
return null;
|
|
10772
|
+
}
|
|
10773
|
+
}
|
|
10774
|
+
function toAlgebraString(p) {
|
|
10775
|
+
if (p.terms.size === 0) return "0";
|
|
10776
|
+
const fmt = (c) => c.toString();
|
|
10777
|
+
const terms = [...p.terms].map(([k, v]) => ({ exps: unkey(k), coeff: v })).reverse().map(({ exps, coeff }) => {
|
|
10778
|
+
const varPart = exps.map((e, i) => e === 0 ? "" : e === 1 ? p.vars[i] : `${p.vars[i]}^${e}`).filter(Boolean).join("*");
|
|
10779
|
+
return varPart ? `${fmt(coeff)}*${varPart}` : fmt(coeff);
|
|
10780
|
+
});
|
|
10781
|
+
return terms.join(" + ").replace(/\+ -/g, "- ");
|
|
10782
|
+
}
|
|
10783
|
+
|
|
10784
|
+
// src/typed/factorization/kronecker.ts
|
|
10785
|
+
function substitutionBases(p) {
|
|
10786
|
+
const n = p.vars.length;
|
|
10787
|
+
const bases = new Array(n);
|
|
10788
|
+
let prod2 = 1n;
|
|
10789
|
+
for (let k = 0; k < n; k += 1) {
|
|
10790
|
+
bases[k] = prod2;
|
|
10791
|
+
const d = degreeIn(p, k);
|
|
10792
|
+
const radix = d < 0 ? 1n : BigInt(d) + 1n;
|
|
10793
|
+
prod2 *= radix;
|
|
10794
|
+
}
|
|
10795
|
+
return bases;
|
|
10796
|
+
}
|
|
10797
|
+
function substitutedDegree(p, bases) {
|
|
10798
|
+
let total = 0n;
|
|
10799
|
+
for (let i = 0; i < bases.length; i += 1) {
|
|
10800
|
+
const d = degreeIn(p, i);
|
|
10801
|
+
const dd = d < 0 ? 0n : BigInt(d);
|
|
10802
|
+
total += dd * bases[i];
|
|
10803
|
+
}
|
|
10804
|
+
return total;
|
|
10805
|
+
}
|
|
10806
|
+
function substitute(p, bases) {
|
|
10807
|
+
const maxDeg = substitutedDegree(p, bases);
|
|
10808
|
+
if (maxDeg > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
10809
|
+
throw new RangeError(
|
|
10810
|
+
`substitute: substituted degree ${maxDeg.toString()} exceeds Number.MAX_SAFE_INTEGER`
|
|
10811
|
+
);
|
|
10812
|
+
}
|
|
10813
|
+
const len = Number(maxDeg) + 1;
|
|
10814
|
+
const out = new Array(len).fill(0n);
|
|
10815
|
+
for (const [k, coeff] of p.terms) {
|
|
10816
|
+
const exps = unkey(k);
|
|
10817
|
+
let deg = 0n;
|
|
10818
|
+
for (let i = 0; i < exps.length; i += 1) {
|
|
10819
|
+
deg += BigInt(exps[i]) * bases[i];
|
|
10820
|
+
}
|
|
10821
|
+
const idx = Number(deg);
|
|
10822
|
+
out[idx] += coeff;
|
|
10823
|
+
}
|
|
10824
|
+
return trim(out);
|
|
10825
|
+
}
|
|
10826
|
+
function backSubstitute(u, bases, degBounds, vars) {
|
|
10827
|
+
const n = bases.length;
|
|
10828
|
+
const trimmed = trim(u);
|
|
10829
|
+
const entries = [];
|
|
10830
|
+
for (let e = 0; e < trimmed.length; e += 1) {
|
|
10831
|
+
const coeff = trimmed[e];
|
|
10832
|
+
if (coeff === 0n) {
|
|
10833
|
+
continue;
|
|
10834
|
+
}
|
|
10835
|
+
let remaining = BigInt(e);
|
|
10836
|
+
const exps = new Array(n);
|
|
10837
|
+
for (let i = 0; i < n; i += 1) {
|
|
10838
|
+
const radix = BigInt(degBounds[i]) + 1n;
|
|
10839
|
+
exps[i] = Number(remaining % radix);
|
|
10840
|
+
remaining = remaining / radix;
|
|
10841
|
+
}
|
|
10842
|
+
if (remaining !== 0n) {
|
|
10843
|
+
return null;
|
|
10844
|
+
}
|
|
10845
|
+
entries.push([exps, coeff]);
|
|
10846
|
+
}
|
|
10847
|
+
return fromTerms(vars, entries);
|
|
10848
|
+
}
|
|
10849
|
+
|
|
10850
|
+
// src/typed/factorization/kronecker-factor.ts
|
|
10851
|
+
var KRONECKER_MAX_DEGREE = 2000n;
|
|
10852
|
+
var MAX_MODULAR_FACTORS2 = 24;
|
|
10853
|
+
function log4(message) {
|
|
10854
|
+
console.warn(message);
|
|
10855
|
+
}
|
|
10856
|
+
function* subsetsOfSize(n, s) {
|
|
10857
|
+
if (s === 0) {
|
|
10858
|
+
yield [];
|
|
10859
|
+
return;
|
|
10860
|
+
}
|
|
10861
|
+
if (s > n) {
|
|
10862
|
+
return;
|
|
10863
|
+
}
|
|
10864
|
+
const idx = Array.from({ length: s }, (_, i) => i);
|
|
10865
|
+
for (; ; ) {
|
|
10866
|
+
yield idx.slice();
|
|
10867
|
+
let i = s - 1;
|
|
10868
|
+
while (i >= 0 && idx[i] === n - s + i) {
|
|
10869
|
+
i -= 1;
|
|
10870
|
+
}
|
|
10871
|
+
if (i < 0) {
|
|
10872
|
+
return;
|
|
10873
|
+
}
|
|
10874
|
+
idx[i] += 1;
|
|
10875
|
+
for (let j = i + 1; j < s; j += 1) {
|
|
10876
|
+
idx[j] = idx[j - 1] + 1;
|
|
10877
|
+
}
|
|
10878
|
+
}
|
|
10879
|
+
}
|
|
10880
|
+
function removeIndices(pool, indices) {
|
|
10881
|
+
const sorted = [...indices].sort((a, b) => b - a);
|
|
10882
|
+
for (const i of sorted) {
|
|
10883
|
+
pool.splice(i, 1);
|
|
10884
|
+
}
|
|
10885
|
+
}
|
|
10886
|
+
function subsetProduct(pool, indices) {
|
|
10887
|
+
let prod2 = [1n];
|
|
10888
|
+
for (const idx of indices) {
|
|
10889
|
+
prod2 = mul(prod2, pool[idx]);
|
|
10890
|
+
}
|
|
10891
|
+
return prod2;
|
|
10892
|
+
}
|
|
10893
|
+
function candidateFor(pool, indices, bases, degBounds, vars) {
|
|
10894
|
+
const back = backSubstitute(subsetProduct(pool, indices), bases, degBounds, vars);
|
|
10895
|
+
if (back === null) {
|
|
10896
|
+
return null;
|
|
10897
|
+
}
|
|
10898
|
+
const cand = primitivePartMP(back);
|
|
10899
|
+
if (totalDegree(cand) < 1) {
|
|
10900
|
+
return null;
|
|
10901
|
+
}
|
|
10902
|
+
return cand;
|
|
10903
|
+
}
|
|
10904
|
+
function findMatchingSubset(pool, s, cand, bases, degBounds, vars) {
|
|
10905
|
+
for (const indices of subsetsOfSize(pool.length, s)) {
|
|
10906
|
+
const c = candidateFor(pool, indices, bases, degBounds, vars);
|
|
10907
|
+
if (c !== null && equals(c, cand)) {
|
|
10908
|
+
return indices;
|
|
10909
|
+
}
|
|
10910
|
+
}
|
|
10911
|
+
return null;
|
|
10912
|
+
}
|
|
10913
|
+
function factorMultivariateKronecker(p) {
|
|
10914
|
+
if (p.vars.length < 2) {
|
|
10915
|
+
return null;
|
|
10916
|
+
}
|
|
10917
|
+
if (isZero2(p) || totalDegree(p) < 1) {
|
|
10918
|
+
return null;
|
|
10919
|
+
}
|
|
10920
|
+
const cont = integerContentMP(p);
|
|
10921
|
+
const pLead = leadingTerm(p);
|
|
10922
|
+
const sign3 = pLead !== null && pLead.coeff < 0n ? -1n : 1n;
|
|
10923
|
+
let constant = cont * sign3;
|
|
10924
|
+
const g = primitivePartMP(p);
|
|
10925
|
+
const bases = substitutionBases(g);
|
|
10926
|
+
if (substitutedDegree(g, bases) > KRONECKER_MAX_DEGREE) {
|
|
10927
|
+
log4(
|
|
10928
|
+
`factorMultivariateKronecker: substituted degree exceeds KRONECKER_MAX_DEGREE=${KRONECKER_MAX_DEGREE.toString()}; declining`
|
|
10929
|
+
);
|
|
10930
|
+
return null;
|
|
10931
|
+
}
|
|
10932
|
+
const image = substitute(g, bases);
|
|
10933
|
+
const uf = factorUnivariateZ(image);
|
|
10934
|
+
const totalCount = uf.factors.reduce((acc, f) => acc + f.mult, 0);
|
|
10935
|
+
if (totalCount <= 1) {
|
|
10936
|
+
return { constant, factors: [{ poly: g, mult: 1 }] };
|
|
10937
|
+
}
|
|
10938
|
+
const pool = [];
|
|
10939
|
+
for (const { poly, mult } of uf.factors) {
|
|
10940
|
+
for (let i = 0; i < mult; i += 1) {
|
|
10941
|
+
pool.push(poly);
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
if (pool.length > MAX_MODULAR_FACTORS2) {
|
|
10945
|
+
log4(
|
|
10946
|
+
`factorMultivariateKronecker: ${pool.length} univariate factors exceeds MAX_MODULAR_FACTORS=${MAX_MODULAR_FACTORS2}; returning input whole`
|
|
10947
|
+
);
|
|
10948
|
+
return { constant, factors: [{ poly: g, mult: 1 }] };
|
|
10949
|
+
}
|
|
10950
|
+
const degBounds = g.vars.map((_, i) => degreeIn(g, i));
|
|
10951
|
+
let gCur = g;
|
|
10952
|
+
const found = [];
|
|
10953
|
+
let s = 1;
|
|
10954
|
+
while (pool.length > 0 && 2 * s <= pool.length) {
|
|
10955
|
+
let extracted = false;
|
|
10956
|
+
for (const indices of subsetsOfSize(pool.length, s)) {
|
|
10957
|
+
const cand = candidateFor(pool, indices, bases, degBounds, g.vars);
|
|
10958
|
+
if (cand === null) {
|
|
10959
|
+
continue;
|
|
10960
|
+
}
|
|
10961
|
+
const quotient = multiExactDivide(gCur, cand);
|
|
10962
|
+
if (quotient === null) {
|
|
10963
|
+
continue;
|
|
10964
|
+
}
|
|
10965
|
+
gCur = quotient;
|
|
10966
|
+
removeIndices(pool, indices);
|
|
10967
|
+
let mult = 1;
|
|
10968
|
+
for (; ; ) {
|
|
10969
|
+
const next = multiExactDivide(gCur, cand);
|
|
10970
|
+
if (next === null) {
|
|
10971
|
+
break;
|
|
10972
|
+
}
|
|
10973
|
+
const copy = findMatchingSubset(pool, s, cand, bases, degBounds, g.vars);
|
|
10974
|
+
if (copy === null) {
|
|
10975
|
+
break;
|
|
10976
|
+
}
|
|
10977
|
+
removeIndices(pool, copy);
|
|
10978
|
+
gCur = next;
|
|
10979
|
+
mult += 1;
|
|
10980
|
+
}
|
|
10981
|
+
found.push({ poly: cand, mult });
|
|
10982
|
+
extracted = true;
|
|
10983
|
+
break;
|
|
10984
|
+
}
|
|
10985
|
+
if (extracted) {
|
|
10986
|
+
s = 1;
|
|
10987
|
+
} else {
|
|
10988
|
+
s += 1;
|
|
10989
|
+
}
|
|
10990
|
+
}
|
|
10991
|
+
if (!isZero2(gCur)) {
|
|
10992
|
+
const c = integerContentMP(gCur);
|
|
10993
|
+
const l = leadingTerm(gCur);
|
|
10994
|
+
const sgn = l !== null && l.coeff < 0n ? -1n : 1n;
|
|
10995
|
+
constant *= c * sgn;
|
|
10996
|
+
if (totalDegree(gCur) >= 1) {
|
|
10997
|
+
found.push({ poly: primitivePartMP(gCur), mult: 1 });
|
|
10998
|
+
}
|
|
10999
|
+
}
|
|
11000
|
+
found.sort((a, b) => {
|
|
11001
|
+
const la = leadingTerm(a.poly);
|
|
11002
|
+
const lb = leadingTerm(b.poly);
|
|
11003
|
+
if (la === null || lb === null) {
|
|
11004
|
+
return 0;
|
|
11005
|
+
}
|
|
11006
|
+
return canonicalCompare(la.exps, lb.exps);
|
|
11007
|
+
});
|
|
11008
|
+
return { constant, factors: found };
|
|
11009
|
+
}
|
|
11010
|
+
|
|
10576
11011
|
// src/typed/factorization/index.ts
|
|
10577
11012
|
var INT_TOLERANCE = 1e-7;
|
|
10578
11013
|
function polyToDense(p) {
|
|
@@ -10659,6 +11094,24 @@ function factorPolynomialUnivariate(expr, v) {
|
|
|
10659
11094
|
}
|
|
10660
11095
|
return parts.join("*");
|
|
10661
11096
|
}
|
|
11097
|
+
function renderMultiFactorization(fact) {
|
|
11098
|
+
const parts = [];
|
|
11099
|
+
if (fact.constant !== 1n) parts.push(String(fact.constant));
|
|
11100
|
+
for (const { poly, mult } of fact.factors) {
|
|
11101
|
+
const term = `(${toAlgebraString(poly)})`;
|
|
11102
|
+
parts.push(mult > 1 ? `${term}^${mult}` : term);
|
|
11103
|
+
}
|
|
11104
|
+
return parts.join("*");
|
|
11105
|
+
}
|
|
11106
|
+
function factorMultivariateString(expr, vars, minFactors = 2) {
|
|
11107
|
+
const p = fromAlgebraExpr(expr, vars);
|
|
11108
|
+
if (p === null) return null;
|
|
11109
|
+
const fact = factorMultivariateKronecker(p);
|
|
11110
|
+
if (fact === null) return null;
|
|
11111
|
+
const count2 = fact.factors.reduce((acc, f) => acc + f.mult, 0);
|
|
11112
|
+
if (count2 < minFactors) return null;
|
|
11113
|
+
return renderMultiFactorization(fact);
|
|
11114
|
+
}
|
|
10662
11115
|
|
|
10663
11116
|
// src/typed/algebra.ts
|
|
10664
11117
|
var MATH_KEYWORDS = /* @__PURE__ */ new Set([
|
|
@@ -10898,13 +11351,13 @@ function variables(expr) {
|
|
|
10898
11351
|
}
|
|
10899
11352
|
return [...vars].sort();
|
|
10900
11353
|
}
|
|
10901
|
-
function
|
|
11354
|
+
function substitute2(expr, vars) {
|
|
10902
11355
|
let result = expr;
|
|
10903
11356
|
const keys = Object.keys(vars).sort((a, b) => b.length - a.length);
|
|
10904
|
-
for (const
|
|
10905
|
-
const escaped =
|
|
11357
|
+
for (const key2 of keys) {
|
|
11358
|
+
const escaped = key2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10906
11359
|
const pattern = new RegExp("\\b" + escaped + "\\b", "g");
|
|
10907
|
-
result = result.replace(pattern, vars[
|
|
11360
|
+
result = result.replace(pattern, vars[key2]);
|
|
10908
11361
|
}
|
|
10909
11362
|
return result;
|
|
10910
11363
|
}
|
|
@@ -11121,13 +11574,22 @@ function factorMultivariate(expr, vars) {
|
|
|
11121
11574
|
if (hasMonomial) parts.push(monomialString(monPow, vars));
|
|
11122
11575
|
if (dsq) parts.push(dsq[0], dsq[1]);
|
|
11123
11576
|
else parts.push(`(${polyToString(cofactor, vars)})`);
|
|
11124
|
-
|
|
11577
|
+
const monomialFactors = monPow.reduce((acc, e) => acc + e, 0);
|
|
11578
|
+
const count2 = monomialFactors + (dsq ? 2 : 1);
|
|
11579
|
+
return { text: parts.join("*"), count: count2 };
|
|
11125
11580
|
}
|
|
11126
11581
|
function factor(expr) {
|
|
11127
11582
|
const univariateVars = variables(expr);
|
|
11128
11583
|
if (univariateVars.length >= 2) {
|
|
11129
11584
|
const mv = factorMultivariate(expr, univariateVars);
|
|
11130
|
-
if (mv
|
|
11585
|
+
if (mv === null) {
|
|
11586
|
+
const kron2 = factorMultivariateString(expr, univariateVars);
|
|
11587
|
+
if (kron2 !== null) return kron2;
|
|
11588
|
+
} else {
|
|
11589
|
+
const refined = factorMultivariateString(expr, univariateVars, mv.count + 1);
|
|
11590
|
+
if (refined !== null) return refined;
|
|
11591
|
+
return mv.text;
|
|
11592
|
+
}
|
|
11131
11593
|
}
|
|
11132
11594
|
if (univariateVars.length === 1) {
|
|
11133
11595
|
try {
|
|
@@ -11618,7 +12080,7 @@ var typedAlgebra = {
|
|
|
11618
12080
|
expand,
|
|
11619
12081
|
factor,
|
|
11620
12082
|
collect,
|
|
11621
|
-
substitute,
|
|
12083
|
+
substitute: substitute2,
|
|
11622
12084
|
variables,
|
|
11623
12085
|
cancel,
|
|
11624
12086
|
together,
|
|
@@ -16655,19 +17117,19 @@ function minimumSpanningTree(adj) {
|
|
|
16655
17117
|
const n = adj.length;
|
|
16656
17118
|
if (n === 0) return [];
|
|
16657
17119
|
const inMST = new Array(n).fill(false);
|
|
16658
|
-
const
|
|
17120
|
+
const key2 = new Array(n).fill(Infinity);
|
|
16659
17121
|
const parent = new Array(n).fill(-1);
|
|
16660
|
-
|
|
17122
|
+
key2[0] = 0;
|
|
16661
17123
|
for (let count2 = 0; count2 < n; count2++) {
|
|
16662
17124
|
let u = -1;
|
|
16663
17125
|
for (let v = 0; v < n; v++) {
|
|
16664
|
-
if (!inMST[v] && (u === -1 ||
|
|
17126
|
+
if (!inMST[v] && (u === -1 || key2[v] < key2[u])) u = v;
|
|
16665
17127
|
}
|
|
16666
|
-
if (u === -1 ||
|
|
17128
|
+
if (u === -1 || key2[u] === Infinity) break;
|
|
16667
17129
|
inMST[u] = true;
|
|
16668
17130
|
for (let v = 0; v < n; v++) {
|
|
16669
|
-
if (adj[u][v] > 0 && !inMST[v] && adj[u][v] <
|
|
16670
|
-
|
|
17131
|
+
if (adj[u][v] > 0 && !inMST[v] && adj[u][v] < key2[v]) {
|
|
17132
|
+
key2[v] = adj[u][v];
|
|
16671
17133
|
parent[v] = u;
|
|
16672
17134
|
}
|
|
16673
17135
|
}
|
|
@@ -20401,8 +20863,8 @@ function bigNumberToBase(bn, base, wordSize) {
|
|
|
20401
20863
|
return numberToBase(n, base, wordSize);
|
|
20402
20864
|
}
|
|
20403
20865
|
function interpolate2(template, values, options) {
|
|
20404
|
-
return template.replace(printTemplate, function(original,
|
|
20405
|
-
const keys =
|
|
20866
|
+
return template.replace(printTemplate, function(original, key2) {
|
|
20867
|
+
const keys = key2.split(".");
|
|
20406
20868
|
let value = values[keys.shift()];
|
|
20407
20869
|
if (value !== void 0 && value.isMatrix) {
|
|
20408
20870
|
value = value.toArray();
|
|
@@ -21049,7 +21511,7 @@ __export(factories_exports, {
|
|
|
21049
21511
|
isNumeric: () => isNumeric,
|
|
21050
21512
|
isPositive: () => isPositive,
|
|
21051
21513
|
isPrime: () => isPrime2,
|
|
21052
|
-
isZero: () =>
|
|
21514
|
+
isZero: () => isZero3,
|
|
21053
21515
|
josephson: () => josephson,
|
|
21054
21516
|
kldivergence: () => kldivergence,
|
|
21055
21517
|
klitzing: () => klitzing,
|
|
@@ -23015,8 +23477,8 @@ var createPrint = /* @__PURE__ */ factory(
|
|
|
23015
23477
|
}
|
|
23016
23478
|
);
|
|
23017
23479
|
function _print(template, values, options) {
|
|
23018
|
-
return template.replace(printTemplate, function(original,
|
|
23019
|
-
const keys =
|
|
23480
|
+
return template.replace(printTemplate, function(original, key2) {
|
|
23481
|
+
const keys = key2.split(".");
|
|
23020
23482
|
let value = values[keys.shift()];
|
|
23021
23483
|
if (value !== void 0 && value.isMatrix) {
|
|
23022
23484
|
value = value.toArray();
|
|
@@ -24928,7 +25390,7 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
24928
25390
|
({
|
|
24929
25391
|
typed: typed3,
|
|
24930
25392
|
matrix: matrix2,
|
|
24931
|
-
isZero:
|
|
25393
|
+
isZero: isZero4
|
|
24932
25394
|
}) => {
|
|
24933
25395
|
return typed3(name91, {
|
|
24934
25396
|
"Array | Matrix, function, string, string": function(size2, fn, format4, datatype) {
|
|
@@ -24960,7 +25422,7 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
24960
25422
|
m.resize(size2);
|
|
24961
25423
|
m.forEach(function(_, index) {
|
|
24962
25424
|
const val = fn(index);
|
|
24963
|
-
if (
|
|
25425
|
+
if (isZero4(val)) return;
|
|
24964
25426
|
m.set(index, val);
|
|
24965
25427
|
});
|
|
24966
25428
|
return m;
|
|
@@ -25226,7 +25688,7 @@ var dependencies96 = [
|
|
|
25226
25688
|
var createDet = /* @__PURE__ */ factory(
|
|
25227
25689
|
name96,
|
|
25228
25690
|
dependencies96,
|
|
25229
|
-
({ typed: typed3, matrix: matrix2, subtractScalar: subtractScalar2, multiply: multiply2, divideScalar: divideScalar2, isZero:
|
|
25691
|
+
({ typed: typed3, matrix: matrix2, subtractScalar: subtractScalar2, multiply: multiply2, divideScalar: divideScalar2, isZero: isZero4, unaryMinus: unaryMinus2 }) => {
|
|
25230
25692
|
return typed3(name96, {
|
|
25231
25693
|
any: function(x) {
|
|
25232
25694
|
return clone(x);
|
|
@@ -25321,10 +25783,10 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
25321
25783
|
}
|
|
25322
25784
|
for (let k = 0; k < rows; k++) {
|
|
25323
25785
|
let k_ = rowIndices[k];
|
|
25324
|
-
if (
|
|
25786
|
+
if (isZero4(matrix3[k_][k])) {
|
|
25325
25787
|
let _k;
|
|
25326
25788
|
for (_k = k + 1; _k < rows; _k++) {
|
|
25327
|
-
if (!
|
|
25789
|
+
if (!isZero4(matrix3[rowIndices[_k]][k])) {
|
|
25328
25790
|
k_ = rowIndices[_k];
|
|
25329
25791
|
rowIndices[_k] = rowIndices[k];
|
|
25330
25792
|
rowIndices[k] = k_;
|
|
@@ -28349,11 +28811,11 @@ function _getObjectProperty(object, index) {
|
|
|
28349
28811
|
if (index.size().length !== 1) {
|
|
28350
28812
|
throw new DimensionError(index.size(), 1);
|
|
28351
28813
|
}
|
|
28352
|
-
const
|
|
28353
|
-
if (typeof
|
|
28814
|
+
const key2 = index.dimension(0);
|
|
28815
|
+
if (typeof key2 !== "string") {
|
|
28354
28816
|
throw new TypeError("String expected as index to retrieve an object property");
|
|
28355
28817
|
}
|
|
28356
|
-
return getSafeProperty(object,
|
|
28818
|
+
return getSafeProperty(object, key2);
|
|
28357
28819
|
}
|
|
28358
28820
|
function _setObjectProperty(object, index, replacement) {
|
|
28359
28821
|
if (isEmptyIndex(index)) {
|
|
@@ -28362,12 +28824,12 @@ function _setObjectProperty(object, index, replacement) {
|
|
|
28362
28824
|
if (index.size().length !== 1) {
|
|
28363
28825
|
throw new DimensionError(index.size(), 1);
|
|
28364
28826
|
}
|
|
28365
|
-
const
|
|
28366
|
-
if (typeof
|
|
28827
|
+
const key2 = index.dimension(0);
|
|
28828
|
+
if (typeof key2 !== "string") {
|
|
28367
28829
|
throw new TypeError("String expected as index to retrieve an object property");
|
|
28368
28830
|
}
|
|
28369
28831
|
const updated = clone(object);
|
|
28370
|
-
setSafeProperty(updated,
|
|
28832
|
+
setSafeProperty(updated, key2, replacement);
|
|
28371
28833
|
return updated;
|
|
28372
28834
|
}
|
|
28373
28835
|
|
|
@@ -30193,7 +30655,7 @@ var dependencies143 = ["typed", "config", "divideScalar", "log", "Complex"];
|
|
|
30193
30655
|
var createLog1p = /* @__PURE__ */ factory(
|
|
30194
30656
|
name143,
|
|
30195
30657
|
dependencies143,
|
|
30196
|
-
({ typed: typed3, config: config2, divideScalar: divideScalar2, log:
|
|
30658
|
+
({ typed: typed3, config: config2, divideScalar: divideScalar2, log: log5, Complex: Complex13 }) => {
|
|
30197
30659
|
return typed3(name143, {
|
|
30198
30660
|
number: function(x) {
|
|
30199
30661
|
if (x >= -1 || config2.predictable) {
|
|
@@ -30216,7 +30678,7 @@ var createLog1p = /* @__PURE__ */ factory(
|
|
|
30216
30678
|
),
|
|
30217
30679
|
"any, any": typed3.referToSelf(
|
|
30218
30680
|
(self) => (x, base) => {
|
|
30219
|
-
return divideScalar2(self(x),
|
|
30681
|
+
return divideScalar2(self(x), log5(base));
|
|
30220
30682
|
}
|
|
30221
30683
|
)
|
|
30222
30684
|
});
|
|
@@ -32237,7 +32699,7 @@ var createQr = /* @__PURE__ */ factory(
|
|
|
32237
32699
|
matrix: matrix2,
|
|
32238
32700
|
zeros: zeros4,
|
|
32239
32701
|
identity: identity2,
|
|
32240
|
-
isZero:
|
|
32702
|
+
isZero: isZero4,
|
|
32241
32703
|
equal: equal2,
|
|
32242
32704
|
sign: sign3,
|
|
32243
32705
|
sqrt: sqrt2,
|
|
@@ -32323,7 +32785,7 @@ var createQr = /* @__PURE__ */ factory(
|
|
|
32323
32785
|
alphaSquared = addScalar2(alphaSquared, multiplyScalar2(Rdata[i][k], conj3(Rdata[i][k])));
|
|
32324
32786
|
}
|
|
32325
32787
|
const alpha = multiplyScalar2(sgn, sqrt2(alphaSquared));
|
|
32326
|
-
if (!
|
|
32788
|
+
if (!isZero4(alpha)) {
|
|
32327
32789
|
const u1 = subtractScalar2(pivot, alpha);
|
|
32328
32790
|
w[k] = 1;
|
|
32329
32791
|
for (i = k + 1; i < rows; i++) {
|
|
@@ -32415,7 +32877,7 @@ var createRange = /* @__PURE__ */ factory(
|
|
|
32415
32877
|
larger: larger2,
|
|
32416
32878
|
largerEq: largerEq2,
|
|
32417
32879
|
add: add5,
|
|
32418
|
-
isZero:
|
|
32880
|
+
isZero: isZero4,
|
|
32419
32881
|
isPositive: isPositive2
|
|
32420
32882
|
}) => {
|
|
32421
32883
|
return typed3(name174, {
|
|
@@ -32522,7 +32984,7 @@ var createRange = /* @__PURE__ */ factory(
|
|
|
32522
32984
|
}
|
|
32523
32985
|
function _range(start, end, step, includeEnd) {
|
|
32524
32986
|
const array = [];
|
|
32525
|
-
if (
|
|
32987
|
+
if (isZero4(step)) throw new Error("Step must be non-zero");
|
|
32526
32988
|
const ongoing = isPositive2(step) ? includeEnd ? smallerEq2 : smaller2 : includeEnd ? largerEq2 : larger2;
|
|
32527
32989
|
let x = start;
|
|
32528
32990
|
while (ongoing(x, end)) {
|
|
@@ -32790,10 +33252,10 @@ var dependencies177 = ["typed", "compareText", "isZero"];
|
|
|
32790
33252
|
var createEqualText = /* @__PURE__ */ factory(
|
|
32791
33253
|
name177,
|
|
32792
33254
|
dependencies177,
|
|
32793
|
-
({ typed: typed3, compareText: compareText4, isZero:
|
|
33255
|
+
({ typed: typed3, compareText: compareText4, isZero: isZero4 }) => {
|
|
32794
33256
|
return typed3(name177, {
|
|
32795
33257
|
"any, any": function(x, y) {
|
|
32796
|
-
return
|
|
33258
|
+
return isZero4(compareText4(x, y));
|
|
32797
33259
|
}
|
|
32798
33260
|
});
|
|
32799
33261
|
}
|
|
@@ -34359,9 +34821,9 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
34359
34821
|
return obj;
|
|
34360
34822
|
}
|
|
34361
34823
|
if (isObjectNode(obj) && index.dimensions.length === 1 && isConstantNode(index.dimensions[0])) {
|
|
34362
|
-
const
|
|
34363
|
-
if (
|
|
34364
|
-
return obj.properties[
|
|
34824
|
+
const key2 = index.dimensions[0].value;
|
|
34825
|
+
if (key2 in obj.properties) {
|
|
34826
|
+
return obj.properties[key2];
|
|
34365
34827
|
}
|
|
34366
34828
|
return new ConstantNode();
|
|
34367
34829
|
}
|
|
@@ -35464,9 +35926,9 @@ var createFibonacciHeapClass = /* @__PURE__ */ factory(
|
|
|
35464
35926
|
* list of this heap. Running time: O(1) actual.
|
|
35465
35927
|
* @memberof FibonacciHeap
|
|
35466
35928
|
*/
|
|
35467
|
-
insert(
|
|
35929
|
+
insert(key2, value) {
|
|
35468
35930
|
const node = {
|
|
35469
|
-
key,
|
|
35931
|
+
key: key2,
|
|
35470
35932
|
value,
|
|
35471
35933
|
degree: 0
|
|
35472
35934
|
};
|
|
@@ -35476,7 +35938,7 @@ var createFibonacciHeapClass = /* @__PURE__ */ factory(
|
|
|
35476
35938
|
node.right = minimum.right;
|
|
35477
35939
|
minimum.right = node;
|
|
35478
35940
|
node.right.left = node;
|
|
35479
|
-
if (smaller2(
|
|
35941
|
+
if (smaller2(key2, minimum.key)) {
|
|
35480
35942
|
this._minimum = node;
|
|
35481
35943
|
}
|
|
35482
35944
|
} else {
|
|
@@ -35558,8 +36020,8 @@ var createFibonacciHeapClass = /* @__PURE__ */ factory(
|
|
|
35558
36020
|
this.extractMinimum();
|
|
35559
36021
|
}
|
|
35560
36022
|
}
|
|
35561
|
-
function _decreaseKey(minimum, node,
|
|
35562
|
-
node.key =
|
|
36023
|
+
function _decreaseKey(minimum, node, key2) {
|
|
36024
|
+
node.key = key2;
|
|
35563
36025
|
const parent = node.parent;
|
|
35564
36026
|
if (parent && smaller2(node.key, parent.key)) {
|
|
35565
36027
|
_cut(minimum, node, parent);
|
|
@@ -37150,7 +37612,7 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
37150
37612
|
smaller: smaller2,
|
|
37151
37613
|
equalScalar: equalScalar3,
|
|
37152
37614
|
flatten: flatten5,
|
|
37153
|
-
isZero:
|
|
37615
|
+
isZero: isZero4,
|
|
37154
37616
|
isNumeric: isNumeric2
|
|
37155
37617
|
}) => {
|
|
37156
37618
|
return typed3("intersect", {
|
|
@@ -37265,7 +37727,7 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
37265
37727
|
multiplyScalar2(d1[0], d2[1]),
|
|
37266
37728
|
multiplyScalar2(d2[0], d1[1])
|
|
37267
37729
|
);
|
|
37268
|
-
if (
|
|
37730
|
+
if (isZero4(det2)) return null;
|
|
37269
37731
|
if (smaller2(abs2(det2), config2.relTol)) {
|
|
37270
37732
|
return null;
|
|
37271
37733
|
}
|
|
@@ -37339,7 +37801,7 @@ var createIntersect = /* @__PURE__ */ factory(
|
|
|
37339
37801
|
multiplyScalar2(d2121, d4343),
|
|
37340
37802
|
multiplyScalar2(d4321, d4321)
|
|
37341
37803
|
);
|
|
37342
|
-
if (
|
|
37804
|
+
if (isZero4(denominator)) return null;
|
|
37343
37805
|
const ta = divideScalar2(numerator, denominator);
|
|
37344
37806
|
const tb = divideScalar2(addScalar2(d1343, multiplyScalar2(ta, d4321)), d4343);
|
|
37345
37807
|
const pax = addScalar2(x1, multiplyScalar2(ta, subtract3(x2, x1)));
|
|
@@ -37811,7 +38273,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
37811
38273
|
multiply: multiply2,
|
|
37812
38274
|
map: map3,
|
|
37813
38275
|
dotDivide: dotDivide2,
|
|
37814
|
-
log:
|
|
38276
|
+
log: log5,
|
|
37815
38277
|
isNumeric: isNumeric2
|
|
37816
38278
|
}) => {
|
|
37817
38279
|
return typed3(name223, {
|
|
@@ -37853,7 +38315,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
37853
38315
|
const result = sum3(
|
|
37854
38316
|
multiply2(
|
|
37855
38317
|
qnorm,
|
|
37856
|
-
map3(dotDivide2(qnorm, pnorm), (x) =>
|
|
38318
|
+
map3(dotDivide2(qnorm, pnorm), (x) => log5(x))
|
|
37857
38319
|
)
|
|
37858
38320
|
);
|
|
37859
38321
|
if (isNumeric2(result)) {
|
|
@@ -38561,7 +39023,7 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
38561
39023
|
typed: typed3,
|
|
38562
39024
|
parse: _parse2,
|
|
38563
39025
|
equal: equal2,
|
|
38564
|
-
isZero:
|
|
39026
|
+
isZero: isZero4,
|
|
38565
39027
|
add: _add,
|
|
38566
39028
|
subtract: _subtract,
|
|
38567
39029
|
multiply: _multiply2,
|
|
@@ -38659,10 +39121,10 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
38659
39121
|
const a0 = _simplifyCore(node.args[0], options);
|
|
38660
39122
|
let a1 = _simplifyCore(node.args[1], options);
|
|
38661
39123
|
if (node.op === "+") {
|
|
38662
|
-
if (isConstantNode(a0) &&
|
|
39124
|
+
if (isConstantNode(a0) && isZero4(a0.value)) {
|
|
38663
39125
|
return a1;
|
|
38664
39126
|
}
|
|
38665
|
-
if (isConstantNode(a1) &&
|
|
39127
|
+
if (isConstantNode(a1) && isZero4(a1.value)) {
|
|
38666
39128
|
return a0;
|
|
38667
39129
|
}
|
|
38668
39130
|
if (isOperatorNode(a1) && a1.isUnary() && a1.op === "-") {
|
|
@@ -38674,24 +39136,24 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
38674
39136
|
if (isOperatorNode(a1) && a1.isUnary() && a1.op === "-") {
|
|
38675
39137
|
return _simplifyCore(new OperatorNode("+", "add", [a0, a1.args[0]]), options);
|
|
38676
39138
|
}
|
|
38677
|
-
if (isConstantNode(a0) &&
|
|
39139
|
+
if (isConstantNode(a0) && isZero4(a0.value)) {
|
|
38678
39140
|
return _simplifyCore(new OperatorNode("-", "unaryMinus", [a1]));
|
|
38679
39141
|
}
|
|
38680
|
-
if (isConstantNode(a1) &&
|
|
39142
|
+
if (isConstantNode(a1) && isZero4(a1.value)) {
|
|
38681
39143
|
return a0;
|
|
38682
39144
|
}
|
|
38683
39145
|
return new OperatorNode(node.op, node.fn, [a0, a1]);
|
|
38684
39146
|
}
|
|
38685
39147
|
if (node.op === "*") {
|
|
38686
39148
|
if (isConstantNode(a0)) {
|
|
38687
|
-
if (
|
|
39149
|
+
if (isZero4(a0.value)) {
|
|
38688
39150
|
return node0;
|
|
38689
39151
|
} else if (equal2(a0.value, 1)) {
|
|
38690
39152
|
return a1;
|
|
38691
39153
|
}
|
|
38692
39154
|
}
|
|
38693
39155
|
if (isConstantNode(a1)) {
|
|
38694
|
-
if (
|
|
39156
|
+
if (isZero4(a1.value)) {
|
|
38695
39157
|
return node0;
|
|
38696
39158
|
} else if (equal2(a1.value, 1)) {
|
|
38697
39159
|
return a0;
|
|
@@ -38703,7 +39165,7 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
38703
39165
|
return new OperatorNode(node.op, node.fn, [a0, a1], node.implicit);
|
|
38704
39166
|
}
|
|
38705
39167
|
if (node.op === "/") {
|
|
38706
|
-
if (isConstantNode(a0) &&
|
|
39168
|
+
if (isConstantNode(a0) && isZero4(a0.value)) {
|
|
38707
39169
|
return node0;
|
|
38708
39170
|
}
|
|
38709
39171
|
if (isConstantNode(a1) && equal2(a1.value, 1)) {
|
|
@@ -38713,7 +39175,7 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
38713
39175
|
}
|
|
38714
39176
|
if (node.op === "^") {
|
|
38715
39177
|
if (isConstantNode(a1)) {
|
|
38716
|
-
if (
|
|
39178
|
+
if (isZero4(a1.value)) {
|
|
38717
39179
|
return node1;
|
|
38718
39180
|
} else if (equal2(a1.value, 1)) {
|
|
38719
39181
|
return a0;
|
|
@@ -38811,7 +39273,7 @@ var createPolynomialRoot = /* @__PURE__ */ factory(
|
|
|
38811
39273
|
dependencies234,
|
|
38812
39274
|
({
|
|
38813
39275
|
typed: typed3,
|
|
38814
|
-
isZero:
|
|
39276
|
+
isZero: isZero4,
|
|
38815
39277
|
equalScalar: equalScalar3,
|
|
38816
39278
|
add: add5,
|
|
38817
39279
|
subtract: subtract3,
|
|
@@ -38827,7 +39289,7 @@ var createPolynomialRoot = /* @__PURE__ */ factory(
|
|
|
38827
39289
|
return typed3(name234, {
|
|
38828
39290
|
"number|Complex, ...number|Complex": (constant, restCoeffs) => {
|
|
38829
39291
|
const coeffs = [constant, ...restCoeffs];
|
|
38830
|
-
while (coeffs.length > 0 &&
|
|
39292
|
+
while (coeffs.length > 0 && isZero4(coeffs[coeffs.length - 1])) {
|
|
38831
39293
|
coeffs.pop();
|
|
38832
39294
|
}
|
|
38833
39295
|
if (coeffs.length < 2) {
|
|
@@ -41002,10 +41464,10 @@ var createSimplify = /* @__PURE__ */ factory(
|
|
|
41002
41464
|
const native = /* @__PURE__ */ new Map();
|
|
41003
41465
|
const sm = scope;
|
|
41004
41466
|
if (typeof sm.forEach === "function") {
|
|
41005
|
-
sm.forEach((value,
|
|
41467
|
+
sm.forEach((value, key2) => native.set(key2, value));
|
|
41006
41468
|
} else {
|
|
41007
|
-
for (const [
|
|
41008
|
-
native.set(
|
|
41469
|
+
for (const [key2, value] of Object.entries(scope)) {
|
|
41470
|
+
native.set(key2, value);
|
|
41009
41471
|
}
|
|
41010
41472
|
}
|
|
41011
41473
|
scope = native;
|
|
@@ -41195,19 +41657,19 @@ var createSimplify = /* @__PURE__ */ factory(
|
|
|
41195
41657
|
} else if (!match2.placeholders) {
|
|
41196
41658
|
return match1;
|
|
41197
41659
|
}
|
|
41198
|
-
for (const
|
|
41199
|
-
if (hasOwnProperty(match1.placeholders,
|
|
41200
|
-
res.placeholders[
|
|
41201
|
-
if (hasOwnProperty(match2.placeholders,
|
|
41202
|
-
if (!_exactMatch(match1.placeholders[
|
|
41660
|
+
for (const key2 in match1.placeholders) {
|
|
41661
|
+
if (hasOwnProperty(match1.placeholders, key2)) {
|
|
41662
|
+
res.placeholders[key2] = match1.placeholders[key2];
|
|
41663
|
+
if (hasOwnProperty(match2.placeholders, key2)) {
|
|
41664
|
+
if (!_exactMatch(match1.placeholders[key2], match2.placeholders[key2])) {
|
|
41203
41665
|
return null;
|
|
41204
41666
|
}
|
|
41205
41667
|
}
|
|
41206
41668
|
}
|
|
41207
41669
|
}
|
|
41208
|
-
for (const
|
|
41209
|
-
if (hasOwnProperty(match2.placeholders,
|
|
41210
|
-
res.placeholders[
|
|
41670
|
+
for (const key2 in match2.placeholders) {
|
|
41671
|
+
if (hasOwnProperty(match2.placeholders, key2)) {
|
|
41672
|
+
res.placeholders[key2] = match2.placeholders[key2];
|
|
41211
41673
|
}
|
|
41212
41674
|
}
|
|
41213
41675
|
return res;
|
|
@@ -41449,7 +41911,7 @@ var createDerivative = /* @__PURE__ */ factory(
|
|
|
41449
41911
|
parse: parse3,
|
|
41450
41912
|
simplify: simplify2,
|
|
41451
41913
|
equal: equal2,
|
|
41452
|
-
isZero:
|
|
41914
|
+
isZero: isZero4,
|
|
41453
41915
|
numeric: numeric2,
|
|
41454
41916
|
ConstantNode,
|
|
41455
41917
|
FunctionNode,
|
|
@@ -41925,7 +42387,7 @@ var createDerivative = /* @__PURE__ */ factory(
|
|
|
41925
42387
|
const arg0 = node.args[0];
|
|
41926
42388
|
const arg1 = node.args[1];
|
|
41927
42389
|
if (isConst2(arg0)) {
|
|
41928
|
-
if (isConstantNode(arg0) && (
|
|
42390
|
+
if (isConstantNode(arg0) && (isZero4(arg0.value) || equal2(arg0.value, 1))) {
|
|
41929
42391
|
return createConstantNode2(0);
|
|
41930
42392
|
}
|
|
41931
42393
|
return new OperatorNode("*", "multiply", [
|
|
@@ -41938,7 +42400,7 @@ var createDerivative = /* @__PURE__ */ factory(
|
|
|
41938
42400
|
}
|
|
41939
42401
|
if (isConst2(arg1)) {
|
|
41940
42402
|
if (isConstantNode(arg1)) {
|
|
41941
|
-
if (
|
|
42403
|
+
if (isZero4(arg1.value)) {
|
|
41942
42404
|
return createConstantNode2(0);
|
|
41943
42405
|
}
|
|
41944
42406
|
if (equal2(arg1.value, 1)) {
|
|
@@ -43515,7 +43977,7 @@ var hasNumericValue = createHasNumericValue(
|
|
|
43515
43977
|
factoryScope
|
|
43516
43978
|
);
|
|
43517
43979
|
var isFinite2 = createIsFinite(factoryScope);
|
|
43518
|
-
var
|
|
43980
|
+
var isZero3 = createIsZero(factoryScope);
|
|
43519
43981
|
var factory_unaryPlus = createUnaryPlus(
|
|
43520
43982
|
factoryScope
|
|
43521
43983
|
);
|
|
@@ -43527,7 +43989,7 @@ factoryScope.unaryPlus = factory_unaryPlus;
|
|
|
43527
43989
|
factoryScope.flatten = flatten3;
|
|
43528
43990
|
factoryScope.hasNumericValue = hasNumericValue;
|
|
43529
43991
|
factoryScope.isFinite = isFinite2;
|
|
43530
|
-
factoryScope.isZero =
|
|
43992
|
+
factoryScope.isZero = isZero3;
|
|
43531
43993
|
factoryScope.prod = prod;
|
|
43532
43994
|
factoryScope.dot = factory_dot;
|
|
43533
43995
|
factoryScope.squeeze = squeeze2;
|
|
@@ -44220,7 +44682,7 @@ var mathScope = {
|
|
|
44220
44682
|
};
|
|
44221
44683
|
{
|
|
44222
44684
|
const mwt = factoryScope.mathWithTransform;
|
|
44223
|
-
for (const
|
|
44685
|
+
for (const key2 of [
|
|
44224
44686
|
"and",
|
|
44225
44687
|
"bitAnd",
|
|
44226
44688
|
"bitOr",
|
|
@@ -44247,7 +44709,7 @@ var mathScope = {
|
|
|
44247
44709
|
"sum",
|
|
44248
44710
|
"variance"
|
|
44249
44711
|
]) {
|
|
44250
|
-
if (typeof mwt[
|
|
44712
|
+
if (typeof mwt[key2] === "function") mathScope[key2] = mwt[key2];
|
|
44251
44713
|
}
|
|
44252
44714
|
}
|
|
44253
44715
|
var parse = factoryScope.parse;
|
|
@@ -44278,7 +44740,7 @@ function parser() {
|
|
|
44278
44740
|
},
|
|
44279
44741
|
/** Clear all retained variables. */
|
|
44280
44742
|
clear() {
|
|
44281
|
-
for (const
|
|
44743
|
+
for (const key2 of Object.keys(scope)) delete scope[key2];
|
|
44282
44744
|
}
|
|
44283
44745
|
};
|
|
44284
44746
|
}
|
|
@@ -44916,9 +45378,9 @@ function numericRealRoots(expr, varName) {
|
|
|
44916
45378
|
const addRoot = (r) => {
|
|
44917
45379
|
const rounded = Math.round(r);
|
|
44918
45380
|
const clean = Math.abs(r - rounded) < 1e-8 ? rounded : r;
|
|
44919
|
-
const
|
|
44920
|
-
if (!seen.has(
|
|
44921
|
-
seen.add(
|
|
45381
|
+
const key2 = clean.toFixed(8);
|
|
45382
|
+
if (!seen.has(key2)) {
|
|
45383
|
+
seen.add(key2);
|
|
44922
45384
|
roots.push(clean);
|
|
44923
45385
|
}
|
|
44924
45386
|
};
|
|
@@ -44987,9 +45449,9 @@ function solve(equation, varName) {
|
|
|
44987
45449
|
return Math.abs(x - rounded) < 1e-8 ? rounded : x;
|
|
44988
45450
|
}, pushReal2 = function(x) {
|
|
44989
45451
|
const clean = cleanComponent2(x);
|
|
44990
|
-
const
|
|
44991
|
-
if (!seen.has(
|
|
44992
|
-
seen.add(
|
|
45452
|
+
const key2 = `r${clean.toFixed(8)}`;
|
|
45453
|
+
if (!seen.has(key2)) {
|
|
45454
|
+
seen.add(key2);
|
|
44993
45455
|
reals.push(clean);
|
|
44994
45456
|
}
|
|
44995
45457
|
};
|
|
@@ -45020,9 +45482,9 @@ function solve(equation, varName) {
|
|
|
45020
45482
|
} else {
|
|
45021
45483
|
const re3 = cleanComponent2(r.re);
|
|
45022
45484
|
const im3 = cleanComponent2(r.im);
|
|
45023
|
-
const
|
|
45024
|
-
if (!seen.has(
|
|
45025
|
-
seen.add(
|
|
45485
|
+
const key2 = `${re3.toFixed(8)}|${im3.toFixed(8)}`;
|
|
45486
|
+
if (!seen.has(key2)) {
|
|
45487
|
+
seen.add(key2);
|
|
45026
45488
|
complexRoots.push(new Complex10(re3, im3));
|
|
45027
45489
|
}
|
|
45028
45490
|
}
|
|
@@ -45103,15 +45565,15 @@ function asymptotic(expr, varName, towards = Infinity) {
|
|
|
45103
45565
|
const avgOrder = (logRatio1 + logRatio2) / 2;
|
|
45104
45566
|
const roundedOrder = Math.round(avgOrder * 2) / 2;
|
|
45105
45567
|
const coefficient = f3 / Math.pow(x3, roundedOrder);
|
|
45106
|
-
let
|
|
45568
|
+
let leadingTerm2;
|
|
45107
45569
|
if (roundedOrder === 0) {
|
|
45108
|
-
|
|
45570
|
+
leadingTerm2 = formatCoeff(coefficient);
|
|
45109
45571
|
} else if (roundedOrder === 1) {
|
|
45110
|
-
|
|
45572
|
+
leadingTerm2 = `${formatCoeff(coefficient)}*${varName}`;
|
|
45111
45573
|
} else {
|
|
45112
|
-
|
|
45574
|
+
leadingTerm2 = `${formatCoeff(coefficient)}*${varName}^${roundedOrder}`;
|
|
45113
45575
|
}
|
|
45114
|
-
return { leadingTerm, order: roundedOrder, coefficient };
|
|
45576
|
+
return { leadingTerm: leadingTerm2, order: roundedOrder, coefficient };
|
|
45115
45577
|
}
|
|
45116
45578
|
const lim = limit(expr, varName, towards);
|
|
45117
45579
|
return { leadingTerm: formatCoeff(lim), order: 0, coefficient: lim };
|
|
@@ -45716,8 +46178,8 @@ function _combineLikeTerms(expr) {
|
|
|
45716
46178
|
const cvpMatch = t.match(/^(-?\d*\.?\d*)\s*\*?\s*(\w+)\^(\d+)$/);
|
|
45717
46179
|
if (cvpMatch) {
|
|
45718
46180
|
const c = cvpMatch[1] === "" || cvpMatch[1] === "+" ? 1 : cvpMatch[1] === "-" ? -1 : Number(cvpMatch[1]);
|
|
45719
|
-
const
|
|
45720
|
-
termMap.set(
|
|
46181
|
+
const key2 = cvpMatch[2] + "^" + cvpMatch[3];
|
|
46182
|
+
termMap.set(key2, (termMap.get(key2) ?? 0) + c);
|
|
45721
46183
|
continue;
|
|
45722
46184
|
}
|
|
45723
46185
|
const cvMatch = t.match(/^(-?\d*\.?\d*)\s*\*?\s*(\w+)$/);
|
|
@@ -45729,16 +46191,16 @@ function _combineLikeTerms(expr) {
|
|
|
45729
46191
|
otherTerms.push(t);
|
|
45730
46192
|
}
|
|
45731
46193
|
const parts = [];
|
|
45732
|
-
for (const [
|
|
46194
|
+
for (const [key2, c] of termMap) {
|
|
45733
46195
|
if (Math.abs(c) < 1e-12) continue;
|
|
45734
|
-
if (
|
|
46196
|
+
if (key2 === "__const__") {
|
|
45735
46197
|
parts.push(String(c));
|
|
45736
46198
|
} else if (Math.abs(c - 1) < 1e-12) {
|
|
45737
|
-
parts.push(
|
|
46199
|
+
parts.push(key2);
|
|
45738
46200
|
} else if (Math.abs(c + 1) < 1e-12) {
|
|
45739
|
-
parts.push("-" +
|
|
46201
|
+
parts.push("-" + key2);
|
|
45740
46202
|
} else {
|
|
45741
|
-
parts.push(c + "*" +
|
|
46203
|
+
parts.push(c + "*" + key2);
|
|
45742
46204
|
}
|
|
45743
46205
|
}
|
|
45744
46206
|
parts.push(...otherTerms);
|
|
@@ -45892,8 +46354,8 @@ function casSimplify(input) {
|
|
|
45892
46354
|
const cvpMatch = t.match(/^(-?\d*\.?\d*)\s*\*?\s*(\w+)\^(\d+)$/);
|
|
45893
46355
|
if (cvpMatch) {
|
|
45894
46356
|
const c = cvpMatch[1] === "" || cvpMatch[1] === "+" ? 1 : cvpMatch[1] === "-" ? -1 : Number(cvpMatch[1]);
|
|
45895
|
-
const
|
|
45896
|
-
termMap.set(
|
|
46357
|
+
const key2 = cvpMatch[2] + "^" + cvpMatch[3];
|
|
46358
|
+
termMap.set(key2, (termMap.get(key2) ?? 0) + c);
|
|
45897
46359
|
continue;
|
|
45898
46360
|
}
|
|
45899
46361
|
const cvMatch = t.match(/^(-?\d*\.?\d*)\s*\*?\s*(\w+)$/);
|
|
@@ -45905,16 +46367,16 @@ function casSimplify(input) {
|
|
|
45905
46367
|
otherTerms.push(t);
|
|
45906
46368
|
}
|
|
45907
46369
|
const parts = [];
|
|
45908
|
-
for (const [
|
|
46370
|
+
for (const [key2, c] of termMap) {
|
|
45909
46371
|
if (Math.abs(c) < 1e-12) continue;
|
|
45910
|
-
if (
|
|
46372
|
+
if (key2 === "__const__") {
|
|
45911
46373
|
parts.push(String(c));
|
|
45912
46374
|
} else if (Math.abs(c - 1) < 1e-12) {
|
|
45913
|
-
parts.push(
|
|
46375
|
+
parts.push(key2);
|
|
45914
46376
|
} else if (Math.abs(c + 1) < 1e-12) {
|
|
45915
|
-
parts.push("-" +
|
|
46377
|
+
parts.push("-" + key2);
|
|
45916
46378
|
} else {
|
|
45917
|
-
parts.push(c + "*" +
|
|
46379
|
+
parts.push(c + "*" + key2);
|
|
45918
46380
|
}
|
|
45919
46381
|
}
|
|
45920
46382
|
parts.push(...otherTerms);
|
|
@@ -46140,16 +46602,16 @@ function discreteLog(g, h, p) {
|
|
|
46140
46602
|
const table = /* @__PURE__ */ new Map();
|
|
46141
46603
|
let cur = 1n;
|
|
46142
46604
|
for (let j = 0n; j < m; j++) {
|
|
46143
|
-
const
|
|
46144
|
-
if (!table.has(
|
|
46605
|
+
const key2 = cur.toString();
|
|
46606
|
+
if (!table.has(key2)) table.set(key2, j);
|
|
46145
46607
|
cur = cur * G % P2;
|
|
46146
46608
|
}
|
|
46147
46609
|
const gm = modPowBig(G, m, P2);
|
|
46148
46610
|
const gInvM = modInverseBig(gm, P2);
|
|
46149
46611
|
let gamma2 = H;
|
|
46150
46612
|
for (let i = 0n; i < m; i++) {
|
|
46151
|
-
const
|
|
46152
|
-
const j = table.get(
|
|
46613
|
+
const key2 = gamma2.toString();
|
|
46614
|
+
const j = table.get(key2);
|
|
46153
46615
|
if (j !== void 0) {
|
|
46154
46616
|
return Number(i * m + j);
|
|
46155
46617
|
}
|
|
@@ -52808,14 +53270,14 @@ function alphaShape(points, alpha) {
|
|
|
52808
53270
|
[t[2], t[0]]
|
|
52809
53271
|
];
|
|
52810
53272
|
for (const [u, v] of es) {
|
|
52811
|
-
const
|
|
52812
|
-
edgeCount.set(
|
|
53273
|
+
const key2 = `${Math.min(u, v)},${Math.max(u, v)}`;
|
|
53274
|
+
edgeCount.set(key2, (edgeCount.get(key2) ?? 0) + 1);
|
|
52813
53275
|
}
|
|
52814
53276
|
}
|
|
52815
53277
|
const edges = [];
|
|
52816
|
-
for (const [
|
|
53278
|
+
for (const [key2, count2] of edgeCount) {
|
|
52817
53279
|
if (count2 === 1) {
|
|
52818
|
-
const [lo, hi] =
|
|
53280
|
+
const [lo, hi] = key2.split(",").map(Number);
|
|
52819
53281
|
edges.push([lo, hi]);
|
|
52820
53282
|
}
|
|
52821
53283
|
}
|
|
@@ -53056,9 +53518,9 @@ function halfspaceIntersection(halfspaces, interiorPoint) {
|
|
|
53056
53518
|
const vertices = [];
|
|
53057
53519
|
const seen = /* @__PURE__ */ new Set();
|
|
53058
53520
|
for (const v of candidates) {
|
|
53059
|
-
const
|
|
53060
|
-
if (seen.has(
|
|
53061
|
-
seen.add(
|
|
53521
|
+
const key2 = quantum > 0 ? v.map((x) => Math.round(x / quantum)).join(",") : v.join(",");
|
|
53522
|
+
if (seen.has(key2)) continue;
|
|
53523
|
+
seen.add(key2);
|
|
53062
53524
|
vertices.push(v);
|
|
53063
53525
|
}
|
|
53064
53526
|
if (dim === 2 && vertices.length > 2) {
|
|
@@ -53733,8 +54195,8 @@ function buildMatrix(cls, q) {
|
|
|
53733
54195
|
}
|
|
53734
54196
|
var modeCache = /* @__PURE__ */ new Map();
|
|
53735
54197
|
function solveClass(cls, q) {
|
|
53736
|
-
const
|
|
53737
|
-
const cached = modeCache.get(
|
|
54198
|
+
const key2 = `${cls}:${q}`;
|
|
54199
|
+
const cached = modeCache.get(key2);
|
|
53738
54200
|
if (cached) return cached;
|
|
53739
54201
|
const harmonics = harmonicsFor(cls);
|
|
53740
54202
|
const { values, vectors } = eig4(buildMatrix(cls, q));
|
|
@@ -53758,7 +54220,7 @@ function solveClass(cls, q) {
|
|
|
53758
54220
|
for (let k = 0; k < N; k++) coeffs[k] *= sign3;
|
|
53759
54221
|
return { a: values[idx].re, coeffs, harmonics };
|
|
53760
54222
|
});
|
|
53761
|
-
modeCache.set(
|
|
54223
|
+
modeCache.set(key2, modes);
|
|
53762
54224
|
return modes;
|
|
53763
54225
|
}
|
|
53764
54226
|
function checkOrder(n, min2, name254) {
|
|
@@ -55529,7 +55991,7 @@ export {
|
|
|
55529
55991
|
isNumeric,
|
|
55530
55992
|
isPositive,
|
|
55531
55993
|
isPrime2 as isPrime,
|
|
55532
|
-
|
|
55994
|
+
isZero3 as isZero,
|
|
55533
55995
|
istft,
|
|
55534
55996
|
jacobiCN,
|
|
55535
55997
|
jacobiDN,
|
|
@@ -55966,7 +56428,7 @@ export {
|
|
|
55966
56428
|
studentizedRangeQuantile,
|
|
55967
56429
|
subfactorial,
|
|
55968
56430
|
subset,
|
|
55969
|
-
substitute,
|
|
56431
|
+
substitute2 as substitute,
|
|
55970
56432
|
subtract,
|
|
55971
56433
|
subtractScalar,
|
|
55972
56434
|
sum,
|