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

Home » Public Forums » archive » Re: Cleaver 2d reverse indicies?
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: Cleaver 2d reverse indicies? [message #63292] Tue, 04 November 2008 07:48 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Nov 4, 4:56 am, Chris <beaum...@ifa.hawaii.edu> wrote:
>> In fact, come to think of it, you don't even need to do the
>> transformation. IDL just converts array[x,y,z] back into array[i]
>> anyways - this could save some extra time.
>
> IN FACT, maybe we don't need loops at all...
>
> t0 = systime(/seconds)
> mean3 = fltarr(size(nd,/dim))
>
> ind = ulindgen(nx * ny - 1) + 1 ;- don't include 0- do it manually
> bad = where(ri[ind] eq ri[ind+1], ct) + 1 ;-add 1 because ind starts
> at 1
> newRI = ri[0:nx * ny] - ri[0]
>
> runningSum = total(pxxm[ri[ri[0]:ri[nx * ny] - 1]], /cumulative)
>
> mean3[ind] = (runningSum[newRi[ind+1] - 1] - runningSum[newRi[ind] -
> 1]) / (newRi[ind+1] - newRi[ind])
> if ct ne 0 then mean3[bad] = 0 ;- fix empty bins
>
> ;-manually fill in first element
> if newRI[1] ne 0 then $
>   mean3[0] = runningSum[newRI[1] - 1] / newRI[1]
>
> print, 'time: ',systime(/seconds) - t0
>
> All of the adding and subtracting of 1s is super ugly, but it runs
> about 30x faster for me. Also, the /CUMULATIVE keyword for total seems
> to be unstable - the errors between this method and the earlier method
> grow with the index number. That seems bizarre, but the errors were
> minor (.01%) for the input I used.
>
> chris

Try using /INTEGER with it.

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL hilbert() function
Next Topic: google code search

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

Current Time: Wed Oct 08 15:11:38 PDT 2025

Total time taken to generate the page: 0.00496 seconds