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

SelfAdjointEigenSolver [Eigen] vs eig [Matlab]

Tags: None
(comma "," separated)
Jon Snow
Registered Member
Posts
1
Karma
0
Hello everyone !

I computed with Matlab :
Code: Select all
[eigenVec,eigenVal] = eig(A)


And with Eigen :
Code: Select all
const Eigen::SelfAdjointEigenSolver<Eigen::MatrixXcd> eigenDecomposition(A);
const Eigen::VectorXd eigenVal = eigenDecomposition.eigenvalues();
const Eigen::MatrixXcd eigenVec = eigenDecomposition.eigenvectors();


I have the same eigenvalues in the two cases (except the lowest in the range of 10^-15) but the eigenvectors are really very different.
The matrix A is complex. I noticed more the dimensions of A are important, better is the precision. The errors are much more significant at the level of the imaginary part of the eigenvectors than at the level of the real part.

Do you see where this problem comes from ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
First of all make such that A is self-adjoint, that is (A-A.adjoint()).norm() / A.norm() is below 1e-16. Then, recall that the eigenvectors are not unique. If v is an eigenvector, then -v is also a valid eigenvector. Moreover, the multiplicity of eigenvalue is greater to 1, then the respective eigenvectors can be arbitrarily chosen within the sub-space they define. Finally, you can check the accuracy yourself with:

(A * eigenVec - eigenVec * eigenVal.asDiagonal()).norm() / A.norm()

If you see a large error, then please provide an example.
wendingmai
Registered Member
Posts
16
Karma
0
ggael wrote:First of all make such that A is self-adjoint, that is (A-A.adjoint()).norm() / A.norm() is below 1e-16. Then, recall that the eigenvectors are not unique. If v is an eigenvector, then -v is also a valid eigenvector. Moreover, the multiplicity of eigenvalue is greater to 1, then the respective eigenvectors can be arbitrarily chosen within the sub-space they define. Finally, you can check the accuracy yourself with:

(A * eigenVec - eigenVec * eigenVal.asDiagonal()).norm() / A.norm()

If you see a large error, then please provide an example.



Hi, ggael

I also noticed this porb. It seems like a "-" is miss, as listed in:
viewtopic.php?f=74&t=133853&p=359766&hilit=SelfAdjointEigenSolver%3CMatrixXcd%3E#p359766


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]