@danielsimonjr/mathts-functions 0.45.0 → 0.46.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.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +220 -142
- package/dist/linalg-extra.d.ts +10 -4
- package/dist/linalg-extra.d.ts.map +1 -1
- package/dist/numeric/krylov.d.ts +47 -9
- package/dist/numeric/krylov.d.ts.map +1 -1
- package/dist/numeric/svds.d.ts +32 -0
- package/dist/numeric/svds.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,10 +36,12 @@ export { newton, secant, halley } from './numeric/open-root-finders.js';
|
|
|
36
36
|
export type { NewtonOptions, SecantOptions, HalleyOptions } from './numeric/open-root-finders.js';
|
|
37
37
|
export { fsolve, root } from './numeric/fsolve.js';
|
|
38
38
|
export type { FsolveOptions } from './numeric/fsolve.js';
|
|
39
|
-
export { cg, minres, gmres, bicgstab } from './numeric/krylov.js';
|
|
39
|
+
export { cg, minres, gmres, bicgstab, incompleteLU, incompleteCholesky } from './numeric/krylov.js';
|
|
40
40
|
export type { LinearOperatorInput, Preconditioner, KrylovOptions, GmresOptions, KrylovResult, } from './numeric/krylov.js';
|
|
41
41
|
export { eigsh } from './numeric/eigsh.js';
|
|
42
42
|
export type { EigshOperatorInput, EigshOptions, EigshResult } from './numeric/eigsh.js';
|
|
43
|
+
export { svds } from './numeric/svds.js';
|
|
44
|
+
export type { SvdsOptions, SvdsResult } from './numeric/svds.js';
|
|
43
45
|
export { thomasSolve, solveBanded, toeplitzSolve, ldl } from './numeric/structured-solvers.js';
|
|
44
46
|
export type { LDLResult } from './numeric/structured-solvers.js';
|
|
45
47
|
export { funm, cosm, sinm, complexCos, complexSin } from './numeric/matrix-functions.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../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S,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI1E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -45090,54 +45090,15 @@ function tukeyHSD(groups, alpha = 0.05) {
|
|
|
45090
45090
|
}
|
|
45091
45091
|
|
|
45092
45092
|
// src/linalg-extra.ts
|
|
45093
|
-
import { DenseMatrix as DenseMatrix6, lu as lu3 } from "@danielsimonjr/mathts-matrix";
|
|
45093
|
+
import { DenseMatrix as DenseMatrix6, lu as lu3, matrixSchur as matrixSchur2 } from "@danielsimonjr/mathts-matrix";
|
|
45094
45094
|
var _inv = inv;
|
|
45095
45095
|
var _eigs = eigs;
|
|
45096
45096
|
var _multiply = multiply;
|
|
45097
45097
|
var _qr = qr;
|
|
45098
45098
|
var transposeArr = (A) => A[0].map((_, j) => A.map((r) => r[j]));
|
|
45099
|
-
var identityArr = (n) => Array.from({ length: n }, (_, i) => Array.from({ length: n }, (_2, j) => i === j ? 1 : 0));
|
|
45100
45099
|
function realSchur(M) {
|
|
45101
|
-
const
|
|
45102
|
-
|
|
45103
|
-
let U = identityArr(n);
|
|
45104
|
-
let m = n;
|
|
45105
|
-
const normM = Math.max(...M.map((r) => r.reduce((s, v) => s + Math.abs(v), 0)), 1e-300);
|
|
45106
|
-
for (let iter = 0; iter < 8e3 && m > 1; iter++) {
|
|
45107
|
-
if (Math.abs(A[m - 1][m - 2]) < 1e-14 * (Math.abs(A[m - 2][m - 2]) + Math.abs(A[m - 1][m - 1]) || normM)) {
|
|
45108
|
-
A[m - 1][m - 2] = 0;
|
|
45109
|
-
m--;
|
|
45110
|
-
continue;
|
|
45111
|
-
}
|
|
45112
|
-
const a = A[m - 2][m - 2];
|
|
45113
|
-
const b = A[m - 2][m - 1];
|
|
45114
|
-
const c = A[m - 1][m - 2];
|
|
45115
|
-
const d = A[m - 1][m - 1];
|
|
45116
|
-
const delta = (a - d) / 2;
|
|
45117
|
-
const disc = delta * delta + b * c;
|
|
45118
|
-
if (disc < 0) {
|
|
45119
|
-
if (m === 2) break;
|
|
45120
|
-
if (Math.abs(A[m - 2][m - 3]) < 1e-14 * (Math.abs(A[m - 3][m - 3]) + Math.abs(a) || normM)) {
|
|
45121
|
-
A[m - 2][m - 3] = 0;
|
|
45122
|
-
m -= 2;
|
|
45123
|
-
continue;
|
|
45124
|
-
}
|
|
45125
|
-
}
|
|
45126
|
-
const denom = Math.abs(delta) + Math.sqrt(Math.abs(disc));
|
|
45127
|
-
const s = disc >= 0 && denom > 1e-300 ? d - (Math.sign(delta) || 1) * (b * c) / denom : d;
|
|
45128
|
-
const As = A.map((r, i) => r.map((v, j) => v - (i === j ? s : 0)));
|
|
45129
|
-
const { Q: Q2, R } = _qr(As);
|
|
45130
|
-
A = _multiply(R, Q2).map((r, i) => r.map((v, j) => v + (i === j ? s : 0)));
|
|
45131
|
-
U = _multiply(U, Q2);
|
|
45132
|
-
}
|
|
45133
|
-
for (let i = 2; i < n; i++) {
|
|
45134
|
-
for (let j = 0; j < i - 1; j++) {
|
|
45135
|
-
if (Math.abs(A[i][j]) > 1e-8 * (1 + Math.abs(A[i][i]) + Math.abs(A[j][j]))) {
|
|
45136
|
-
throw new Error("realSchur: QR iteration failed to converge to (quasi-)triangular form");
|
|
45137
|
-
}
|
|
45138
|
-
}
|
|
45139
|
-
}
|
|
45140
|
-
return { U, S: A };
|
|
45100
|
+
const { Q: Q2, T } = matrixSchur2(DenseMatrix6.fromArray(M));
|
|
45101
|
+
return { U: Q2.toArray(), S: T.toArray() };
|
|
45141
45102
|
}
|
|
45142
45103
|
var arr3 = (x) => Array.isArray(x) ? x : Array.from(x);
|
|
45143
45104
|
function generalizedEig(A, B) {
|
|
@@ -45476,9 +45437,14 @@ function resolvePreconditioner(a, preconditioner) {
|
|
|
45476
45437
|
if (typeof preconditioner === "function") return preconditioner;
|
|
45477
45438
|
if (!isDenseMatrix2(a)) {
|
|
45478
45439
|
throw new Error(
|
|
45479
|
-
|
|
45440
|
+
`krylov: '${preconditioner}' preconditioner requires a dense matrix (it reads A's entries) \u2014 pass a custom preconditioner function when using a matvec operator`
|
|
45480
45441
|
);
|
|
45481
45442
|
}
|
|
45443
|
+
if (preconditioner === "jacobi") return makeJacobi(a);
|
|
45444
|
+
if (preconditioner === "ilu") return makeILU0(a);
|
|
45445
|
+
return makeIC0(a);
|
|
45446
|
+
}
|
|
45447
|
+
function makeJacobi(a) {
|
|
45482
45448
|
const n = a.length;
|
|
45483
45449
|
const invDiag = new Array(n);
|
|
45484
45450
|
for (let i = 0; i < n; i++) {
|
|
@@ -45492,6 +45458,102 @@ function resolvePreconditioner(a, preconditioner) {
|
|
|
45492
45458
|
}
|
|
45493
45459
|
return (r) => r.map((v, i) => v * invDiag[i]);
|
|
45494
45460
|
}
|
|
45461
|
+
function sparsityPattern(a) {
|
|
45462
|
+
return a.map((row2, i) => row2.map((v, j) => v !== 0 || i === j));
|
|
45463
|
+
}
|
|
45464
|
+
function incompleteLU(a) {
|
|
45465
|
+
const n = a.length;
|
|
45466
|
+
const pattern = sparsityPattern(a);
|
|
45467
|
+
const LU = a.map((row2) => row2.slice());
|
|
45468
|
+
for (let i = 0; i < n; i++) {
|
|
45469
|
+
for (let k = 0; k < i; k++) {
|
|
45470
|
+
if (!pattern[i][k]) continue;
|
|
45471
|
+
if (Math.abs(LU[k][k]) < 1e-300) {
|
|
45472
|
+
throw new Error(`incompleteLU: ILU(0) zero pivot at U[${k}][${k}] \u2014 matrix needs pivoting`);
|
|
45473
|
+
}
|
|
45474
|
+
const lik = LU[i][k] / LU[k][k];
|
|
45475
|
+
LU[i][k] = lik;
|
|
45476
|
+
for (let j = k + 1; j < n; j++) {
|
|
45477
|
+
if (!pattern[i][j]) continue;
|
|
45478
|
+
LU[i][j] -= lik * LU[k][j];
|
|
45479
|
+
}
|
|
45480
|
+
}
|
|
45481
|
+
if (Math.abs(LU[i][i]) < 1e-300) {
|
|
45482
|
+
throw new Error(`incompleteLU: ILU(0) zero pivot at U[${i}][${i}] \u2014 matrix needs pivoting`);
|
|
45483
|
+
}
|
|
45484
|
+
}
|
|
45485
|
+
const L = Array.from(
|
|
45486
|
+
{ length: n },
|
|
45487
|
+
(_, i) => Array.from({ length: n }, (_2, j) => j < i ? LU[i][j] : j === i ? 1 : 0)
|
|
45488
|
+
);
|
|
45489
|
+
const U = Array.from(
|
|
45490
|
+
{ length: n },
|
|
45491
|
+
(_, i) => Array.from({ length: n }, (_2, j) => j >= i ? LU[i][j] : 0)
|
|
45492
|
+
);
|
|
45493
|
+
return { L, U };
|
|
45494
|
+
}
|
|
45495
|
+
function incompleteCholesky(a) {
|
|
45496
|
+
const n = a.length;
|
|
45497
|
+
const src = a;
|
|
45498
|
+
const pattern = sparsityPattern(src);
|
|
45499
|
+
const L = Array.from({ length: n }, () => new Array(n).fill(0));
|
|
45500
|
+
for (let i = 0; i < n; i++) {
|
|
45501
|
+
for (let j = 0; j <= i; j++) {
|
|
45502
|
+
if (!pattern[i][j]) continue;
|
|
45503
|
+
let sum3 = src[i][j];
|
|
45504
|
+
for (let k = 0; k < j; k++) sum3 -= L[i][k] * L[j][k];
|
|
45505
|
+
if (i === j) {
|
|
45506
|
+
if (sum3 <= 0) {
|
|
45507
|
+
throw new Error(
|
|
45508
|
+
`incompleteCholesky: IC(0) requires a symmetric positive-definite matrix (non-positive pivot ${sum3} at ${i}) \u2014 use ILU(0) for indefinite/nonsymmetric A`
|
|
45509
|
+
);
|
|
45510
|
+
}
|
|
45511
|
+
L[i][i] = Math.sqrt(sum3);
|
|
45512
|
+
} else {
|
|
45513
|
+
L[i][j] = sum3 / L[j][j];
|
|
45514
|
+
}
|
|
45515
|
+
}
|
|
45516
|
+
}
|
|
45517
|
+
return { L };
|
|
45518
|
+
}
|
|
45519
|
+
function makeILU0(a) {
|
|
45520
|
+
const { L, U } = incompleteLU(a);
|
|
45521
|
+
const n = a.length;
|
|
45522
|
+
return (r) => {
|
|
45523
|
+
const y = new Array(n).fill(0);
|
|
45524
|
+
for (let i = 0; i < n; i++) {
|
|
45525
|
+
let s = r[i];
|
|
45526
|
+
for (let j = 0; j < i; j++) s -= L[i][j] * y[j];
|
|
45527
|
+
y[i] = s;
|
|
45528
|
+
}
|
|
45529
|
+
const x = new Array(n).fill(0);
|
|
45530
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
45531
|
+
let s = y[i];
|
|
45532
|
+
for (let j = i + 1; j < n; j++) s -= U[i][j] * x[j];
|
|
45533
|
+
x[i] = s / U[i][i];
|
|
45534
|
+
}
|
|
45535
|
+
return x;
|
|
45536
|
+
};
|
|
45537
|
+
}
|
|
45538
|
+
function makeIC0(a) {
|
|
45539
|
+
const { L } = incompleteCholesky(a);
|
|
45540
|
+
const n = a.length;
|
|
45541
|
+
return (r) => {
|
|
45542
|
+
const y = new Array(n).fill(0);
|
|
45543
|
+
for (let i = 0; i < n; i++) {
|
|
45544
|
+
let s = r[i];
|
|
45545
|
+
for (let j = 0; j < i; j++) s -= L[i][j] * y[j];
|
|
45546
|
+
y[i] = s / L[i][i];
|
|
45547
|
+
}
|
|
45548
|
+
const x = new Array(n).fill(0);
|
|
45549
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
45550
|
+
let s = y[i];
|
|
45551
|
+
for (let j = i + 1; j < n; j++) s -= L[j][i] * x[j];
|
|
45552
|
+
x[i] = s / L[i][i];
|
|
45553
|
+
}
|
|
45554
|
+
return x;
|
|
45555
|
+
};
|
|
45556
|
+
}
|
|
45495
45557
|
function defaultMaxIter(n) {
|
|
45496
45558
|
return Math.min(n * 10, 1e3);
|
|
45497
45559
|
}
|
|
@@ -45545,103 +45607,55 @@ function minres(a, b, opts) {
|
|
|
45545
45607
|
const tol = opts?.tol ?? 1e-10;
|
|
45546
45608
|
const maxIter = opts?.maxIter ?? defaultMaxIter(n);
|
|
45547
45609
|
const bNorm = norm25(b);
|
|
45548
|
-
const
|
|
45549
|
-
|
|
45550
|
-
let
|
|
45551
|
-
|
|
45552
|
-
|
|
45553
|
-
|
|
45554
|
-
|
|
45555
|
-
|
|
45556
|
-
|
|
45557
|
-
|
|
45558
|
-
|
|
45559
|
-
|
|
45560
|
-
|
|
45561
|
-
|
|
45562
|
-
|
|
45563
|
-
let
|
|
45564
|
-
let
|
|
45610
|
+
const x = opts?.x0 ? opts.x0.slice() : zeros2(n);
|
|
45611
|
+
let r1 = subtract2(b, matvec2(x));
|
|
45612
|
+
let y = applyM(r1);
|
|
45613
|
+
const beta1 = Math.sqrt(Math.max(0, dot2(r1, y)));
|
|
45614
|
+
const residual0 = relativeResidualNorm(norm25(r1), bNorm);
|
|
45615
|
+
if (residual0 < tol || beta1 < 1e-300) {
|
|
45616
|
+
return { x, iterations: 0, converged: residual0 < tol, residual: residual0 };
|
|
45617
|
+
}
|
|
45618
|
+
let oldb = 0;
|
|
45619
|
+
let beta2 = beta1;
|
|
45620
|
+
let dbar = 0;
|
|
45621
|
+
let epsln = 0;
|
|
45622
|
+
let phibar = beta1;
|
|
45623
|
+
let cs = -1;
|
|
45624
|
+
let sn = 0;
|
|
45625
|
+
let w = zeros2(n);
|
|
45626
|
+
let w2 = zeros2(n);
|
|
45627
|
+
let r2 = r1.slice();
|
|
45565
45628
|
let iterations = 0;
|
|
45566
|
-
for (let
|
|
45567
|
-
iterations =
|
|
45568
|
-
const
|
|
45569
|
-
|
|
45570
|
-
|
|
45571
|
-
const
|
|
45572
|
-
|
|
45573
|
-
|
|
45574
|
-
|
|
45575
|
-
|
|
45576
|
-
|
|
45577
|
-
|
|
45578
|
-
const
|
|
45579
|
-
const
|
|
45580
|
-
|
|
45581
|
-
|
|
45582
|
-
|
|
45583
|
-
|
|
45584
|
-
|
|
45585
|
-
|
|
45586
|
-
|
|
45587
|
-
|
|
45588
|
-
const
|
|
45589
|
-
|
|
45590
|
-
|
|
45591
|
-
let
|
|
45592
|
-
|
|
45593
|
-
|
|
45594
|
-
|
|
45595
|
-
|
|
45596
|
-
if (residual < bestResidual) {
|
|
45597
|
-
bestResidual = residual;
|
|
45598
|
-
bestX = xCandidate;
|
|
45599
|
-
}
|
|
45600
|
-
if (residual < tol) {
|
|
45601
|
-
return { x: xCandidate, iterations: k, converged: true, residual };
|
|
45602
|
-
}
|
|
45603
|
-
if (betaNext < 1e-300) break;
|
|
45604
|
-
betas.push(betaNext);
|
|
45605
|
-
V.push(scale(1 / betaNext, p));
|
|
45606
|
-
Z.push(scale(1 / betaNext, zRaw));
|
|
45607
|
-
}
|
|
45608
|
-
return { x: bestX, iterations, converged: bestResidual < tol, residual: bestResidual };
|
|
45609
|
-
}
|
|
45610
|
-
function solveLeastSquaresQR(T, rhs) {
|
|
45611
|
-
const m = T.length;
|
|
45612
|
-
const n = T[0]?.length ?? 0;
|
|
45613
|
-
const R = T.map((row2) => row2.slice());
|
|
45614
|
-
const c = rhs.slice();
|
|
45615
|
-
for (let k = 0; k < n; k++) {
|
|
45616
|
-
let normX = 0;
|
|
45617
|
-
for (let i = k; i < m; i++) normX += R[i][k] * R[i][k];
|
|
45618
|
-
normX = Math.sqrt(normX);
|
|
45619
|
-
if (normX < 1e-300) continue;
|
|
45620
|
-
const alpha = R[k][k] >= 0 ? -normX : normX;
|
|
45621
|
-
const v = new Array(m).fill(0);
|
|
45622
|
-
v[k] = R[k][k] - alpha;
|
|
45623
|
-
for (let i = k + 1; i < m; i++) v[i] = R[i][k];
|
|
45624
|
-
let vNormSq = 0;
|
|
45625
|
-
for (let i = k; i < m; i++) vNormSq += v[i] * v[i];
|
|
45626
|
-
if (vNormSq < 1e-300) continue;
|
|
45627
|
-
for (let j = k; j < n; j++) {
|
|
45628
|
-
let dotVR = 0;
|
|
45629
|
-
for (let i = k; i < m; i++) dotVR += v[i] * R[i][j];
|
|
45630
|
-
const factor2 = 2 * dotVR / vNormSq;
|
|
45631
|
-
for (let i = k; i < m; i++) R[i][j] -= factor2 * v[i];
|
|
45632
|
-
}
|
|
45633
|
-
let dotVC = 0;
|
|
45634
|
-
for (let i = k; i < m; i++) dotVC += v[i] * c[i];
|
|
45635
|
-
const factorC = 2 * dotVC / vNormSq;
|
|
45636
|
-
for (let i = k; i < m; i++) c[i] -= factorC * v[i];
|
|
45637
|
-
}
|
|
45638
|
-
const y = new Array(n).fill(0);
|
|
45639
|
-
for (let i = n - 1; i >= 0; i--) {
|
|
45640
|
-
let sum3 = c[i];
|
|
45641
|
-
for (let j = i + 1; j < n; j++) sum3 -= R[i][j] * y[j];
|
|
45642
|
-
y[i] = Math.abs(R[i][i]) > 1e-300 ? sum3 / R[i][i] : 0;
|
|
45643
|
-
}
|
|
45644
|
-
return y;
|
|
45629
|
+
for (let iter = 1; iter <= maxIter; iter++) {
|
|
45630
|
+
iterations = iter;
|
|
45631
|
+
const v = scale(1 / beta2, y);
|
|
45632
|
+
y = matvec2(v);
|
|
45633
|
+
if (iter >= 2) y = axpy(-beta2 / oldb, r1, y);
|
|
45634
|
+
const alfa = dot2(v, y);
|
|
45635
|
+
y = axpy(-alfa / beta2, r2, y);
|
|
45636
|
+
r1 = r2;
|
|
45637
|
+
r2 = y;
|
|
45638
|
+
y = applyM(r2);
|
|
45639
|
+
oldb = beta2;
|
|
45640
|
+
beta2 = Math.sqrt(Math.max(0, dot2(r2, y)));
|
|
45641
|
+
const oldeps = epsln;
|
|
45642
|
+
const delta = cs * dbar + sn * alfa;
|
|
45643
|
+
const gbar = sn * dbar - cs * alfa;
|
|
45644
|
+
epsln = sn * beta2;
|
|
45645
|
+
dbar = -cs * beta2;
|
|
45646
|
+
const gamma2 = Math.max(Math.sqrt(gbar * gbar + beta2 * beta2), 1e-300);
|
|
45647
|
+
cs = gbar / gamma2;
|
|
45648
|
+
sn = beta2 / gamma2;
|
|
45649
|
+
const phi = cs * phibar;
|
|
45650
|
+
phibar = sn * phibar;
|
|
45651
|
+
const w1 = w2;
|
|
45652
|
+
w2 = w;
|
|
45653
|
+
w = scale(1 / gamma2, subtract2(subtract2(v, scale(oldeps, w1)), scale(delta, w2)));
|
|
45654
|
+
for (let i = 0; i < n; i++) x[i] += phi * w[i];
|
|
45655
|
+
if (phibar / beta1 < tol || beta2 < 1e-300) break;
|
|
45656
|
+
}
|
|
45657
|
+
const residual = relativeResidual(matvec2, x, b, bNorm);
|
|
45658
|
+
return { x, iterations, converged: residual < tol, residual };
|
|
45645
45659
|
}
|
|
45646
45660
|
function gmres(a, b, opts) {
|
|
45647
45661
|
const n = b.length;
|
|
@@ -45939,6 +45953,67 @@ function eigsh(a, k = 1, opts) {
|
|
|
45939
45953
|
return { eigenvalues, eigenvectors };
|
|
45940
45954
|
}
|
|
45941
45955
|
|
|
45956
|
+
// src/numeric/svds.ts
|
|
45957
|
+
function matvecA(A, x) {
|
|
45958
|
+
return A.map((row2) => {
|
|
45959
|
+
let s = 0;
|
|
45960
|
+
for (let j = 0; j < row2.length; j++) s += row2[j] * x[j];
|
|
45961
|
+
return s;
|
|
45962
|
+
});
|
|
45963
|
+
}
|
|
45964
|
+
function matvecAt(A, y, n) {
|
|
45965
|
+
const out = new Array(n).fill(0);
|
|
45966
|
+
for (let i = 0; i < A.length; i++) {
|
|
45967
|
+
const yi = y[i];
|
|
45968
|
+
const row2 = A[i];
|
|
45969
|
+
for (let j = 0; j < n; j++) out[j] += row2[j] * yi;
|
|
45970
|
+
}
|
|
45971
|
+
return out;
|
|
45972
|
+
}
|
|
45973
|
+
function norm27(v) {
|
|
45974
|
+
let s = 0;
|
|
45975
|
+
for (let i = 0; i < v.length; i++) s += v[i] * v[i];
|
|
45976
|
+
return Math.sqrt(s);
|
|
45977
|
+
}
|
|
45978
|
+
function svds(A, k = 1, opts) {
|
|
45979
|
+
const m = A.length;
|
|
45980
|
+
const n = A[0]?.length ?? 0;
|
|
45981
|
+
if (m === 0 || n === 0 || A.some((row2) => row2.length !== n)) {
|
|
45982
|
+
throw new Error("svds: A must be a non-empty rectangular matrix");
|
|
45983
|
+
}
|
|
45984
|
+
const minDim = Math.min(m, n);
|
|
45985
|
+
if (!Number.isInteger(k) || k < 1 || k > minDim) {
|
|
45986
|
+
throw new Error(`svds: k must be an integer between 1 and min(m,n)=${minDim}, got ${k}`);
|
|
45987
|
+
}
|
|
45988
|
+
const tol = opts?.tol ?? 1e-10;
|
|
45989
|
+
const useAtA = m >= n;
|
|
45990
|
+
const dim = useAtA ? n : m;
|
|
45991
|
+
const normalOp = useAtA ? (x) => matvecAt(A, matvecA(A, x), n) : (x) => matvecA(A, matvecAt(A, x, n));
|
|
45992
|
+
const { eigenvalues, eigenvectors } = eigsh(normalOp, k, {
|
|
45993
|
+
which: "LM",
|
|
45994
|
+
n: dim,
|
|
45995
|
+
tol,
|
|
45996
|
+
maxIter: opts?.maxIter
|
|
45997
|
+
});
|
|
45998
|
+
const s = eigenvalues.map((lambda) => Math.sqrt(Math.max(0, lambda)));
|
|
45999
|
+
const primaryDim = dim;
|
|
46000
|
+
const otherDim = useAtA ? m : n;
|
|
46001
|
+
const primary = Array.from(
|
|
46002
|
+
{ length: primaryDim },
|
|
46003
|
+
() => new Array(k).fill(0)
|
|
46004
|
+
);
|
|
46005
|
+
const other = Array.from({ length: otherDim }, () => new Array(k).fill(0));
|
|
46006
|
+
for (let col = 0; col < k; col++) {
|
|
46007
|
+
const pvec = eigenvectors.map((row2) => row2[col]);
|
|
46008
|
+
for (let i = 0; i < primaryDim; i++) primary[i][col] = pvec[i];
|
|
46009
|
+
let ovec = useAtA ? matvecA(A, pvec) : matvecAt(A, pvec, n);
|
|
46010
|
+
const nrm = norm27(ovec);
|
|
46011
|
+
ovec = nrm > 1e-300 ? ovec.map((v) => v / nrm) : ovec;
|
|
46012
|
+
for (let i = 0; i < otherDim; i++) other[i][col] = ovec[i];
|
|
46013
|
+
}
|
|
46014
|
+
return useAtA ? { U: other, s, V: primary } : { U: primary, s, V: other };
|
|
46015
|
+
}
|
|
46016
|
+
|
|
45942
46017
|
// src/numeric/structured-solvers.ts
|
|
45943
46018
|
function thomasSolve(sub2, diag2, sup, d) {
|
|
45944
46019
|
const n = diag2.length;
|
|
@@ -47618,7 +47693,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
47618
47693
|
let x = Array.from(x0);
|
|
47619
47694
|
let lambda = 1e-3;
|
|
47620
47695
|
const h = 1e-7;
|
|
47621
|
-
const
|
|
47696
|
+
const norm28 = (v) => v.reduce((s, c) => s + c * c, 0);
|
|
47622
47697
|
const jacobian2 = (xc, r0) => {
|
|
47623
47698
|
const m = r0.length;
|
|
47624
47699
|
const J = Array.from({ length: m }, () => new Array(n).fill(0));
|
|
@@ -47631,7 +47706,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
47631
47706
|
return J;
|
|
47632
47707
|
};
|
|
47633
47708
|
let r = residual(x);
|
|
47634
|
-
let cost =
|
|
47709
|
+
let cost = norm28(r);
|
|
47635
47710
|
let iter = 0;
|
|
47636
47711
|
for (; iter < maxIter; iter++) {
|
|
47637
47712
|
const J = jacobian2(x, r);
|
|
@@ -47662,7 +47737,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
47662
47737
|
}
|
|
47663
47738
|
const xNew = x.map((v, i) => v + delta[i]);
|
|
47664
47739
|
const rNew = residual(xNew);
|
|
47665
|
-
const costNew =
|
|
47740
|
+
const costNew = norm28(rNew);
|
|
47666
47741
|
if (costNew < cost) {
|
|
47667
47742
|
x = xNew;
|
|
47668
47743
|
r = rNew;
|
|
@@ -52441,6 +52516,8 @@ export {
|
|
|
52441
52516
|
ifftshift2 as ifftshift,
|
|
52442
52517
|
im,
|
|
52443
52518
|
implicitDiff,
|
|
52519
|
+
incompleteCholesky,
|
|
52520
|
+
incompleteLU,
|
|
52444
52521
|
indexFn as index,
|
|
52445
52522
|
indexFn,
|
|
52446
52523
|
initializePool,
|
|
@@ -52906,6 +52983,7 @@ export {
|
|
|
52906
52983
|
sum,
|
|
52907
52984
|
summation,
|
|
52908
52985
|
svd4 as svd,
|
|
52986
|
+
svds,
|
|
52909
52987
|
sylvester,
|
|
52910
52988
|
symbolicEqual,
|
|
52911
52989
|
symbolicIntegral,
|
package/dist/linalg-extra.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ type Vec = readonly number[] | Float64Array;
|
|
|
2
2
|
/**
|
|
3
3
|
* Generalized eigenvalues of the pencil `A x = λ B x` (B nonsingular), via the
|
|
4
4
|
* eigendecomposition of `B⁻¹A` — reusing `inv`, `multiply`, and the corrected
|
|
5
|
-
* `eigs
|
|
6
|
-
*
|
|
5
|
+
* `eigs` (Hessenberg + Francis double-shift). Eigenvalues match
|
|
6
|
+
* `scipy.linalg.eig(A, B)` across real, complex-pair and clustered spectra. For
|
|
7
|
+
* a *singular* or numerically near-singular `B` this squaring-free QZ formulation
|
|
8
|
+
* breaks down; extracting the pencil eigenvalues directly from the {@link qz}
|
|
9
|
+
* factors (`diag AA / diag BB`, with 2×2-block handling for complex pairs) is the
|
|
10
|
+
* future enhancement for that regime.
|
|
7
11
|
*/
|
|
8
12
|
export declare function generalizedEig(A: readonly number[][], B: readonly number[][]): {
|
|
9
13
|
values: Array<number | {
|
|
@@ -58,8 +62,10 @@ export declare function logdet(A: readonly number[][]): {
|
|
|
58
62
|
* Generalized (QZ) Schur decomposition of the pencil `(A, B)` with `B` nonsingular:
|
|
59
63
|
* returns orthogonal `Q`, `Z` and upper-(quasi-)triangular `AA`, `BB` with
|
|
60
64
|
* `A = Q·AA·Zᵀ` and `B = Q·BB·Zᵀ`. Built from the real Schur of `B⁻¹A` (= Z S Zᵀ) and
|
|
61
|
-
* the QR of `B·Z` (= Q·BB): then `AA = Qᵀ·A·Z`.
|
|
62
|
-
*
|
|
65
|
+
* the QR of `B·Z` (= Q·BB): then `AA = Qᵀ·A·Z`. The Schur step is the hardened
|
|
66
|
+
* Hessenberg + Francis double-shift `matrixSchur` (see {@link realSchur}), so `qz`
|
|
67
|
+
* no longer stalls on non-symmetric `B⁻¹A` pencils; matches the decomposition
|
|
68
|
+
* contract of `scipy.linalg.qz` (the factors are not unique).
|
|
63
69
|
*/
|
|
64
70
|
export declare function qz(A: readonly number[][], B: readonly number[][]): {
|
|
65
71
|
AA: number[][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linalg-extra.d.ts","sourceRoot":"","sources":["../src/linalg-extra.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linalg-extra.d.ts","sourceRoot":"","sources":["../src/linalg-extra.ts"],"names":[],"mappings":"AAuCA,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAG5C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EACtB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GACrB;IAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAIhF;AAED,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,SAAI,GAAG,MAAM,EAAE,EAAE,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,SAAI,GAAG,MAAM,EAAE,EAAE,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,MAAM,EAAE,EAAE,CAMzE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,CAQpD;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,CAM5C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,CASjD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,EAC9B,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,MAAM,EAAE,EAAE,CAYZ;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA2B9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,EAAE,CAChB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EACtB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GACrB;IAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CASlE"}
|
package/dist/numeric/krylov.d.ts
CHANGED
|
@@ -15,8 +15,15 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** A linear operator: either a dense matrix or a matvec callback `x -> A x`. */
|
|
17
17
|
export type LinearOperatorInput = number[][] | ((x: number[]) => number[]);
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Preconditioner. The three built-ins require a dense matrix (they read `A`'s
|
|
20
|
+
* entries): `'jacobi'` (diagonal `M⁻¹ = diag(1/Aᵢᵢ)`), `'ilu'` (ILU(0) —
|
|
21
|
+
* incomplete LU with zero fill on `A`'s sparsity pattern, for general `A`),
|
|
22
|
+
* `'ic'` (IC(0) — incomplete Cholesky, for symmetric positive-definite `A`).
|
|
23
|
+
* Or pass a custom `M⁻¹` callback (the only option that works with a
|
|
24
|
+
* matvec-only operator).
|
|
25
|
+
*/
|
|
26
|
+
export type Preconditioner = 'jacobi' | 'ilu' | 'ic' | ((r: number[]) => number[]);
|
|
20
27
|
/** Common options accepted by every solver in this module. */
|
|
21
28
|
export interface KrylovOptions {
|
|
22
29
|
/** Initial guess (default: the zero vector). */
|
|
@@ -44,6 +51,31 @@ export interface KrylovResult {
|
|
|
44
51
|
/** Final relative residual `‖b − A x‖₂ / ‖b‖₂`. */
|
|
45
52
|
residual: number;
|
|
46
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* ILU(0) — incomplete LU factorization with zero fill. Returns unit-lower `L`
|
|
56
|
+
* and upper `U` (dense, with zeros outside `A`'s sparsity pattern) such that
|
|
57
|
+
* `(L·U)ᵢⱼ = Aᵢⱼ` on that pattern, dropping any fill that would arise outside
|
|
58
|
+
* it. The classic preconditioner for iterative solvers on general sparse `A`.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* incompleteLU([[4,1,0],[1,4,1],[0,1,4]]) // tridiagonal → exact LU (no fill)
|
|
62
|
+
*/
|
|
63
|
+
export declare function incompleteLU(a: readonly number[][]): {
|
|
64
|
+
L: number[][];
|
|
65
|
+
U: number[][];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* IC(0) — incomplete Cholesky factorization with zero fill, for symmetric
|
|
69
|
+
* positive-definite `A`. Returns lower-triangular `L` on `A`'s sparsity pattern
|
|
70
|
+
* with `(L·Lᵀ)ᵢⱼ = Aᵢⱼ` there. Throws on a non-positive pivot (the `A`-is-SPD
|
|
71
|
+
* precondition failed).
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* incompleteCholesky([[4,1,0],[1,4,1],[0,1,4]]) // tridiagonal → exact Cholesky
|
|
75
|
+
*/
|
|
76
|
+
export declare function incompleteCholesky(a: readonly number[][]): {
|
|
77
|
+
L: number[][];
|
|
78
|
+
};
|
|
47
79
|
/**
|
|
48
80
|
* Conjugate Gradient (CG) — for symmetric positive-definite `A`.
|
|
49
81
|
*
|
|
@@ -54,13 +86,19 @@ export declare function cg(a: LinearOperatorInput, b: number[], opts?: KrylovOpt
|
|
|
54
86
|
/**
|
|
55
87
|
* MINRES — for symmetric (possibly indefinite) `A`.
|
|
56
88
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
89
|
+
* The Paige–Saunders short-recurrence MINRES (Paige & Saunders 1975): a
|
|
90
|
+
* preconditioned Lanczos tridiagonalization coupled with an incrementally
|
|
91
|
+
* updated Givens-rotation QR of the tridiagonal. Each iteration does a fixed
|
|
92
|
+
* number of length-`n` vector operations (one matvec + a handful of `axpy`s)
|
|
93
|
+
* and **O(1)** scalar work — no growing least-squares is ever formed or
|
|
94
|
+
* solved. The solution is advanced through a running 3-term `w`-recurrence, so
|
|
95
|
+
* the whole solve is **O(k·n)** for `k` iterations rather than the O(k³) of the
|
|
96
|
+
* former "re-solve the growing `(k+1)×k` tridiagonal each step" formulation.
|
|
97
|
+
*
|
|
98
|
+
* With a preconditioner `M`, the loop converges the `M⁻¹`-norm relative
|
|
99
|
+
* residual `‖r_k‖_{M⁻¹} / ‖r_0‖_{M⁻¹}` (the estimate MINRES minimizes); for
|
|
100
|
+
* `M = I` this equals `‖b − A x‖₂ / ‖b‖₂`. The reported `residual`/`converged`
|
|
101
|
+
* are always computed from the true Euclidean residual (one final matvec).
|
|
64
102
|
*
|
|
65
103
|
* @example
|
|
66
104
|
* minres([[0, 1], [1, 0]], [1, 2]) // => { x: [2, 1], converged: true, ... }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"krylov.d.ts","sourceRoot":"","sources":["../../src/numeric/krylov.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;AAE3E
|
|
1
|
+
{"version":3,"file":"krylov.d.ts","sourceRoot":"","sources":["../../src/numeric/krylov.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;AAEnF,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,4DAA4D;AAC5D,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AA6FD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG;IAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CA4BrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG;IAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAuB5E;AA6DD;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAwC1F;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CA0E9F;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CA2F5F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAqEhG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Options accepted by {@link svds}. */
|
|
2
|
+
export interface SvdsOptions {
|
|
3
|
+
/** Convergence tolerance forwarded to the Lanczos eigensolver (default 1e-10). */
|
|
4
|
+
tol?: number;
|
|
5
|
+
/** Maximum Lanczos steps (default `min(max(2k + 20, 20), dim)`). */
|
|
6
|
+
maxIter?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Result of {@link svds}. Singular values are returned **descending**
|
|
10
|
+
* (`s[0]` largest — matching this library's full {@link svd}); note this is the
|
|
11
|
+
* opposite of `scipy.sparse.linalg.svds`, which returns them ascending.
|
|
12
|
+
* Singular vectors are stored as **columns**: `U[i][j]` is the `i`-th component
|
|
13
|
+
* of the `j`-th left singular vector (for `s[j]`), and likewise `V` for the
|
|
14
|
+
* right singular vectors.
|
|
15
|
+
*/
|
|
16
|
+
export interface SvdsResult {
|
|
17
|
+
/** Left singular vectors, `m × k`, as columns. */
|
|
18
|
+
U: number[][];
|
|
19
|
+
/** The `k` largest singular values, descending. */
|
|
20
|
+
s: number[];
|
|
21
|
+
/** Right singular vectors, `n × k`, as columns. */
|
|
22
|
+
V: number[][];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The `k` largest singular triplets of `A` (dense `m × n`) via Lanczos on the
|
|
26
|
+
* smaller normal operator.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* svds([[1,2,0],[0,3,1],[4,0,2]], 2) // => { U, s: [σ₁, σ₂] (descending), V }
|
|
30
|
+
*/
|
|
31
|
+
export declare function svds(A: number[][], k?: number, opts?: SvdsOptions): SvdsResult;
|
|
32
|
+
//# sourceMappingURL=svds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svds.d.ts","sourceRoot":"","sources":["../../src/numeric/svds.ts"],"names":[],"mappings":"AAqBA,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACd,mDAAmD;IACnD,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,mDAAmD;IACnD,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CACf;AA0BD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAI,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAkDzE"}
|
package/package.json
CHANGED