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 #63297 is a reply to message #63292] Tue, 04 November 2008 01:56 Go to previous messageGo to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
>
> 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
[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: Fri Oct 10 00:08:11 PDT 2025

Total time taken to generate the page: 0.72160 seconds