Hi, On Tuesday 08 April 2008 10:46:37 Leopold Palomo-Avellaneda wrote: > I have been lately working with the gsl library, using the SVD > decomposition, but I am having real trouble, so i thought that i was > probably doing something wrong and you could help me. yes, you are doing something wrong: You calculate the pseudoinverse in a completely different way in the C++ program and in the Matlab script and expect to get the same results. In the C++ program, you do it using gsl_linalg_LU_decomp () and gsl_linalg_LU_invert () which goes badly wrong because the third diagonal entry of the matrix S is very close to zero. In the Matlab script, you apparently thought of this problem and did it this way: % As S is diagonal, que can compute its inverse by dividing inverting its % diagonal values for i = 1:max if (S(i,i) > 0.0000000001) S(i,i) = 1/S(i,i); else S(i,i) = 0; end end The "if (S(i,i) > 0.0000000001)" check avoids the huge matrix entries which caused the problems in your C++ program. I've attached a fixed version of your program which reproduces the results of the Matlab script (at least up to the limited precision of the Matlab results). Frank P.S.: Apparently, my first reply was rejected by the list server because the Google Mail web interface for some reason decided to send it as text/html.