[Numpy-discussion] floating point exceptions

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Aug 12 06:01:03 EDT 2002


bryan cole <bryan.cole at teraview.co.uk> writes:

> 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?

Yes, rebuild the Python interpreter (not NumPy!) and add the compilation
option "-lieee". Alternatively, download and install the current
development version of Python from the CVS server (I haven't tried it,
but it is supposed to fix this problem as well).

Ultimately the problem is in the C standard library. On some platforms
it signals underflow as an overflow error, on others it doesn't. Python
thus has to get work around such problems in a platform-specific way.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------




More information about the NumPy-Discussion mailing list