MKL SGEEV的错误特征向量
我想计算矩阵的特征值和特征向量。我正在使用Mkl Lapack的SGEEV
。
我有一个非常简单的测试代码:
integer :: i,n, info
real, allocatable:: A(:,:), B(:,:), C(:,:)
real, allocatable:: wr(:), wi(:), vl(:, :), vr(:, :), work(:)
n=3
allocate(vr(n,n), vl(n,n), wr(n), wi(n), work(4*n))
allocate(A(n,n),B(n,n), C(n,n))
A(1,:)=(/-1.0,3.0,-1.0/)
A(2,:)=(/-3.0,5.0,-1.0/)
A(3,:)=(/-3.0,3.0,1.0/)
call sgeev('V','V',n,A,n,wr,wi,vl,n,vr,n,work,size(work,1),info)
print*,info
do i=1,n
print*,i,wr(i),wi(i)
enddo
print*,'vr'
do i=1, n
print*, vr(i,:)
enddo
print*,'vl'
do i=1, n
print*, vl(i,:)
enddo
它给出了正确的特征值(2,2,1
),但是错误的特征向量。
我有:
vr
-0.577350259 0.557844639 -0.539340019
-0.577350557 0.704232574 -0.273908198
-0.577349961 0.439164847 0.796295524
vl
-0.688247085 -0.617912114 -0.815013587
0.688247383 0.771166325 0.364909053
-0.229415640 -0.153254643 0.450104564
当VR应该是
-1 1 1
0 1 1
3 0 1
什么时候我做错了什么?
I want to compute the eigenvalues and eigenvectors of a matrix. I'm using sgeev
of MKL lapack.
I have this very simple test code:
integer :: i,n, info
real, allocatable:: A(:,:), B(:,:), C(:,:)
real, allocatable:: wr(:), wi(:), vl(:, :), vr(:, :), work(:)
n=3
allocate(vr(n,n), vl(n,n), wr(n), wi(n), work(4*n))
allocate(A(n,n),B(n,n), C(n,n))
A(1,:)=(/-1.0,3.0,-1.0/)
A(2,:)=(/-3.0,5.0,-1.0/)
A(3,:)=(/-3.0,3.0,1.0/)
call sgeev('V','V',n,A,n,wr,wi,vl,n,vr,n,work,size(work,1),info)
print*,info
do i=1,n
print*,i,wr(i),wi(i)
enddo
print*,'vr'
do i=1, n
print*, vr(i,:)
enddo
print*,'vl'
do i=1, n
print*, vl(i,:)
enddo
It gives the right eigenvalues (2, 2, 1
) but the wrong eigenvectors.
I have:
vr
-0.577350259 0.557844639 -0.539340019
-0.577350557 0.704232574 -0.273908198
-0.577349961 0.439164847 0.796295524
vl
-0.688247085 -0.617912114 -0.815013587
0.688247383 0.771166325 0.364909053
-0.229415640 -0.153254643 0.450104564
when vr should be
-1 1 1
0 1 1
3 0 1
What am I doing the wrong way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的矩阵为 demenerate (具有两个eigenvalues,彼此相同)特征向量可以是两个退化特征向量的任意线性组合。
另外,
sgeev
的输出ises特征向量,而您给出的特征向量尚未归一化。给出的第一个特征值是
1
,相应的特征向量是vr
,l1 =( - 0.57 ...,-0.57 ...,-0.57 ...,,-0.57 ..., -0.57 ...)
。这与您给出的第三个特征向量(1,1,1)成正比。第二和第三特征值都是
2
。相应的特征向量是vr
,l2 =(0.55 ...,0.70 ...,0.70 ...,0.43 ...)
and code> l3 = l3 = l3 =(0.55 ...,0.70 ...,0.70 ...,0.70 ...,0.70 ...,0.70 ...,0.70 ...,0.70 ... (-0.53 ...,-0.27 ...,0.79 ...)。服用0.27 ...*L2+0.70 ...*L3
给出(-0.22 ...,0,0.66 ...)
,与(( -1,0,3)
,并服用0.79 ...*l2-0.43 ...*l3
给出(0.66 ...,0.66 ...,0 )
,与(1,1,0)
成比例。Your matrix is degenerate (has two eigenvalues which are the same as one another), so the corresponding eigenvectors can be an arbitrary linear combination of the two degenerate eigenvectors.
Also, the output of
sgeev
normalises the eigenvectors, whereas the eigenvectors you have given are not normalised.The first eigenvalue given is
1
, and the corresponding eigenvector is the first column ofvr
,l1=(-0.57..., -0.57..., -0.57...)
. This is proportional to the third eigenvector you have given,(1, 1, 1)
.The second and third eigenvalues are both
2
. The corresponding eigenvectors are the second and third columns ofvr
,l2=(0.55..., 0.70..., 0.43...)
andl3=(-0.53..., -0.27..., 0.79...)
. Taking0.27...*l2+0.70...*l3
gives(-0.22..., 0, 0.66...)
, proportional to(-1, 0, 3)
, and taking0.79...*l2-0.43...*l3
gives(0.66..., 0.66..., 0)
, proportional to(1, 1, 0)
.