Re: is this a bug in IDL? [message #37376] |
Tue, 16 December 2003 02:58  |
Wonko[3]
Messages: 9 Registered: February 2003
|
Junior Member |
|
|
aramisgm@hotmail.com (Aramis Martinez) wrote:
> k=0
> for i=0,8759 do begin
> x=vbs(2,i)
> if x gt 0.0 then k=k+1 & x=0 & vbs(2,i)=x
> endfor
> print, k
Which is the same as:
k=0
for i=0,8759 do begin
x=vbs(2,i)
if x gt 0.0 then k=k+1
x=0
vbs(2,i)=x
endfor
print, k
> 1) How would you vectorize this? I tried a few things that I could
> remember from my work this summer, but four months of quantum
> mechanics wipes a lot from memory :)
This should do:
index = where( vbs[ 2, lindgen( 8760 ) ] gt 0, k )
if k gt 0 then vbs[ 2, index ] = 0
[...]
> Is this a bug? as far as I can tell, the statements are logically
> identical since an &'s behavior should never vary, so what in the guts
> of IDL would make these statements be different? Is there some rule
> kicking in here that's not so obvious but makes this behavior to be
> expected? Would parenthesis around the THEN block make these identical
> in IDL? The environment is either IDL 6 on Red Hat 9 or IDL 5.1 on
> Red Hat 8.1.
Using & ist the same as wrting the next statement in another line. You
need to use begin and endif statements.
Alex
--
Alex Schuster Wonko@wonkology.org PGP Key available
alex@pet.mpin-koeln.mpg.de
|
|
|