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

Home » Public Forums » archive » Avoiding FOR loops (version googleplex.infinity)
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: Avoiding FOR loops (version googleplex.infinity) [message #59779 is a reply to message #59696] Fri, 11 April 2008 00:52 Go to previous messageGo to previous message
weitkamp is currently offline  weitkamp
Messages: 33
Registered: October 1998
Member
Gaurav,

I suggest a solution that is essentially identical to yours, with the
sole difference that I think the use of WHERE is superfluous because
it is much easier to use only its argument. (Using WHERE in cases
where its argument alone is much easier to handle is actually one of
the most frequent programming flaws that I have seen in this group,
and I was tempted to submit to David Fanning's recent survey.) Below
is the code I propose.

Cheers,
Timm

count = 0B * image ; This will contain the result

FOR ix = -width/2, width/2 DO BEGIN
FOR iy = -height/2, height/2 DO BEGIN
IF (ix NE 0) OR (iy NE 0) THEN BEGIN
shiftedImage = SHIFT(image, ix, iy)
count = count + (shiftedImage EQ image)
ENDIF
ENDFOR
ENDFOR

END

Gaurav a écrit :
> Dear Tom,
> The trouble is that coming into this group, I always feel I am a
> novice with IDL programming and algorithm designing. Hence, my
> reluctance in asserting my views.
>
> For example, my perusal of IDL help documents has led me to the belief
> that creating temporary arrays help hasten things up while you mention
> something to the contrary. I shall definitely look this up and would
> appreciate pointers in the right direction.
>
> As far as your code generating a result different from mine at the
> edges is concerned, that-of course-is true. In that respect, my code
> produces the same effect as the normal FOR loop, and this has been
> verified.
>
> And as for the bug in my code, I definitely stand corrected for my
> code would fail if all the array elements in the kernel are different.
> Thanks indeed for pointing it out to me.
>
> Thanks indeed,
> Gaurav
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: cryptic error message from "plot"
Next Topic: how to display shape file in a windows

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

Current Time: Fri Oct 10 17:50:00 PDT 2025

Total time taken to generate the page: 0.88058 seconds