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

Home » Public Forums » archive » Re: Cool and Bizzare error in IDL 5.2.1
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Cool and Bizzare error in IDL 5.2.1 [message #20390] Tue, 20 June 2000 00:00
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
Actually this turned out to be just the reult of calling a function
with a keyword being sent in my reference and the same thing
being passed as a parameter (doh). Ah, the perils
of recursion. It was pretty cool anyway though.

-bob




R.G. Stockwell <stockwell@co-ra.comremove> wrote in message
news:0dN35.38$482.32405@den-news1.rmi.net...
> 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
>
>
>
>
>
>
>
>
>
>
>
Re: Cool and Bizzare error in IDL 5.2.1 [message #20391 is a reply to message #20390] Tue, 20 June 2000 00:00 Go to previous message
promashkin is currently offline  promashkin
Messages: 169
Registered: December 1999
Senior Member
I have a strong suspicion that the answer is in the rest of the code
that we did not get a chance to see. I have never seen IDL alter a
variable that it is not supposed to alter. It is likely that
current_mean gets passed to a function as a reference and then it may
get altered to NEWMEAN inside that function. Certainly, if you enter the
code provided on command line, nothing unpredictable happens:

IDL> current_mean = 175.05
IDL> npoints = 531
IDL> newpoint = 168.24
IDL> newmean = (current_mean*npoints+newpoint)/(npoints+1)
IDL> print, newmean, current_mean
175.037 175.050

No surprises at all (same IDL 5.2.1). Let us see the rest of the code,
the fluke is got to be there.
Cheers,
Pavel

"R.G. Stockwell" wrote:
>
> 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: axis in scientific notation
Next Topic: Cool and Bizzare error in IDL 5.2.1

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

Current Time: Wed Oct 08 15:49:12 PDT 2025

Total time taken to generate the page: 0.00590 seconds