The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Wrong eigenvectors? HELP!

Open discussion regarding features, bugs, issues, vendors, etc.

Wrong eigenvectors? HELP!

Postby bountynella » Tue Oct 23, 2007 4:06 pm

HI,

I'm trying to compute the eigenvalues and eigenvectors of a complex hermitean matrix and noticed that I seem to get different answers depending on if I call zheevx with UPLO='U' or UPLO='L'. Sometimes both runs give the wrong answer, i.e. eigenvectors are not orthonormal, sometimes just one of them is wrong. The eigenvalues are always correct. I normally don't program in Fortran, so maybe I'm doing something wrong with my errors.
I posted an example-code below. It would be great, if you can give me some hints. I really need to get this working. Thx a lot!!!
Oh, I compiled with: g77 -o code code.f -L/usr/local/lib -llapack -lblas



PROGRAM test_lapack
INTEGER :: i,j,k
COMPLEX*16 Im,test
COMPLEX*16 fortran_array (8,8), WORK(264), evec(8,8)
DOUBLE PRECISION :: ABSTOL, VL, VU, RWORK(56), eval(8)
INTEGER :: row, column,column2
INTEGER :: IL, INFO, IU, LWORK, M,N, LDA
INTEGER :: IFAIL(8), IWORK(40)
N=8
VL=0.
VU=1.
IL=0
IU=1
ABSTOL=2*DLAMCH('S')
M=8
Im =(0.,1.)
LWORK=264
LDA = 8;

fortran_array(1,1)=-56.
fortran_array(2,1)= (0.,1.)
fortran_array(3,1)= 0.
fortran_array(4,1)= 0.
fortran_array(5,1)= 0.
fortran_array(6,1)= 0.
fortran_array(7,1)= -1.
fortran_array(8,1)= 0.

fortran_array(1,2)= (0.,-1.)
fortran_array(2,2)=-15.
fortran_array(3,2)= 0.
fortran_array(4,2)= 0.
fortran_array(5,2)= 0.
fortran_array(6,2)= 0.
fortran_array(7,2)= 0.
fortran_array(8,2)= 0.

fortran_array(1,3)= 0.
fortran_array(2,3)= 0.
fortran_array(3,3)=-46.
fortran_array(4,3)= (0.,17.)
fortran_array(5,3)= -1.
fortran_array(6,3)= 0.
fortran_array(7,3)= 0.
fortran_array(8,3)= 0.

fortran_array(1,4)= 0.
fortran_array(2,4)= 0.
fortran_array(3,4)= (0.,-17.)
fortran_array(4,4)=-25.
fortran_array(5,4)= 0.
fortran_array(6,4)= 0.
fortran_array(7,4)= 0.
fortran_array(8,4)= 0.

fortran_array(1,5)= 0.
fortran_array(2,5)= 0.
fortran_array(3,5)= -1.
fortran_array(4,5)= 0.
fortran_array(5,5)=-26.
fortran_array(6,5)= 0.
fortran_array(7,5)= 0.
fortran_array(8,5)= 0.

fortran_array(1,6)= 0.
fortran_array(2,6)= 0.
fortran_array(3,6)= 0.
fortran_array(4,6)= 0.
fortran_array(5,6)= 0.
fortran_array(6,6)=-5.
fortran_array(7,6)= 0.
fortran_array(8,6)= 0.

fortran_array(1,7)= -1.;
fortran_array(2,7)= 0.
fortran_array(3,7)= 0.
fortran_array(4,7)= 0.
fortran_array(5,7)= 0.
fortran_array(6,7)= 0.
fortran_array(7,7)=-16.
fortran_array(8,7)= (0.,3.)

fortran_array(1,8)= 0.
fortran_array(2,8)= 0.
fortran_array(3,8)= 0.
fortran_array(4,8)= 0.
fortran_array(5,8)= 0.
fortran_array(6,8)= 0.
fortran_array(7,8)= (0.,-3.)
fortran_array(8,8)=-35.

CALL zheevx('v','a','U',N,fortran_array,LDA,VL,VU,IL,IU,ABSTOL,M,
2 eval,evec, N, WORK,LWORK,RWORK,IWORK,isuppz,info)


STOP
END
bountynella
 
Posts: 2
Joined: Tue Oct 23, 2007 4:03 pm

Postby sven » Wed Oct 24, 2007 6:35 am

You have isuppz as the penultimate argument in your call to zheevx, which you have not declared, but I suspect that you meant to put IFAIL.

Best wishes,

Sven Hammarling.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby bountynella » Thu Oct 25, 2007 3:10 am

Thx. I figured out the reason for the different eigenvectors. My matrix has degenerate eigenvalues. The eigenvectors of degenerate eigenvalues span a subspace. Depending on the solver, I get a different set of basis eigenvectors but they actually do span the same subspace. So, I guess, everything is fine. :-)
bountynella
 
Posts: 2
Joined: Tue Oct 23, 2007 4:03 pm


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests