Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

## HEEVR and computing eigenvectors Beginner
277 Views
I'm trying to use HEEVR to find some eigenvectors for me but was getting wrong values. I suspect that I'm missing something either in the documentation, but haven't been able to figure it out. I reduced my problem to the code snippet below, and am comparing the output with Matlab. For UPLO='U' the computed values match Matlab in magnitude, but are both complex and real conjugates of the matlab answer. Switching UPLO='L' has values that differ from Matlab by a small amount (~0.05 or so).

Furthermore I've tried to specify the il and iu parmeters by il=1 and iu=3, but MKL prints an error that indicates an invalid argument to CHEEVR at the il position. I can't tell from documentation if it is necessary to specify il and iu in order to compute eigenvectors.

```[fortran]program heevr_test

use lapack95

implicit none

complex :: A(3,3), Z(3,3)
real    :: W(3)
integer :: M, isuppz(512), info

integer :: il,iu

M         = 3
isuppz(:) = 0
info      = 0

A(1,:) = (/  (02., 00.), (06.,-02.), (10.,-04.) /)
A(2,:) = (/  (06., 02.), (10., 00.), (14.,-02.) /)
A(3,:) = (/  (10., 04.), (14., 02.), (18., 00.) /)
call heevr(A,W,UPLO='U',Z=Z,M=M,ISUPPZ=isuppz,INFO=info,abstol=1.0E-25)

print *,'info,M are ',info,M
print *,'Eigen Values',W
print *,'Eigen Vectors'
print *,Z(:,1)
print *,Z(:,2)
print *,Z(:,3)

end program heevr_test
[/fortran]```

This is IVF12 on Windows XP in VS2008.
6 Replies Moderator
277 Views
Hi,

Which version of Intel MKL are you using now?I could get the following result. Is this the same with your?

info,M are 0 3
Eigen Values -3.574176 -2.1457672E-06 33.57416
Eigen Vectors
(-0.8100331,0.2077581) (-0.1458781,0.1038791) (0.5182776,0.0000000E+00)
(-0.4082486,4.4703484E-08) (0.8164966,5.9604645E-08) (-0.4082481,0.0000000E+00)
(-0.3368758,0.1432858) (-0.5441777,7.1642905E-02) (-0.7514797,0.0000000E+00)

Thanks,
Chao Black Belt
277 Views
Are you aware that your matrix is rank-deficient (matrix size = 3 X 3, rank =2)?

The determinant is zero. Beginner
277 Views
mecej4,
Thanks for pointing that out. I should have gathered as much from the 0 eigen value. If you change the matrix to have A(1,1) = 1 then the rank is 3 and this is no longer a problem.

Chao Y,
I have whatever MKL was provided with ComposerXE2011. It's not clear to me what version that is.
Yes, that is the result I get given that UPLO='U', but when UPLO='L' the values are completely different.

After updating the matrix so that A(1,1) = 1, the rank is now 3 and I reran my program. Using UPLO='U' gives the same answer as Matlab. Using UPLO='L' gives different answers from matlab but Z*W - A*V < 0.001 in both cases, so this must be a normalization difference.

I still haven't been able to specify any inputs using the il or iu arguments without throwing an MKL error. Any insight into why that might be? Moderator
277 Views Moderator
277 Views
Hi,

I can reproduct this problem here. We are further checkingthe problem, and will prvoide you an update.

Thanks,
Chao Employee
277 Views
Hello,

The difference in eigenvectors is ok.
As comes from eigenvalues definition Ax=lx, where x is eigenvector and l is eigenvalue, the x is defined up to scaling by a constant. Since x is normalized, for real cases we see allways the the same eigenvalues. However for complex case there is still a dimenson of freedom ofscaling bydifferentcomplex numbers which has modulesequal toone (rotation of the vector).
Thus you could have different correcteigenvectors for the same eigenvalue in complex case, but for every pair of such egenvectors x1 and x2 the following applies: x1=c*x2, where c is complex number with norm=1.
For upper and lower cases order of simple mathematicaloperation in the algorithm differs (only the half of matrix is readed, but it is always readedcolumnwise for performance reasons), this causes that algorithm comes to different corret eigenvalues just due approximations during computations.

I've just checked that the rule of x1=c*x2, norm(c)=1works for all of the eigenvectorsin your testcase.

And one could conclude from your observations that MATLAB does UPLO='U'... :)

Also I've tried putting IL=1 and IU=3 and didn't found any error reports. EQ this way:
call heevr(A,W,UPLO='U',Z=Z,M=M,ISUPPZ=isuppz,IL=1,IU=3,abstol=1.0E-25,INFO=info)

W.B.R.,
Alexander 