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

DGEEV Issues

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

DGEEV Issues

Postby kayronjm » Fri Jul 30, 2010 8:46 pm

I'm close to having my FORTRAN program be able to calculate eigenvalues and eigenvectors from my 10x10 real non-symmetric matrix. I am using the DGEEV LAPACK subroutine and it seems to be doing a good job. The 10 eigenvalues are perfectly correct. The eigenvectors however, look weird.

To compare, I took the matrix and put it into MATLAB and had MATLAB calculate the eigenvalues and eigenvectors. Then I input the eigenvalues and eigenvectors calculated by DGEEV in FORTRAN. Everything is here:

Image

On the top is my matrix. Right below are the eigenvalues and eigenvectors calculated by MATLAB. At the bottom are the real eigenvalues and right eigenvectors calculated by DGEEV in FORTRAN. The eigenvalues are perfectly fine, but on close inspection, the eigenvectors are also perfectly fine except for the 6th and 8th eigenvectors, which don't match MATLAB's at all. Considering the other eigenvectors are perfectly fine, this is really baffling. Can anyone help?
Could it have something to do with degeneracy of eigenvalues and eigenvectors?
It seems I only have this issue when the previous eigenvalue and is degenerate with it, as MATLAB gives the same eigenvector for both.

This is my call to the DGEEV subroutine in FORTRAN:

CALL DGEEV('N', 'V', 10, states_matrix, 10, eigenvalues_R,
& eigenvalues_I, eigenvectors_left, 10, eigenvectors_right, 10,
& WORK, 100, INFO)


And for the eig function in MATLAB, simply:

[V, D] = eig(states_matrix);
D = diag(real(D))';
V = real(V);


I've also tried this with the 'nobalance' flag and though MATLAB's eigenvectors change slightly (little match DGEEV's in this case), I do not get anything similar for the 6th and 8th right eigenvectors.

Thanks in advance for any tips.
kayronjm
 
Posts: 9
Joined: Fri Jul 30, 2010 9:50 am

Re: DGEEV Issues

Postby kayronjm » Sat Jul 31, 2010 9:18 am

Perhaps I'm being a bit hasty thinking this is an issue. Perhaps DGEEV is resolving these degenerate eigenvalues by choosing an orthonormal eigenvector for the second eigenvalue, thus the whole set of eigenvectors is correct except that the eigenvectors corresponding to degenerate eigenvalues were made orthonormal and thus, not the same. I could always just copy over the orthonormal eigenvector with the one before it to obtain the same numbers as MATLAB returns. However, would there be a better way of doing that with DGEEV directly?
I definitely should do this as the different values in each eigenvector correspond partly to the strength of a transition between electron states in an atom. It's all well and good if the eigenvectors are made orthonormal, but the actual values therefore change, which therefore would change my calculated transition rates. I hope this makes sense.
kayronjm
 
Posts: 9
Joined: Fri Jul 30, 2010 9:50 am

Re: DGEEV Issues

Postby kayronjm » Sat Jul 31, 2010 8:02 pm

Just to say, my query is null as I have solved the issue. DGEEV was indeed correct and the different eigenvectors from MATLAB's was because DGEEV was finding an eigenvector orthonormal to the eigenvector for the degenerate eigenvalue. Therefore I wrote a small piece of code after the call to DGEEV to find the degenerate eigenvalues and thus replace the second degenerate eigenvalue's eigenvector with the first's, making both eigenvectors the same, as MATLAB does. It would seem pointless but for my task, it's necessary.
kayronjm
 
Posts: 9
Joined: Fri Jul 30, 2010 9:50 am

Re: DGEEV Issues

Postby DavidB » Sun Aug 01, 2010 8:49 pm

A couple other aspects to keep in mind when comparing results from different software routines:
(i) an eigenvector for a particular eigenvalue doesn't necessarily have to be unique, and
(ii) some routines normalize eigenvectors while others don't (this tripped me up once; I was comparing results from different programs and couldn't figure out why the eigenvalues were the same but the eigenvectors were different--until I realized one program was normalizing the eigenvectors output).
DavidB
 
Posts: 38
Joined: Thu Dec 15, 2005 1:49 pm
Location: Vancouver, B.C. Canada

Re: DGEEV Issues

Postby kayronjm » Mon Aug 02, 2010 10:47 am

Indeed, thanks. I will keep it in mind.
kayronjm
 
Posts: 9
Joined: Fri Jul 30, 2010 9:50 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 2 guests