JuliaLang/julia — pull request #9101 by zgimbutas (2014-11-21 22:11:34+00:00)
Title: Implement the tolerance parameter for the pseudo-inverse of diagonal matrices

Following the yesterday's bug fixes and discussions, I looked more into the related issue #5407. This pull request addresses consistency requirements (users expect `pinv` to be similar to `\`) discussed in the thread above and simplifies implementation logic.

For consistency, this branch implements the threshold parameter for all diagonal matrices (dense and sparse), and `pinv(a,0)` will use all singular vectors to compute the pseudo-inverse. The pinv operator now behaves similarly to the one in matlab, in fact, this code is quite similar to the original Andreas' implementation plus some tweaks for speed and guarding for zero and denormalized numbers.

Unfortunately, the adaptive thresholding option had to go, but that can be addressed by simply documenting the fact that general dense ill-conditioned matrices will benefit from using the threshold parameter `sqrt(eps(real(float(one(T)))))`. The test driver was updated accordingly.