How are built eigenvectors with lapack in C

87 Views Asked by At

I am working on eigenvectors with lapacke in C code and I was wondering how are they built when the the eigenvalue has a imaginary part? I mean I have to malloc on the same dimension as if they were only real, so how is the eigenvectors built?

Thank you

1

There are 1 best solutions below

0
francis On

If the matrix is real, double precision, finding the eigenvalues and eigenvectors for such a general matrix could be performed in C by using LAPACKE_dgeev() from LAPACKE. LAPACKE is an interface to LAPACK. Hence, the documentation about the dgeev() function likely answers your question :

If the j-th eigenvalue is real, then v(j) = VR(:,j), the j-th column of VR. If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and v(j+1) = VR(:,j) - i*VR(:,j+1).

While the real and complex parts of eigenvalues are stored in two different arrays WR and WI, the eigenvectors, including those featuring a complex part, are completely stored in a real double precision array of size NxN. It is possible because the eigenvectors corresponding to a pair of complex conjugate eigenvalues are pointwise complex conjugate of one another.

An example showing how to handle complex eigenvectors found by LAPACKE_dgeev() is available in this Intel code sample

This interleaving technique is also featured in LAPACK sgeev() for single precision real general matrices.