pinv(input: Tensor, rcond: float | Tensor | None = None, hermitian: bool = False, atol: float | Tensor | None = None, rtol: float | Tensor | None = None)Implementing kernel
C++ engine symbols that back this Python API.Moore-Penrose pseudo-inverse of a matrix.
Returns the unique matrix satisfying the four Moore-Penrose conditions
For a thin SVD , the pseudo-inverse is
Parameters
inputTensorInput matrix of shape
(*, m, n). Need not be square or
full-rank.Alias for
rtol; mutually exclusive with atol and rtol.hermitianbool= FalseIf
True, assumes input is symmetric / Hermitian and uses
eigh of the lower triangle instead of svd.Absolute tolerance threshold (treated as
0.0 when None).Relative tolerance threshold; defaults to
unless
atol > 0, in
which case 0.0.Returns
TensorPseudo-inverse of shape (*, n, m).
Notes
Every shape goes through the SVD-based kernel, a singular square
matrix included (routing square input through inv answered
a singular one with a non-finite matrix). The gradient follows the
reference framework's closed form for a matrix of constant rank,
which needs no singular-value gaps, and differentiates again.
The pseudo-inverse provides the least-squares solution of even when is singular: .
Examples
>>> import lucid
>>> from lucid.linalg import pinv
>>> A = lucid.tensor([[1.0, 0.0], [0.0, 2.0], [0.0, 0.0]])
>>> lucid.allclose(pinv(A) @ A, lucid.eye(2), atol=1e-5)
True