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

Home » Public Forums » archive » Re: elegant array index expansion using INTERPOLATE
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: elegant array index expansion using INTERPOLATE [message #58040] Fri, 11 January 2008 14:32
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Jan 11, 5:07 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
>   > Isn't array[expidxrange] just array[3:6] or
>
>> array[idxrange[0]:idxrange[1]] ?
>> ...or are you after the explicit list of expidxrange?
>
> Hi Bob,
>
> 'expidxrange' is just a 2-element array.  I find the indices using
> another method and throw them into a 2-element array.  I ultimately need
> to extract the explicit list of elements from 'array'.
>
> Ryan.

Looked to me like expidxrange was the 4 element array [3,4,5,6] in
your example and
idxrange was the 2 element array giving the endpoints of expidxrange.

Anyway, using the ':' notation on your array should get you your list
of elements without having to calculate an explicit list of indexes
(since you want all indexes between the endpoints).

Bob.
Re: elegant array index expansion using INTERPOLATE [message #58042 is a reply to message #58040] Fri, 11 January 2008 14:07 Go to previous message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
> Isn't array[expidxrange] just array[3:6] or
> array[idxrange[0]:idxrange[1]] ?
> ...or are you after the explicit list of expidxrange?

Hi Bob,

'expidxrange' is just a 2-element array. I find the indices using
another method and throw them into a 2-element array. I ultimately need
to extract the explicit list of elements from 'array'.

Ryan.
Re: elegant array index expansion using INTERPOLATE [message #58043 is a reply to message #58042] Fri, 11 January 2008 13:56 Go to previous message
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Jan 11, 3:33 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
> Hi All,
>
> If I have a range of array indices I want to be able to interpolate
> between this to get all indices in between.  What is an elegant way of
> doing this?
>
> Here is an example of what I want:
>
> array = [0,2,4,6,8,10,12,14,16,18]
> idxrange = [3, 6]
>
> expidxrange = Interpolate('idxrange') to get [3,4,5,6]
>
> so that I can get
> array[expidxrange] OR [6,8,10,12]
>
> I would like it to be as general as possible.  This is what I have, but
> it doesn't work for a range of 1:
>
> expidxrange = INTERPOLATE(idx, $
> (1./(idxrange[1]-idxrange[0])*FINDGEN(idxrange[1]-idxrange[0 ]) ) )
>
> Any thoughts?
>
> Ryan.

Isn't array[expidxrange] just array[3:6] or
array[idxrange[0]:idxrange[1]] ?
...or are you after the explicit list of expidxrange?

Bob.
Re: elegant array index expansion using INTERPOLATE [message #58045 is a reply to message #58043] Fri, 11 January 2008 12:50 Go to previous message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
> Do you want:
>
> expidxrange = lindgen(idxrange[1]-idxrange[0]+1)+idxrange[0]

Thanks Vince,

I was making it more complicated than it should be! That's exactly what
I wanted. It must be because it is Friday afternoon.

Leaving soon,
Ryan.
Re: elegant array index expansion using INTERPOLATE [message #58048 is a reply to message #58045] Fri, 11 January 2008 12:45 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jan 11, 2:33 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
> Hi All,
>
> If I have a range of array indices I want to be able to interpolate
> between this to get all indices in between. What is an elegant way of
> doing this?
>
> Here is an example of what I want:
>
> array = [0,2,4,6,8,10,12,14,16,18]
> idxrange = [3, 6]
>
> expidxrange = Interpolate('idxrange') to get [3,4,5,6]
>
> so that I can get
> array[expidxrange] OR [6,8,10,12]
>
> I would like it to be as general as possible. This is what I have, but
> it doesn't work for a range of 1:
>
> expidxrange = INTERPOLATE(idx, $
> (1./(idxrange[1]-idxrange[0])*FINDGEN(idxrange[1]-idxrange[0 ]) ) )
>
> Any thoughts?
>
> Ryan.

Do you want:

expidxrange = lindgen(idxrange[1]-idxrange[0]+1)+idxrange[0]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: combinatorial annealing
Next Topic: image on map

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

Current Time: Wed Oct 08 20:06:20 PDT 2025

Total time taken to generate the page: 0.79603 seconds