Ticket #8847: trac_8847.patch

File trac_8847.patch, 2.3 KB (added by mhansen, 9 years ago)
  • sage/symbolic/pynac.pyx

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1272890296 25200
    # Node ID e8fec070b091eee7b04782b526222d67cb4e0b4b
    # Parent  c05b0b1c419fe3e3cad13ea2f33d2fd98e185f47
    Trac #8847: pynac.pyx use double precision special functions instead of long double
    
    diff -r c05b0b1c419f -r e8fec070b091 sage/symbolic/pynac.pyx
    a b  
    77#                  http://www.gnu.org/licenses/
    88###############################################################################
    99
    10 cdef extern from "math.h":
    11     long double logl(long double)
    12     long double sqrtl(long double)
    13     long double tgammal(long double)
    14     long double lgammal(long double)
    15 
    1610include "../ext/cdefs.pxi"
    1711include "../ext/stdsage.pxi"
    1812include "../libs/ginac/decl.pxi"
     
    2014# for complex log
    2115include "../gsl/gsl_complex.pxi"
    2216
     17cdef extern from "math.h":
     18    double log(double)
     19    double lgamma(double)
     20    double tgamma(double)
     21    double sqrt(double)
     22
    2323from sage.structure.element import Element
    2424from sage.rings.integer_ring import ZZ
    2525from sage.rings.integer cimport Integer
     
    10271027#################################################################
    10281028cdef public object py_tgamma(object x) except +:
    10291029    if PY_TYPE_CHECK_EXACT(x, float):
    1030         return tgammal(x)
     1030        return tgamma(x)
    10311031    #FIXME: complex
    10321032    try:
    10331033        return x.gamma()
     
    12551255        x = float(x)
    12561256    if PY_TYPE_CHECK_EXACT(x, float):
    12571257        if (<float>x) > 0:
    1258             return logl(x)
     1258            return log(x)
    12591259        elif x < 0:
    12601260            res = gsl_complex_log(gsl_complex_rect(PyFloat_AsDouble(x), 0))
    12611261            return PyComplex_FromDoubles(res.dat[0], res.dat[1])
     
    13821382
    13831383cdef public object py_lgamma(object x) except +:
    13841384    if PY_TYPE_CHECK_EXACT(x, float):
    1385         return lgammal(x)
     1385        return lgamma(x)
    13861386    #FIXME: complex
    13871387    try:
    13881388        return x.log_gamma()
     
    13971397        # WORRY: What if Integer's sqrt calls symbolic one and we go in circle?
    13981398        return x.sqrt() 
    13991399    except AttributeError, msg:
    1400         return sqrtl(float(x))
     1400        return sqrt(float(x))
    14011401
    14021402cdef public object py_abs(object x) except +:
    14031403    return abs(x)