Skip to main content

Module linalg

Module linalg 

Source
Expand description

Linear algebra following jax.numpy.linalg (and NumPy’s semantics), on matrices and batches of matrices (see lax::linalg for the decompositions). The decompositions and solves (cholesky, solve, inv, qr, eigh, eigvalsh, svd, svdvals) take f32, f64, c64, and c128; det, slogdet, and norm take f32 and f64.

Enums§

NormAxes
The axes of norm.
NormOrd
The kind of norm of norm (NumPy’s ord).
QrMode
The shape of q of qr.

Functions§

cholesky
The Cholesky factor L (lower triangular, a = L L^T) of each symmetric positive definite matrix, as jnp.linalg.cholesky (the input is symmetrized first). Matrices that are not positive definite give NaNs.
det
The determinant of each square matrix, as jnp.linalg.det: the sign times the exponential of the log-determinant from slogdet (JAX uses closed forms for 2 x 2 and 3 x 3 matrices, which round differently).
eigh
The eigenvalues (ascending) and eigenvectors (columns) of each symmetric matrix, as jnp.linalg.eigh (the input is symmetrized first).
eigvalsh
The eigenvalues (ascending) of each symmetric matrix, as jnp.linalg.eigvalsh.
inv
The inverse of each square matrix, as jnp.linalg.inv (a solve with the identity).
norm
A norm of vectors or matrices, as jnp.linalg.norm.
qr
The QR decomposition of each matrix, as jnp.linalg.qr (NumPy’s mode "r" is the second result).
slogdet
The sign and the natural logarithm of the absolute value of the determinant of each square matrix, as jnp.linalg.slogdet (from the LU factorization). Singular matrices give a sign of 0 and -inf.
solve
Solves a x = b for x, as jnp.linalg.solve: b of shape [n] is a vector (the result is [..., n]), otherwise a batch of matrices [..., n, k] whose batch dimensions broadcast with a’s. The solve uses the LU factorization of a; singular matrices give infinities or NaNs.
svd
The singular value decomposition (u, s, vh) of each matrix, as jnp.linalg.svd (see lax::linalg::svd).
svdvals
The singular values of each matrix in descending order, as jnp.linalg.svdvals.