[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Locate an underflow
Paul van Delst <firstname.lastname@example.org> writes:
>William Thompson wrote:
>> Paul van Delst <email@example.com> writes:
>> >... 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 ...
>> I disagree. It's exceedingly easy to get underflow errors, and extremely
>> difficult to program around them. For example, a simple Gaussian
>> Y = A*exp(-((X-X0)/Sig)^2)
>> is almost guaranteed to generate underflow errors. At some point this is going
>> to be indistinguishable from zero. You'd have to jump through hoops to avoid
>> getting the completely useless underfloat messages.
>Not really. what about something like (assuming double precision):
> tolerance = (MACHAR(/DOUBLE)).EPS
> y = DBLARR( N_ELEMENTS( X ) )
> xarg = ((X-X0)/Sig)^2
> index = WHERE( xarg < tolerance, count )
> IF ( count GT 0 ) THEN $
> y = A*exp(-xarg[index])
And that's not jumping through hoops???
>Or, as I mentioned in my reply to Craig:
> y = A * gaussian_function( (X-X0)/Sig )
>(or similar) which contains all the bits and pieces for checking. Craig also provided a
>method of avoiding the underflows.
When IDL first starting printing out tons of underflow errors, and users
started complaining about them, I also wrote out a routine very much like what
you suggest, called SAFE_EXP(), simply to avoid the messages. In the end,
though, it didn't help, because one ends up multiplying arrays with very tiny
numbers in them with other arrays with very tiny numbers in them, and you end
up with an underfloat anyway. They're all over the place. In the end, you
just give up and ignore them.
If somebody has a real need to make sure that underfloat errors are not
occuring in their programs, then there should be a mechanism to check for that,
as there is. But must people don't care, and find the messages useless and
annoying. There should be a way of suppressing them, if you want. RSI has
supplied a way of doing that, but only by suppressing *ALL* error messages.
All I'm asking for is an option for selectively suppressing the underfloat
Underfloat messages are like the kid who kept crying wolf. Eventually, you
start ignoring them.