Ticket #8847: trac_8847-take2.patch

File trac_8847-take2.patch, 2.1 KB (added by was, 9 years ago)

apply only this (not the one below)

  • sage/symbolic/pynac.pyx

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1274838015 25200
    # Node ID f57d301de3488988c1ca412ff8b04ead86983830
    # Parent  bb9e9b1ca4f0c18671752b7911566ee21f06daa4
    trac 8847 -- pynac.pyx use double precision special functions instead of long double
    
    diff --git a/sage/symbolic/pynac.pyx b/sage/symbolic/pynac.pyx
    a b  
    1313    long double tgammal(long double)
    1414    long double lgammal(long double)
    1515
     16    # We use the following only on Cygwin
     17    double log(double)
     18    double lgamma(double)
     19    double tgamma(double)
     20    double sqrt(double)
     21
     22# We do this so we can very quickly decide if we're on Cygwin
     23import os
     24cdef bint CYGWIN = os.uname()[0].startswith('CYGWIN')
     25
    1626include "../ext/cdefs.pxi"
    1727include "../ext/stdsage.pxi"
    1828include "../libs/ginac/decl.pxi"
     
    11221132#################################################################
    11231133cdef public object py_tgamma(object x) except +:
    11241134    if PY_TYPE_CHECK_EXACT(x, float):
    1125         return tgammal(x)
     1135        return tgamma(x) if CYGWIN else tgammal(x)
    11261136    #FIXME: complex
    11271137    try:
    11281138        return x.gamma()
     
    13501360        x = float(x)
    13511361    if PY_TYPE_CHECK_EXACT(x, float):
    13521362        if (<float>x) > 0:
    1353             return logl(x)
     1363            return log(x) if CYGWIN else logl(x)
    13541364        elif x < 0:
    13551365            res = gsl_complex_log(gsl_complex_rect(PyFloat_AsDouble(x), 0))
    13561366            return PyComplex_FromDoubles(res.dat[0], res.dat[1])
     
    14771487
    14781488cdef public object py_lgamma(object x) except +:
    14791489    if PY_TYPE_CHECK_EXACT(x, float):
    1480         return lgammal(x)
     1490        return lgamma(x) if CYGWIN else lgammal(x)
    14811491    #FIXME: complex
    14821492    try:
    14831493        return x.log_gamma()
     
    14921502        # WORRY: What if Integer's sqrt calls symbolic one and we go in circle?
    14931503        return x.sqrt() 
    14941504    except AttributeError, msg:
    1495         return sqrtl(float(x))
     1505        return sqrt(float(x)) if CYGWIN else sqrtl(float(x))
    14961506
    14971507cdef public object py_abs(object x) except +:
    14981508    return abs(x)