[SciPy-user] Vector indexing

Simon Burton simon at arrowtheory.com
Sun Jun 4 19:13:56 CDT 2006


On Sun, 04 Jun 2006 17:03:49 -0700
David Grant <david.grant at telus.net> wrote:

> 
> 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)

a[x,:][:,y]

?

Simon.

-- 
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com 



More information about the SciPy-user mailing list