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

Home » Public Forums » archive » Can I do this without using loops?
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: Can I do this without using loops? [message #6404 is a reply to message #6323] Sat, 15 June 1996 00:00 Go to previous messageGo to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <31C17DE4.50C@zibmt.uni-ulm.de>, David Ritscher
<david.ritscher@zibmt.uni-ulm.de> wrote:

> The algorithms:
> 1. array = fltarr(rows, columns, /nozero)
> for j = 0L, columns-1 do array(*, j) = float(j)

> 3. array = FINDGEN(rows) # REPLICATE(1, columns)

> Here are the execution times, in seconds, under IDL and PV-Wave, for
> the specified array sizes, for each of the algorithms above. The left
> two columns show the times for inserting columns, the second two
> columns involve inserting rows.
>
> Tested using the following number of rows and columns: 3000, 3000
>
> Insert columns Insert rows
> IDL PV-Wave IDL PV-Wave
> 1. 22.84 17.58 30.48 21.31

> 3. 3.88 9.73 3.87 9.70
>
> Tested using the following number of rows and columns: 1000, 30000
>
> Insert columns Insert rows
> IDL PV-Wave IDL PV-Wave
> 1. 84.95 71.09 Inf Inf

> 3. 27.65 42.95 30.88 50.10

I confess to being surprised by how fast (3) is compared to (1). I always
thought these tricks using the # operator to avoid loops were 'too clever
by half'. At least on the face of it, (3) creates an unnecessary
temporary vector and does useless multiply operations. The multiplies can
probably be perfectly overlapped with the stores on a RISC machine (and so
lead to no additional cost), but even so it seems more complicated. There
may still be aspects of (1) that are interpreted, (the loop probably is),
but it would seem to be the simplest possible operation to write as
optimized code.

Thanks for the lesson.

This does point out how useful a good IDL profiling tool would be.

Ken Bowman

--
Kenneth P. Bowman, Assoc. Prof. 409-862-4060
Department of Meteorology 409-862-4132 fax
Texas A&M University bowman@csrp.tamu.edu
College Station, TX 77843-3150
Satellite ozone movies on CD-ROM --> http://www.lenticular.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Searching for Constraint Optimization IDL Routine
Next Topic: Re: polar surfaces

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

Current Time: Fri Oct 10 11:29:13 PDT 2025

Total time taken to generate the page: 0.56487 seconds