# 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


7  7  # http://www.gnu.org/licenses/ 
8  8  ############################################################################### 
9  9  
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   
16  10  include "../ext/cdefs.pxi" 
17  11  include "../ext/stdsage.pxi" 
18  12  include "../libs/ginac/decl.pxi" 
… 
… 

20  14  # for complex log 
21  15  include "../gsl/gsl_complex.pxi" 
22  16  
 17  cdef extern from "math.h": 
 18  double log(double) 
 19  double lgamma(double) 
 20  double tgamma(double) 
 21  double sqrt(double) 
 22  
23  23  from sage.structure.element import Element 
24  24  from sage.rings.integer_ring import ZZ 
25  25  from sage.rings.integer cimport Integer 
… 
… 

1027  1027  ################################################################# 
1028  1028  cdef public object py_tgamma(object x) except +: 
1029  1029  if PY_TYPE_CHECK_EXACT(x, float): 
1030   return tgammal(x) 
 1030  return tgamma(x) 
1031  1031  #FIXME: complex 
1032  1032  try: 
1033  1033  return x.gamma() 
… 
… 

1255  1255  x = float(x) 
1256  1256  if PY_TYPE_CHECK_EXACT(x, float): 
1257  1257  if (<float>x) > 0: 
1258   return logl(x) 
 1258  return log(x) 
1259  1259  elif x < 0: 
1260  1260  res = gsl_complex_log(gsl_complex_rect(PyFloat_AsDouble(x), 0)) 
1261  1261  return PyComplex_FromDoubles(res.dat[0], res.dat[1]) 
… 
… 

1382  1382  
1383  1383  cdef public object py_lgamma(object x) except +: 
1384  1384  if PY_TYPE_CHECK_EXACT(x, float): 
1385   return lgammal(x) 
 1385  return lgamma(x) 
1386  1386  #FIXME: complex 
1387  1387  try: 
1388  1388  return x.log_gamma() 
… 
… 

1397  1397  # WORRY: What if Integer's sqrt calls symbolic one and we go in circle? 
1398  1398  return x.sqrt() 
1399  1399  except AttributeError, msg: 
1400   return sqrtl(float(x)) 
 1400  return sqrt(float(x)) 
1401  1401  
1402  1402  cdef public object py_abs(object x) except +: 
1403  1403  return abs(x) 