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

Home » Public Forums » archive » Re: negative indices, am I missing something here?
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: negative indices, am I missing something here? [message #81990 is a reply to message #81989] Fri, 02 November 2012 14:39 Go to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Friday, November 2, 2012 8:51:56 PM UTC+1, d.rowe...@gmail.com wrote:
> IDL 8 brought negative indices for arrays. Great, love them. However, I am getting strange results.
>
>
>
> IDL> a = indgen(3,5)
>
> IDL> print, a[*,-1]
>
> 12 13 14
>
>
>
> Good, that is what I thought I should get.
>
>
>
> IDL> print, a[*, [3,1,4]]
>
> 9 10 11
>
> 3 4 5
>
> 12 13 14
>
>
>
> Also, this looks right to me.
>
>
>
> So why doesn't this work?
>
> IDL> print, a[*, [3,1,-1]]
>
> 9 10 11
>
> 3 4 5
>
> 0 1 2
>
>
>
> Is this the expected behavior? Or a bug?
>
>
>
> Mac 10.8.2 IDL 8.2.1

Array subscripts are always clipped. From IDL help:

"If an element of the subscript array is less than or equal to zero, the first element of the subscripted array is selected. ...

Note: Because of the confusion between the clipping of array subscripts and the use of negative indices (see the next section), it is best to avoid using code that relies on this clipping behavior."

regards,
Lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: change values of structure variable
Next Topic: use of temporary in IDL

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

Current Time: Sun Oct 12 14:34:46 PDT 2025

Total time taken to generate the page: 0.56207 seconds