[SciPy-user] Vector indexing

David Grant david.grant at telus.net
Sun Jun 4 19:03:49 CDT 2006


On Sunday 04 June 2006 16:34, David Grant wrote:
> Vector indexing question:
>
> a=rand(10,10)
>
> 1) a[0:3, 0:3] #gives me the first 3 rows and columns
>
> 2) a[range(2),range(2)] gives me a one-dimensional array of elements [0,0],
> [1,1], [2,2]
>
> How do I do 1) using some on-the-fly generated array?

I figured out one way to do it:

take(take(a,x,0),y,1)

It looks like take is in numpy.core.oldnumeric, so is there are new way to do 
it?

I am very used to Matlab, unfortunately.... 

Dave



More information about the SciPy-user mailing list