Cool and Bizzare error in IDL 5.2.1 [message #20392] |
Tue, 20 June 2000 00:00 |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
Well, I've spent the last hour or so tracking down an error,
and finally found the cuplrit. Check out the result of the following
commands
IDL> help,current_mean
CURRENT_MEAN DOUBLE = -1.0853418
IDL> help,newmean
CURRENT_MEAN DOUBLE = -1.0853418
I have two variables, current_mean and newmean. There are no pointers
used, and the code is very straighforward (just iteratively calculating the
mean).
Note how IDL>help,newmean give the result of current_mean, is that weird or
what??
The error is that when newmean was calculated, current mean was being
modified.
The code fragment that demonstrates this is:
print,'current mean: ',current_mean
newmean = (current_mean*npoints+newpoint)/(npoints+1)
print,'current mean: ',current_mean
And the resulting output is:
current mean: -1.0853418
current mean: -0.13970473
I'm not sure how I was able to do this, but if it's repeatable, I think I
smell
some obsfucated IDL code in my future!
better get back to work, I just thought it was cool. If any one can explain
this,
I'd be interested to hear it. But I'm guessing it will be difficult to
reproduce.
Cheers,
bob
|
|
|