python
runtime_error
ai_generated
true
numpy.linalg.LinAlgError: Singular matrix
ID: python/numpy-linalg-singular
80%Fix Rate
90%Confidence
0Evidence
2024-03-27First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Matrix is not invertible (determinant zero); linear system has no unique solution.
generic中文
矩阵不可逆(行列式为零);线性系统无唯一解。
Workarounds
-
95% success
x = np.linalg.lstsq(A, b, rcond=None)[0]
-
90% success
x = np.linalg.pinv(A) @ b
Dead Ends
Common approaches that don't work:
-
80% fail
Perturbation may still be singular; unstable results
-
70% fail
Ill-conditioned; large numerical error