Registered Member
|
Hi all,
I am getting a bit of contradicting results so I was wondering if someone can shed some light. I have a symmetric matrix, that should be positive definite. I usually use L*L^T to solve a normal equations matrix. In this specific case I am looking at, I get no errors. I checked using L*D*L^T function isPositive (I understand that the check is for semi-definite) and it returns true. I check the eigenvalues using SelfAdjointEigenSolver, there is 1 negative eigenvalue (-1.4384e+10) I check the eigenvalues using matlab, all are > 0. I check the eigenvalues using EigenSolver all are > 0. What am I missing here ? |
Moderator
|
Which Eigen version are you using? Are you using float or double? complex or real?
Could you share the matrix or a self-contained exemple so that we can reproduce the issue? |
Registered Member
|
Hi ggael,
I am using 3.2.9 but also tried 3.3-beta2. The values are real doubles. There is no problem in sharing the matrix so here is a reproduction sample and the matrix in comma delimited format. Reproduction code https://app.box.com/s/pbpcff3baz80abafje7k6kmy1byk3sly Matrix https://app.box.com/s/7isc1kh1kcp3rmsbr4jfmuy8pcyyisl4 |
Moderator
|
Thank you, I can reproduce. There seems to be some overflow or the likes as scaling the matrix with:
mat = mat/mat.norm(); fixes the inconsistency. But this is weird as I'm pretty sure that SelfAdjointEigenSolver performs such a scaling under the hood... I'll investigate... |
Moderator
|
ah, wrong alarm, actually this -1.4384e+10 eigenvalue is numerically equal to 0 because the largest eigenvalue is much larger. Your test should be:
bool adj_es_ispos = !((adj_es.eigenvalues().array() < -std::numeric_limits<double>::epsilon()*adj_es.eigenvalues()(mat.cols()-1)).any()); |
Moderator
|
For the record, here are the eigenvalues computed by SelfAdjointEigenSolver:
and the one computed by the equivalent routine in Lapack:
|
Registered Member
|
Thanks ggael,
That makes sense, Below are the eigen values that I get from matlab (R2012a) which are all positive
|
Moderator
|
Yes, matlab calls a generic eigen solver, more like Eigen::EigenSolver instead of a one specialized for symmetric problems. Without more precision there is not much we can do in SelfAdjointEigenSolver because with double, there is no way to assess the accuracy of eiegnvalues smaller than 1e-16 * largest eigenvalues. Actually, if you call it with "long double", SelfAdjointEigenSolver also returns positive eigenvalues.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]