[Numpy-discussion] addressing a submatrix (original) (raw)
Martin Wiechert martin.wiechert at gmx.de
Wed Jun 14 10:19:35 EDT 2006
- Previous message (by thread): [Numpy-discussion] addressing a submatrix
- Next message (by thread): [Numpy-discussion] addressing a submatrix
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks Pau, that's exactly what I was looking for.
Martin
On Wednesday 14 June 2006 12:01, you wrote:
On 6/14/06, Martin Wiechert <Martin.Wiechert at mpimf-heidelberg.mpg.de> wrote: > Hi Simon, > > thanks for your reply. > > A [I, J] > > seems to only work if the indices are strides as in your example. I > need fancy indices (like I = (1,3,4), J = (0,3,5)), and for them A [I, J] > won't do what I want. As you can see from the example session I posted it > does not address the whole rectangle IxJ but only the elements (I1, > J1), (I2, J2). E.g., if I==J this is the diagonal of the submatrix, > not the full submatrix.
you can use A[ ix(I,J) ] to do what you want. But, if you just want subrectangular regions then A[1:4,1:4] is enough. Please note that A[1:4,1:4] is not the same as A[ arange(1,4), arange(1,4) ], but is the same as A[ ix(arange(1,4), arange(1,4)) ]. hope this heps pau
- Previous message (by thread): [Numpy-discussion] addressing a submatrix
- Next message (by thread): [Numpy-discussion] addressing a submatrix
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]