我试图解决特征值方程,A x = λ B x与A和B作为16×16平方厄米矩阵。使用python (Spyder4)上的线性库,我得到一个错误说:
LinAlgError: The leading minor of order 12 of B is not positive definite. The factorization of B could not be completed and no eigenvalues or eigenvectors were computed.
下面是矩阵和我使用的命令:
H = np.array([[a11,0,0,0,0,0,0,0,a19,a110,a111,a112,a113,a114,a115,a116]
[0,a22,0,0,0,0,0,0,a29,a210,a211,a212,a213,a214,a215,a216],
[0,0,a33,0,0,0,0,0,a39,a310,a311,a312,a313,a314,a315,a316],
[0,0,0,a44,0,0,0,0,a49,a410,a411,a412,a413,a414,a415,a416],
[0,0,0,0,a55,0,0,0,a59,a510,a511,a512,a513,a514,a515,a516],
[0,0,0,0,0,a66,0,0,a69,a610,a611,a612,a613,a614,a615,a616],
[0,0,0,0,0,0,a77,0,a79,a710,a711,a712,a713,a714,a715,a716],
[0,0,0,0,0,0,0,a88,a89,a810,a811,a812,a813,a814,a815,a816],
[0,0,0,0,0,0,0,0,a99,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,a1010,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,a1111,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,a1212,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,a1313,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,a1414,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,a1515,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a1616]])
S = np.array([[1,0,0,0,0,0,0,0,b19,b110,b111,b112,b113,b114,b115,b116],
[0,1,0,0,0,0,0,0,b29,b210,b211,b212,b213,b214,b215,b216],
[0,0,1,0,0,0,0,0,b39,b310,b311,b312,b313,b314,b315,b316],
[0,0,0,1,0,0,0,0,b49,b410,b411,b412,b413,b414,b415,b416],
[0,0,0,0,1,0,0,0,b59,b510,b511,b512,b513,b514,b515,b516],
[0,0,0,0,0,1,0,0,b69,b610,b611,b612,b613,b614,b615,b616],
[0,0,0,0,0,0,1,0,b79,b710,b711,b712,b713,b714,b715,b716],
[0,0,0,0,0,0,0,1,b89,b810,b811,b812,b813,b814,b815,b816],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]])
lamda, x = lg.eigh(H, S, lower=False, eigvals_only=False)
print("Eigenvalues")
print(lamda)
矩阵中的变量是用户输入(一些-ve值和复数)。
当我使用"linalg.eig
";命令,但由于我的实际矩阵是对称的,我试图使用高命令。
有人遇到过这个问题和/或建议错误是关于什么的吗?由于
文档说第二个参数必须是复厄米矩阵或实对称正定矩阵。如果你的b
是复杂的,那么这个论证似乎两者都不是。
文档还说这个方法抛出一个LinAlgError
:
如果特征值计算不收敛,则发生错误,或b矩阵不是定正的。注意,如果输入矩阵不是对称的或厄米的,不会报告错误,但结果会错了。