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

repeated eigenvalues and wrong eigenvectors

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

after using solvers in eigen and we get repeated eigenvalues how can we find true values of vectors? I cant find any way to get rid of this problem.If you answer I will be more than happy.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Do you have a concrete example so that we can reproduce? (note that in case of repeated eigenvalues, the respective eigenvectors are not uniquely defined).
ahmetsag
Registered Member
Posts
3
Karma
0
hi ggeal,

my matris is :
--------------------
Matrix:
40411.7 -16498 0 -13470.6
-16498 40411.7 -20205.9 0
0 -20205.9 40411.7 -16498
-13470.6 0 -16498 40411.7
--------------------

and I used EigenSolver and SelfAdjointEigenSolver and for example for EigenSolver:
--------------------
Values:
(74088.2,0)
(6735.25,0)
(40411.7,0)
(40411.6,0)
--------------------
Vectors:
(-0.447213,0) (0.447213,0) (0.541911,0) (0.553473,0)
(0.547723,0) (0.547723,0) (0.451909,0) (-0.442468,0) !
(-0.547723,0) (0.547723,0) (-0.442468,0) (-0.451909,0) !
(0.447213,0) (0.447214,0) (-0.553473,0) (0.541911,0)
--------------------

eigenvalues are rigth but eigenvectors are wrong I am almost sure the problem is repeated eigenvalues "40411.7 " I have searched google and I found something when eigenvalues repeat they use "gram-schmidt".

I have no idea how it can be used with Eigen. I saw also "DGMRES" here http://eigen.tuxfamily.org/dox-devel/un ... GMRES.html but how can it be used when eigenvalues repeated? what are exactly for solver.set_restart() and setEigenv() and also GMRES?

Thank you for all answer from now on
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I don't get the same, and the ones I get are correct (eigen 3.2). Here is a self contained example:

Code: Select all

#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main() {
  MatrixXd M(4,4);
  M <<  40411.7, -16498, 0, -13470.6,
        -16498, 40411.7, -20205.9, 0,
        0, -20205.9, 40411.7, -16498,
        -13470.6, 0, -16498, 40411.7;
       
  SelfAdjointEigenSolver<MatrixXd> eig(M);
  std::cout << eig.eigenvalues().transpose() << "\n\n";
  std::cout << eig.eigenvectors() << "\n\n";
 
  std::cout << "Check reconstruction:\n"
            << (eig.eigenvectors() * eig.eigenvalues().asDiagonal() * eig.eigenvectors().transpose() - M).norm() / M.norm() << "\n\n";
  std::cout << "Check eigenvectors form a unitary basis:\n"
            << (eig.eigenvectors()*eig.eigenvectors().transpose()) << "\n";
}


output:

Code: Select all
6735.25 40411.7 40411.7 74088.2

 0.447213  0.547723  0.547723  0.447213
 0.547723 -0.447213  0.447213 -0.547723
 0.547723 -0.447213 -0.447213  0.547723
 0.447213  0.547723 -0.547723 -0.447213

Check reconstruction:
7.38342e-16

Check eigenvectors form a unitary basis:
           1  1.38778e-16  8.32667e-17 -1.66533e-16
 1.38778e-16            1            0  3.60822e-16
 8.32667e-17            0            1  5.55112e-17
-1.66533e-16  3.60822e-16  5.55112e-17            1
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I checked the ones you printed out and they correct too. As I said, in case of duplicated eigenvalues, the respective eigenvectors are not uniquely defined. What is important is that 1) they are eigenvectors (M*V=lamda*V) and that they form a unitary basis with respect to the underlying metric, in your case: V*V^T=Identity.
ahmetsag
Registered Member
Posts
3
Karma
0
I see Ggal,
by the way how can I use deflate method DGMRES I have looked document but I dont understand how it can be used exactly?

Thank you for your all answers.


Bookmarks



Who is online

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