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

Home » Public Forums » archive » Re: Was: Index... Now: Vectorize, huh?
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: Was: Index... Now: Vectorize, huh? [message #24607 is a reply to message #24606] Thu, 05 April 2001 14:13 Go to previous messageGo to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Craig Markwardt wrote:

> Part of the
> problem is that you coded your vectorized path inefficiently.

I tried it the way you did, but decided to try the full "one-line"
vectorized solution.

> I've always said that if you can vectorize the inner loop of your
> operation then you are usually fine. Pavel, you actually did that in
> your *non*-vectorized case. :-)

This is true, and I do this in my code since I found that out a while
ago. I wonder if that means, in fact, that array operations in IDL are
optimized for vectors (row-wise arrays) only, and once you are into more
than 1 dimension, you are better off looping through other dimensions.

> A new version of TEST improves things slightly, but doesn't tip the
> scales. w/ your version I get 1.6 and 3.8 s. With my version I get
> 1.5 and 2.7 s.

On my system, your own solution from the previous post is faster still,
but the loop can not be defeated:
;***********
function test, s, vec=vec
start = systime(1)
x = findgen(s)
if keyword_set(vec) then begin
;a = rebin(x, s, s)^2
;a = sqrt(transpose(a) + a)
;a = sqrt((transpose(rebin(x, s, s)))^2 + (rebin(x, s, s))^2)
a = (x # (fltarr(s)+1))^2
a = sqrt(transpose(a) + a)
endif else begin
a = fltarr(s, s)
for i = 0, s-1 do a[0, i] = sqrt(x^2 + i^2.)
endelse
print, systime(1) - start
return, a
end
;***********

Cheers,
Pavel
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Header File *.h?
Next Topic: Re: Cant find functions in lib

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

Current Time: Sat Oct 11 10:38:45 PDT 2025

Total time taken to generate the page: 0.48107 seconds