[pypy-svn] pypy cmath: (lac, arigo)

arigo commits-noreply at bitbucket.org
Mon Jan 17 16:09:09 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: cmath
Changeset: r40771:aec4e393d77a
Date: 2011-01-17 16:07 +0100
http://bitbucket.org/pypy/pypy/changeset/aec4e393d77a/

Log:	(lac, arigo)

	Special cases for acos.

diff --git a/pypy/module/cmath/interp_cmath.py b/pypy/module/cmath/interp_cmath.py
--- a/pypy/module/cmath/interp_cmath.py
+++ b/pypy/module/cmath/interp_cmath.py
@@ -7,6 +7,7 @@
 from pypy.module.cmath.constant import CM_LARGE_DOUBLE, M_LN2
 from pypy.module.cmath.special_value import isfinite, special_type
 from pypy.module.cmath.special_value import sqrt_special_values
+from pypy.module.cmath.special_value import acos_special_values
 
 
 def unaryfn(c_func):
@@ -78,6 +79,9 @@
 
 @unaryfn
 def c_acos(x, y):
+    if not isfinite(x) or not isfinite(y):
+        return acos_special_values[special_type(x)][special_type(y)]
+
     if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE:
         # avoid unnecessary overflow for large arguments
         real = math.atan2(fabs(y), x)

diff --git a/pypy/module/cmath/special_value.py b/pypy/module/cmath/special_value.py
--- a/pypy/module/cmath/special_value.py
+++ b/pypy/module/cmath/special_value.py
@@ -56,15 +56,15 @@
         table.append(row)
     return table
 
-##acos_special_values = build_table([
-## C(P34,INF),C(P,INF), C(P,INF), C(P,-INF), C(P,-INF), C(P34,-INF),C(N,INF),
-## C(P12,INF),C(U,U),   C(U,U),   C(U,U),    C(U,U),    C(P12,-INF),C(N,N),
-## C(P12,INF),C(U,U),   C(P12,0.),C(P12,-0.),C(U,U),    C(P12,-INF),C(P12,N),
-## C(P12,INF),C(U,U),   C(P12,0.),C(P12,-0.),C(U,U),    C(P12,-INF),C(P12,N),
-## C(P12,INF),C(U,U),   C(U,U),   C(U,U),    C(U,U),    C(P12,-INF),C(N,N),
-## C(P14,INF),C(0.,INF),C(0.,INF),C(0.,-INF),C(0.,-INF),C(P14,-INF),C(N,INF),
-## C(N,INF),  C(N,N),   C(N,N),   C(N,N),    C(N,N),    C(N,-INF),  C(N,N) 
-## ])
+acos_special_values = build_table([
+    (P34,INF), (P,INF),  (P,INF),  (P,-INF),  (P,-INF),  (P34,-INF), (N,INF),
+    (P12,INF), (U,U),    (U,U),    (U,U),     (U,U),     (P12,-INF), (N,N),
+    (P12,INF), (U,U),    (P12,0.), (P12,-0.), (U,U),     (P12,-INF), (P12,N),
+    (P12,INF), (U,U),    (P12,0.), (P12,-0.), (U,U),     (P12,-INF), (P12,N),
+    (P12,INF), (U,U),    (U,U),    (U,U),     (U,U),     (P12,-INF), (N,N),
+    (P14,INF), (0.,INF), (0.,INF), (0.,-INF), (0.,-INF), (P14,-INF), (N,INF),
+    (N,INF),   (N,N),    (N,N),    (N,N),     (N,N),     (N,-INF),   (N,N),
+    ])
 
 sqrt_special_values = build_table([
     (INF,-INF), (0.,-INF), (0.,-INF), (0.,INF), (0.,INF), (INF,INF), (N,INF),


More information about the Pypy-commit mailing list