a question about numpy

sturlamolden sturlamolden at yahoo.no
Tue Sep 8 23:24:55 EDT 2009


On 9 Sep, 03:45, hi_roger <rechardc... at gmail.com> 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.

So the only way to do this is to make an ndarray subclass that
overloads __getitem__, __setitem__, and __iter__, and takes care of
the mapping into A. Thus you get a double indirection.









More information about the Python-list mailing list