ymorinrivest
Registered Member

Hi everyone,
I have encountered a problem, and i wanted to know if anyone had faced the same issue. I want to find b in Ax = b, so i was using VectorXd and MatrixXd and the following line
and everything was working perfectly fine. I decided to change the VectorXd to VectorXf and MatrixXd to MatrixXf because I was puttting float in the container anyway. Using the float version made it not work. I then tried using the fullPivLU solver and they both worked. Is there a reason why the ldlt solver did not work on the float version of the container even if both the float and double version of the container were populated from float data. I still have the matrix and vector in txt format if anyone is interested... 
ggael
Moderator

Hi,
that happens: a LDLT factorization will lost accuracy if the matrix is not diagonal dominant, while a full pivoting LU will move largest values to the diagonal (and break the original symmetry). It would still be interesting to see your matrix to check there is really nothing to worry. 
ymorinrivest
Registered Member

The curious thing is still that the system can be solved using the double version but not the float for ldlt.
If anyone is interested, here are the matrix and vector i am using : https://docs.google.com/open?id=0B31wzs ... m91MVBjOGM 
Dee33
Registered Member

Your matrix is actually badly conditioned. The condition number is around 1e+18
You can check it by computing the ratio between the maximum singular value and the minimum one. So, you should stick to a robust solver, LU with pivoting or QR or change the model that generates the linear problem. Hope it helps 
ymorinrivest
Registered Member

Thank you for all your answers. There is still one thing that I don't understand: why are the result of the solver different when using MatrixXd and MatrixXf ( by different i mean one is not working and the other is).

Dee33
Registered Member

I think it is exactly because of the bad condition number: http://en.wikipedia.org/wiki/Condition_number
Having a condition number of 1e+18 means that you can loose up to 18 digits of accuracy due to roundoff errors. These roundoff errors depend on the robustness of the numerical method and the representation of floating point numbers. single precision is not good for your problem, only the 8 first digits are the most significant. with double precision, you need a robust solver. You can also try quadruple precision. 
ymorinrivest
Registered Member

That make sense, thank for all the answers !

Registered users: akhilesh, alikazmi, andreas_k, Artmessiah, Baidu [Spider], Bing [Bot], cglwdm, Exabot [Bot], Google [Bot], google01103, jmacleod, k_sze, ken300, metzman, nharmony, pouar, sdh, TheraHedwig, tokiedian, Yahoo [Bot]