[SciPy-user] Reference to algorithm for matrix rank
Robert Kern
robert.kern@gmail....
Thu Oct 9 18:40:06 CDT 2008
On Thu, Oct 9, 2008 at 13:13, Matthew Brett <matthew.brett@gmail.com> wrote:
> Hi,
>
> I wanted to write a generic matrix rank algorithm. The general form
> seems to be standard:
>
> def matrix_rank(M, tol):
> S = svd(M, compute_uv=False)
> return np.sum(S > tol)
>
> but what I can't find is some citable reference for a general way to
> choose 'tol'. Does anyone know of the right source for this?
You should get the book _Matrix Computations_ by Golub and van Loan.
You actually want tol to be relative to S.max(), not an absolute
tolerance. I like this:
np.sum(S > (S.max() * np.finfo(M.dtype).eps)
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-user
mailing list