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 #14308 is a reply to message #14302] Thu, 11 February 1999 00:00 Go to previous message
David Ritscher is currently offline  David Ritscher
Messages: 30
Registered: August 1995
Member
> 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
>
> Because of the way IDL manages memory for expression evaluation
> and assignments, what happens for the last two elements of the
> addition is that the original value of array[4] is used twice,
> rather than what I want, which is to use the current value of
> array[4] each time. I.e. IDL gives the resulting values for
> array to be:
>
> 1 0 1 0 1
>



With my version, IDL Version 5.1.1, I get the latter, not the former!
I suspect it is true with your version, as well. What IDL does is,
for the duplicate subscript, it does the operation twice, but since
'array' on the right hand of the expression is a copy of the original,
it goes and gets the same '0' twice, incremnts it by '1', and inserts
it into the same location twice.

If in your actual application you're having similar problems, the
uniq function might help you out:

array = intarr(5)
subs = [0,2,4,4]

subs = subs(uniq(subs, sort(subs)))

print, subs
0 2 4


array[subs] = array[subs] + 1

In this case, it gives the same result, as I explained, but in your
application, it might serve to solve your problem.


Good luck,


David Ritscher


--
Cardiac Rhythm Management Laboratory
Department of Medicine
University of Alabama at Birmingham
B168 Volker Hall - 1670 University Boulevard
Birmingham AL 35294-0019
Tel: (205) 975-2122 Fax: (205) 975-4720
Email: david.ritscher@bigfoot.com
[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: Sun Oct 12 04:15:30 PDT 2025

Total time taken to generate the page: 1.04144 seconds