comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » indexing arrays with arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: indexing arrays with arrays [message #55203 is a reply to message #2442] Tue, 07 August 2007 12:25 Go to previous message
GeoffS is currently offline  GeoffS
Messages: 1
Registered: August 2007
Junior Member
The only way I know to do that is using an "array of indices" to index
into the source array. For example, the answer to your specific
problem would be to create an array containing:
indexes = [0,1, 1,2, 2,3, 3,4, 4,5]
then the extraction statement is simply:
extract = res[indexes]

The extraction statement should be pretty efficient as it uses
implicit loops inside the IDL interpreter/VM. If you need to extract
the same elements many times, then this would be a reasonable
solution, but if you need an efficient/loopless way to create the
'indexes' array then it probably won't help you.

Cheers,

Geoff S.


On Aug 7, 8:39 am, Conor <cmanc...@gmail.com> wrote:
> It seems to me that a highly useful syntax for IDL would be something
> like this:
>
> res = randomu(seed,10)
> start_ind = indgen(5)
> end_ind = start_ind + 1
>
> extract = res[start_ind:end_ind]
>
> In this case, I would envision extract being a 10 element array.
> Namely, it would be the equivelent of:
>
> extract = [res[start_ind[0]:end_ind[0]], res[start_ind[1]:end_ind[1]],
> res[start_ind[2]:end_ind[2]], etc...]
[Message index]
 
Read Message
Read Message
Previous Topic: question regarding 3d plotting
Next Topic: Re: question regarding 3d plotting

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:45:14 PDT 2025

Total time taken to generate the page: 0.00517 seconds