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

## SGEEV giving incorrect results

Beginner
273 Views
Hello,
I am using SGEEV to calculate the eigenvalues and right eigenvectors of a block diagonal matrix. For some examples SGEEV seems to be giving the wrong result. I have attached the code along with this post. It is almost exactly the same code as the mkl example for sgeev. I have just changed the matrix and the output routine (since I know that the eigenvectors and values are real). If V_r is the right eigenvector and D = diagonal matrix of eigenvalues for matrix A, it can be verified from the output that A*V_r != V_r*D.

I think I might be abusing the interface or just doing something plain wrong. Could someone please clarify whether the issue is with mkl or with my usage of the routine?

C.S.N
1 Solution
Black Belt
273 Views
You call the Fortran77 routine from C, and pass a one-dimensional array to it. Fortran-77 convention dictates that the matrix be stored in the one-dimensional array by concatenating the columns of the matrix. C, however, has the opposite convention, with rows concatenated. In effect, you computed the left eigenvectors of the matrix, which are equivalent to the right eigenvectors of the transpose matrix.

You can adjust for this mismatch in several ways:

1. Enter the matrix in the expected Fortran column-1, column-2, ... order.

2. Call SGEEV('V','N',...) and print VL(:)

3. Use the C-oriented LAPACKE_sgeev routine.

2 Replies
Black Belt
274 Views
You call the Fortran77 routine from C, and pass a one-dimensional array to it. Fortran-77 convention dictates that the matrix be stored in the one-dimensional array by concatenating the columns of the matrix. C, however, has the opposite convention, with rows concatenated. In effect, you computed the left eigenvectors of the matrix, which are equivalent to the right eigenvectors of the transpose matrix.

You can adjust for this mismatch in several ways:

1. Enter the matrix in the expected Fortran column-1, column-2, ... order.

2. Call SGEEV('V','N',...) and print VL(:)

3. Use the C-oriented LAPACKE_sgeev routine.

Beginner
273 Views
Ah, of course! Thanks mecej4, that clarifies the situation!