matrix_rank(A: Tensor, tol: float | Tensor | None = None, hermitian: bool = False, atol: float | Tensor | None = None, rtol: float | Tensor | None = None)Compute the numerical rank of a matrix or a batch of matrices.
Counts singular values (or eigenvalue magnitudes when hermitian=True)
above :
Parameters
Input matrix of shape
(*, m, n).Alias for
atol with rtol=0; mutually exclusive with atol/rtol.hermitianbool= FalseIf
True, use eigvalsh of the lower triangle instead of svdvals.Absolute tolerance (treated as
0.0 when None).Relative tolerance; defaults to
unless
atol > 0, in which case 0.0.Returns
Tensorint64 tensor of numerical ranks per matrix.
Examples
>>> import lucid
>>> from lucid.linalg import matrix_rank
>>> matrix_rank(lucid.tensor([[1.0, 2.0], [2.0, 4.0]]))
tensor(1, dtype=lucid.int64)