[Numpy-discussion] isinf raises in inf

Charles R Harris charlesr.harris at gmail.com
Thu Jul 15 21:33:07 EDT 2010


On Thu, Jul 15, 2010 at 7:09 PM, Charles R Harris <charlesr.harris at gmail.com
> wrote:

>
>
> On Thu, Jul 15, 2010 at 6:55 PM, Charles R Harris <
> charlesr.harris at gmail.com> wrote:
>
>>
>>
>> On Thu, Jul 15, 2010 at 6:42 PM, John Hunter <jdh2358 at gmail.com> wrote:
>>
>>> On Thu, Jul 15, 2010 at 7:27 PM, Charles R Harris
>>> <charlesr.harris at gmail.com> wrote:
>>> >
>>> >
>>> > On Thu, Jul 15, 2010 at 6:11 PM, John Hunter <jdh2358 at gmail.com>
>>> wrote:
>>> >>
>>> >> On Thu, Jul 15, 2010 at 6:14 PM, Eric Firing <efiring at hawaii.edu>
>>> wrote:
>>> >> > Is it certain that the Solaris compiler lacks isinf?  Is it possible
>>> >> > that it has it, but it is not being detected?
>>> >>
>>> >> Just to clarify, I'm not using the sun compiler, but gcc-3.4.3 on
>>> solaris
>>> >> x86
>>> >
>>> > Might be related to this thread.  What version of numpy are you using?
>>>
>>> svn HEAD (2.0.0.dev8480)
>>>
>>> After reading the thread you suggested, I tried forcing the
>>>
>>>  CFLAGS=-DNPY_HAVE_DECL_ISFINITE
>>>
>>> flag to be set, but this is apparently a bad idea for my platform...
>>>
>>>  File
>>> "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/core/__init__.py",
>>> line 5, in ?
>>>    import multiarray
>>> ImportError: ld.so.1: python: fatal: relocation error: file
>>>
>>> /home/titan/johnh/dev/lib/python2.4/site-packages/numpy/core/multiarray.so:
>>> symbol isfinite: referenced symbol not found
>>>
>>> so while I think my bug is related to that thread, I don't see
>>> anything in that thread to help me fix my problem.  Or am I missing
>>> something?
>>> ____
>>>
>>
>> In the thread there is a way to check if isinf is in the library. You can
>> also grep through the python include files where its presence should be set,
>> that's in /usr/include/python2.6/pyconfig.h on my system. If it's present,
>> then you should be able to apply David's fix<http://projects.scipy.org/numpy/changeset/8455>which amount to just a few lines.
>>
>>
> PS, of course we should fix the macro also. Since the bit values of +/-
> infinity are known we should be able to define them as constants using a
> couple of ifdefs and unions. I believe SUN has quad precision so we might
> need to check the layout, but the usual case seems to be zero mantissa,
> maximum exponent, and the sign. Not a number differs in that the mantissa is
> non-zero. I believe there are two versions of nans, signaling and
> non-signaling, but in any case it doesn't look to me like it should be
> impossible to simply have all those values as numpy constants like pi and e.
>
>
And here are some functions stolen from
here<http://ftp.math.utah.edu/pub//zsh/zsh-4.1.1-nonstop-fp.tar.gz>.
They have have an oldstyle BSD type license which need quoting.

#if !defined(HAVE_ISINF)
/**/
int
(isinf)(double x)
{
    if ((-1.0 < x) && (x < 1.0))    /* x is small, and thus finite */
    return (0);
    else if ((x + x) == x)        /* only true if x == Infinity */
    return (1);
    else                /* must be finite (normal or subnormal), or NaN */
    return (0);
}
#endif

#if !defined(HAVE_ISNAN)
/**/
static double
(store)(double *x)
{
    return (*x);
}

/**/
int
(isnan)(double x)
{
    /* (x != x) should be sufficient, but some compilers incorrectly
optimize it away */
    return (store(&x) != store(&x));
}
#endif

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100715/f0ef35bc/attachment.html>


More information about the NumPy-Discussion mailing list