Now I am using CLAPACK, I want to calculate the pseudo inverse for ill conditioned matrix by calling dgelss and setting B to a identity matrix. The matrix is overdetermined(100*64) and not full rank. The condition number is 2.2e+16. The result I got is different from that of MATLAB. There is no huge number in the result so it seems right, but actually it's wrong(if MATLAB is right). But for a small matrix, which is 2*2 with a condition number 2.2e+8, the results are both right.

I'm wonderring is there any way that I can get a right result? Or should I call dgesvd and do the rest calculate myself? Or should I treat the matrix first to eliminate the ill condition before doing the dgelss?

For deeper understanding, what's the different between the algorithms of pinv in MATLAB and dgelss in CLAPACK? Is there any additional ill condition elimination treatment in MATLAB?

I appreciate any comment.

Best regards,