python
runtime_error
ai_generated
true
numpy.linalg.LinAlgError:奇异矩阵
numpy.linalg.LinAlgError: Singular matrix
ID: python/numpy-linalg-singular
80%修复率
90%置信度
0证据数
2024-03-27首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
矩阵不可逆(行列式为零);线性系统无唯一解。
English
Matrix is not invertible (determinant zero); linear system has no unique solution.
解决方案
-
95% 成功率
x = np.linalg.lstsq(A, b, rcond=None)[0]
-
90% 成功率
x = np.linalg.pinv(A) @ b
无效尝试
常见但无效的做法:
-
80% 失败
Perturbation may still be singular; unstable results
-
70% 失败
Ill-conditioned; large numerical error