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

Home » Public Forums » archive » Would you consider this a bug?
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: Would you consider this a bug? [message #13044 is a reply to message #12982] Sat, 03 October 1998 00:00 Go to previous messageGo to previous message
muswick is currently offline  muswick
Messages: 10
Registered: April 1998
Junior Member
In article <m2ogrw9df6.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>,
David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> wrote:
> Kevin Ivory <Kevin.Ivory@linmpi.mpg.de> writes:
>
>> Leaving the bug topic - switching to algorithms
>>
>> David Kastrup wrote:
>>> Unfortunately, translating something like
>>>
>>> a[[5,2,3,0,4,1]] = a
>>> into the equivalent
>>> a = a[[3,5,1,2,4,0]]
>>> is not easy to do in the general case.
>>
>> Actually it is: you need a second call to sort. See example below.
>>
>>> some data that needed to be processed in sorted order, the results
>>> needed to be rearranged in original order.
>>>
>>> Something like
>>> s = sort(a)
>>> a = a[s]
>>> process(a)
>> ; a[s] = a ; I still think this a dangerous thing to do.
>> r = sort(s)
>> a = a[r]
>
> First, it is extremely impolite to send a copy of a followup in the
> newsgroup to the original poster without marking it as such. Now I
> have to type my reply all over again. Double work.
>
> Second, I refuse to call a significantly time-consuming routine like
> "sort" (O(n log n)) twice without good reason. Especially when a
> simple workaround like writing
> a[s] = a+0
> will do the trick.
>
> --

Actually I don't think it is a bug. One needs to carefully review how IDL
handles arrays and indices.

If we go back to the original posted question:

> a = [3,4,5]
> a[[2,1,0]] = a

> a will be set to [3,4,3]

Which is correct, based on 'a' being overwritten. This is avoid huge memory
overhead in many cases where the right side equation is complex.

David Kastrup then suggested:
> One has to write
> a[[2,1,0]] = a + 0

> in order to get the more correct seeming [5,4,3].

Which does work, however this is not necessary to get the desired answer.
The following works just fine and follows the access methods shown in

a[[2,1,0]] = a[*]

the IDL manuals, but not fully explained. In every example in the IDL
manuals where left side subscripting is be used, the right hand is subscripted
(even if with only the asteriks) except where left variable is not the same.

So, I do not consider the original question a bug, since the above works just
fine by using [*]. It is also about 5 percent faster on large arrays versus
adding zero.

Gary Muswick
University Hospitals of Cleveland.


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: CENTERING TEXT
Next Topic: what am I doing wrong?

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

Current Time: Mon Dec 01 08:59:32 PST 2025

Total time taken to generate the page: 1.36768 seconds