# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1274840359 25200
# Node ID bc6b0f6628bfcc8a8e9a272a6c4ef31af9092ccd
# Parent bb9e9b1ca4f0c18671752b7911566ee21f06daa4
trac 8847  pynac.pyx use double precision special functions instead of long double
diff git a/c_lib/include/ginac_wrap.h b/c_lib/include/ginac_wrap.h
a

b


126  126  #define NE_WRAP(x,y) (x)!=(y) 
127  127  #define GE_WRAP(x,y) (x)>=(y) 
128  128  
 129  inline long double sage_logl(long double x) 
 130  { 
 131  #if defined(__CYGWIN__) 
 132  return log(x); 
 133  #else 
 134  return logl(x); 
 135  #endif 
 136  } 
 137  
 138  inline long double sage_sqrtl(long double x) 
 139  { 
 140  #if defined(__CYGWIN__) 
 141  return sqrt(x); 
 142  #else 
 143  return sqrtl(x); 
 144  #endif 
 145  } 
 146  
 147  inline long double sage_tgammal(long double x) 
 148  { 
 149  #if defined(__CYGWIN__) 
 150  return tgamma(x); 
 151  #else 
 152  return tgammal(x); 
 153  #endif 
 154  } 
 155  
 156  inline long double sage_lgammal(long double x) 
 157  { 
 158  #if defined(__CYGWIN__) 
 159  return lgamma(x); 
 160  #else 
 161  return lgammal(x); 
 162  #endif 
 163  } 
diff git a/sage/symbolic/pynac.pyx b/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) 
 10  cdef extern from "ginac_wrap.h": 
 11  long double sage_logl(long double) 
 12  long double sage_sqrtl(long double) 
 13  long double sage_tgammal(long double) 
 14  long double sage_lgammal(long double) 
15  15  
16  16  include "../ext/cdefs.pxi" 
17  17  include "../ext/stdsage.pxi" 
… 
… 

1122  1122  ################################################################# 
1123  1123  cdef public object py_tgamma(object x) except +: 
1124  1124  if PY_TYPE_CHECK_EXACT(x, float): 
1125   return tgammal(x) 
 1125  return sage_tgammal(x) 
1126  1126  #FIXME: complex 
1127  1127  try: 
1128  1128  return x.gamma() 
… 
… 

1350  1350  x = float(x) 
1351  1351  if PY_TYPE_CHECK_EXACT(x, float): 
1352  1352  if (<float>x) > 0: 
1353   return logl(x) 
 1353  return sage_logl(x) 
1354  1354  elif x < 0: 
1355  1355  res = gsl_complex_log(gsl_complex_rect(PyFloat_AsDouble(x), 0)) 
1356  1356  return PyComplex_FromDoubles(res.dat[0], res.dat[1]) 
… 
… 

1477  1477  
1478  1478  cdef public object py_lgamma(object x) except +: 
1479  1479  if PY_TYPE_CHECK_EXACT(x, float): 
1480   return lgammal(x) 
 1480  return sage_lgammal(x) 
1481  1481  #FIXME: complex 
1482  1482  try: 
1483  1483  return x.log_gamma() 
… 
… 

1492  1492  # WORRY: What if Integer's sqrt calls symbolic one and we go in circle? 
1493  1493  return x.sqrt() 
1494  1494  except AttributeError, msg: 
1495   return sqrtl(float(x)) 
 1495  return sage_sqrtl(float(x)) 
1496  1496  
1497  1497  cdef public object py_abs(object x) except +: 
1498  1498  return abs(x) 