[Numpy-discussion] floating point exceptions
bryan.cole at teraview.co.uk
Fri Aug 9 09:21:04 EDT 2002
OK, I've worked out how to do this with MA.
I mask the Numeric array input to MA.exp() using MA.masked_outside( ...
,-700, 700) then convert the result back to a Numeric array using
MA.filled( ..., 0.0) then continue as normal.
I'm still interested if there's a more elegant approach.
On Fri, 2002-08-09 at 16:52, bryan cole wrote:
> 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
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
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