linalg namespace. Access them as np.linalg.eig(...), np.linalg.svd(...), etc.
linalg.eig
Compute the eigenvalues and right eigenvectors of a square matrix. For each eigenvaluew[i], the corresponding eigenvector is the column v[:, i].
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input square matrix. |
{ w, v } — Object where w has shape [n] (eigenvalues) and v has shape [n, n] (eigenvectors). The column v[:, i] is the eigenvector corresponding to w[i].
linalg.eigh
Compute eigenvalues and eigenvectors of a symmetric (Hermitian) matrix. The eigenvalues are returned in ascending order. This is faster thaneig for symmetric matrices and guarantees real eigenvalues.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input symmetric matrix. |
UPLO | 'L' | 'U' | 'L' | Whether to use the lower ('L') or upper ('U') triangle of a. |
{ w, v } — Object where w contains eigenvalues in ascending order and v contains orthonormal eigenvectors.
linalg.eigvals
Compute the eigenvalues of a square matrix. This is equivalent tolinalg.eig but only returns eigenvalues, which can be more efficient when eigenvectors are not needed.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input square matrix. |
NDArray — 1-D array of eigenvalues (may be complex-valued).
linalg.eigvalsh
Compute the eigenvalues of a symmetric (Hermitian) matrix. Returns eigenvalues only, sorted in ascending order.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input symmetric matrix. |
UPLO | 'L' | 'U' | 'L' | Whether to use the lower or upper triangle. |
NDArray — 1-D array of real eigenvalues in ascending order.
linalg.svd
Compute the singular value decomposition (SVD) of a matrix. Factors the matrixa as U @ diag(S) @ Vh.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input matrix of shape [M, N]. |
full_matrices | boolean | true | If true, U is [M, M] and Vh is [N, N]. If false, U is [M, K] and Vh is [K, N] where K = min(M, N). |
compute_uv | boolean | true | If false, return only singular values. |
{ u, s, vt } when compute_uv is true, where u contains left singular vectors, s contains singular values (descending), and vt contains right singular vectors (conjugate-transposed). Returns NDArray of singular values when compute_uv is false.
linalg.svdvals
Compute the singular values of a matrix. This is equivalent tolinalg.svd but only returns the singular values, which can be more efficient.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input matrix. |
NDArray — 1-D array of singular values in descending order.
linalg.qr
Compute the QR decomposition of a matrix. Factors the matrixa as Q @ R, where Q is orthogonal and R is upper triangular.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input matrix of shape [M, N]. |
mode | 'reduced' | 'complete' | 'r' | 'raw' | 'reduced' | If 'reduced'/'complete', returns { q, r }. If 'r', returns only R. If 'raw', returns { h, tau }. |
{ q, r } for 'reduced'/'complete', NDArray for 'r', and { h, tau } for 'raw'.
linalg.cholesky
Compute the Cholesky decomposition of a positive-definite symmetric matrix. Returns the lower-triangular matrixL such that a = L @ L.T.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input positive-definite symmetric matrix. |
upper | boolean | false | If true, compute upper-triangular factor instead of lower-triangular. |
NDArray — Lower-triangular Cholesky factor L.
Throws: Error if the matrix is not positive definite.