a question about numpy

Robert Kern robert.kern at gmail.com
Thu Sep 10 19:30:16 CEST 2009

On 2009-09-09 20:46 PM, rechard wrote:
> Robert Kern wrote:
>> On 2009-09-08 20:45 PM, hi_roger wrote:
>>> hello, i want to ask a question about numpy.
>>> 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 )
>>> The submatrix must share data memory with original matrix.
>>> Any one help? thank you
>> Sturla is almost correct. What you really want is this:
>> i = [[i1], [i2], [i3]]
>> j = [[j1, j2, j3]]
>> B = A[i, j]
>> http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer
>> If you have more numpy questions, please ask on the numpy mailing list.
>> http://www.scipy.org/Mailing_Lists
> wow..., thank you all :)
> but it seems it is impossible to make the submatrix share data with the
> original matrix in pure numpy code ?

That is correct.

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