关于vl
,eig
文档字符串说:
a.H vl[:,i] = w[i].conj() b.H vl[:,i]
或者,取两边的共轭转置b
(即 Hermitian 转置)(这就是 .H 的意思),假设是恒等式,
vl[:,i].H a = w[i] vl[:,i].H
所以 的共轭转置的行vl
是 的实际左特征向量a
。
Numpy 数组实际上没有 .H 属性,因此您必须使用 .conj().T。
这是一个验证计算的脚本:
import numpy as np
from scipy.linalg import eig
# This only affects the printed output.
np.set_printoptions(precision=4)
a = np.array([[6, 2],
[-1, 4]])
w, vl, vr = eig(a, left=True)
print "eigenvalues:", w
print
# check the left eigenvectors one-by-one:
for k in range(a.shape[0]):
val = w[k]
# Use a slice to maintain shape; vec is a 2x1 array.
# That allows a meaningful transpose using .T.
vec = vl[:, k:k+1]
# rowvec is 1x2; it is the conjugate transpose of vec.
# This should be the left eigenvector.
rowvec = vec.conj().T
# Verify that rowvec is a left eigenvector
lhs = rowvec.dot(a)
rhs = val * rowvec
print "Compare", lhs, "to", rhs
print rowvec, "is",
if not np.allclose(lhs, rhs):
print "*NOT*",
print "a left eigenvector for eigenvalue", val
print
print "Matrix version:"
print "This"
print vl.conj().T.dot(a)
print "should equal this"
print np.diag(w).dot(vl.conj().T)
输出:
eigenvalues: [ 5.+1.j 5.-1.j]
Compare [[ 1.6330+2.4495j 4.0825+0.8165j]] to [[ 1.6330+2.4495j 4.0825+0.8165j]]
[[ 0.4082+0.4082j 0.8165-0.j ]] is a left eigenvector for eigenvalue (5+1j)
Compare [[ 1.6330-2.4495j 4.0825-0.8165j]] to [[ 1.6330-2.4495j 4.0825-0.8165j]]
[[ 0.4082-0.4082j 0.8165+0.j ]] is a left eigenvector for eigenvalue (5-1j)
Matrix version:
This
[[ 1.6330+2.4495j 4.0825+0.8165j]
[ 1.6330-2.4495j 4.0825-0.8165j]]
should equal this
[[ 1.6330+2.4495j 4.0825+0.8165j]
[ 1.6330-2.4495j 4.0825-0.8165j]]
现在,eig
文档字符串还在返回值的描述中说:
vl : double or complex ndarray
The normalized left eigenvector corresponding to the eigenvalue
``w[i]`` is the column v[:,i]. Only returned if ``left=True``.
Of shape ``(M, M)``.
这可能会产生误导,因为左特征向量的传统定义(例如http://mathworld.wolfram.com/LeftEigenvector.html或http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#Left_and_right_eigenvectors)是一个行向量,所以它vl
实际上是左特征向量的列的共轭转置。