This forum has been archived. All content is frozen. Please use KDE Discuss instead.

SelfAdjointEigenSolver Eigenvectors depend on g++ optimizer!

Tags: None
(comma "," separated)
sb933
Registered Member
Posts
3
Karma
0
Hi all,

I've been using Eigen for two months now, and I successfully used it to calculate the eigenvalues and eigenvectors of a 20 x 20 Hermitian matrix using the self-adjoint solver.

When I scale the problem up to 400 x 400, I find that the eigenvectors were not the ones I expected. I then noticed that the eigenvectors depend on the g++ optimizer option! Note that the eigenvalues are correct. So if you think you might have a clue to what's going on please let me know. I will start posting parts of my code as needed.

Thanks in advance,
sb
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
what's wrong with the result you get?

anyway, the first thing is to check that M V = V L, e.g.:

std::cout << (M - eig.eigenvectors() * eig.eigenvalues().diagonal() * eig.eigenvectors().adjoint()).cwiseAbs().maxCoeff() / M.cwiseAbs().maxCoeff() << "\n";
sb933
Registered Member
Posts
3
Karma
0
Thanks for the prompt response. I tried your test and got ~ 10^(-13) for g++ -O0 to -O3.

I think I know what the problem is. The 400 x 400 system has high degeneracy. Many eigenvectors correspond to the same eigenvalue. My earlier 20 x 20 problem had no degeneracy. I broke the symmetry and my C++ eigen code produced the same result as zheev in lapack with FORTRAN90. I can do with this at the moment and won't be looking at highly symmetric systems in the near future, so as far as my application is concerned, problem solved.

It is likely that for the degenerate case, zheev and SelfAdjointEigenSolver arrange the eigenvectors corresponding to the same eigenvalue (or linear combinations of them) in different ways. It would be good to know if the solver has an option to control the way eigenvectors are given. However, with zheev, the optimizer did not change the output of the program in the degenerate case, unlike in eigen with SelfAdjointEigenSolver. Does this mean that at the moment the solver should not be used for highly degenerate cases?

Thanks,
sb
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ok, this seems to be something to look at more closely, though as far as I remember, Eigen's SelfAdjointEigenSolver passed the lapack numerical tests.
bgreene
Registered Member
Posts
11
Karma
0
>Does this mean that at the moment the solver should not be used for highly degenerate cases?

If the eigenvalues are the same, isn't it the case that any linear
combination of their eigenvectors is just as valid as any other?
That the particular linear combination changes depending on small changes
in the numerical operations doesn't seem like a reason for concern to me.

Bill Greene
sb933
Registered Member
Posts
3
Karma
0
bgreene wrote:>That the particular linear combination changes depending on small changes in the numerical operations doesn't seem like a reason for concern to me.

Bill Greene


Of course this should not be of concern. I am just interested why such linear combinations depend on the optimizer ...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar