Calculate Matrix Rank using scipy
Posted
by Hooked
on Stack Overflow
See other posts from Stack Overflow
or by Hooked
Published on 2010-03-18T23:10:19Z
Indexed on
2010/03/18
23:31 UTC
Read the original article
Hit count: 667
I'd like to calculate the mathematical rank of a matrix using scipy. The most obvious function numpy.rank
calculates the dimension of an array (ie. scalars have dimension 0, vectors 1, matrices 2, etc...). I am aware that the numpy.linalg.lstsq
module has this capability, but I was wondering if such a fundamental operation is built into the matrix class somewhere.
Here is an explicit example:
from numpy import matrix, rank
A = matrix([[1,3,7],[2,8,3],[7,8,1]])
print rank(A)
This gives 2
the dimension, where I'm looking for an answer of 3
.
© Stack Overflow or respective owner