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

Home » Public Forums » archive » Re: subscript array question
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: subscript array question [message #14302 is a reply to message #14298] Thu, 11 February 1999 00:00 Go to previous messageGo to previous message
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
> I'm using IDL 5.0 and need to be able to use a subscript
> array containing duplicate values like this:
>
> array = intarr(5)
> subs = [0,2,4,4]
> array[subs] = array[subs] + 1
>
> and have the resulting values for array be:
>
> 1 0 1 0 2

How about something like this:
IDL> array = intarr(9)
IDL> subs = [2,3,4,2,4,4,7,5]
IDL> array[min(subs):max(subs)] = array[min(subs):max(subs)] +
histogram(subs)
IDL> print, array
0 0 2 1 3 1 0 1 0

I checked it with arrays up to a size of findgen(100000) and it runs
without
any noticeable time delays. I have not, however, done any error
checking,
i.e., if subs contain elements outside of array, or any real checking of
any
sort for that matter. :-) HTH

cheers,
eddie

----- ---- --- --- ---- --- -- --- --- -- -- - - - -
|\ A G Edward Haskell
|\ Center for Coastal Physical Oceanography
|\ Old Dominion University, Norfolk VA 23529
|\ Voice 757.683.4816 Fax 757.683.5550
|\ e-mail haskell*ccpo.odu.edu
----- ---- --- ---- --- --- --- --- -- -- -- - - - -
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: DICOM3 read/write module with AVS and/or IDL ?
Next Topic: Re: Timer events

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

Current Time: Sat Nov 29 20:05:09 PST 2025

Total time taken to generate the page: 0.00863 seconds