@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.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +536 -299
- 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/solveODE.d.ts +32 -0
- package/dist/numeric/solveODE.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 +2 -2
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,SA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|
|
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,W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function `g(t, y)` whose zero crossings `solveODE` locates. May carry scipy-style
|
|
4
|
+
* `terminal`/`direction` attributes directly on the function object.
|
|
5
|
+
*
|
|
6
|
+
* - `terminal`: `true` (stop at the first crossing), a positive integer (stop after that many
|
|
7
|
+
* crossings), or omitted/`false` (record every crossing, never stop).
|
|
8
|
+
* - `direction`: `+1` (trigger only on `−`→`+` crossings), `−1` (only `+`→`−`), or `0`/omitted
|
|
9
|
+
* (either direction).
|
|
10
|
+
*
|
|
11
|
+
* The state `y` is passed in the same shape the forcing function receives it (a `number[]` — a
|
|
12
|
+
* length-1 array for a scalar ODE).
|
|
13
|
+
*/
|
|
14
|
+
interface EventFunction {
|
|
15
|
+
(t: number, y: number[]): number;
|
|
16
|
+
terminal?: boolean | number;
|
|
17
|
+
direction?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Object form of an ODE event: the function plus its `terminal`/`direction` attributes. */
|
|
20
|
+
interface EventSpec {
|
|
21
|
+
event: (t: number, y: number[]) => number;
|
|
22
|
+
terminal?: boolean | number;
|
|
23
|
+
direction?: number;
|
|
24
|
+
}
|
|
25
|
+
/** One event, or an array of events, accepted by the `events` option. */
|
|
26
|
+
type ODEEvents = EventFunction | EventSpec | Array<EventFunction | EventSpec>;
|
|
2
27
|
/**
|
|
3
28
|
* Options for ODE solver
|
|
4
29
|
*/
|
|
@@ -17,6 +42,13 @@ interface ODEOptions {
|
|
|
17
42
|
* (n = state dimension). Ignored by the explicit RK23/RK45 methods.
|
|
18
43
|
*/
|
|
19
44
|
jac?: (t: number, y: number[]) => number[][];
|
|
45
|
+
/**
|
|
46
|
+
* Event detection (scipy `solve_ivp`-style). One event function `g(t, y)` or an array of them;
|
|
47
|
+
* `solveODE` locates each zero crossing between accepted steps and reports it in `tEvents`/
|
|
48
|
+
* `yEvents`. A `terminal` event stops the integration at its crossing; `direction` filters the
|
|
49
|
+
* crossing sign. Requires plain-number state (throws otherwise). See {@link EventFunction}.
|
|
50
|
+
*/
|
|
51
|
+
events?: ODEEvents;
|
|
20
52
|
}
|
|
21
53
|
/**
|
|
22
54
|
* Forcing function type for ODE
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solveODE.d.ts","sourceRoot":"","sources":["../../src/numeric/solveODE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solveODE.d.ts","sourceRoot":"","sources":["../../src/numeric/solveODE.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAU,IAAI,EAAa,MAAM,aAAa,CAAC;AAkCvF;;;;;;;;;;;GAWG;AACH,UAAU,aAAa;IACrB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4FAA4F;AAC5F,UAAU,SAAS;IACjB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,yEAAyE;AACzE,KAAK,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;AAS9E;;GAEG;AACH,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,EAAE,CAAC;IAC7C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAcD;;GAEG;AACH,KAAK,eAAe,GAAG,CACrB,CAAC,EAAE,eAAe,EAClB,CAAC,EAAE,eAAe,GAAG,SAAS,KAC3B,eAAe,GAAG,SAAS,CAAC;AAmWjC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,eAAe,EAClB,KAAK,EAAE,OAAO,EAAE,EAChB,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,GAAE,UAAe,GACvB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAmFhC;AAgDD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,CAAC,EAAE,eAAe,EAClB,KAAK,EAAE,OAAO,EAAE,EAChB,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,GAAE,UAAe,GACvB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAiHhC;AAED,eAAO,MAAM,cAAc,yDAyrB1B,CAAC"}
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@danielsimonjr/mathts-core": "^0.13.0",
|
|
38
38
|
"@danielsimonjr/mathts-expression": "^0.6.7",
|
|
39
39
|
"@danielsimonjr/mathts-gpu": "^0.2.0",
|
|
40
|
-
"@danielsimonjr/mathts-matrix": "^0.
|
|
40
|
+
"@danielsimonjr/mathts-matrix": "^0.7.0",
|
|
41
41
|
"@danielsimonjr/mathts-parallel": "^0.6.3",
|
|
42
42
|
"bignumber.js": "^9.1.2",
|
|
43
43
|
"complex.js": "^2.2.5",
|