a question about numpy

Robert Kern robert.kern at gmail.com
Wed Sep 9 17:58:11 CEST 2009


On 2009-09-08 22:03 PM, sturlamolden wrote:
> On 9 Sep, 03:45, hi_roger<rechardc... at gmail.com>  wrote:
>
>> i know how to select a submatrix using the slice object in numpy. But
>> how can i select a submatrix
>> A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column
>> j1,j2,j3 ,  and i1,i2,i3,j1,j2,j3 are all arbitrary numbers )
>
> You just pass an array of ints for each dimension. If you want a 3x3
> submatrix, you must pass in two 3x3 arrays of indices.

Oops! I just responded to the OP saying that you were "almost correct"; but I 
was just thinking of your latter 1D example rather than this correct statement. 
My apologies.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list