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

Home » Public Forums » archive » How to make IDL faster
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: How to make IDL faster [message #36868 is a reply to message #36775] Wed, 29 October 2003 11:18 Go to previous message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
> for i=0,207 do begin
> for j=1200,1700 do begin
> for k=0,di(0)-1 do begin
>
> if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
> geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 then begin
> printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)
> endif
>
> endfor
> endfor
> endfor
>
> How can I change this program?
> Help me.

This is minor, but you can get a small speed advantage by taking out
the begin...end where possible. For example your code could be

for i=0,207 do $
for j=1200,1700 do $
for k=0,di(0)-1 do $
if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04 $
then printf,lun3,loc(k),lon(k),lat(k),rain1(k),rain(k),highf(0,i, j)

It makes a small difference but it can help. You have to use
begin...end only when there is more than one line of code to execute.
Here, you can string them together.

You could change

if geo(0,i,j) gt lat(k)-0.04 and geo(0,i,j) lt lat(k)+0.04 and $
geo(1,i,j) gt lon(k)-0.04 and geo(1,i,j) lt lon(k)+0.04

to this

if (abs(geo(0,i,j) - lat(k)) LT 0.04) and $
(abs(geo(1,i,j) - lon(k)) LT 0.04) then . . .

Here I am thinking that you minimize the number of times you have to
go to the geo() array and get the (0,i,j) element.

M. Katz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Solving nonlinear equations
Next Topic: vector t-test?

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

Current Time: Wed Oct 08 18:43:28 PDT 2025

Total time taken to generate the page: 0.00448 seconds