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

Home » Public Forums » archive » Locate an underflow
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: Locate an underflow [message #25203 is a reply to message #25132] Thu, 24 May 2001 07:21 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Craig Markwardt wrote:
>
> Paul van Delst <paul.vandelst@noaa.gov> writes:
>
>> Hmm. I do see your point, but if I grab someone else's code (not
>> just IDL code BTW) the first thing I do is run their supplied test
>> case (I hope there is one) with all warning flags on (for IDL,
>> !EXCEPT = 2; for Fortran or similar, set the platform specific
>> compiler switch to trap under/overflows, divide by zero, etc.).
>>
>> If, on running said code, I get a crapload of underflow errors, it's
>> an indication that that either a) the code hasn't been tested very
>> well or b) the programmer didn't really think about the problem
>> enough (and I'm guilty of both of these.... most of the time
>> actually). If there are (usually harmelss) underflow errors, how do
>> I know that there won't be other more serious errors at some point
>> for different input?
>
> Yah, but consider the difference between the following bits of code:
>
> 1> y = exp(-x^2)
>
> 2> u = x^2
> 2> sz = size(x)
> 2> isdouble = sz(sz(0)+1) EQ 5
> 2> mask = u LT alog(machar(double=isdouble).xmax)
> 2> y = mask*exp(-u*mask)
>
> Both sets of code accomplish the same thing, computing a gaussian
> function, except the second one avoids bogus underflow error messages.
> Which one do you think I'd rather write? :-)

The one that avoids errors? :o)

> Which one shows the original mathematical intent more ?

If the code is commented I fail to see the problem. Really. How about

y = gaussian_function( x )

which encapsulates all the checking? (Prefixed with the original author's initials of
course to avoid namespace collisions... :o)

To be fair, the entire debate has no meaning without some context. I agree with you (and
William Thompson) completely for "regular" stuff - you know, the day to day computing that
everyone does. However, for applications (e.g. flight control software, numerical weather
prediction, etc.) upon which a lot more is at stake (e.g. lives, property damage, etc) I
think it's worth the extra (not much more) effort. And when you've done it once, you just
re-use the same function/routine/procedure/whatever.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: read Nexrad level 3 data
Next Topic: Re: read Nexrad level 3 data

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

Current Time: Fri Oct 10 04:44:00 PDT 2025

Total time taken to generate the page: 0.32181 seconds