@danielsimonjr/mathts-functions 0.44.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.js CHANGED
@@ -11738,6 +11738,7 @@ function factory(name254, dependencies254, create, meta) {
11738
11738
  }
11739
11739
 
11740
11740
  // src/numeric/solveODE.ts
11741
+ import { DenseMatrix as DenseMatrix3, lu, luSolve } from "@danielsimonjr/mathts-matrix";
11741
11742
  var WASM_ODE_THRESHOLD = 10;
11742
11743
  var name = "solveODE";
11743
11744
  var dependencies = [
@@ -11762,7 +11763,7 @@ function _rmsNorm(v) {
11762
11763
  for (let i = 0; i < v.length; i++) s += v[i] * v[i];
11763
11764
  return Math.sqrt(s / v.length);
11764
11765
  }
11765
- function _luSolve(A, b) {
11766
+ function _inlineLuSolve(A, b) {
11766
11767
  const n = b.length;
11767
11768
  const M = A.map((r) => r.slice());
11768
11769
  const x = b.slice();
@@ -11785,6 +11786,18 @@ function _luSolve(A, b) {
11785
11786
  }
11786
11787
  return x;
11787
11788
  }
11789
+ var LU_ROUTE_THRESHOLD = 8;
11790
+ function _factorSolver(A, n) {
11791
+ if (n < LU_ROUTE_THRESHOLD) {
11792
+ return (b) => _inlineLuSolve(A, b);
11793
+ }
11794
+ try {
11795
+ const fac = lu(DenseMatrix3.fromArray(A));
11796
+ return (b) => luSolve(fac, b);
11797
+ } catch {
11798
+ return () => new Array(n).fill(NaN);
11799
+ }
11800
+ }
11788
11801
  function _fArr(f, t, y) {
11789
11802
  const r = f(t, y);
11790
11803
  return Array.isArray(r) ? r : [r];
@@ -11820,6 +11833,138 @@ function _fdTimeDerivative(f, t, y, f0) {
11820
11833
  const fp = _fArr(f, t + delt, y);
11821
11834
  return f0.map((v, i) => (fp[i] - v) / delt);
11822
11835
  }
11836
+ function _terminalCount(t) {
11837
+ if (t === true) return 1;
11838
+ if (typeof t === "number" && t > 0) return Math.floor(t);
11839
+ return 0;
11840
+ }
11841
+ function _directionSign(d) {
11842
+ return typeof d === "number" && d !== 0 ? Math.sign(d) : 0;
11843
+ }
11844
+ function _normalizeEvents(events) {
11845
+ const list = Array.isArray(events) ? events : [events];
11846
+ return list.map((spec) => {
11847
+ if (typeof spec === "function") {
11848
+ return {
11849
+ g: spec,
11850
+ terminal: _terminalCount(spec.terminal),
11851
+ direction: _directionSign(spec.direction)
11852
+ };
11853
+ }
11854
+ return {
11855
+ g: spec.event,
11856
+ terminal: _terminalCount(spec.terminal),
11857
+ direction: _directionSign(spec.direction)
11858
+ };
11859
+ });
11860
+ }
11861
+ function _hermite(ta, tb, ya, yb, fa, fb, t) {
11862
+ const h = tb - ta;
11863
+ const theta = h === 0 ? 0 : (t - ta) / h;
11864
+ const th2 = theta * theta;
11865
+ const th3 = th2 * theta;
11866
+ const h00 = 2 * th3 - 3 * th2 + 1;
11867
+ const h10 = th3 - 2 * th2 + theta;
11868
+ const h01 = -2 * th3 + 3 * th2;
11869
+ const h11 = th3 - th2;
11870
+ return ya.map((_, i) => h00 * ya[i] + h10 * h * fa[i] + h01 * yb[i] + h11 * h * fb[i]);
11871
+ }
11872
+ function _bisectEventRoot(gEval, ta, tb, ga, gb) {
11873
+ if (gb === 0) return tb;
11874
+ if (ga === 0) return ta;
11875
+ let a = ta;
11876
+ let b = tb;
11877
+ let gaCur = ga;
11878
+ for (let iter = 0; iter < 100; iter++) {
11879
+ const m = 0.5 * (a + b);
11880
+ const gm = gEval(m);
11881
+ if (gm === 0 || Math.abs(b - a) <= 1e-15 * Math.max(1, Math.abs(m))) return m;
11882
+ if (gaCur < 0 === gm < 0) {
11883
+ a = m;
11884
+ gaCur = gm;
11885
+ } else {
11886
+ b = m;
11887
+ }
11888
+ }
11889
+ return 0.5 * (a + b);
11890
+ }
11891
+ function _detectEvents(f, tArr, yArr, evs, dir) {
11892
+ const nEv = evs.length;
11893
+ const tEvents = evs.map(() => []);
11894
+ const yEvents = evs.map(() => []);
11895
+ const remaining = evs.map((e) => e.terminal);
11896
+ let trunc = null;
11897
+ let gPrev = evs.map((e) => e.g(tArr[0], yArr[0]));
11898
+ for (let i = 0; i < tArr.length - 1 && trunc === null; i++) {
11899
+ const ta = tArr[i];
11900
+ const tb = tArr[i + 1];
11901
+ const ya = yArr[i];
11902
+ const yb = yArr[i + 1];
11903
+ const gCurr = evs.map((e) => e.g(tb, yb));
11904
+ let fa = null;
11905
+ let fb = null;
11906
+ const hits = [];
11907
+ for (let e = 0; e < nEv; e++) {
11908
+ const ga = gPrev[e];
11909
+ const gb = gCurr[e];
11910
+ const up = ga < 0 && gb >= 0;
11911
+ const down = ga > 0 && gb <= 0;
11912
+ if (!up && !down) continue;
11913
+ const d = evs[e].direction;
11914
+ if (d > 0 && !up) continue;
11915
+ if (d < 0 && !down) continue;
11916
+ let tStar;
11917
+ let yStar;
11918
+ if (gb === 0) {
11919
+ tStar = tb;
11920
+ yStar = yb.slice();
11921
+ } else {
11922
+ if (fa === null) {
11923
+ fa = _fArr(f, ta, ya);
11924
+ fb = _fArr(f, tb, yb);
11925
+ }
11926
+ const interp = (t) => _hermite(ta, tb, ya, yb, fa, fb, t);
11927
+ tStar = _bisectEventRoot((t) => evs[e].g(t, interp(t)), ta, tb, ga, gb);
11928
+ yStar = interp(tStar);
11929
+ }
11930
+ hits.push({ eventIndex: e, tStar, yStar });
11931
+ }
11932
+ hits.sort((p, q) => dir >= 0 ? p.tStar - q.tStar : q.tStar - p.tStar);
11933
+ for (const hit of hits) {
11934
+ tEvents[hit.eventIndex].push(hit.tStar);
11935
+ yEvents[hit.eventIndex].push(hit.yStar);
11936
+ if (remaining[hit.eventIndex] > 0) {
11937
+ remaining[hit.eventIndex] -= 1;
11938
+ if (remaining[hit.eventIndex] === 0) {
11939
+ trunc = { tStar: hit.tStar, yStar: hit.yStar, stepIndex: i };
11940
+ break;
11941
+ }
11942
+ }
11943
+ }
11944
+ gPrev = gCurr;
11945
+ }
11946
+ return { tEvents, yEvents, trunc };
11947
+ }
11948
+ function _applyEvents(f, sol, events, dir) {
11949
+ const numeric2 = sol.y.every((s) => Array.isArray(s) && s.every((v) => typeof v === "number")) && sol.t.every((v) => typeof v === "number");
11950
+ if (!numeric2) {
11951
+ throw new Error('solveODE: the "events" option requires plain-number state and time');
11952
+ }
11953
+ const tArr = sol.t;
11954
+ const yArr = sol.y;
11955
+ const evs = _normalizeEvents(events);
11956
+ const { tEvents, yEvents, trunc } = _detectEvents(f, tArr, yArr, evs, dir);
11957
+ if (trunc) {
11958
+ const keep = trunc.stepIndex + 1;
11959
+ return {
11960
+ t: [...tArr.slice(0, keep), trunc.tStar],
11961
+ y: [...yArr.slice(0, keep), trunc.yStar],
11962
+ tEvents,
11963
+ yEvents
11964
+ };
11965
+ }
11966
+ return { t: tArr, y: yArr, tEvents, yEvents };
11967
+ }
11823
11968
  function rosenbrockSolve(f, tspan, y0raw, options = {}) {
11824
11969
  const t0 = tspan[0];
11825
11970
  const tf = tspan[1];
@@ -11858,20 +12003,15 @@ function rosenbrockSolve(f, tspan, y0raw, options = {}) {
11858
12003
  const F0 = _fArr(f, t, y);
11859
12004
  const J = _jacobianAt(f, t, y, F0, options);
11860
12005
  const W = identityMinus(J, h * gamma2);
11861
- const k1 = _luSolve(W, F0);
12006
+ const solveW = _factorSolver(W, n);
12007
+ const k1 = solveW(F0);
11862
12008
  const y1 = y.map((yi, i) => yi + 0.5 * h * k1[i]);
11863
12009
  const F1 = _fArr(f, t + 0.5 * h, y1);
11864
- const dk = _luSolve(
11865
- W,
11866
- F1.map((v, i) => v - k1[i])
11867
- );
12010
+ const dk = solveW(F1.map((v, i) => v - k1[i]));
11868
12011
  const k2 = k1.map((v, i) => v + dk[i]);
11869
12012
  const yNew = y.map((yi, i) => yi + h * k2[i]);
11870
12013
  const F2 = _fArr(f, t + h, yNew);
11871
- const k3 = _luSolve(
11872
- W,
11873
- F2.map((v, i) => v - c32 * (k2[i] - F1[i]) - 2 * (k1[i] - F0[i]))
11874
- );
12014
+ const k3 = solveW(F2.map((v, i) => v - c32 * (k2[i] - F1[i]) - 2 * (k1[i] - F0[i])));
11875
12015
  let errNorm = 0;
11876
12016
  for (let i = 0; i < n; i++) {
11877
12017
  const err = h / 6 * (k1[i] - 2 * k2[i] + k3[i]);
@@ -11969,26 +12109,19 @@ function rodasSolve(f, tspan, y0raw, options = {}) {
11969
12109
  const J = _jacobianAt(f, t, y, F0, options);
11970
12110
  const fx = _fdTimeDerivative(f, t, y, F0);
11971
12111
  const E = J.map((row2, i) => row2.map((v, j) => (i === j ? 1 / (g * h) : 0) - v));
11972
- const k1 = _luSolve(
11973
- E,
11974
- F0.map((v, i) => v + h * RODAS.d1 * fx[i])
11975
- );
12112
+ const solveE = _factorSolver(E, n);
12113
+ const k1 = solveE(F0.map((v, i) => v + h * RODAS.d1 * fx[i]));
11976
12114
  const g2 = y.map((yi, i) => yi + RODAS.a21 * k1[i]);
11977
12115
  const f2 = _fArr(f, t + RODAS.alpha2 * h, g2);
11978
- const k2 = _luSolve(
11979
- E,
11980
- f2.map((v, i) => v + RODAS.C21 * k1[i] / h + h * RODAS.d2 * fx[i])
11981
- );
12116
+ const k2 = solveE(f2.map((v, i) => v + RODAS.C21 * k1[i] / h + h * RODAS.d2 * fx[i]));
11982
12117
  const g3 = y.map((yi, i) => yi + RODAS.a31 * k1[i] + RODAS.a32 * k2[i]);
11983
12118
  const f3 = _fArr(f, t + RODAS.alpha3 * h, g3);
11984
- const k3 = _luSolve(
11985
- E,
12119
+ const k3 = solveE(
11986
12120
  f3.map((v, i) => v + (RODAS.C31 * k1[i] + RODAS.C32 * k2[i]) / h + h * RODAS.d3 * fx[i])
11987
12121
  );
11988
12122
  const g4 = y.map((yi, i) => yi + RODAS.a41 * k1[i] + RODAS.a42 * k2[i] + RODAS.a43 * k3[i]);
11989
12123
  const f4 = _fArr(f, t + RODAS.alpha4 * h, g4);
11990
- const k4 = _luSolve(
11991
- E,
12124
+ const k4 = solveE(
11992
12125
  f4.map(
11993
12126
  (v, i) => v + (RODAS.C41 * k1[i] + RODAS.C42 * k2[i] + RODAS.C43 * k3[i]) / h + h * RODAS.d4 * fx[i]
11994
12127
  )
@@ -11997,16 +12130,14 @@ function rodasSolve(f, tspan, y0raw, options = {}) {
11997
12130
  (yi, i) => yi + RODAS.a51 * k1[i] + RODAS.a52 * k2[i] + RODAS.a53 * k3[i] + RODAS.a54 * k4[i]
11998
12131
  );
11999
12132
  const f5 = _fArr(f, t + h, g5);
12000
- const k5 = _luSolve(
12001
- E,
12133
+ const k5 = solveE(
12002
12134
  f5.map(
12003
12135
  (v, i) => v + (RODAS.C51 * k1[i] + RODAS.C52 * k2[i] + RODAS.C53 * k3[i] + RODAS.C54 * k4[i]) / h
12004
12136
  )
12005
12137
  );
12006
12138
  const g6 = g5.map((v, i) => v + k5[i]);
12007
12139
  const f6 = _fArr(f, t + h, g6);
12008
- const k6 = _luSolve(
12009
- E,
12140
+ const k6 = solveE(
12010
12141
  f6.map(
12011
12142
  (v, i) => v + (RODAS.C61 * k1[i] + RODAS.C62 * k2[i] + RODAS.C63 * k3[i] + RODAS.C64 * k4[i] + RODAS.C65 * k5[i]) / h
12012
12143
  )
@@ -12347,7 +12478,17 @@ var createSolveODE = /* @__PURE__ */ factory(
12347
12478
  if (method.toUpperCase() in methods) {
12348
12479
  const methodOptions = { ...opt };
12349
12480
  delete methodOptions.method;
12350
- return methods[method.toUpperCase()](f, tspan, y0, methodOptions);
12481
+ const sol = methods[method.toUpperCase()](
12482
+ f,
12483
+ tspan,
12484
+ y0,
12485
+ methodOptions
12486
+ );
12487
+ if (opt.events !== void 0) {
12488
+ const dir = tspan[1] >= tspan[0] ? 1 : -1;
12489
+ return _applyEvents(f, sol, opt.events, dir);
12490
+ }
12491
+ return sol;
12351
12492
  } else {
12352
12493
  const methodsWithQuotes = Object.keys(methods).map((x) => `"${x}"`);
12353
12494
  const availableMethodsString = `${methodsWithQuotes.slice(0, -1).join(", ")} and ${methodsWithQuotes.slice(-1)}`;
@@ -12371,28 +12512,46 @@ var createSolveODE = /* @__PURE__ */ factory(
12371
12512
  }
12372
12513
  function _matrixSolveODE(f, T, y0, options) {
12373
12514
  const sol = _solveODE(f, T.toArray(), y0.toArray(), options);
12374
- return { t: matrix2(sol.t), y: matrix2(sol.y) };
12515
+ const out = {
12516
+ t: matrix2(sol.t),
12517
+ y: matrix2(sol.y)
12518
+ };
12519
+ if (sol.tEvents) {
12520
+ out.tEvents = sol.tEvents;
12521
+ out.yEvents = sol.yEvents;
12522
+ }
12523
+ return out;
12524
+ }
12525
+ function _unwrapScalarSol(sol) {
12526
+ const out = { t: sol.t, y: sol.y.map((Y) => Y[0]) };
12527
+ if (sol.tEvents) {
12528
+ out.tEvents = sol.tEvents;
12529
+ out.yEvents = sol.yEvents?.map((list) => list.map((Y) => Y[0]));
12530
+ }
12531
+ return out;
12375
12532
  }
12376
12533
  return typed3("solveODE", {
12377
12534
  "function, Array, Array, Object": _solveODE,
12378
12535
  "function, Matrix, Matrix, Object": _matrixSolveODE,
12379
12536
  "function, Array, Array": (f, T, y0) => _solveODE(f, T, y0, {}),
12380
12537
  "function, Matrix, Matrix": (f, T, y0) => _matrixSolveODE(f, T, y0, {}),
12381
- "function, Array, number | BigNumber | Unit": (f, T, y0) => {
12382
- const sol = _solveODE(f, T, [y0], {});
12383
- return { t: sol.t, y: sol.y.map((Y) => Y[0]) };
12384
- },
12538
+ "function, Array, number | BigNumber | Unit": (f, T, y0) => _unwrapScalarSol(_solveODE(f, T, [y0], {})),
12385
12539
  "function, Matrix, number | BigNumber | Unit": (f, T, y0) => {
12386
12540
  const sol = _solveODE(f, T.toArray(), [y0], {});
12387
12541
  return { t: matrix2(sol.t), y: matrix2(sol.y.map((Y) => Y[0])) };
12388
12542
  },
12389
- "function, Array, number | BigNumber | Unit, Object": (f, T, y0, options) => {
12390
- const sol = _solveODE(f, T, [y0], options);
12391
- return { t: sol.t, y: sol.y.map((Y) => Y[0]) };
12392
- },
12543
+ "function, Array, number | BigNumber | Unit, Object": (f, T, y0, options) => _unwrapScalarSol(_solveODE(f, T, [y0], options)),
12393
12544
  "function, Matrix, number | BigNumber | Unit, Object": (f, T, y0, options) => {
12394
12545
  const sol = _solveODE(f, T.toArray(), [y0], options);
12395
- return { t: matrix2(sol.t), y: matrix2(sol.y.map((Y) => Y[0])) };
12546
+ const out = {
12547
+ t: matrix2(sol.t),
12548
+ y: matrix2(sol.y.map((Y) => Y[0]))
12549
+ };
12550
+ if (sol.tEvents) {
12551
+ out.tEvents = sol.tEvents;
12552
+ out.yEvents = sol.yEvents?.map((list) => list.map((Y) => Y[0]));
12553
+ }
12554
+ return out;
12396
12555
  }
12397
12556
  });
12398
12557
  }
@@ -17345,7 +17504,7 @@ import {
17345
17504
  matrixExpm as matrixExpmPrimitive,
17346
17505
  matrixLogm as matrixLogmPrimitive,
17347
17506
  matrixSqrtm as matrixSqrtmPrimitive,
17348
- DenseMatrix as DenseMatrix3
17507
+ DenseMatrix as DenseMatrix4
17349
17508
  } from "@danielsimonjr/mathts-matrix";
17350
17509
  import { mathTyped as mathTyped13 } from "@danielsimonjr/mathts-core";
17351
17510
  import { computePool as computePool11 } from "@danielsimonjr/mathts-parallel";
@@ -17494,7 +17653,7 @@ function cholesky(A) {
17494
17653
  }
17495
17654
  }
17496
17655
  }
17497
- const { L } = matrixCholesky(DenseMatrix3.fromArray(A));
17656
+ const { L } = matrixCholesky(DenseMatrix4.fromArray(A));
17498
17657
  return { L: L.toArray() };
17499
17658
  }
17500
17659
  function hessenbergForm(A) {
@@ -17965,8 +18124,8 @@ var pinv = mathTyped13("pinv", {
17965
18124
  "DenseMatrix, Object": (A, opts) => matrixPinv(A, opts),
17966
18125
  // Array in → Array out (mathjs convention). Previously `pinv([[...]])` threw
17967
18126
  // "expected DenseMatrix, actual Array" — the common call form was unsupported.
17968
- Array: (A) => matrixPinv(DenseMatrix3.fromArray(A)).toArray(),
17969
- "Array, Object": (A, opts) => matrixPinv(DenseMatrix3.fromArray(A), opts).toArray()
18127
+ Array: (A) => matrixPinv(DenseMatrix4.fromArray(A)).toArray(),
18128
+ "Array, Object": (A, opts) => matrixPinv(DenseMatrix4.fromArray(A), opts).toArray()
17970
18129
  });
17971
18130
  var cond = mathTyped13("cond", {
17972
18131
  Array: (A) => matrixCond(A)
@@ -17987,7 +18146,7 @@ var matrixExpm = mathTyped13("matrixExpm", {
17987
18146
  DenseMatrix: (A) => matrixExpmPrimitive(A),
17988
18147
  "DenseMatrix, Object": (A, _opts) => matrixExpmPrimitive(A),
17989
18148
  Array: (A) => {
17990
- const D = DenseMatrix3.fromArray(A);
18149
+ const D = DenseMatrix4.fromArray(A);
17991
18150
  return matrixExpmPrimitive(D).toArray();
17992
18151
  }
17993
18152
  });
@@ -17995,7 +18154,7 @@ var matrixLogm = mathTyped13("matrixLogm", {
17995
18154
  DenseMatrix: (A) => matrixLogmPrimitive(A),
17996
18155
  "DenseMatrix, Object": (A, opts) => matrixLogmPrimitive(A, opts),
17997
18156
  Array: (A) => {
17998
- const D = DenseMatrix3.fromArray(A);
18157
+ const D = DenseMatrix4.fromArray(A);
17999
18158
  return matrixLogmPrimitive(D).toArray();
18000
18159
  }
18001
18160
  });
@@ -18003,7 +18162,7 @@ var matrixSqrtm = mathTyped13("matrixSqrtm", {
18003
18162
  DenseMatrix: (A) => matrixSqrtmPrimitive(A),
18004
18163
  "DenseMatrix, Object": (A, opts) => matrixSqrtmPrimitive(A, opts),
18005
18164
  Array: (A) => {
18006
- const D = DenseMatrix3.fromArray(A);
18165
+ const D = DenseMatrix4.fromArray(A);
18007
18166
  return matrixSqrtmPrimitive(D).toArray();
18008
18167
  }
18009
18168
  });
@@ -22452,7 +22611,7 @@ var dependencies86 = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "
22452
22611
  var createIdentity = /* @__PURE__ */ factory(
22453
22612
  name86,
22454
22613
  dependencies86,
22455
- ({ typed: typed3, config: config2, matrix: matrix2, BigNumber: BigNumber9, DenseMatrix: DenseMatrix6, SparseMatrix }) => {
22614
+ ({ typed: typed3, config: config2, matrix: matrix2, BigNumber: BigNumber9, DenseMatrix: DenseMatrix7, SparseMatrix }) => {
22456
22615
  return typed3(name86, {
22457
22616
  "": function() {
22458
22617
  return config2.matrix === "Matrix" ? matrix2([]) : [];
@@ -22515,7 +22674,7 @@ var createIdentity = /* @__PURE__ */ factory(
22515
22674
  return SparseMatrix.diagonal(size2, one, 0, defaultValue);
22516
22675
  }
22517
22676
  if (format4 === "dense") {
22518
- return DenseMatrix6.diagonal(size2, one, 0, defaultValue);
22677
+ return DenseMatrix7.diagonal(size2, one, 0, defaultValue);
22519
22678
  }
22520
22679
  throw new TypeError(`Unknown matrix type "${format4}"`);
22521
22680
  }
@@ -22623,7 +22782,7 @@ var dependencies89 = ["typed", "matrix", "DenseMatrix", "SparseMatrix"];
22623
22782
  var createDiag = /* @__PURE__ */ factory(
22624
22783
  name89,
22625
22784
  dependencies89,
22626
- ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix6, SparseMatrix }) => {
22785
+ ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix7, SparseMatrix }) => {
22627
22786
  return typed3(name89, {
22628
22787
  // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments
22629
22788
  Array: function(x) {
@@ -22682,7 +22841,7 @@ var createDiag = /* @__PURE__ */ factory(
22682
22841
  if (format4 && format4 !== "sparse" && format4 !== "dense") {
22683
22842
  throw new TypeError(`Unknown matrix type ${format4}"`);
22684
22843
  }
22685
- const m = format4 === "sparse" ? SparseMatrix.diagonal(ms, x, k) : DenseMatrix6.diagonal(ms, x, k);
22844
+ const m = format4 === "sparse" ? SparseMatrix.diagonal(ms, x, k) : DenseMatrix7.diagonal(ms, x, k);
22686
22845
  return format4 !== null ? m : m.valueOf();
22687
22846
  }
22688
22847
  function _getDiagonal(x, k, format4, s, kSub, kSuper) {
@@ -23245,7 +23404,7 @@ var createDet = /* @__PURE__ */ factory(
23245
23404
  );
23246
23405
 
23247
23406
  // src/matrix/native-accel.ts
23248
- import { DenseMatrix as DenseMatrix4, lu, eig as eig2 } from "@danielsimonjr/mathts-matrix";
23407
+ import { DenseMatrix as DenseMatrix5, lu as lu2, eig as eig2 } from "@danielsimonjr/mathts-matrix";
23249
23408
  import { Complex as Complex8 } from "@danielsimonjr/mathts-core";
23250
23409
  var NATIVE_MATRIX_THRESHOLD = 8;
23251
23410
  function isLargeNumericSquare(a) {
@@ -23277,7 +23436,7 @@ var SINGULAR = /singular|zero pivot/i;
23277
23436
  function acceleratedDet(a, factoryDet2) {
23278
23437
  if (!isLargeNumericSquare(a)) return factoryDet2(a);
23279
23438
  try {
23280
- const { U, P: P2 } = lu(DenseMatrix4.fromArray(a));
23439
+ const { U, P: P2 } = lu2(DenseMatrix5.fromArray(a));
23281
23440
  const Ud = U.toArray();
23282
23441
  let d = permutationParity(P2);
23283
23442
  for (let i = 0; i < a.length; i++) d *= Ud[i][i];
@@ -23290,7 +23449,7 @@ function acceleratedDet(a, factoryDet2) {
23290
23449
  function acceleratedInv(a, factoryInv2) {
23291
23450
  if (!isLargeNumericSquare(a)) return factoryInv2(a);
23292
23451
  try {
23293
- const { L, U, P: P2 } = lu(DenseMatrix4.fromArray(a));
23452
+ const { L, U, P: P2 } = lu2(DenseMatrix5.fromArray(a));
23294
23453
  const Ld = L.toArray();
23295
23454
  const Ud = U.toArray();
23296
23455
  const n = a.length;
@@ -24253,7 +24412,7 @@ var createCsSymperm = /* @__PURE__ */ factory(
24253
24412
  );
24254
24413
 
24255
24414
  // src/algebra/solver/utils/solveValidation.ts
24256
- function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24415
+ function createSolveValidation({ DenseMatrix: DenseMatrix7 }) {
24257
24416
  return function solveValidation(m, b, copy) {
24258
24417
  const mSize = m.size();
24259
24418
  if (mSize.length !== 2) {
@@ -24276,7 +24435,7 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24276
24435
  for (let i = 0; i < rows; i++) {
24277
24436
  data[i] = [bdata[i]];
24278
24437
  }
24279
- return new DenseMatrix6({
24438
+ return new DenseMatrix7({
24280
24439
  data,
24281
24440
  size: [rows, 1],
24282
24441
  datatype: bm._datatype
@@ -24292,7 +24451,7 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24292
24451
  for (let i = 0; i < rows; i++) {
24293
24452
  data[i] = [bdata[i][0]];
24294
24453
  }
24295
- return new DenseMatrix6({
24454
+ return new DenseMatrix7({
24296
24455
  data,
24297
24456
  size: [rows, 1],
24298
24457
  datatype: bm._datatype
@@ -24311,7 +24470,7 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24311
24470
  const i = index[k];
24312
24471
  data[i][0] = values[k];
24313
24472
  }
24314
- return new DenseMatrix6({
24473
+ return new DenseMatrix7({
24315
24474
  data,
24316
24475
  size: [rows, 1],
24317
24476
  datatype: bm._datatype
@@ -24331,7 +24490,7 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24331
24490
  for (let i = 0; i < rows; i++) {
24332
24491
  data[i] = [b[i]];
24333
24492
  }
24334
- return new DenseMatrix6({
24493
+ return new DenseMatrix7({
24335
24494
  data,
24336
24495
  size: [rows, 1]
24337
24496
  });
@@ -24343,7 +24502,7 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
24343
24502
  for (let i = 0; i < rows; i++) {
24344
24503
  data[i] = [b[i][0]];
24345
24504
  }
24346
- return new DenseMatrix6({
24505
+ return new DenseMatrix7({
24347
24506
  data,
24348
24507
  size: [rows, 1]
24349
24508
  });
@@ -24413,10 +24572,10 @@ var createLsolve = /* @__PURE__ */ factory(
24413
24572
  multiplyScalar: multiplyScalar2,
24414
24573
  subtractScalar: subtractScalar2,
24415
24574
  equalScalar: equalScalar3,
24416
- DenseMatrix: DenseMatrix6
24575
+ DenseMatrix: DenseMatrix7
24417
24576
  }) => {
24418
24577
  const solveValidation = createSolveValidation({
24419
- DenseMatrix: DenseMatrix6
24578
+ DenseMatrix: DenseMatrix7
24420
24579
  });
24421
24580
  return typed3(name102, {
24422
24581
  "SparseMatrix, Array | Matrix": function(m, b) {
@@ -24454,7 +24613,7 @@ var createLsolve = /* @__PURE__ */ factory(
24454
24613
  for (let i = 0; i < rows; i++) {
24455
24614
  x2[i] = [resultAlloc.array[i]];
24456
24615
  }
24457
- return new DenseMatrix6({
24616
+ return new DenseMatrix7({
24458
24617
  data: x2,
24459
24618
  size: [rows, 1]
24460
24619
  });
@@ -24487,7 +24646,7 @@ var createLsolve = /* @__PURE__ */ factory(
24487
24646
  }
24488
24647
  x[j] = [xj];
24489
24648
  }
24490
- return new DenseMatrix6({
24649
+ return new DenseMatrix7({
24491
24650
  data: x,
24492
24651
  size: [rows, 1]
24493
24652
  });
@@ -24531,7 +24690,7 @@ var createLsolve = /* @__PURE__ */ factory(
24531
24690
  x[j] = [0];
24532
24691
  }
24533
24692
  }
24534
- return new DenseMatrix6({
24693
+ return new DenseMatrix7({
24535
24694
  data: x,
24536
24695
  size: [rows, 1]
24537
24696
  });
@@ -24560,10 +24719,10 @@ var createLsolveAll = /* @__PURE__ */ factory(
24560
24719
  multiplyScalar: multiplyScalar2,
24561
24720
  subtractScalar: subtractScalar2,
24562
24721
  equalScalar: equalScalar3,
24563
- DenseMatrix: DenseMatrix6
24722
+ DenseMatrix: DenseMatrix7
24564
24723
  }) => {
24565
24724
  const solveValidation = createSolveValidation({
24566
- DenseMatrix: DenseMatrix6
24725
+ DenseMatrix: DenseMatrix7
24567
24726
  });
24568
24727
  return typed3(name103, {
24569
24728
  "SparseMatrix, Array | Matrix": function(m, b) {
@@ -24613,7 +24772,7 @@ var createLsolveAll = /* @__PURE__ */ factory(
24613
24772
  }
24614
24773
  }
24615
24774
  return B.map(
24616
- (x) => new DenseMatrix6({
24775
+ (x) => new DenseMatrix7({
24617
24776
  data: x.map((e) => [e]),
24618
24777
  size: [rows, 1]
24619
24778
  })
@@ -24672,7 +24831,7 @@ var createLsolveAll = /* @__PURE__ */ factory(
24672
24831
  }
24673
24832
  }
24674
24833
  return B.map(
24675
- (x) => new DenseMatrix6({
24834
+ (x) => new DenseMatrix7({
24676
24835
  data: x.map((e) => [e]),
24677
24836
  size: [rows, 1]
24678
24837
  })
@@ -24738,10 +24897,10 @@ var createUsolve = /* @__PURE__ */ factory(
24738
24897
  multiplyScalar: multiplyScalar2,
24739
24898
  subtractScalar: subtractScalar2,
24740
24899
  equalScalar: equalScalar3,
24741
- DenseMatrix: DenseMatrix6
24900
+ DenseMatrix: DenseMatrix7
24742
24901
  }) => {
24743
24902
  const solveValidation = createSolveValidation({
24744
- DenseMatrix: DenseMatrix6
24903
+ DenseMatrix: DenseMatrix7
24745
24904
  });
24746
24905
  return typed3(name104, {
24747
24906
  "SparseMatrix, Array | Matrix": function(m, b) {
@@ -24779,7 +24938,7 @@ var createUsolve = /* @__PURE__ */ factory(
24779
24938
  for (let i = 0; i < rows; i++) {
24780
24939
  x2[i] = [resultAlloc.array[i]];
24781
24940
  }
24782
- return new DenseMatrix6({
24941
+ return new DenseMatrix7({
24783
24942
  data: x2,
24784
24943
  size: [rows, 1]
24785
24944
  });
@@ -24812,7 +24971,7 @@ var createUsolve = /* @__PURE__ */ factory(
24812
24971
  }
24813
24972
  x[j] = [xj];
24814
24973
  }
24815
- return new DenseMatrix6({
24974
+ return new DenseMatrix7({
24816
24975
  data: x,
24817
24976
  size: [rows, 1]
24818
24977
  });
@@ -24856,7 +25015,7 @@ var createUsolve = /* @__PURE__ */ factory(
24856
25015
  x[j] = [0];
24857
25016
  }
24858
25017
  }
24859
- return new DenseMatrix6({
25018
+ return new DenseMatrix7({
24860
25019
  data: x,
24861
25020
  size: [rows, 1]
24862
25021
  });
@@ -24885,10 +25044,10 @@ var createUsolveAll = /* @__PURE__ */ factory(
24885
25044
  multiplyScalar: multiplyScalar2,
24886
25045
  subtractScalar: subtractScalar2,
24887
25046
  equalScalar: equalScalar3,
24888
- DenseMatrix: DenseMatrix6
25047
+ DenseMatrix: DenseMatrix7
24889
25048
  }) => {
24890
25049
  const solveValidation = createSolveValidation({
24891
- DenseMatrix: DenseMatrix6
25050
+ DenseMatrix: DenseMatrix7
24892
25051
  });
24893
25052
  return typed3(name105, {
24894
25053
  "SparseMatrix, Array | Matrix": function(m, b) {
@@ -24938,7 +25097,7 @@ var createUsolveAll = /* @__PURE__ */ factory(
24938
25097
  }
24939
25098
  }
24940
25099
  return B.map(
24941
- (x) => new DenseMatrix6({
25100
+ (x) => new DenseMatrix7({
24942
25101
  data: x.map((e) => [e]),
24943
25102
  size: [rows, 1]
24944
25103
  })
@@ -24997,7 +25156,7 @@ var createUsolveAll = /* @__PURE__ */ factory(
24997
25156
  }
24998
25157
  }
24999
25158
  return B.map(
25000
- (x) => new DenseMatrix6({
25159
+ (x) => new DenseMatrix7({
25001
25160
  data: x.map((e) => [e]),
25002
25161
  size: [rows, 1]
25003
25162
  })
@@ -25221,7 +25380,7 @@ var dependencies109 = ["typed", "DenseMatrix"];
25221
25380
  var createMatAlgo12xSfs = /* @__PURE__ */ factory(
25222
25381
  name109,
25223
25382
  dependencies109,
25224
- ({ typed: typed3, DenseMatrix: DenseMatrix6 }) => {
25383
+ ({ typed: typed3, DenseMatrix: DenseMatrix7 }) => {
25225
25384
  return function matAlgo12xSfs(s, b, callback, inverse) {
25226
25385
  const avalues = s._values;
25227
25386
  const aindex = s._index;
@@ -25261,7 +25420,7 @@ var createMatAlgo12xSfs = /* @__PURE__ */ factory(
25261
25420
  }
25262
25421
  }
25263
25422
  }
25264
- return new DenseMatrix6({
25423
+ return new DenseMatrix7({
25265
25424
  data: cdata,
25266
25425
  size: [rows, columns],
25267
25426
  datatype: dt
@@ -25334,9 +25493,9 @@ var dependencies111 = [
25334
25493
  var createRound = /* @__PURE__ */ factory(
25335
25494
  name111,
25336
25495
  dependencies111,
25337
- ({ typed: typed3, config: config2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, BigNumber: BigNumber9, DenseMatrix: DenseMatrix6 }) => {
25496
+ ({ typed: typed3, config: config2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, BigNumber: BigNumber9, DenseMatrix: DenseMatrix7 }) => {
25338
25497
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
25339
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
25498
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
25340
25499
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
25341
25500
  function toExponent(epsilon) {
25342
25501
  return Math.abs(splitNumber(epsilon).exponent);
@@ -26751,13 +26910,13 @@ var createEqual = /* @__PURE__ */ factory(
26751
26910
  typed: typed3,
26752
26911
  matrix: matrix2,
26753
26912
  equalScalar: equalScalar3,
26754
- DenseMatrix: DenseMatrix6,
26913
+ DenseMatrix: DenseMatrix7,
26755
26914
  concat: _concat,
26756
26915
  SparseMatrix
26757
26916
  }) => {
26758
26917
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
26759
26918
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
26760
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
26919
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
26761
26920
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({ typed: typed3, matrix: matrix2 });
26762
26921
  return typed3(
26763
26922
  name125,
@@ -27123,7 +27282,7 @@ var createDotDivide = /* @__PURE__ */ factory(
27123
27282
  matrix: matrix2,
27124
27283
  equalScalar: equalScalar3,
27125
27284
  divideScalar: divideScalar2,
27126
- DenseMatrix: DenseMatrix6,
27285
+ DenseMatrix: DenseMatrix7,
27127
27286
  concat: concat3,
27128
27287
  SparseMatrix
27129
27288
  }) => {
@@ -27131,7 +27290,7 @@ var createDotDivide = /* @__PURE__ */ factory(
27131
27290
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
27132
27291
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
27133
27292
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
27134
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
27293
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
27135
27294
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
27136
27295
  typed: typed3,
27137
27296
  matrix: matrix2,
@@ -27300,9 +27459,9 @@ var createFloorNumber = /* @__PURE__ */ factory(
27300
27459
  var createFloor = /* @__PURE__ */ factory(
27301
27460
  name134,
27302
27461
  dependencies134,
27303
- ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6 }) => {
27462
+ ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7 }) => {
27304
27463
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
27305
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
27464
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
27306
27465
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
27307
27466
  const floorNumber = createFloorNumber({ typed: typed3, config: config2, round: round2 });
27308
27467
  function _bigFloor(x) {
@@ -27513,7 +27672,7 @@ var dependencies136 = [
27513
27672
  var createMod = /* @__PURE__ */ factory(
27514
27673
  name136,
27515
27674
  dependencies136,
27516
- ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
27675
+ ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
27517
27676
  const floor2 = createFloor({
27518
27677
  typed: typed3,
27519
27678
  config: config2,
@@ -27521,13 +27680,13 @@ var createMod = /* @__PURE__ */ factory(
27521
27680
  matrix: matrix2,
27522
27681
  equalScalar: equalScalar3,
27523
27682
  zeros: zeros4,
27524
- DenseMatrix: DenseMatrix6
27683
+ DenseMatrix: DenseMatrix7
27525
27684
  });
27526
27685
  const matAlgo02xDS0 = createMatAlgo02xDS0({ typed: typed3, equalScalar: equalScalar3 });
27527
27686
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
27528
27687
  const matAlgo05xSfSf = createMatAlgo05xSfSf({ typed: typed3, equalScalar: equalScalar3 });
27529
27688
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
27530
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
27689
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
27531
27690
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
27532
27691
  typed: typed3,
27533
27692
  matrix: matrix2,
@@ -27740,7 +27899,7 @@ var dependencies139 = ["typed", "DenseMatrix"];
27740
27899
  var createMatAlgo10xSids = /* @__PURE__ */ factory(
27741
27900
  name139,
27742
27901
  dependencies139,
27743
- ({ typed: typed3, DenseMatrix: DenseMatrix6 }) => {
27902
+ ({ typed: typed3, DenseMatrix: DenseMatrix7 }) => {
27744
27903
  return function matAlgo10xSids(s, b, callback, inverse) {
27745
27904
  const avalues = s._values;
27746
27905
  const aindex = s._index;
@@ -27780,7 +27939,7 @@ var createMatAlgo10xSids = /* @__PURE__ */ factory(
27780
27939
  }
27781
27940
  }
27782
27941
  }
27783
- return new DenseMatrix6({
27942
+ return new DenseMatrix7({
27784
27943
  data: cdata,
27785
27944
  size: [rows, columns],
27786
27945
  datatype: dt
@@ -27819,7 +27978,7 @@ var createGcd = /* @__PURE__ */ factory(
27819
27978
  equalScalar: equalScalar3,
27820
27979
  zeros: zeros4,
27821
27980
  BigNumber: BigNumber9,
27822
- DenseMatrix: DenseMatrix6,
27981
+ DenseMatrix: DenseMatrix7,
27823
27982
  concat: concat3
27824
27983
  }) => {
27825
27984
  const mod3 = createMod({
@@ -27829,12 +27988,12 @@ var createGcd = /* @__PURE__ */ factory(
27829
27988
  matrix: matrix2,
27830
27989
  equalScalar: equalScalar3,
27831
27990
  zeros: zeros4,
27832
- DenseMatrix: DenseMatrix6,
27991
+ DenseMatrix: DenseMatrix7,
27833
27992
  concat: concat3
27834
27993
  });
27835
27994
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
27836
27995
  const matAlgo04xSidSid = createMatAlgo04xSidSid({ typed: typed3, equalScalar: equalScalar3 });
27837
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
27996
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
27838
27997
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
27839
27998
  typed: typed3,
27840
27999
  matrix: matrix2,
@@ -28401,9 +28560,9 @@ var createCeilNumber = /* @__PURE__ */ factory(
28401
28560
  var createCeil = /* @__PURE__ */ factory(
28402
28561
  name146,
28403
28562
  dependencies146,
28404
- ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6 }) => {
28563
+ ({ typed: typed3, config: config2, round: round2, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7 }) => {
28405
28564
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
28406
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
28565
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
28407
28566
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
28408
28567
  const ceilNumber = createCeilNumber({ typed: typed3, config: config2, round: round2 });
28409
28568
  function _bigCeil(x) {
@@ -28537,10 +28696,10 @@ var dependencies148 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"
28537
28696
  var createBitOr = /* @__PURE__ */ factory(
28538
28697
  name148,
28539
28698
  dependencies148,
28540
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
28699
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
28541
28700
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
28542
28701
  const matAlgo04xSidSid = createMatAlgo04xSidSid({ typed: typed3, equalScalar: equalScalar3 });
28543
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
28702
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
28544
28703
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
28545
28704
  typed: typed3,
28546
28705
  matrix: matrix2,
@@ -28568,10 +28727,10 @@ var dependencies149 = ["typed", "matrix", "DenseMatrix", "concat", "SparseMatrix
28568
28727
  var createBitXor = /* @__PURE__ */ factory(
28569
28728
  name149,
28570
28729
  dependencies149,
28571
- ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix6, concat: concat3, SparseMatrix }) => {
28730
+ ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix7, concat: concat3, SparseMatrix }) => {
28572
28731
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
28573
28732
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
28574
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
28733
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
28575
28734
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
28576
28735
  typed: typed3,
28577
28736
  matrix: matrix2,
@@ -28712,11 +28871,11 @@ var dependencies151 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix",
28712
28871
  var createLeftShift = /* @__PURE__ */ factory(
28713
28872
  name151,
28714
28873
  dependencies151,
28715
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
28874
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
28716
28875
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
28717
28876
  const matAlgo02xDS0 = createMatAlgo02xDS0({ typed: typed3, equalScalar: equalScalar3 });
28718
28877
  const matAlgo08xS0Sid = createMatAlgo08xS0Sid({ typed: typed3, equalScalar: equalScalar3 });
28719
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
28878
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
28720
28879
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
28721
28880
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
28722
28881
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
@@ -28783,11 +28942,11 @@ var dependencies152 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix",
28783
28942
  var createRightArithShift = /* @__PURE__ */ factory(
28784
28943
  name152,
28785
28944
  dependencies152,
28786
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
28945
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
28787
28946
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
28788
28947
  const matAlgo02xDS0 = createMatAlgo02xDS0({ typed: typed3, equalScalar: equalScalar3 });
28789
28948
  const matAlgo08xS0Sid = createMatAlgo08xS0Sid({ typed: typed3, equalScalar: equalScalar3 });
28790
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
28949
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
28791
28950
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
28792
28951
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
28793
28952
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
@@ -28854,11 +29013,11 @@ var dependencies153 = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix",
28854
29013
  var createRightLogShift = /* @__PURE__ */ factory(
28855
29014
  name153,
28856
29015
  dependencies153,
28857
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
29016
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
28858
29017
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
28859
29018
  const matAlgo02xDS0 = createMatAlgo02xDS0({ typed: typed3, equalScalar: equalScalar3 });
28860
29019
  const matAlgo08xS0Sid = createMatAlgo08xS0Sid({ typed: typed3, equalScalar: equalScalar3 });
28861
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
29020
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
28862
29021
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
28863
29022
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
28864
29023
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
@@ -28924,10 +29083,10 @@ var dependencies154 = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"
28924
29083
  var createOr = /* @__PURE__ */ factory(
28925
29084
  name154,
28926
29085
  dependencies154,
28927
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
29086
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
28928
29087
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
28929
29088
  const matAlgo05xSfSf = createMatAlgo05xSfSf({ typed: typed3, equalScalar: equalScalar3 });
28930
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29089
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
28931
29090
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
28932
29091
  typed: typed3,
28933
29092
  matrix: matrix2,
@@ -28963,10 +29122,10 @@ var dependencies155 = ["typed", "matrix", "DenseMatrix", "concat", "SparseMatrix
28963
29122
  var createXor = /* @__PURE__ */ factory(
28964
29123
  name155,
28965
29124
  dependencies155,
28966
- ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix6, concat: concat3, SparseMatrix }) => {
29125
+ ({ typed: typed3, matrix: matrix2, DenseMatrix: DenseMatrix7, concat: concat3, SparseMatrix }) => {
28967
29126
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
28968
29127
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
28969
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29128
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
28970
29129
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
28971
29130
  typed: typed3,
28972
29131
  matrix: matrix2,
@@ -29018,12 +29177,12 @@ var createCompare = /* @__PURE__ */ factory(
29018
29177
  matrix: matrix2,
29019
29178
  BigNumber: BigNumber9,
29020
29179
  Fraction: Fraction5,
29021
- DenseMatrix: DenseMatrix6,
29180
+ DenseMatrix: DenseMatrix7,
29022
29181
  concat: concat3
29023
29182
  }) => {
29024
29183
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29025
29184
  const matAlgo05xSfSf = createMatAlgo05xSfSf({ typed: typed3, equalScalar: equalScalar3 });
29026
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29185
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29027
29186
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29028
29187
  typed: typed3,
29029
29188
  matrix: matrix2,
@@ -29149,10 +29308,10 @@ var dependencies159 = [
29149
29308
  var createLarger = /* @__PURE__ */ factory(
29150
29309
  name159,
29151
29310
  dependencies159,
29152
- ({ typed: typed3, config: config2, bignumber: bignumber2, matrix: matrix2, DenseMatrix: DenseMatrix6, concat: concat3, SparseMatrix }) => {
29311
+ ({ typed: typed3, config: config2, bignumber: bignumber2, matrix: matrix2, DenseMatrix: DenseMatrix7, concat: concat3, SparseMatrix }) => {
29153
29312
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29154
29313
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29155
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29314
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29156
29315
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29157
29316
  typed: typed3,
29158
29317
  matrix: matrix2,
@@ -29207,10 +29366,10 @@ var dependencies160 = ["typed", "config", "matrix", "DenseMatrix", "concat", "Sp
29207
29366
  var createLargerEq = /* @__PURE__ */ factory(
29208
29367
  name160,
29209
29368
  dependencies160,
29210
- ({ typed: typed3, config: config2, matrix: matrix2, DenseMatrix: DenseMatrix6, concat: concat3, SparseMatrix }) => {
29369
+ ({ typed: typed3, config: config2, matrix: matrix2, DenseMatrix: DenseMatrix7, concat: concat3, SparseMatrix }) => {
29211
29370
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29212
29371
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29213
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29372
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29214
29373
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29215
29374
  typed: typed3,
29216
29375
  matrix: matrix2,
@@ -29273,13 +29432,13 @@ var createSmaller = /* @__PURE__ */ factory(
29273
29432
  config: config2,
29274
29433
  bignumber: bignumber2,
29275
29434
  matrix: matrix2,
29276
- DenseMatrix: DenseMatrix6,
29435
+ DenseMatrix: DenseMatrix7,
29277
29436
  concat: concat3,
29278
29437
  SparseMatrix
29279
29438
  }) => {
29280
29439
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29281
29440
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29282
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29441
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29283
29442
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29284
29443
  typed: typed3,
29285
29444
  matrix: matrix2,
@@ -29334,10 +29493,10 @@ var dependencies162 = ["typed", "config", "matrix", "DenseMatrix", "concat", "Sp
29334
29493
  var createSmallerEq = /* @__PURE__ */ factory(
29335
29494
  name162,
29336
29495
  dependencies162,
29337
- ({ typed: typed3, config: config2, matrix: matrix2, DenseMatrix: DenseMatrix6, concat: concat3, SparseMatrix }) => {
29496
+ ({ typed: typed3, config: config2, matrix: matrix2, DenseMatrix: DenseMatrix7, concat: concat3, SparseMatrix }) => {
29338
29497
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29339
29498
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29340
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29499
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29341
29500
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29342
29501
  typed: typed3,
29343
29502
  matrix: matrix2,
@@ -29398,13 +29557,13 @@ var createUnequal = /* @__PURE__ */ factory(
29398
29557
  config: _config,
29399
29558
  equalScalar: equalScalar3,
29400
29559
  matrix: matrix2,
29401
- DenseMatrix: DenseMatrix6,
29560
+ DenseMatrix: DenseMatrix7,
29402
29561
  concat: concat3,
29403
29562
  SparseMatrix
29404
29563
  }) => {
29405
29564
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29406
29565
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29407
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29566
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29408
29567
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29409
29568
  typed: typed3,
29410
29569
  matrix: matrix2,
@@ -29455,12 +29614,12 @@ var dependencies164 = ["typed", "matrix", "equalScalar", "BigNumber", "DenseMatr
29455
29614
  var createAtan2 = /* @__PURE__ */ factory(
29456
29615
  name164,
29457
29616
  dependencies164,
29458
- ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, BigNumber: BigNumber9, DenseMatrix: DenseMatrix6, concat: concat3 }) => {
29617
+ ({ typed: typed3, matrix: matrix2, equalScalar: equalScalar3, BigNumber: BigNumber9, DenseMatrix: DenseMatrix7, concat: concat3 }) => {
29459
29618
  const matAlgo02xDS0 = createMatAlgo02xDS0({ typed: typed3, equalScalar: equalScalar3 });
29460
29619
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29461
29620
  const matAlgo09xS0Sf = createMatAlgo09xS0Sf({ typed: typed3, equalScalar: equalScalar3 });
29462
29621
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
29463
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29622
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29464
29623
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29465
29624
  typed: typed3,
29466
29625
  matrix: matrix2,
@@ -29529,14 +29688,14 @@ var createDotPow = /* @__PURE__ */ factory(
29529
29688
  equalScalar: equalScalar3,
29530
29689
  matrix: matrix2,
29531
29690
  pow: pow2,
29532
- DenseMatrix: DenseMatrix6,
29691
+ DenseMatrix: DenseMatrix7,
29533
29692
  concat: concat3,
29534
29693
  SparseMatrix
29535
29694
  }) => {
29536
29695
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
29537
29696
  const matAlgo07xSSf = createMatAlgo07xSSf({ typed: typed3, SparseMatrix });
29538
29697
  const matAlgo11xS0s = createMatAlgo11xS0s({ typed: typed3, equalScalar: equalScalar3 });
29539
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29698
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29540
29699
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
29541
29700
  typed: typed3,
29542
29701
  matrix: matrix2,
@@ -29593,8 +29752,8 @@ var createFixNumber = /* @__PURE__ */ factory(
29593
29752
  var createFix = /* @__PURE__ */ factory(
29594
29753
  name167,
29595
29754
  dependencies167,
29596
- ({ typed: typed3, Complex: Complex13, matrix: matrix2, ceil: ceil2, floor: floor2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix6 }) => {
29597
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
29755
+ ({ typed: typed3, Complex: Complex13, matrix: matrix2, ceil: ceil2, floor: floor2, equalScalar: equalScalar3, zeros: zeros4, DenseMatrix: DenseMatrix7 }) => {
29756
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
29598
29757
  const matAlgo14xDs = createMatAlgo14xDs({ typed: typed3 });
29599
29758
  const fixNumber = createFixNumber({ typed: typed3, ceil: ceil2, floor: floor2 });
29600
29759
  return typed3("fix", {
@@ -32758,15 +32917,15 @@ var createSubtract = /* @__PURE__ */ factory(
32758
32917
  equalScalar: equalScalar3,
32759
32918
  subtractScalar: subtractScalar2,
32760
32919
  unaryMinus: _unaryMinus,
32761
- DenseMatrix: DenseMatrix6,
32920
+ DenseMatrix: DenseMatrix7,
32762
32921
  concat: concat3,
32763
32922
  nodeOperations: nodeOperations2
32764
32923
  }) => {
32765
32924
  const matAlgo01xDSid = createMatAlgo01xDSid({ typed: typed3 });
32766
32925
  const matAlgo03xDSf = createMatAlgo03xDSf({ typed: typed3 });
32767
32926
  const matAlgo05xSfSf = createMatAlgo05xSfSf({ typed: typed3, equalScalar: equalScalar3 });
32768
- const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix6 });
32769
- const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix6 });
32927
+ const matAlgo10xSids = createMatAlgo10xSids({ typed: typed3, DenseMatrix: DenseMatrix7 });
32928
+ const matAlgo12xSfs = createMatAlgo12xSfs({ typed: typed3, DenseMatrix: DenseMatrix7 });
32770
32929
  const matrixAlgorithmSuite = createMatrixAlgorithmSuite({
32771
32930
  typed: typed3,
32772
32931
  matrix: matrix2,
@@ -33572,8 +33731,8 @@ var dependencies206 = ["smaller", "DenseMatrix"];
33572
33731
  var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33573
33732
  name206,
33574
33733
  dependencies206,
33575
- ({ smaller: smaller2, DenseMatrix: DenseMatrix6 }) => {
33576
- class ImmutableDenseMatrix extends DenseMatrix6 {
33734
+ ({ smaller: smaller2, DenseMatrix: DenseMatrix7 }) => {
33735
+ class ImmutableDenseMatrix extends DenseMatrix7 {
33577
33736
  /**
33578
33737
  * Type identifier
33579
33738
  */
@@ -33613,7 +33772,7 @@ var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33613
33772
  throw new Error("Invalid datatype: " + datatype);
33614
33773
  }
33615
33774
  if (isMatrix(data) || isArray(data)) {
33616
- const matrix2 = new DenseMatrix6(data, datatype);
33775
+ const matrix2 = new DenseMatrix7(data, datatype);
33617
33776
  this._data = matrix2._data;
33618
33777
  this._size = matrix2._size;
33619
33778
  this._datatype = matrix2._datatype;
@@ -33652,7 +33811,7 @@ var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33652
33811
  subset(index, _replacement, _defaultValue) {
33653
33812
  switch (arguments.length) {
33654
33813
  case 1: {
33655
- const m = DenseMatrix6.prototype.subset.call(this, index);
33814
+ const m = DenseMatrix7.prototype.subset.call(this, index);
33656
33815
  if (isMatrix(m)) {
33657
33816
  const mm = m;
33658
33817
  return new ImmutableDenseMatrix({
@@ -33764,7 +33923,7 @@ var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33764
33923
  if (this._min === null) {
33765
33924
  let m = null;
33766
33925
  const smallerFn = smaller2;
33767
- DenseMatrix6.prototype.forEach.call(this, function(v) {
33926
+ DenseMatrix7.prototype.forEach.call(this, function(v) {
33768
33927
  if (m === null || smallerFn(v, m)) {
33769
33928
  m = v;
33770
33929
  }
@@ -33781,7 +33940,7 @@ var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33781
33940
  if (this._max === null) {
33782
33941
  let m = null;
33783
33942
  const smallerFn = smaller2;
33784
- DenseMatrix6.prototype.forEach.call(this, function(v) {
33943
+ DenseMatrix7.prototype.forEach.call(this, function(v) {
33785
33944
  if (m === null || smallerFn(m, v)) {
33786
33945
  m = v;
33787
33946
  }
@@ -33791,7 +33950,7 @@ var createImmutableDenseMatrixClass = /* @__PURE__ */ factory(
33791
33950
  return this._max ?? void 0;
33792
33951
  }
33793
33952
  }
33794
- Object.setPrototypeOf(ImmutableDenseMatrix.prototype, DenseMatrix6.prototype);
33953
+ Object.setPrototypeOf(ImmutableDenseMatrix.prototype, DenseMatrix7.prototype);
33795
33954
  const proto = ImmutableDenseMatrix.prototype;
33796
33955
  proto.constructor = ImmutableDenseMatrix;
33797
33956
  proto.type = "ImmutableDenseMatrix";
@@ -34171,7 +34330,7 @@ var createLup = /* @__PURE__ */ factory(
34171
34330
  larger: larger2,
34172
34331
  equalScalar: equalScalar3,
34173
34332
  unaryMinus: unaryMinus2,
34174
- DenseMatrix: DenseMatrix6,
34333
+ DenseMatrix: DenseMatrix7,
34175
34334
  SparseMatrix,
34176
34335
  Spa
34177
34336
  }) => {
@@ -34230,11 +34389,11 @@ var createLup = /* @__PURE__ */ factory(
34230
34389
  for (let i2 = 0; i2 < rows; i2++) {
34231
34390
  p2[i2] = permAlloc.array[i2];
34232
34391
  }
34233
- const l2 = new DenseMatrix6({
34392
+ const l2 = new DenseMatrix7({
34234
34393
  data: ldata2,
34235
34394
  size: [rows, n]
34236
34395
  });
34237
- const u2 = new DenseMatrix6({
34396
+ const u2 = new DenseMatrix7({
34238
34397
  data: udata2,
34239
34398
  size: [n, columns]
34240
34399
  });
@@ -34291,7 +34450,7 @@ var createLup = /* @__PURE__ */ factory(
34291
34450
  }
34292
34451
  if (j !== pi) {
34293
34452
  p[j] = [p[pi], p[pi] = p[j]][0];
34294
- DenseMatrix6._swapRows(j, pi, data);
34453
+ DenseMatrix7._swapRows(j, pi, data);
34295
34454
  }
34296
34455
  if (j < rows) {
34297
34456
  for (i = j + 1; i < rows; i++) {
@@ -34336,11 +34495,11 @@ var createLup = /* @__PURE__ */ factory(
34336
34495
  }
34337
34496
  }
34338
34497
  }
34339
- const l = new DenseMatrix6({
34498
+ const l = new DenseMatrix7({
34340
34499
  data: ldata,
34341
34500
  size: lsize
34342
34501
  });
34343
- const u = new DenseMatrix6({
34502
+ const u = new DenseMatrix7({
34344
34503
  data: udata,
34345
34504
  size: usize
34346
34505
  });
@@ -35914,7 +36073,7 @@ var dependencies226 = ["typed", "size", "subset", "compareNatural", "Index", "De
35914
36073
  var createSetCartesian = /* @__PURE__ */ factory(
35915
36074
  name226,
35916
36075
  dependencies226,
35917
- ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
36076
+ ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix7 }) => {
35918
36077
  return typed3(name226, {
35919
36078
  "Array | Matrix, Array | Matrix": function(a1, a2) {
35920
36079
  let result = [];
@@ -35931,7 +36090,7 @@ var createSetCartesian = /* @__PURE__ */ factory(
35931
36090
  if (Array.isArray(a1) && Array.isArray(a2)) {
35932
36091
  return result;
35933
36092
  }
35934
- return new DenseMatrix6(result);
36093
+ return new DenseMatrix7(result);
35935
36094
  }
35936
36095
  });
35937
36096
  }
@@ -35943,7 +36102,7 @@ var dependencies227 = ["typed", "size", "subset", "compareNatural", "Index", "De
35943
36102
  var createSetDifference = /* @__PURE__ */ factory(
35944
36103
  name227,
35945
36104
  dependencies227,
35946
- ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
36105
+ ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix7 }) => {
35947
36106
  return typed3(name227, {
35948
36107
  "Array | Matrix, Array | Matrix": function(a1, a2) {
35949
36108
  let result;
@@ -35972,7 +36131,7 @@ var createSetDifference = /* @__PURE__ */ factory(
35972
36131
  if (Array.isArray(a1) && Array.isArray(a2)) {
35973
36132
  return generalize(result);
35974
36133
  }
35975
- return new DenseMatrix6(generalize(result));
36134
+ return new DenseMatrix7(generalize(result));
35976
36135
  }
35977
36136
  });
35978
36137
  }
@@ -35984,7 +36143,7 @@ var dependencies228 = ["typed", "size", "subset", "compareNatural", "Index", "De
35984
36143
  var createSetDistinct = /* @__PURE__ */ factory(
35985
36144
  name228,
35986
36145
  dependencies228,
35987
- ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
36146
+ ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix7 }) => {
35988
36147
  return typed3(name228, {
35989
36148
  "Array | Matrix": function(a) {
35990
36149
  let result;
@@ -36003,7 +36162,7 @@ var createSetDistinct = /* @__PURE__ */ factory(
36003
36162
  if (Array.isArray(a)) {
36004
36163
  return result;
36005
36164
  }
36006
- return new DenseMatrix6(result);
36165
+ return new DenseMatrix7(result);
36007
36166
  }
36008
36167
  });
36009
36168
  }
@@ -36015,7 +36174,7 @@ var dependencies229 = ["typed", "size", "subset", "compareNatural", "Index", "De
36015
36174
  var createSetIntersect = /* @__PURE__ */ factory(
36016
36175
  name229,
36017
36176
  dependencies229,
36018
- ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
36177
+ ({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix7 }) => {
36019
36178
  return typed3(name229, {
36020
36179
  "Array | Matrix, Array | Matrix": function(a1, a2) {
36021
36180
  let result;
@@ -36037,7 +36196,7 @@ var createSetIntersect = /* @__PURE__ */ factory(
36037
36196
  if (Array.isArray(a1) && Array.isArray(a2)) {
36038
36197
  return generalize(result);
36039
36198
  }
36040
- return new DenseMatrix6(generalize(result));
36199
+ return new DenseMatrix7(generalize(result));
36041
36200
  }
36042
36201
  });
36043
36202
  }
@@ -38110,9 +38269,9 @@ var dependencies238 = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "Den
38110
38269
  var createLusolve = /* @__PURE__ */ factory(
38111
38270
  name238,
38112
38271
  dependencies238,
38113
- ({ typed: typed3, matrix: matrix2, lup: lup2, slu: slu2, usolve: usolve2, lsolve: lsolve2, DenseMatrix: DenseMatrix6 }) => {
38272
+ ({ typed: typed3, matrix: matrix2, lup: lup2, slu: slu2, usolve: usolve2, lsolve: lsolve2, DenseMatrix: DenseMatrix7 }) => {
38114
38273
  const solveValidation = createSolveValidation({
38115
- DenseMatrix: DenseMatrix6
38274
+ DenseMatrix: DenseMatrix7
38116
38275
  });
38117
38276
  return typed3(name238, {
38118
38277
  "Array, Array | Matrix": function(a, b) {
@@ -38195,7 +38354,7 @@ var createLusolve = /* @__PURE__ */ factory(
38195
38354
  for (let i = 0; i < rows; i++) {
38196
38355
  x[i] = [resultAlloc.array[i]];
38197
38356
  }
38198
- return new DenseMatrix6({
38357
+ return new DenseMatrix7({
38199
38358
  data: x,
38200
38359
  size: [rows, 1]
38201
38360
  });
@@ -40641,7 +40800,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
40641
40800
  norm: norm4,
40642
40801
  BigNumber: BigNumber9,
40643
40802
  matrix: matrix2,
40644
- DenseMatrix: DenseMatrix6,
40803
+ DenseMatrix: DenseMatrix7,
40645
40804
  SparseMatrix,
40646
40805
  cos: cos2,
40647
40806
  sin: sin2
@@ -40705,7 +40864,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
40705
40864
  return new SparseMatrix(data);
40706
40865
  }
40707
40866
  if (format4 === "dense") {
40708
- return new DenseMatrix6(data);
40867
+ return new DenseMatrix7(data);
40709
40868
  }
40710
40869
  throw new TypeError(`Unknown matrix type "${format4}"`);
40711
40870
  }
@@ -44931,54 +45090,15 @@ function tukeyHSD(groups, alpha = 0.05) {
44931
45090
  }
44932
45091
 
44933
45092
  // src/linalg-extra.ts
44934
- import { DenseMatrix as DenseMatrix5, lu as lu2 } from "@danielsimonjr/mathts-matrix";
45093
+ import { DenseMatrix as DenseMatrix6, lu as lu3, matrixSchur as matrixSchur2 } from "@danielsimonjr/mathts-matrix";
44935
45094
  var _inv = inv;
44936
45095
  var _eigs = eigs;
44937
45096
  var _multiply = multiply;
44938
45097
  var _qr = qr;
44939
45098
  var transposeArr = (A) => A[0].map((_, j) => A.map((r) => r[j]));
44940
- var identityArr = (n) => Array.from({ length: n }, (_, i) => Array.from({ length: n }, (_2, j) => i === j ? 1 : 0));
44941
45099
  function realSchur(M) {
44942
- const n = M.length;
44943
- let A = M.map((r) => r.slice());
44944
- let U = identityArr(n);
44945
- let m = n;
44946
- const normM = Math.max(...M.map((r) => r.reduce((s, v) => s + Math.abs(v), 0)), 1e-300);
44947
- for (let iter = 0; iter < 8e3 && m > 1; iter++) {
44948
- 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)) {
44949
- A[m - 1][m - 2] = 0;
44950
- m--;
44951
- continue;
44952
- }
44953
- const a = A[m - 2][m - 2];
44954
- const b = A[m - 2][m - 1];
44955
- const c = A[m - 1][m - 2];
44956
- const d = A[m - 1][m - 1];
44957
- const delta = (a - d) / 2;
44958
- const disc = delta * delta + b * c;
44959
- if (disc < 0) {
44960
- if (m === 2) break;
44961
- if (Math.abs(A[m - 2][m - 3]) < 1e-14 * (Math.abs(A[m - 3][m - 3]) + Math.abs(a) || normM)) {
44962
- A[m - 2][m - 3] = 0;
44963
- m -= 2;
44964
- continue;
44965
- }
44966
- }
44967
- const denom = Math.abs(delta) + Math.sqrt(Math.abs(disc));
44968
- const s = disc >= 0 && denom > 1e-300 ? d - (Math.sign(delta) || 1) * (b * c) / denom : d;
44969
- const As = A.map((r, i) => r.map((v, j) => v - (i === j ? s : 0)));
44970
- const { Q: Q2, R } = _qr(As);
44971
- A = _multiply(R, Q2).map((r, i) => r.map((v, j) => v + (i === j ? s : 0)));
44972
- U = _multiply(U, Q2);
44973
- }
44974
- for (let i = 2; i < n; i++) {
44975
- for (let j = 0; j < i - 1; j++) {
44976
- if (Math.abs(A[i][j]) > 1e-8 * (1 + Math.abs(A[i][i]) + Math.abs(A[j][j]))) {
44977
- throw new Error("realSchur: QR iteration failed to converge to (quasi-)triangular form");
44978
- }
44979
- }
44980
- }
44981
- return { U, S: A };
45100
+ const { Q: Q2, T } = matrixSchur2(DenseMatrix6.fromArray(M));
45101
+ return { U: Q2.toArray(), S: T.toArray() };
44982
45102
  }
44983
45103
  var arr3 = (x) => Array.isArray(x) ? x : Array.from(x);
44984
45104
  function generalizedEig(A, B) {
@@ -45043,7 +45163,7 @@ function laplacianMatrix(adjacency, opts = {}) {
45043
45163
  );
45044
45164
  }
45045
45165
  function logdet(A) {
45046
- const { U, P: P2 } = lu2(DenseMatrix5.fromArray(A));
45166
+ const { U, P: P2 } = lu3(DenseMatrix6.fromArray(A));
45047
45167
  const Ud = U.toArray();
45048
45168
  const seen = new Array(P2.length).fill(false);
45049
45169
  let sign3 = 1;
@@ -45317,9 +45437,14 @@ function resolvePreconditioner(a, preconditioner) {
45317
45437
  if (typeof preconditioner === "function") return preconditioner;
45318
45438
  if (!isDenseMatrix2(a)) {
45319
45439
  throw new Error(
45320
- "krylov: 'jacobi' preconditioner requires a dense matrix (need the diagonal) \u2014 pass a custom preconditioner function when using a matvec operator"
45440
+ `krylov: '${preconditioner}' preconditioner requires a dense matrix (it reads A's entries) \u2014 pass a custom preconditioner function when using a matvec operator`
45321
45441
  );
45322
45442
  }
45443
+ if (preconditioner === "jacobi") return makeJacobi(a);
45444
+ if (preconditioner === "ilu") return makeILU0(a);
45445
+ return makeIC0(a);
45446
+ }
45447
+ function makeJacobi(a) {
45323
45448
  const n = a.length;
45324
45449
  const invDiag = new Array(n);
45325
45450
  for (let i = 0; i < n; i++) {
@@ -45333,6 +45458,102 @@ function resolvePreconditioner(a, preconditioner) {
45333
45458
  }
45334
45459
  return (r) => r.map((v, i) => v * invDiag[i]);
45335
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
+ }
45336
45557
  function defaultMaxIter(n) {
45337
45558
  return Math.min(n * 10, 1e3);
45338
45559
  }
@@ -45386,103 +45607,55 @@ function minres(a, b, opts) {
45386
45607
  const tol = opts?.tol ?? 1e-10;
45387
45608
  const maxIter = opts?.maxIter ?? defaultMaxIter(n);
45388
45609
  const bNorm = norm25(b);
45389
- const x0 = opts?.x0 ? opts.x0.slice() : zeros2(n);
45390
- const r0 = subtract2(b, matvec2(x0));
45391
- let residual = relativeResidualNorm(norm25(r0), bNorm);
45392
- if (residual < tol) {
45393
- return { x: x0, iterations: 0, converged: true, residual };
45394
- }
45395
- const z0 = applyM(r0);
45396
- const beta1 = Math.sqrt(dot2(r0, z0));
45397
- if (beta1 < 1e-300) {
45398
- return { x: x0, iterations: 0, converged: residual < tol, residual };
45399
- }
45400
- const V = [zeros2(n), scale(1 / beta1, r0)];
45401
- const Z = [zeros2(n), scale(1 / beta1, z0)];
45402
- const alphas = [];
45403
- const betas = [beta1];
45404
- let bestX = x0.slice();
45405
- let bestResidual = residual;
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();
45406
45628
  let iterations = 0;
45407
- for (let k = 1; k <= maxIter; k++) {
45408
- iterations = k;
45409
- const vK = V[k];
45410
- const zK = Z[k];
45411
- const vKm1 = V[k - 1];
45412
- const betaK = betas[k - 1];
45413
- let p = matvec2(zK);
45414
- p = subtract2(p, scale(betaK, vKm1));
45415
- const alphaK = dot2(p, zK);
45416
- alphas.push(alphaK);
45417
- p = subtract2(p, scale(alphaK, vK));
45418
- const zRaw = applyM(p);
45419
- const betaNext = Math.sqrt(Math.max(0, dot2(p, zRaw)));
45420
- const T = Array.from({ length: k + 1 }, () => new Array(k).fill(0));
45421
- for (let i = 0; i < k; i++) {
45422
- T[i][i] = alphas[i];
45423
- if (i + 1 < k) {
45424
- T[i + 1][i] = betas[i + 1];
45425
- T[i][i + 1] = betas[i + 1];
45426
- }
45427
- }
45428
- T[k][k - 1] = betaNext;
45429
- const rhs = new Array(k + 1).fill(0);
45430
- rhs[0] = beta1;
45431
- const y = solveLeastSquaresQR(T, rhs);
45432
- let xCandidate = x0.slice();
45433
- for (let i = 0; i < k; i++) {
45434
- xCandidate = axpy(y[i], Z[i + 1], xCandidate);
45435
- }
45436
- residual = relativeResidual(matvec2, xCandidate, b, bNorm);
45437
- if (residual < bestResidual) {
45438
- bestResidual = residual;
45439
- bestX = xCandidate;
45440
- }
45441
- if (residual < tol) {
45442
- return { x: xCandidate, iterations: k, converged: true, residual };
45443
- }
45444
- if (betaNext < 1e-300) break;
45445
- betas.push(betaNext);
45446
- V.push(scale(1 / betaNext, p));
45447
- Z.push(scale(1 / betaNext, zRaw));
45448
- }
45449
- return { x: bestX, iterations, converged: bestResidual < tol, residual: bestResidual };
45450
- }
45451
- function solveLeastSquaresQR(T, rhs) {
45452
- const m = T.length;
45453
- const n = T[0]?.length ?? 0;
45454
- const R = T.map((row2) => row2.slice());
45455
- const c = rhs.slice();
45456
- for (let k = 0; k < n; k++) {
45457
- let normX = 0;
45458
- for (let i = k; i < m; i++) normX += R[i][k] * R[i][k];
45459
- normX = Math.sqrt(normX);
45460
- if (normX < 1e-300) continue;
45461
- const alpha = R[k][k] >= 0 ? -normX : normX;
45462
- const v = new Array(m).fill(0);
45463
- v[k] = R[k][k] - alpha;
45464
- for (let i = k + 1; i < m; i++) v[i] = R[i][k];
45465
- let vNormSq = 0;
45466
- for (let i = k; i < m; i++) vNormSq += v[i] * v[i];
45467
- if (vNormSq < 1e-300) continue;
45468
- for (let j = k; j < n; j++) {
45469
- let dotVR = 0;
45470
- for (let i = k; i < m; i++) dotVR += v[i] * R[i][j];
45471
- const factor2 = 2 * dotVR / vNormSq;
45472
- for (let i = k; i < m; i++) R[i][j] -= factor2 * v[i];
45473
- }
45474
- let dotVC = 0;
45475
- for (let i = k; i < m; i++) dotVC += v[i] * c[i];
45476
- const factorC = 2 * dotVC / vNormSq;
45477
- for (let i = k; i < m; i++) c[i] -= factorC * v[i];
45478
- }
45479
- const y = new Array(n).fill(0);
45480
- for (let i = n - 1; i >= 0; i--) {
45481
- let sum3 = c[i];
45482
- for (let j = i + 1; j < n; j++) sum3 -= R[i][j] * y[j];
45483
- y[i] = Math.abs(R[i][i]) > 1e-300 ? sum3 / R[i][i] : 0;
45484
- }
45485
- 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 };
45486
45659
  }
45487
45660
  function gmres(a, b, opts) {
45488
45661
  const n = b.length;
@@ -45780,6 +45953,67 @@ function eigsh(a, k = 1, opts) {
45780
45953
  return { eigenvalues, eigenvectors };
45781
45954
  }
45782
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
+
45783
46017
  // src/numeric/structured-solvers.ts
45784
46018
  function thomasSolve(sub2, diag2, sup, d) {
45785
46019
  const n = diag2.length;
@@ -47459,7 +47693,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
47459
47693
  let x = Array.from(x0);
47460
47694
  let lambda = 1e-3;
47461
47695
  const h = 1e-7;
47462
- const norm27 = (v) => v.reduce((s, c) => s + c * c, 0);
47696
+ const norm28 = (v) => v.reduce((s, c) => s + c * c, 0);
47463
47697
  const jacobian2 = (xc, r0) => {
47464
47698
  const m = r0.length;
47465
47699
  const J = Array.from({ length: m }, () => new Array(n).fill(0));
@@ -47472,7 +47706,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
47472
47706
  return J;
47473
47707
  };
47474
47708
  let r = residual(x);
47475
- let cost = norm27(r);
47709
+ let cost = norm28(r);
47476
47710
  let iter = 0;
47477
47711
  for (; iter < maxIter; iter++) {
47478
47712
  const J = jacobian2(x, r);
@@ -47503,7 +47737,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
47503
47737
  }
47504
47738
  const xNew = x.map((v, i) => v + delta[i]);
47505
47739
  const rNew = residual(xNew);
47506
- const costNew = norm27(rNew);
47740
+ const costNew = norm28(rNew);
47507
47741
  if (costNew < cost) {
47508
47742
  x = xNew;
47509
47743
  r = rNew;
@@ -52282,6 +52516,8 @@ export {
52282
52516
  ifftshift2 as ifftshift,
52283
52517
  im,
52284
52518
  implicitDiff,
52519
+ incompleteCholesky,
52520
+ incompleteLU,
52285
52521
  indexFn as index,
52286
52522
  indexFn,
52287
52523
  initializePool,
@@ -52747,6 +52983,7 @@ export {
52747
52983
  sum,
52748
52984
  summation,
52749
52985
  svd4 as svd,
52986
+ svds,
52750
52987
  sylvester,
52751
52988
  symbolicEqual,
52752
52989
  symbolicIntegral,