[Numpy-discussion] floating point exceptions

bryan cole bryan.cole at teraview.co.uk
Fri Aug 9 08:52:19 EDT 2002

I've just ported a Numeric+Python program from windows to linux and I'm
generating floating point exceptions in the linux version which did not
occur in windows. 

I'm trying to generate a gaussian distribution by:

Input = Numeric.arange(-1024,1024)/20.0
Output = Numeric.exp(-(Input**2))

At the edges of the distribution the largish negative arguments cause
the f.p. exception and prevent calculation of the entire array.

On windows the underflow errors are presumably rounded down to 0.0
automatically. Is it possible to get this behaviour on linux/ix86?

Anyone got any suggestions on a workarround for this? I see the numpy
docs suggest using Masked Arrays, but since I don't know in advance
which array items will generate the exceptions, I don't know which items
to mask. Can the MA module generate an array mask based on f.p.
exceptions from a calculation?

any suggestions would be much appreciated.


Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge
CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382

More information about the NumPy-Discussion mailing list