Skip to content
fn

svdvals

→Tensor
svdvals(A: Tensor, driver: str | None = None)

Compute only the singular values of a matrix.

Returns the singular values σ1≥⋯≥σk≥0\sigma_1 \ge \cdots \ge \sigma_k \ge 0 (with k=min⁡(m,n)k = \min(m, n)) of an input matrix AA without forming UU or V⊤V^\top. Equivalent to svd(A, full_matrices=False)[1] but avoids the work of constructing the singular vectors.

Parameters

Input matrix of shape (*, m, n).
driver(str or None, keyword - only)= None
LAPACK driver name. Must be None.

Returns

Tensor

Singular values in descending order, shape (*, k).

Notes

When gradients are required this routes through the reduced svd so backward still works. Without requires_grad, the engine kernel skips assembly of the singular vectors and is roughly 2×2\times faster. Useful for computing matrix_rank, cond, or the nuclear / spectral norms.

Examples

>>> import lucid
>>> from lucid.linalg import svdvals
>>> svdvals(lucid.tensor([[3.0, 0.0], [0.0, 4.0]]))
tensor([4., 3.])

Used by 1