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 #13053 is a reply to message #12982] Fri, 02 October 1998 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Kastrup 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]
>
> [netiquette comment cut]
>
> 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.
>

Although I really agree with Kevin in terms of the danger that lies in
using some pecularity of IDL (which makes it hard to understand a
program, too), I must admit that there is a significant difference in
execution speed if you can avoid the second sort command. For a 20000
floating point array ( a=sin(findgen(20000)/360.*!PI) ), I find
execution times of 0.01xx vs 0.06xx secs if once compares (in Eric's
'terminology') a[s]=a[*] with a=a[sort(s)]. Well, this is definitively
not worth risking anything. BUT if you go to 2M elements, the difference
becomes one between 2 secs and 22 secs, which does matter. In any case,
as always: a nice comment in the program would help ;-)

Regards,
Martin.


------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
[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: Tue Apr 14 06:39:22 PDT 2026

Total time taken to generate the page: 2.16134 seconds