Registered Member
|
Hi,
I am trying to solve sparse & over-determined system in a least-squares manner (L * px = m). What I did with Eigen is, I apply SimplicialLDLt decomposition to normal matrix (L' * L) and solve L' * m using decomposition. I could not manage to get right output with large L matrix (error is too high that can not be any numerical error). I also try to emulate Cholesky factorization & solution with Matlab which gives expected output. It is not logical to think that there is something wrong with Eigen's SimplicialLDLt but I don't know what I can do else... I provide 'working' c++ code for demonstrating the problem (you should just check main method) which can read matrices from txt files, matlab code which is also reading matrices and emulating cholesky solution, also links to problematic L and px txt rars.
http://dl.dropbox.com/u/54262186/px.rar Note: I append reading & writing utility (actually all of the code) recently (previous hour) so other people can try the code. I test it using Matlab, before solution step all matrices and vectors in Matlab and C++ are matching. So there should not be any problem related to reading & writing utilities. I am very sorry for long question, any help will be appreciated. Thanks for reading. |
Moderator
|
there is nothing wrong, it's just the limitations of float (what you used) versus double (what Matlab uses).
For instance, with float, the infinite norm (Ls * pxd - mLt).cwiseAbs().maxCoeff() gives 3.68746e-07 which is the best accuracy you can get with floats, leading to: (L * pxd - m).cwiseAbs().maxCoeff() = 0.00026805 (px - pxd).cwiseAbs().maxCoeff()/px.cwiseAbs().maxCoeff() = 0.300609 With double this drops down to: (Ls * pxd - mLt).cwiseAbs().maxCoeff() = 8.68229e-16 (L * pxd - m).cwiseAbs().maxCoeff() = 5.95531e-14 (px - pxd).cwiseAbs().maxCoeff()/px.cwiseAbs().maxCoeff() = 6.48869e-11 |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]