@tangent.to/lina 0.1.4 → 0.1.5

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/types/ops.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Matrix product A B, or matrix-vector product A b.
3
+ *
4
+ * @param {Array<Array<number>>} A - m x n nested matrix
5
+ * @param {Array<Array<number>>|Array<number>} B - n x p nested matrix, or
6
+ * vector of length n
7
+ * @returns {Array<Array<number>>|Array<number>} m x p nested matrix, or
8
+ * vector of length m
9
+ */
10
+ export function matmul(A: Array<Array<number>>, B: Array<Array<number>> | Array<number>): Array<Array<number>> | Array<number>;
11
+ /**
12
+ * Matrix transpose.
13
+ *
14
+ * @param {Array<Array<number>>} A - m x n nested matrix
15
+ * @returns {Array<Array<number>>} n x m nested matrix
16
+ */
17
+ export function transpose(A: Array<Array<number>>): Array<Array<number>>;
18
+ /**
19
+ * Identity matrix of size n.
20
+ *
21
+ * @param {number} n - Dimension (positive integer)
22
+ * @returns {Array<Array<number>>}
23
+ */
24
+ export function identity(n: number): Array<Array<number>>;
25
+ /**
26
+ * Build a diagonal matrix from a vector, or extract the diagonal of a matrix.
27
+ *
28
+ * @param {Array<number>|Array<Array<number>>} x - Vector (returns an n x n
29
+ * nested matrix) or nested matrix (returns its diagonal, length min(m, n))
30
+ * @returns {Array<Array<number>>|Array<number>}
31
+ */
32
+ export function diag(x: Array<number> | Array<Array<number>>): Array<Array<number>> | Array<number>;
33
+ /**
34
+ * Matrix or vector norm.
35
+ *
36
+ * For a nested matrix: 'fro' (Frobenius), 1 (max column abs sum), or
37
+ * Infinity (max row abs sum). For a vector: 'fro' or 2 (euclidean),
38
+ * 1 (abs sum), or Infinity (max abs).
39
+ *
40
+ * @param {Array<Array<number>>|Array<number>} A - Nested matrix or vector
41
+ * @param {'fro'|1|2|Infinity} [kind='fro'] - Norm kind
42
+ * @returns {number}
43
+ */
44
+ export function norm(A: Array<Array<number>> | Array<number>, kind?: "fro" | 1 | 2 | number): number;
45
+ /**
46
+ * Sum of the diagonal of a square matrix.
47
+ *
48
+ * @param {Array<Array<number>>} A - Square nested matrix
49
+ * @returns {number}
50
+ */
51
+ export function trace(A: Array<Array<number>>): number;
package/types/qr.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * QR decomposition A = Q R via Householder reflections.
3
+ *
4
+ * Works for any shape: m >= n and m < n alike.
5
+ *
6
+ * @param {Array<Array<number>>} A - m x n matrix
7
+ * @param {Object} [options]
8
+ * @param {string} [options.mode='reduced'] - 'reduced' (Q is m x min(m,n),
9
+ * R is min(m,n) x n) or 'full' (Q is m x m, R is m x n)
10
+ * @returns {{Q: Array<Array<number>>, R: Array<Array<number>>}}
11
+ */
12
+ export function qr(A: Array<Array<number>>, options?: {
13
+ mode?: string | undefined;
14
+ }): {
15
+ Q: Array<Array<number>>;
16
+ R: Array<Array<number>>;
17
+ };
18
+ /**
19
+ * Least-squares solution of A x ≈ b via reduced QR.
20
+ *
21
+ * Requires m >= n and full column rank: solves R x = Q^T b by back
22
+ * substitution. Throws for rank-deficient R.
23
+ *
24
+ * @param {Array<Array<number>>} A - m x n matrix with m >= n
25
+ * @param {Array<number>} b - Right-hand side of length m
26
+ * @returns {{x: Array<number>, residualNorm: number}} residualNorm = ||A x - b||_2
27
+ */
28
+ export function lstsq(A: Array<Array<number>>, b: Array<number>): {
29
+ x: Array<number>;
30
+ residualNorm: number;
31
+ };
package/types/svd.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Thin SVD: A = U diag(s) V^T with U m×k, s length k, V n×k, k = min(m, n).
3
+ * Singular values are non-negative and descending.
4
+ *
5
+ * @param {Array<Array<number>>} A - Matrix (any shape)
6
+ * @param {Object} [options]
7
+ * @param {number} [options.maxSweeps=60] - Maximum Jacobi sweeps
8
+ * @param {number} [options.tol=1e-15] - Column-pair orthogonality tolerance
9
+ * @returns {{U: Array<Array<number>>, s: Array<number>, V: Array<Array<number>>}}
10
+ */
11
+ export function svd(A: Array<Array<number>>, options?: {
12
+ maxSweeps?: number | undefined;
13
+ tol?: number | undefined;
14
+ }): {
15
+ U: Array<Array<number>>;
16
+ s: Array<number>;
17
+ V: Array<Array<number>>;
18
+ };
19
+ /**
20
+ * Numerical rank via SVD.
21
+ *
22
+ * @param {Array<Array<number>>} A - Matrix
23
+ * @param {number} [tol] - Threshold; default max(m,n) * eps * s[0] (numpy convention)
24
+ * @returns {number}
25
+ */
26
+ export function rank(A: Array<Array<number>>, tol?: number): number;
27
+ /**
28
+ * Condition number (2-norm): s_max / s_min. Infinity when singular.
29
+ *
30
+ * @param {Array<Array<number>>} A - Matrix
31
+ * @returns {number}
32
+ */
33
+ export function cond(A: Array<Array<number>>): number;
34
+ /**
35
+ * Moore-Penrose pseudoinverse via SVD, with numpy's default cutoff.
36
+ * Solves rank-deficient least squares: x = pinv(A) b is the minimum-norm
37
+ * solution.
38
+ *
39
+ * @param {Array<Array<number>>} A - Matrix (any shape)
40
+ * @param {number} [rcond] - Relative cutoff; default max(m,n) * eps
41
+ * @returns {Array<Array<number>>} n×m pseudoinverse
42
+ */
43
+ export function pinv(A: Array<Array<number>>, rcond?: number): Array<Array<number>>;
44
+ /**
45
+ * Minimum-norm least squares via the pseudoinverse (works for any rank).
46
+ *
47
+ * @param {Array<Array<number>>} A - m×n matrix
48
+ * @param {Array<number>} b - Vector of length m
49
+ * @returns {Array<number>} x of length n
50
+ */
51
+ export function pinvSolve(A: Array<Array<number>>, b: Array<number>): Array<number>;
@@ -0,0 +1,2 @@
1
+ /** This package's version. */
2
+ export const version: "0.1.5";