[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: Was: Index... Now: Vectorize, huh?*From*: "Pavel A. Romashkin" <pavel.romashkin(at)noaa.gov>*Date*: Thu, 05 Apr 2001 15:13:06 -0600*Newsgroups*: comp.lang.idl-pvwave*Organization*: NOAA-CMDL-CIRES*References*: <3ACBABB3.A5DD07B7@noaa.gov> <3ACCC66A.26E1C63A@noaa.gov> <on1yr7yuit.fsf@cow.physics.wisc.edu>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:24415

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

**References**:**Index of a sector***From:*Pavel A. Romashkin

**Was: Index... Now: Vectorize, huh?***From:*Pavel A. Romashkin

**Re: Was: Index... Now: Vectorize, huh?***From:*Craig Markwardt

- Prev by Date:
**Re: Was: Index... Now: Vectorize, huh?** - Next by Date:
**Re: Was: Index... Now: Vectorize, huh?** - Prev by thread:
**Re: Was: Index... Now: Vectorize, huh?** - Next by thread:
**Re: Was: Index... Now: Vectorize, huh?** - Index(es):