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

Home » Public Forums » archive » Re: do I need this IF statement?
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: do I need this IF statement? [message #43246 is a reply to message #43241] Thu, 24 March 2005 04:48 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Margrethe writes:

> I find that in some cases I really need an IF statement to make sure
> that I don't address some arrays with index -1. In the example below I
> have vectorized the inner loop over j, but have kept the loop over i.
> Is there a way to avoid the IF statement? Grateful for help! -Margrethe
>
> FOR i=0,N-1 DO BEGIN
>
> d = sqrt ( x(i) ^2 + y (INDGEN(N)) ^2 )
> indx = WHERE ( d LT 3.*sigma, ct )
>
> IF (ct GT 0) THEN BEGIN
>
> v = v1 + vr (i,indx)
> p = some_function ( x(i), y(indx) )
> profile = profile + TOTAL ( p * image(i,indx) )
>
> ENDIF
>
> ENDFOR

JD has me totally intimidated about making sweeping generalizations,
but I'm going to state emphatically that you NEED the IF statement.
We'll see if that turns out to be true. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: paralel/serial ports
Next Topic: Still more fun with XML

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

Current Time: Wed Oct 08 19:32:37 PDT 2025

Total time taken to generate the page: 0.00441 seconds