Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Expensive loops...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 5469 of 5995
Post > Topic >>

Expensive loops... can they be avoided?

by Rainer <renari@[EMAIL PROTECTED] > Feb 26, 2008 at 01:41 AM

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
 




 4 Posts in Topic:
Expensive loops... can they be avoided?
Rainer <renari@[EMAIL   2008-02-26 01:41:45 
Re: Expensive loops... can they be avoided?
Allan Whiteford <allan  2008-02-26 23:15:21 
Re: Expensive loops... can they be avoided?
Rainer <renari@[EMAIL   2008-02-26 08:15:19 
Re: Expensive loops... can they be avoided?
Spon <christoph.blau@[  2008-03-04 14:02:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 20:32:22 CDT 2008.