[Python-checkins] r60726 - python/branches/trunk-math/Modules/cmathmodule.c

christian.heimes python-checkins at python.org
Mon Feb 11 10:10:30 CET 2008


Author: christian.heimes
Date: Mon Feb 11 10:10:30 2008
New Revision: 60726

Modified:
   python/branches/trunk-math/Modules/cmathmodule.c
Log:
As expected the new code didn't work on Windows. HUGE_VAL is not a constant but an extern variable on Windows. The compiler also didn't like {}. I had to replace it with {0,0}.

Modified: python/branches/trunk-math/Modules/cmathmodule.c
==============================================================================
--- python/branches/trunk-math/Modules/cmathmodule.c	(original)
+++ python/branches/trunk-math/Modules/cmathmodule.c	Mon Feb 11 10:10:30 2008
@@ -91,19 +91,30 @@
 	}
 
 #define P Py_MATH_PI
-#define I Py_HUGE_VAL
-#define N Py_NAN
+#define P14 0.25*Py_MATH_PI
+#define P12 0.5*Py_MATH_PI
+#define P34 0.75*Py_MATH_PI
+#ifdef MS_WINDOWS
+/* On Windows HUGE_VAL is an extern variable and not a constant. Since the
+   special value arrays need a constant we have to role our own infinity
+   and nan. */
+#  define I (DBL_MAX*DBL_MAX)
+#  define N (I*0.)
+#else
+#  define I Py_HUGE_VAL
+#  define N Py_NAN
+#endif /* MS_WINDOWS */
 
 /* First, the C functions that do the real work */
 
 static Py_complex acos_special_values[7][7] = {
-	{{.75*P,I},{P,I}, {P,I},    {P,-I},    {P, -I}, {.75*P,-I},{N,I}},
-	{{.5*P,I}, {},    {},       {},        {},      {.5*P,-I}, {N,N}},
-	{{.5*P,I}, {},    {.5*P,0.},{.5*P,-0.},{},      {.5*P,-I}, {.5*P,N}},
-	{{.5*P,I}, {},    {.5*P,0.},{.5*P,-0.},{},      {.5*P,-I}, {.5*P,N}},
-	{{.5*P,I}, {},    {},       {},        {},      {.5*P,-I}, {N,N}},
-	{{.25*P,I},{0.,I},{0.,I},   {0.,-I},   {0.,-I}, {.25*P,-I},{N,I}},
-	{{N,I},    {N,N}, {N,N},    {N,N},     {N,N},   {N,-I},    {N,N}}
+	{{P34,I}, {P,I}, {P,I},    {P,-I},    {P, -I}, {P34,-I}, {N,I}},
+	{{P12,I}, {0,0}, {0,0},    {0,0},     {0,0},   {P12,-I}, {N,N}},
+	{{P12,I}, {0,0}, {P12,0.}, {P12,-0.}, {0,0},   {P12,-I}, {P12,N}},
+	{{P12,I}, {0,0}, {P12,0.}, {P12,-0.}, {0,0},   {P12,-I}, {P12,N}},
+	{{P12,I}, {0,0}, {0,0},    {0,0},     {0,0},   {P12,-I}, {N,N}},
+	{{P14,I}, {0.,I},{0.,I},   {0.,-I},   {0.,-I}, {P14,-I}, {N,I}},
+	{{N,I},   {N,N}, {N,N},    {N,N},     {N,N},   {N,-I},    {N,N}}
 };
 
 static Py_complex
@@ -146,13 +157,13 @@
 
 
 static Py_complex acosh_special_values[7][7] = {
-	{{I,-.75*P},{I,-P}, {I,-P},    {I,P},    {I,P}, {I,.75*P},{I,N}},
-	{{I,-.5*P}, {},     {},        {},       {},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {0.,-.5*P},{0.,.5*P},{},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {0.,-.5*P},{0.,.5*P},{},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {},        {},       {},    {I,.5*P}, {N,N}},
-	{{I,-.25*P},{I,-0.},{I,-0.},   {I,0.},   {I,0.},{I,.25*P},{I,N}},
-	{{I,N},     {N,N},  {N,N},     {N,N},    {N,N}, {I,N},    {N,N}}
+	{{I,-P34}, {I,-P}, {I,-P},    {I,P},    {I,P}, {I,P34}, {I,N}},
+	{{I,-P12}, {0,0},  {0,0},     {0,0},    {0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {0.,-P12}, {0.,P12}, {0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {0.,-P12}, {0.,P12}, {0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {0,0},     {0,0},    {0,0}, {I,P12}, {N,N}},
+	{{I,-P14}, {I,-0.},{I,-0.},   {I,0.},   {I,0.},{I,P14}, {I,N}},
+	{{I,N},    {N,N},  {N,N},     {N,N},    {N,N}, {I,N},   {N,N}}
 };
 
 static Py_complex
@@ -206,13 +217,13 @@
 
 
 static Py_complex asinh_special_values[7][7] = {
-	{{-I,-.25*P},{-I,-0.},{-I,-0.}, {-I,0.}, {-I,0.},{-I,.25*P},{-I,N}},
-	{{-I,-.5*P}, {},      {},       {},      {},     {-I,.5*P}, {N,N}},
-	{{-I,-.5*P}, {},      {-0.,-0.},{-0.,0.},{},     {-I,.5*P}, {N,N}},
-	{{I,-.5*P},  {},      {0.,-0.}, {0.,0.}, {},     {I,.5*P},  {N,N}},
-	{{I,-.5*P},  {},      {},       {},      {},     {I,.5*P},  {N,N}},
-	{{I,-.25*P}, {I,-0.}, {I,-0.},  {I,0.},  {I,0.}, {I,.25*P}, {I,N}},
-	{{I,N},      {N,N},   {N,-0.},  {N,0.},  {N,N},  {I,N},     {N,N}}
+	{{-I,-P14}, {-I,-0.},{-I,-0.}, {-I,0.}, {-I,0.},{-I,P14}, {-I,N}},
+	{{-I,-P12}, {0,0},   {0,0},    {0,0},   {0,0},  {-I,P12}, {N,N}},
+	{{-I,-P12}, {0,0},   {-0.,-0.},{-0.,0.},{0,0},  {-I,P12}, {N,N}},
+	{{I,-P12},  {0,0},   {0.,-0.}, {0.,0.}, {0,0},  {I,P12},  {N,N}},
+	{{I,-P12},  {0,0},   {0,0},    {0,0},   {0,0},  {I,P12},  {N,N}},
+	{{I,-P14},  {I,-0.}, {I,-0.},  {I,0.},  {I,0.}, {I,P14},  {I,N}},
+	{{I,N},     {N,N},   {N,-0.},  {N,0.},  {N,N},  {I,N},    {N,N}}
 };
 
 static Py_complex
@@ -271,13 +282,13 @@
 
 
 static Py_complex atanh_special_values[7][7] = {
-	{{-0.,-.5*P},{-0.,-.5*P},{-0.,-.5*P},{-0.,.5*P},{-0.,.5*P},{-0.,.5*P},{-0.,N}},
-	{{-0.,-.5*P},{},         {},         {},        {},        {-0.,.5*P},{N,N}},
-	{{-0.,-.5*P},{},         {-0.,-0.},  {-0.,0.},  {},        {-0.,.5*P},{-0.,N}},
-	{{0.,-.5*P}, {},         {0.,-0.},   {0.,0.},   {},        {0.,.5*P}, {0.,N}},
-	{{0.,-.5*P}, {},         {},         {},        {},        {0.,.5*P}, {N,N}},
-	{{0.,-.5*P}, {0.,-.5*P}, {0.,-.5*P}, {0.,.5*P}, {0.,.5*P}, {0.,.5*P}, {0.,N}},
-	{{0.,-.5*P}, {N,N},      {N,N},      {N,N},     {N,N},     {0.,.5*P}, {N,N}}
+	{{-0.,-P12},{-0.,-P12}, {-0.,-P12}, {-0.,P12}, {-0.,P12}, {-0.,P12},{-0.,N}},
+	{{-0.,-P12},{0,0},      {0,0},      {0,0},     {0,0},     {-0.,P12},{N,N}},
+	{{-0.,-P12},{0,0},      {-0.,-0.},  {-0.,0.},  {0,0},     {-0.,P12},{-0.,N}},
+	{{0.,-P12}, {0,0},      {0.,-0.},   {0.,0.},   {0,0},     {0.,P12}, {0.,N}},
+	{{0.,-P12}, {0,0},      {0,0},      {0,0},     {0,0},     {0.,P12}, {N,N}},
+	{{0.,-P12}, {0.,-P12},  {0.,-P12},  {0.,P12},  {0.,P12},  {0.,P12}, {0.,N}},
+	{{0.,-P12}, {N,N},      {N,N},      {N,N},     {N,N},     {0.,P12}, {N,N}}
 };
 
 static Py_complex
@@ -352,12 +363,12 @@
 
 /* cosh(infinity + i*y) needs to be dealt with specially */
 static Py_complex cosh_special_values[7][7] = {
-	{{I,N}, {},   {I,0.},  {I,-0.}, {},   {I,N}, {I,N}},
-	{{N,N}, {},   {},      {},      {},   {N,N}, {N,N}},
-	{{N,0.},{},   {1.,0.}, {1.,-0.},{},   {N,0.},{N,0.}},
-	{{N,0.},{},   {1.,-0.},{1.,0.}, {},   {N,0.},{N,0.}},
-	{{N,N}, {},   {},      {},      {},   {N,N}, {N,N}},
-	{{I,N}, {},   {I,-0.}, {I,0.},  {},   {I,N}, {I,N}},
+	{{I,N}, {0,0},{I,0.},  {I,-0.}, {0,0},{I,N}, {I,N}},
+	{{N,N}, {0,0},{0,0},   {0,0},   {0,0},{N,N}, {N,N}},
+	{{N,0.},{0,0},{1.,0.}, {1.,-0.},{0,0},{N,0.},{N,0.}},
+	{{N,0.},{0,0},{1.,-0.},{1.,0.}, {0,0},{N,0.},{N,0.}},
+	{{N,N}, {0,0},{0,0},   {0,0},   {0,0},{N,N}, {N,N}},
+	{{I,N}, {0,0},{I,-0.}, {I,0.},  {0,0},{I,N}, {I,N}},
 	{{N,N}, {N,N},{N,0.},  {N,0.},  {N,N},{N,N}, {N,N}}
 };
 
@@ -420,12 +431,12 @@
 /* exp(infinity + i*y) and exp(-infinity + i*y) need special treatment for
    finite y */
 static Py_complex exp_special_values[7][7] = {
-	{{0.,0.},{},   {0.,-0.},{0.,0.},{},   {0.,0.},{0.,0.}},
-	{{N,N},  {},   {},      {},     {},   {N,N},  {N,N}},
-	{{N,N},  {},   {1.,-0.},{1.,0.},{},   {N,N},  {N,N}},
-	{{N,N},  {},   {1.,-0.},{1.,0.},{},   {N,N},  {N,N}},
-	{{N,N},  {},   {},      {},     {},   {N,N},  {N,N}},
-	{{I,N},  {},   {I,-0.}, {I,0.}, {},   {I,N},  {I,N}},
+	{{0.,0.},{0,0},{0.,-0.},{0.,0.},{0,0},{0.,0.},{0.,0.}},
+	{{N,N},  {0,0},{0,0},   {0,0},  {0,0},{N,N},  {N,N}},
+	{{N,N},  {0,0},{1.,-0.},{1.,0.},{0,0},{N,N},  {N,N}},
+	{{N,N},  {0,0},{1.,-0.},{1.,0.},{0,0},{N,N},  {N,N}},
+	{{N,N},  {0,0},{0,0},   {0,0},  {0,0},{N,N},  {N,N}},
+	{{I,N},  {0,0},{I,-0.}, {I,0.}, {0,0},{I,N},  {I,N}},
 	{{N,N},  {N,N},{N,-0.}, {N,0.}, {N,N},{N,N},  {N,N}}
 };
 
@@ -486,13 +497,13 @@
 
 
 static Py_complex log_special_values[7][7] = {
-	{{I,-.75*P},{I,-P}, {I,-P},  {I,P},  {I,P}, {I,.75*P},{I,N}},
-	{{I,-.5*P}, {},     {},      {},     {},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {-I,-P}, {-I,P}, {},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {-I,-0.},{-I,0.},{},    {I,.5*P}, {N,N}},
-	{{I,-.5*P}, {},     {},      {},     {},    {I,.5*P}, {N,N}},
-	{{I,-.25*P},{I,-0.},{I,-0.}, {I,0.}, {I,0.},{I,.25*P},{I,N}},
-	{{I,N},     {N,N},  {N,N},   {N,N},  {N,N}, {I,N},    {N,N}}
+	{{I,-P34}, {I,-P}, {I,-P},  {I,P},  {I,P}, {I,P34}, {I,N}},
+	{{I,-P12}, {0,0},  {0,0},   {0,0},  {0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {-I,-P}, {-I,P}, {0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {-I,-0.},{-I,0.},{0,0}, {I,P12}, {N,N}},
+	{{I,-P12}, {0,0},  {0,0},   {0,0},  {0,0}, {I,P12}, {N,N}},
+	{{I,-P14}, {I,-0.},{I,-0.}, {I,0.}, {I,0.},{I,P14}, {I,N}},
+	{{I,N},    {N,N},  {N,N},   {N,N},  {N,N}, {I,N},   {N,N}}
 };
 
 static Py_complex
@@ -606,12 +617,12 @@
 
 /* sinh(infinity + i*y) needs to be dealt with specially */
 static Py_complex sinh_special_values[7][7] = {
-	{{I,N}, {},   {-I,-0.}, {-I,0.}, {},   {I,N}, {I,N}},
-	{{N,N}, {},   {},       {},      {},   {N,N}, {N,N}},
-	{{0.,N},{},   {-0.,-0.},{-0.,0.},{},   {0.,N},{0.,N}},
-	{{0.,N},{},   {0.,-0.}, {0.,0.}, {},   {0.,N},{0.,N}},
-	{{N,N}, {},   {},       {},      {},   {N,N}, {N,N}},
-	{{I,N}, {},   {I,-0.},  {I,0.},  {},   {I,N}, {I,N}},
+	{{I,N}, {0,0},{-I,-0.}, {-I,0.}, {0,0},{I,N}, {I,N}},
+	{{N,N}, {0,0},{0,0},    {0,0},   {0,0},{N,N}, {N,N}},
+	{{0.,N},{0,0},{-0.,-0.},{-0.,0.},{0,0},{0.,N},{0.,N}},
+	{{0.,N},{0,0},{0.,-0.}, {0.,0.}, {0,0},{0.,N},{0.,N}},
+	{{N,N}, {0,0},{0,0},    {0,0},   {0,0},{N,N}, {N,N}},
+	{{I,N}, {0,0},{I,-0.},  {I,0.},  {0,0},{I,N}, {I,N}},
 	{{N,N}, {N,N},{N,-0.},  {N,0.},  {N,N},{N,N}, {N,N}}
 };
 
@@ -673,10 +684,10 @@
 
 static Py_complex sqrt_special_values[7][7] = {
 	{{I,-I},{0.,-I},{0.,-I}, {0.,I}, {0.,I},{I,I},{N,I}},
-	{{I,-I},{},     {},      {},     {},    {I,I},{N,N}},
-	{{I,-I},{},     {0.,-0.},{0.,0.},{},    {I,I},{N,N}},
-	{{I,-I},{},     {0.,-0.},{0.,0.},{},    {I,I},{N,N}},
-	{{I,-I},{},     {},      {},     {},    {I,I},{N,N}},
+	{{I,-I},{0,0},  {0,0},   {0,0},  {0,0}, {I,I},{N,N}},
+	{{I,-I},{0,0},  {0.,-0.},{0.,0.},{0,0}, {I,I},{N,N}},
+	{{I,-I},{0,0},  {0.,-0.},{0.,0.},{0,0}, {I,I},{N,N}},
+	{{I,-I},{0,0},  {0,0},   {0,0},  {0,0}, {I,I},{N,N}},
 	{{I,-I},{I,-0.},{I,-0.}, {I,0.}, {I,0.},{I,I},{I,N}},
 	{{I,-I},{N,N},  {N,N},   {N,N},  {N,N}, {I,I},{N,N}}
 };
@@ -775,12 +786,12 @@
 
 /* tanh(infinity + i*y) needs to be dealt with specially */
 static Py_complex tanh_special_values[7][7] = {
-	{{-1.,0.},{},   {-1.,-0.},{-1.,0.},{},   {-1.,0.},{-1.,0.}},
-	{{N,N},   {},   {},       {},      {},   {N,N},   {N,N}},
-	{{N,N},   {},   {-0.,-0.},{-0.,0.},{},   {N,N},   {N,N}},
-	{{N,N},   {},   {0.,-0.}, {0.,0.}, {},   {N,N},   {N,N}},
-	{{N,N},   {},   {},       {},      {},   {N,N},   {N,N}},
-	{{1.,0.}, {},   {1.,-0.}, {1.,0.}, {},   {1.,0.}, {1.,0.}},
+	{{-1.,0.},{0,0},{-1.,-0.},{-1.,0.},{0,0},{-1.,0.},{-1.,0.}},
+	{{N,N},   {0,0},{0,0},    {0,0},   {0,0},{N,N},   {N,N}},
+	{{N,N},   {0,0},{-0.,-0.},{-0.,0.},{0,0},{N,N},   {N,N}},
+	{{N,N},   {0,0},{0.,-0.}, {0.,0.}, {0,0},{N,N},   {N,N}},
+	{{N,N},   {0,0},{0,0},    {0,0},   {0,0},{N,N},   {N,N}},
+	{{1.,0.}, {0,0},{1.,-0.}, {1.,0.}, {0,0},{1.,0.}, {1.,0.}},
 	{{N,N},   {N,N},{N,-0.},  {N,0.},  {N,N},{N,N},   {N,N}}
 };
 


More information about the Python-checkins mailing list