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
Input matrix of shape
(*, m, n). Need not be square or
full-rank.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