Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong eigenvalues in the EJML v0.34 #35

Open
nhavt opened this issue Jun 10, 2018 · 5 comments
Open

Wrong eigenvalues in the EJML v0.34 #35

nhavt opened this issue Jun 10, 2018 · 5 comments
Labels
verified Bug/Problem has been verified

Comments

@nhavt
Copy link

nhavt commented Jun 10, 2018

Hi there,
When computing eigenvalues for the matrix D ( see in attached file) with the EJML v0.34 [D.txt] (https://github.com/lessthanoptimal/ejml/files/2087909/D.txt), I found there is a bug in the function D.svd.getW() as it returned wrong eigenvalues for the matrix D. However when I used the function D.eig().getEigenvalues(), it returned the correct eigenvalues, which are 0.866, and 0.866. Therefore, could you please check this? Thank you in advance!
Nha

@nhavt nhavt changed the title Errors in Eigen A bug in the EJML v0.34 Jun 10, 2018
@nhavt nhavt changed the title A bug in the EJML v0.34 Wrong eigenvalues in the EJML v0.34 Jun 10, 2018
@lessthanoptimal
Copy link
Owner

Could you provide a couple of lines of code which demonstrate this problem?

@nhavt
Copy link
Author

nhavt commented Jun 11, 2018

thank you for your response. Here they are

SimpleMatrix D; // read a matrix from the D.txt file
SimpleEVD evd = D.eig();
SimpleSVD svd = D.svd();

System.out.println("evd"+evd.getEigenvalues());
System.out.println("svd"+svd.getW().diag().transpose());

As you can see the last two lines of the code will return different eigenvalues. In principle, both functions should return the correct non-zero eigenvalues, which are 0.866 and -0.866. Also, I have another problem when computing eigenvalues for the M matrix (see in attached file) M.txt. For example, if I use the following codes:
SimpleMatrix M; // read a matrix from the M.txt file
SimpleEVD evd = M.eig(), it returned the error messages:
Eigenvalue Decomposition failed
at org.ejml.simple.SimpleEVD.(SimpleEVD.java:57)
at org.ejml.simple.SimpleBase.eig(SimpleBase.java:950)

Could you please have a look at it? Thank you in advance!

@lessthanoptimal
Copy link
Owner

I've verified that this is a real issue. I was able to decompose the M.txt matrix by increasing the number of exceptional shifts, but I'm wondering if there might be a better way to perform this iteration. Eigenvalue decomposition is very tricky to get right.

I'll look into the SVD issue a little bit later

@lessthanoptimal
Copy link
Owner

@nhavt If possible can you figure out a simple formula to generate matrices which cause the current algorithm to fail? That will make creating a unit test much easier.

@lessthanoptimal lessthanoptimal added the verified Bug/Problem has been verified label Jul 12, 2018
@nhavt
Copy link
Author

nhavt commented Jul 24, 2018

Thank you for your help. As to a simple formula to generate such matrices, I don't have a simple formula at the moment. Looking at the structure of M matrix, I observe there are a lot of zeros in this matrix. So, my guess is that if you could create a sparse matrix with a few non-zero elements. That might give you a unit test. However, I will double check it and let you know. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
verified Bug/Problem has been verified
Projects
None yet
Development

No branches or pull requests

2 participants