这不是倒退吗? A*V = V*D
从定义来看,所以A = V*D*V^(-1)
.
>>> import numpy as np
>>> from scipy import linalg
>>> A = np.matrix([[16,-9,0],[-9,20,-11],[0,-11,11]])
>>> D, V = linalg.eig(A)
>>> D = np.diagflat(D)
>>>
>>> b = np.matrix(linalg.inv(V))*np.matrix(D)*np.matrix(V)
>>> b
matrix([[ 15.52275377+0.j, 9.37603361+0.j, 0.79257097+0.j],
[ 9.37603361+0.j, 21.12538282+0.j, -10.23535271+0.j],
[ 0.79257097+0.j, -10.23535271+0.j, 10.35186341+0.j]])
>>> np.allclose(A, b)
False
但
>>> f = np.matrix(V)*np.matrix(D)*np.matrix(linalg.inv(V))
>>> f
matrix([[ 1.60000000e+01+0.j, -9.00000000e+00+0.j, -9.54791801e-15+0.j],
[ -9.00000000e+00+0.j, 2.00000000e+01+0.j, -1.10000000e+01+0.j],
[ -1.55431223e-15+0.j, -1.10000000e+01+0.j, 1.10000000e+01+0.j]])
>>> np.allclose(A, f)
True
另外:有一些方法可以np.dot
用来避免所有这些转换为矩阵,比如
>>> dotm = lambda *args: reduce(np.dot, args)
>>> dotm(V, D, inv(V))
array([[ 1.60000000e+01+0.j, -9.00000000e+00+0.j, -9.54791801e-15+0.j],
[ -9.00000000e+00+0.j, 2.00000000e+01+0.j, -1.10000000e+01+0.j],
[ -1.55431223e-15+0.j, -1.10000000e+01+0.j, 1.10000000e+01+0.j]])
我经常发现它更干净,但是 YMMV。