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

Home » Public Forums » archive » Re: User selectable lower array bound?
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: User selectable lower array bound? [message #25978] Thu, 02 August 2001 17:52 Go to previous message
bennetsc is currently offline  bennetsc
Messages: 18
Registered: January 1998
Junior Member
In article <3B69CA57.FD3B1D8D@noaa.gov>,
Paul van Delst <paul.vandelst@noaa.gov> wrote:
> Hey there,
>
> Is is just me, or would anyone else find useful the ability to
> define arrays in IDL such
> that the lower bound is *not* always zero? Sorta like:
>
> x = FINDGEN( 11, LOWER = -5 )
> or
> y = DBLARR( 100, LOWER = 1 )
>
> so that accessing elements such as x[ -4 ] or y[ 100 ] are o.k.?

Yes, that would make a lot of code much more understandable
and less prone to errors during development.
>
> I know this can be done now with judicious use of proxy indices, e.g.
>
> FOR i = -5, 5 DO BEGIN
> ix = i + 5
> PRINT, x[ ix ]
> ....do other stuff with negative i's....
> ENDFOR
>
> but sometimes this makes code hard to follow (or explain to
> someone who's never used the
> code before) in direct correspondence with a physical process.
>
> It seems like such a simple thing to be able to do (with default
> action being start at
> index 0) although I'm sure the amount of work required to
> implement this would be
> horrendous. Still, it shur would be nice.....
>
That depends upon how IDL already keeps track of arrays
internally. In PL/1, for example, one declared an array with the
boundaries for each dimension in the form lowerbound:upperbound,
where specification of the lower bound and the colon were optional.
If only the upper bound were specified, then the lower bound defaulted
to 1. In its internal representation of arrays, IIRC, PL/1 kept
the lower and upper boundaries of each dimension as part of a control
block preceding the actual array memory. If a language implementation
doesn't already store both boundaries, or equivalently, the lower
boundary and number of elements, for each dimension, then yes, adding
such support might well be a major headache.


Scott Bennett, Comm. ASMELG, CFIAG
College of Oceanic and Atmospheric
Sciences
Oregon State University
Corvallis, Oregon 97331
************************************************************ **********
* Internet: sbennett at oce.orst.edu *
*----------------------------------------------------------- ---------*
* "Lay then the axe to the root, and teach governments humanity. *
* It is their sanguinary punishments which corrupt mankind." *
* -- _The_Rights_of_Man_ by Tom Paine (1791.) *
************************************************************ **********
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL virtual reality (was 3D Object IDL )
Next Topic: IDL virtual reality (was 3D Object IDL )

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

Current Time: Wed Oct 08 14:33:00 PDT 2025

Total time taken to generate the page: 0.33525 seconds