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

*To*: "Liam E. Gumley" <Liam.Gumley(at)ssec.wisc.edu>*Subject*: Re: Vectorization question*From*: Pavel Romashkin <promashkin(at)cmdl.noaa.gov>*Date*: Tue, 12 Sep 2000 13:34:51 -0600*Newsgroups*: comp.lang.idl-pvwave*Organization*: NOAA-CMDL-CIRES*References*: <39BD53C5.78E9D166@ssec.wisc.edu>*Reply-To*: promashkin(at)cmdl.noaa.gov*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:21372

Hi Liam, I came up with a different approach. For short arrays in a loop, it is 3 times slower than your method, Liam. However, with A being 1,000,000 and both X and B 100,000 elements long, your method could not allocate memory on my machine, while mine ran in 0.07 s. Check out the code below. The loops were put in to get runtime extimates. I run 5.3 on PowerMac G4, 192 MB total RAM, 64 MB allocated to IDL. Cheers, Pavel pro pavel, a, b, x out = a start = systime(1) ;for i =0, 10000 do begin ind = x[uniq(x, sort(x))] loc = value_locate(x, ind) sum_b = total(b, /cumulative) res = [0, sum_b[loc], 0] a_values = (res-shift(res, 1))[1:n_elements(res)-2] out[ind] = a_values ;endfor print, systime(1) - start ;print, out, format='(10i4)' end pro liam, a, b, x out = a start = systime(1) ;for i =0, 10000 do begin tmp = intarr(n_elements(a), n_elements(x)) tmp[x, indgen(n_elements(x))] = b out = a + total(tmp, 2) ;endfor print, systime(1) - start ;print, out, format='(10i4)' end

**Follow-Ups**:**Re: Vectorization question***From:*Craig Markwardt

**References**:**Vectorization question***From:*Liam E. Gumley

- Prev by Date:
**Axis labels** - Next by Date:
**Re: Axis labels** - Prev by thread:
**Re: Vectorization question** - Next by thread:
**Re: Vectorization question** - Index(es):