[Numpy-discussion] Handling underflow

John J. Lee phrxy at csv.warwick.ac.uk
Fri Feb 23 07:38:54 EST 2001


On 22 Feb 2001, Victor S. Miller wrote:

> Is there some way of having calculations which cause underflow
> automatically set their result to 0.0?  For example when I take
> exp(a), where a is a floating point array.

Not 'automatically', but:

a = whatever()
choose(greater(a, MAX), (a, MAX))
answer = exp(-a)

any good?  This is with a 1D array -- I haven't used higher dimensions
much.


John





More information about the NumPy-Discussion mailing list