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

Home » Public Forums » archive » Re: Odd behaviour in array indexing ?
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: Odd behaviour in array indexing ? [message #34184 is a reply to message #34182] Fri, 21 February 2003 07:53 Go to previous messageGo to previous message
tam is currently offline  tam
Messages: 48
Registered: February 2000
Member
David Fanning wrote:
> mwvogel (mvogel@rdiag.fgg.eur.nl) writes:
>
>
>> Today I realized something is amiss in IDL
>> When I do
>> index = [1,0,2,3,1,2,3,4]
>> m = FLTARR(8)
>> d = FINDGEN(8)
>> m[index] = d
>> print, m
>> 1.00000 4.00000 5.00000 6.00000 7.00000
>> 0.000000 0.000000 0.000000
>>
>> Now I would have assumed that IDL would automatically *add* the numbers with
>> identical indices. Not doing
>> so is a potential performance penaly, right ? Or am I mistaken....
>
>
> I find it hard to say what exactly you are trying to
> do here, but IDL seems to be working exactly as I would
> expect it to. Variables on the left hand side of the
> expression are having things assigned to them. I'm not
> sure why you think the assignments should *add*. If I do
> this:
>
> a = intarr(2)
> a[1] = 5
>
> And later,
>
> a[1] = 6
>
> I sure don't want a[1] to equal 11. That is exactly
> what you seem to be asking for above.
>
> Cheers,
>
> David
>

Just to amplify a little. Even if you had written this as
m[index] = m[index] + d
where you might have a more realistic hope that
the m's would accumulate values, it wouldn't work.
It's best to think of IDL array operations as fully parallelized
operations, where there is a separate little CPU handling
the operation for each index. If you need dependencies
on prior iterations, then you need to do things in some different
fashion.

Beware, I think you are about to enter the 'Histogram Zone'.
Dee da dee da ....

Regards,
Tom McGlynn
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Plotting to more than one window
Next Topic: Altivec support in ENVI and/or IDL?

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

Current Time: Thu Oct 09 21:58:40 PDT 2025

Total time taken to generate the page: 0.63996 seconds