[Numpy-discussion] syntax for obtaining rank of two columns? (original) (raw)
Tim Hochberg tim.hochberg at cox.net
Thu Jun 15 20:27:42 EDT 2006
- Previous message (by thread): [Numpy-discussion] syntax for obtaining rank of two columns?
- Next message (by thread): [Numpy-discussion] syntax for obtaining rank of two columns?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
JJ wrote:
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? This isn't really my field, so this could be wrong, but try:
linalg.lstsq(d[:,[i,j]], ones_like(d[:,[i,j]]))[2]
and see if that works for you.
-tim
JJ
Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
- Previous message (by thread): [Numpy-discussion] syntax for obtaining rank of two columns?
- Next message (by thread): [Numpy-discussion] syntax for obtaining rank of two columns?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]