[Numpy-discussion] Selecting columns of a matrix (original) (raw)
Bill Baxter wbaxter at gmail.com
Wed Jun 21 23:23:38 EDT 2006
- Previous message (by thread): [Numpy-discussion] Selecting columns of a matrix
- Next message (by thread): [Numpy-discussion] "运用DOE改进工艺提高产品质量(AD)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6/22/06, Alan G Isaac <aisaac at american.edu> wrote:
> Alan G Isaac wrote: >> M.transpose()[V>0] >> If you want the columns as columns, >> you can transpose again.
On Wed, 21 Jun 2006, Keith Goodman apparently wrote: > I can't get that to work when M is a n by m matrix: The problem is not M being a matrix. You made V a matrix (i.e., 2d). So you need to ravel() it first. >> M.transpose()[V.ravel()>0]
No dice, V.ravel() returns a matrix still. Looks like you'll need M.T[V.A.ravel()>0].T
Just lovely. Is the new bool conversion thingy going to help make the syntax more reasonable for matrices, too? Seems like it will still require M[:,V.A.ravel() > 0] or M[:, V.A.squeeze() > 0] or M[:,V.A[:,0]>0]
Anyway, this seems to me just more evidence that one is better off getting used to the 'array' way of doing things rather than clinging to Matlab ways by using 'matrix'. Is it worth dealing with the extra A's and asmatrix()'s and squeeze()'s that seem to crop up just to be able to write AB instead of dot(A,B) ()?
--Bill
(*) Ok, there's also the bit about being able to tell column vectors from row vectors and getting useful errors when you try to use a row that should have been a column. And then there's also the .T, .I, .H convenience factor. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060622/9c1e1b0e/attachment-0001.html>
- Previous message (by thread): [Numpy-discussion] Selecting columns of a matrix
- Next message (by thread): [Numpy-discussion] "运用DOE改进工艺提高产品质量(AD)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]