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

Home » Public Forums » archive » help - speeding up a loop
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: help - speeding up a loop [message #92558 is a reply to message #92551] Wed, 13 January 2016 06:26 Go to previous messageGo to previous message
Burch is currently offline  Burch
Messages: 28
Registered: December 2013
Junior Member
On Monday, January 11, 2016 at 11:29:42 AM UTC-6, nata wrote:
> Hi guys,
>
> I am trying to implement a circular smooth on an irregular x, y grid.
> The following loop takes too much time. How do you think I could make it faster?
>
> for i=0L, n_rang-1 do for j=0L, n_azim-1 do begin
>
> distkm=sqrt((xx-xx[i,j])^2. + (yy-yy[i,j])^2.)
>
> ww=where(distkm lt 5.,nn_w)
> if nn_w gt 0 then data_res[i,j]=total(data[ww]) / nn_w
>
> endfor
>
> Thank you for your help,
> nata

There are some quick changes that can be made for modest speed improvements. For example, compare this with the original:

for i=0L, n_rang-1 do for j=0L, n_azim-1 do begin

deltaX = xx - xx[i,j]
deltaY = yy - yy[i,j]
distkm_squared=(deltaX*deltaX + deltaY*deltaY)
ww=where(distkm_squared lt 25.,nn_w)
if nn_w gt 0 then data_res[i,j]=total(data[ww]) / nn_w

endfor

-Jeff
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: regarding IDL implementation of Gabor Filter based Image Feature Extraction and Image Classification
Next Topic: help - cgimage revise x and y positions

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

Current Time: Wed Oct 08 17:30:36 PDT 2025

Total time taken to generate the page: 0.00419 seconds