在MATLAB中,计算矩阵A的特征值和特征向量的函数是eig(A),常用的调用格式有
5种:
(1) E=eig(A):求矩阵A的全部特征值,构成向量E。
(2) [V,D]=eig(A):求矩阵A的全部特征值,构成对角阵D,并求A的特征向量构成
V的列向量。
(3)
[V,D]=eig(A,'nobalance'):与第2种格式类似,但第2种格式中先对A作相似
变换后求矩阵A的特征值和特征向量,而格式3直接求矩阵A的特征值和特征向量。
(4) E=eig(A,B):由eig(A,B)返回N×N阶方阵A和B的N个广义特征值,构成向量E
。
(5) [V,D]=eig(A,B):由eig(A,B)返回方阵A和B的N个广义特征值,构成N×N阶对
角阵D,其对角线上的N个元素即为相应的广义特征值,同时将返回相应的特征向
量构成N×N阶满秩矩阵,且满足AV=BVD。
eig
Find eigenvalues and
eigenvectors
Syntax
d = eig(A)
d = eig(A,B)
[V,D] = eig(A)
[V,D] = eig(A,'nobalance')
[V,D] = eig(A,B)
[V,D] = eig(A,B,flag)
d = eig(A)和 [V,D] = eig(A)最为常用 注意,第一列为对应第一个特征值的特征向量。
如果是eig(A)的形式,取决于A是否是Hermite阵:
如果A是Hermite阵则选用对称QR算法(对小矩阵)和divide and conquer算法(对大矩阵);
如果A不是Hermite阵则使用非对称QR算法。
如果是eig(A,B)的形式,也取决于对称性:
如果A和B都是Hermite阵且至少有一个半正定,那么应该会利用Cholesky分解归约到普通的对称特征值问题;
如果上述结构不满足,那么会使用QZ算法。
Jacobi算法虽然精度很高,但是速度相对慢一些,所以不作为默认的算法。
附录:
matlab中关于eig的说明:
EIG Eigenvalues and eigenvectors.
E =
EIG(X) is a vector containing the eigenvalues of a
square
matrix X.
[V,D] = EIG(X) produces a diagonal matrix D of eigenvalues and
a
full
matrix V whose columns are the corresponding eigenvectors
so
that
X*V = V*D.
[V,D] = EIG(X,'nobalance') performs the computation with
balancing
disabled, which sometimes gives more accurate results for
certain
problems with unusual scaling. If X is symmetric,
EIG(X,'nobalance')
is
ignored since X is already balanced.
E =
EIG(A,B) is a vector containing the generalized
eigenvalues
of
square matrices A and B.
[V,D] = EIG(A,B) produces a diagonal matrix D of
generalized
eigenvalues and a full matrix V whose columns are the
corresponding eigenvectors so that A*V = B*V*D.
EIG(A,B,'chol') is the same as EIG(A,B) for symmetric A and
symmetric
positive definite B. It computes the generalized
eigenvalues of A and B
using the Cholesky factorization of B.
EIG(A,B,'qz') ignores the symmetry of A and B and uses the QZ
algorithm.
In
general, the two algorithms return the same result, however using
the
QZ
algorithm may be more stable for certain problems.
The flag is
ignored when A and B are not symmetric.