[Numpy-discussion] syntax for obtaining rank of two columns? (original) (raw)

JJ josh8912 at yahoo.com
Thu Jun 15 18:56:56 EDT 2006


Hello. I am a matlab user learning the syntax of numpy. Id like to check that I am not missing some easy steps on column selection and concatenation. The example task is to determine if two columns selected out of an array are of full rank (rank 2). Lets say we have an array d that is size (10,10) and we select the ith and jth columns to test their rank. In matlab the command is quite simple:

rank([d(:,i),d(:,j)])

In numpy, the best I have thought of so far is:

linalg.lstsq(transpose(vstack((d[:,i],d[:,j]))),
ones((shape(transpose(vstack((d[:,i],d[:,j]))))
[0],1),'d'))[2]

Im thinking there must be a less awkward way. Any ideas?

JJ


Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com



More information about the NumPy-Discussion mailing list