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

Home » Public Forums » archive » Expensive loops... can they be avoided?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Expensive loops... can they be avoided? [message #58910] Tue, 26 February 2008 01:41
Rainer is currently offline  Rainer
Messages: 5
Registered: November 2007
Junior Member
Hi!

I need to render 2D slices cut from 3D spherical grid data. So far, I
am using a brute force method which, using two FOR loops, is
unfortunately rather slow (although working just fine). The problem
and my approach boil down to this:

-- A[i,j] is the input array, with r[i] and chi[j] being curvilinear
coordinates (not necessarily uniformly spaced)
-- B[k,l] is the output array with x[l] and y[l] being uniformly
spaced Cartesian coordinates (to be plotted with TVSCALE)

for k=0,nx-1 do begin
for l=0,ny-1 do begin

curr = sqrt(x[k]^2+y[l]^2)
curchi = atan(x[k],y[l])

if "curchi or curr are out of bounds" then begin
B[k,l] = environment_value
continue
endif

foo = min( r - curr ,nearestr,/absolute)
foo = min( chi - curchi ,nearestchi,/absolute)

B[k,l] = A[nearestr,nearestchi]

endfor
endfor


The calculation of "curr" and "curchi" can easily be done outside the
loops of course. But what can I do with the rest?


Thanks,
Rainer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Problem with ENVI_CONVERT_File_COORDINATES
Next Topic: No enough valid points...

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

Current Time: Sun Oct 12 12:08:56 PDT 2025

Total time taken to generate the page: 1.43778 seconds