I'm struggling with the following problem: I have some very big matrices (say, at least, 2000x2000, and probably in the future they will even reach 10000x10000) with very small rank (2 or 3, call it N) and I need to find an efficient Python routine to extract the linear independent rows (or columns, the matrix is symmetric!) From them. I tried to take the first N columns of the Q matrix of QR decomposition but it seems not to work correctly (is this wrong maybe?).
Here's the Python code I use to implement the method suggested by Ami Tavory:
from numpy import absolute
from numpy.linalg import qr
q = qr(R)[1] #R is my matrix
q = absolute(q)
sums = sum(q,axis=1)
i = 0
while( i < dim ): #dim is the matrix dimension
if(sums[i] > 1.e-10):
print "%d is a good index!" % i
i += 1
This should tell me if the row is non-zero and therefore if the I-th column of R is linearly independent.