![]() Registered Member ![]()
|
Greetings!
I've encountered a rather curious issue (heretofore, Eigen has served me perfectly without any problems!). I am trying to solve a linear eigenvalue problem (the Schrodinger equation, precisely) : H psi = E psi; Where H is an NxN matrix (Self-adjoint, real, &c). I defined it as such, and then called on :
Here's a comparison of the result from Mathematica with that of Eigen's: Eigen: ![]() Mathematica: ![]() (Obviously, Mathematica's output is the correct one; and Eigen's behaviour here is particularly strange: the entries of the vector seem to oscillate between positive and negative -- an utterly improbable outcome). How do I resolve this problem? Thank you for your attention, Daniel P.S. H was populated identically in Mathematica & Eigen. All elements match. |
![]() Moderator ![]()
|
In order to help you, we need a way to reproduce the issue: either the input matrix or a self-contained example.
|
![]() Registered Member ![]()
|
Hi!
Thanks for your reply. Here's the link for it -- I've had to compress it (the matrix itself is very large (as you might imagine). It's also (rather) sparse). http://speedy.sh/nm39y/HMatrix.tar.bz2 Please let me know if there's anything else I can provide to resolve this issue. Thankful, Daniel |
![]() Registered Member ![]()
|
Furthermore, to ease matters, here's the code that populates the matrix:
(A typical tridiagonal matrix); "i" goes from 0 to N=2000; dr = 7.5*10^(-3); r0 = 0.001; |
![]() Moderator ![]()
|
I get the same eigenvalues than mathlab:
Code to reproduce:
|
![]() Registered Member ![]()
|
Hi, thanks for your reply.
The problem is specifically with the eigenvectors. Take a look at the eigenvector corresponding to the 2nd eigenvalue (-1.97..). If you compare Eigen's with Mathematica's (or Matlab's) you'll end with two fundamentally different vectors. As you can see in my original post, the vector itself contains entries which simply oscillate between positive and negative -- i.e. a nonsensical result. Can you reproduce the same result, on your end? Beholden for your help, Daniel |
![]() Moderator ![]()
|
Note that if V is an eigenvector, then -V is also one.
edit: for the record, here are the first entries of the first eigenvectors, Eigen (i.e., eig.eigenvectors().topLeftCorner(30,6)):
Lapack/MatLab (i.e., V(1:30,1:6))
|
![]() Registered Member ![]()
|
Hi Ggael!
I've finally managed to resolve the problem. I can't thank you enough for your time and help. The matter was due to a ridiculous mistake of mine, in unloading the eigenvectors into a dedicated file. So that's been cleared. Thanks again! One more question, if I may: is there a dedicated routine for the eigenvalues/vectors of a sparse matrix? (I am aware that Armadillo/Lapack has those, not sure if Eigen's already implemented that) Once again, Bound and grateful for your attention and aid, Daniel |
![]() Moderator ![]()
|
For tridiagonal, yes, as I showed in a previous example (see above):
For general sparse matrices, we have a wrapper to ARPACK. |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]