matrix rank of numpy array or matrix
Hello - Is there a function to compute the matrix rank of a numpy array or matrix? So I don't mean the current rank(), which gives the number of dimensions. I mean the number of independent equations of a matrix. Thanks, Mark
On Tue, 5 Feb 2008 10:54:01 -0800 (PST) mark <markbak@gmail.com> wrote:
Hello -
Is there a function to compute the matrix rank of a numpy array or matrix? So I don't mean the current rank(), which gives the number of dimensions. I mean the number of independent equations of a matrix.
Thanks,
Mark _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
AFAIK, a build-in function is (still) missing. However you might use a singular value decomposition to compute the numerical rank of a matrix. See e.g. http://osdir.com/ml/python.numeric.general/2006-02/msg00154.html Nils
Thanks. I rewrote the line as: from numpy.linalg import svd from numpy import sum,where def matrixrank(A,tol=1e-8): s = svd(A,compute_uv=0) return sum( where( s>tol, 1, 0 ) ) Would be nice to include matrixrank in numpy, as it is really useful, Thanks again, Mark On Feb 5, 7:59 pm, "Nils Wagner" <nwag...@iam.uni-stuttgart.de> wrote:
On Tue, 5 Feb 2008 10:54:01 -0800 (PST) mark <mark...@gmail.com> wrote:
Hello -
Is there a function to compute the matrix rank of a numpy array or matrix? So I don't mean the current rank(), which gives the number of dimensions. I mean the number of independent equations of a matrix.
Thanks,
Mark _______________________________________________ Numpy-discussion mailing list Numpy-discuss...@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
AFAIK, a build-in function is (still) missing. However you might use a singular value decomposition to compute the numerical rank of a matrix.
See e.g.http://osdir.com/ml/python.numeric.general/2006-02/msg00154.html
Nils
_______________________________________________ Numpy-discussion mailing list Numpy-discuss...@scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion
On Tue, 5 Feb 2008 11:37:12 -0800 (PST) mark <markbak@gmail.com> wrote:
Thanks. I rewrote the line as:
from numpy.linalg import svd from numpy import sum,where
def matrixrank(A,tol=1e-8): s = svd(A,compute_uv=0) return sum( where( s>tol, 1, 0 ) )
Would be nice to include matrixrank in numpy, as it is really useful,
+1 And a nullspace function - how about that ? See http://aspn.activestate.com/ASPN/Mail/Message/scipy-user/2726126 Nils
participants (3)
-
Keith Goodman -
mark -
Nils Wagner