python
runtime_error
ai_generated
true
numpy.linalg.LinAlgError: Matrix is not positive definite
ID: python/scipy-linalg-singular
80%Fix Rate
87%Confidence
0Evidence
2024-07-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Cholesky decomposition (np.linalg.cholesky / scipy.linalg.cholesky) requires a symmetric positive-definite matrix. Numerical noise, non-symmetric input, or a truly indefinite matrix breaks this.
generic中文
Cholesky 分解(np.linalg.cholesky / scipy.linalg.cholesky)要求对称正定矩阵。数值噪声、非对称输入或真正非正定的矩阵会导致失败。
Workarounds
-
90% success
A = (A + A.T) / 2; A += 1e-8 * np.eye(A.shape[0]); L = np.linalg.cholesky(A)
-
85% success
Use scipy.linalg.ldl(A) or np.linalg.eigh(A) for indefinite matrices
Dead Ends
Common approaches that don't work:
-
70% fail
Regularization too small for ill-conditioned matrices
-
90% fail
Triangular part isn't symmetric