## eigen vs Matlab

lorenzoz
Registered Member
Posts
2
Karma
0

### eigen vs Matlab

Fri Dec 14, 2012 5:08 pm
Hello,

I'm solving a generalized eigenvalue problem which looks like this

Code: Select all
`      Matrix<long double, Dynamic, Dynamic> m_A(N,N);    Matrix<long double, Dynamic, Dynamic> m_B(N,N);      for (unsigned int i=0; i<N; i++)      for (unsigned int j=0; j<N; j++)      {         m_A(i,j)=RB_system_matrix_A(i,j);         m_B(i,j)=RB_system_matrix_B(i,j);      }      GeneralizedSelfAdjointEigenSolver<Matrix<long double, Dynamic, Dynamic> > solverAB(m_A,m_B);   Matrix<long double, Dynamic, 1> eigenvAB(N);   eigenvAB = solverAB.eigenvalues();   std::cout << eigenvAB << std::endl;`

But the results I get using the same matrices in Matlab are different, and apparently more reliable. Switching every time to Matlab is annoying though. Can anvbody give me an explanation?

Thanks!!
ggael
Moderator
Posts
2822
Karma
18
OS

### Re: eigen vs Matlab

Sat Dec 15, 2012 6:19 pm
Recall that for GeneralizedSelfAdjointEigenSolver, B must be positive definite. Maybe in your case it is nearly singular? Without the matrices A and B, I cannot help more!!
lorenzoz
Registered Member
Posts
2
Karma
0

### Re: eigen vs Matlab

Fri Jan 11, 2013 11:33 am
Sorry for reviving the topic only now, but I had vacation!

Yes, my B is s.p.d. but condition number is quite high, 10^6.

## Who is online

Registered users: adving, andreas_k, Baidu [Spider], Bing [Bot], davidemme, Exabot [Bot], Google [Bot], google01103, jstaniek, kkamg, louis94, Majestic-12 [Bot], metzman, michelb, planhths, ramskulls, rumangerst, ScionicSpectre, smankowski, Sogou [Bot], textamoebe, tienhung, timeknows, vicr123, Yahoo [Bot]