Page 1 of 1

Problem with ZGEEV

PostPosted: Sat Jul 26, 2008 9:39 am
by raad
Hi all,

In part of my code, I should calculate the eigenvectors of a matrix. What I obtain by using ZGGEV is different from what matlab calculates. Here is my fortran code:

program testeig
IMPLICIT NONE
C
INTEGER N1,N3
PARAMETER (N1=4)
INTEGER LWORK,LRWORK
PARAMETER (LWORK=2*N1,LRWORK=2*N1)
INTEGER INFO
COMPLEX*16 VL(1,1),VR(N1,N1),W(N1),WORK(LWORK)
COMPLEX*16 WORK2(LWORKhat),Dkn(4,4)
DOUBLE PRECISION RWORK(LRWORK)
EXTERNAL ZGEEV
C
Dkn ( 1, 1) =(1585.96849,92.8490244)
Dkn ( 1, 2) =(-92.8488992,4.53196508E-17)
Dkn ( 1, 3) =(0.,0.)
Dkn ( 1, 4)= (0.,14.5905841)
Dkn ( 2, 1)= (92.8488992,-4.53196508E-17)
Dkn ( 2, 2) =(1585.96849,-92.8490244)
Dkn ( 2, 3)= (0.,-14.5905841)
Dkn ( 2, 4) =(0.,0.)
Dkn ( 3, 1)= (0.,0.)
Dkn ( 3, 2)= (0.,-14.5905841)
Dkn ( 3, 3)= (1585.96849,92.8490244)
Dkn ( 3, 4) =(92.8488992,-4.53196508E-17)
Dkn ( 4, 1) =(0.,14.5905841)
Dkn ( 4, 2) =(0.,0.)
Dkn ( 4, 3) =(-92.8488992,4.53196508E-17)
Dkn ( 4, 4) =(1585.96849,-92.8490244)
CALL ZGEEV('N','V',N1,Dkn,N1,W,VL,1,VR,N1,WORK,N1*2,RWORK,INFO)
DO 200 ii=1,N1,1
DO 100 jj=1,N1,1
Write(*,*) 'v(',i,',',j,') is ',VR(ii,jj)
100 CONTINUE
200 CONTINUE
C
END PROGRAM testeig


results:

v( 1, 1) is (0.923879662,0.)
v( 1, 2) is (-2.55356717E-16,-0.382683121)
v( 1, 3) is (0.,0.)
v( 1, 4) is (0.,0.)
v( 2, 1) is (-1.82246465E-19,-0.382683121)
v( 2, 2) is (0.923879662,0.)
v( 2, 3) is (0.,0.)
v( 2, 4) is (0.,0.)
v( 3, 1) is (0.,0.)
v( 3, 2) is (0.,0.)
v( 3, 3) is (0.923879662,0.)
v( 3, 4) is (2.55356717E-16,0.382683121)
v( 4, 1) is (0.,0.)
v( 4, 2) is (0.,0.)
v( 4, 3) is (1.82246465E-19,0.382683121)
v( 4, 4) is (0.923879662,0.)


what i get from matlab is:
v =

Column 1

0.92270849830536
-0.00000000000000 - 0.38082503809785i
0
0.05984411009315 - 0.00000000000000i

Column 2

-0.00000000000000 - 0.38549841394625i
0.91152255445945
0
-0.00000000000000 + 0.14323967870895i

Column 3

-0.00027322438045 + 0.00109083579468i
-0.00264300756859 + 0.14259300786723i
-0.00017141755625 + 0.38549673564999i
0.91162010808412

Column 4

-0.00132881698445 + 0.00000000000000i
-0.05984404803584 + 0.00054843623924i
0.92270754147257
-0.00008618309039 + 0.38082464318886i


Can any one help me?
Bests.

Re: Problem with ZGEEV

PostPosted: Thu Jul 31, 2008 2:09 pm
by Julien Langou
Hello,

(1) With this matrix, you have multiple eigenvalues, you have twice the complex conjugate
pair: (1585.97+/- 132.12i). This implies that two different eigensolvers will find
the same four eigenvalues, but are likely to give different eigenvectors. This is because
in this case there is no unicity (even up to a sign) of the eigenvectors. As long as you have
the relation: A = V D V^{-1}. The eigensolver has dons its job.

(2) Matlab uses LAPACK-3.0 (as far as I have been updated), so if you uses LAPACK-3.0
(and not 3.1) you might be able to find the same eigenvectors, although this is without
any importance.

(3) You can note that your matrix is normal since A^H A = A A^H.

--julien.

Re: Problem with ZGEEV

PostPosted: Tue Aug 05, 2008 11:40 pm
by raad
Thanks Julien.