import numpy as np
B=np.array([[5,-2,6,-1],[0,3,-8,0],[0,0,5,4],[0,0,0,1]])
print(B)
print(B.shape)
w,v= np.linalg.eig(B)
print("eigenvalues are: ", w)
for i in range(4):
print (np.dot((B-w[i]*np.eye(4)),v[:,i]))
The normalized (unit “length”) eigenvectors, such that the column v[:,i] is the eigenvector corresponding to the eigenvalue w[i].
换句话说,特征值的顺序原则上是任意的。但无论特征值的阶数是多少,阶数都会与特征向量相匹配。你知道吗
您可以通过计算B对v的列向量的应用来验证特征值和特征向量顺序是否匹配。在代码中
for i in range(B.shape[0]):
# Apply B to the eigenvectors
scaled = np.dot(B, v[:, i])
# Check that applying B only applies a scaling to the eigenvector
np.testing.assert_allclose(scaled, w[i] * v[:, i])
是的,特征向量的顺序是一样的,你可以通过在代码中加两行来验证这一点
就多重性的概念而言,单个特征值可以与多个线性无关的特征向量相联系。你可以阅读更多关于这个here
documentation提供关于特征向量的以下信息。你知道吗
换句话说,特征值的顺序原则上是任意的。但无论特征值的阶数是多少,阶数都会与特征向量相匹配。你知道吗
您可以通过计算
B
对v
的列向量的应用来验证特征值和特征向量顺序是否匹配。在代码中相关问题 更多 >
编程相关推荐