@@ -117,7 +117,7 @@ enum special_types {
117
117
static enum special_types
118
118
special_type (double d )
119
119
{
120
- if (Py_IS_FINITE (d )) {
120
+ if (isfinite (d )) {
121
121
if (d != 0 ) {
122
122
if (copysign (1. , d ) == 1. )
123
123
return ST_POS ;
@@ -131,19 +131,19 @@ special_type(double d)
131
131
return ST_NZERO ;
132
132
}
133
133
}
134
- if (Py_IS_NAN (d ))
134
+ if (isnan (d ))
135
135
return ST_NAN ;
136
136
if (copysign (1. , d ) == 1. )
137
137
return ST_PINF ;
138
138
else
139
139
return ST_NINF ;
140
140
}
141
141
142
- #define SPECIAL_VALUE (z , table ) \
143
- if (!Py_IS_FINITE ((z).real) || !Py_IS_FINITE ((z).imag)) { \
144
- errno = 0; \
145
- return table[special_type((z).real)] \
146
- [special_type((z).imag)]; \
142
+ #define SPECIAL_VALUE (z , table ) \
143
+ if (!isfinite ((z).real) || !isfinite ((z).imag)) { \
144
+ errno = 0; \
145
+ return table[special_type((z).real)] \
146
+ [special_type((z).imag)]; \
147
147
}
148
148
149
149
#define P Py_MATH_PI
@@ -329,10 +329,10 @@ cmath_atan_impl(PyObject *module, Py_complex z)
329
329
static double
330
330
c_atan2 (Py_complex z )
331
331
{
332
- if (Py_IS_NAN (z .real ) || Py_IS_NAN (z .imag ))
332
+ if (isnan (z .real ) || isnan (z .imag ))
333
333
return Py_NAN ;
334
- if (Py_IS_INFINITY (z .imag )) {
335
- if (Py_IS_INFINITY (z .real )) {
334
+ if (isinf (z .imag )) {
335
+ if (isinf (z .real )) {
336
336
if (copysign (1. , z .real ) == 1. )
337
337
/* atan2(+-inf, +inf) == +-pi/4 */
338
338
return copysign (0.25 * Py_MATH_PI , z .imag );
@@ -343,7 +343,7 @@ c_atan2(Py_complex z)
343
343
/* atan2(+-inf, x) == +-pi/2 for finite x */
344
344
return copysign (0.5 * Py_MATH_PI , z .imag );
345
345
}
346
- if (Py_IS_INFINITY (z .real ) || z .imag == 0. ) {
346
+ if (isinf (z .real ) || z .imag == 0. ) {
347
347
if (copysign (1. , z .real ) == 1. )
348
348
/* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
349
349
return copysign (0. , z .imag );
@@ -448,8 +448,8 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
448
448
double x_minus_one ;
449
449
450
450
/* special treatment for cosh(+/-inf + iy) if y is not a NaN */
451
- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
452
- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag ) &&
451
+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
452
+ if (isinf (z .real ) && isfinite (z .imag ) &&
453
453
(z .imag != 0. )) {
454
454
if (z .real > 0 ) {
455
455
r .real = copysign (INF , cos (z .imag ));
@@ -466,7 +466,7 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
466
466
}
467
467
/* need to set errno = EDOM if y is +/- infinity and x is not
468
468
a NaN */
469
- if (Py_IS_INFINITY (z .imag ) && !Py_IS_NAN (z .real ))
469
+ if (isinf (z .imag ) && !isnan (z .real ))
470
470
errno = EDOM ;
471
471
else
472
472
errno = 0 ;
@@ -484,7 +484,7 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
484
484
r .imag = sin (z .imag ) * sinh (z .real );
485
485
}
486
486
/* detect overflow, and set errno accordingly */
487
- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
487
+ if (isinf (r .real ) || isinf (r .imag ))
488
488
errno = ERANGE ;
489
489
else
490
490
errno = 0 ;
@@ -509,8 +509,8 @@ cmath_exp_impl(PyObject *module, Py_complex z)
509
509
Py_complex r ;
510
510
double l ;
511
511
512
- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
513
- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
512
+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
513
+ if (isinf (z .real ) && isfinite (z .imag )
514
514
&& (z .imag != 0. )) {
515
515
if (z .real > 0 ) {
516
516
r .real = copysign (INF , cos (z .imag ));
@@ -527,9 +527,9 @@ cmath_exp_impl(PyObject *module, Py_complex z)
527
527
}
528
528
/* need to set errno = EDOM if y is +/- infinity and x is not
529
529
a NaN and not -infinity */
530
- if (Py_IS_INFINITY (z .imag ) &&
531
- (Py_IS_FINITE (z .real ) ||
532
- (Py_IS_INFINITY (z .real ) && z .real > 0 )))
530
+ if (isinf (z .imag ) &&
531
+ (isfinite (z .real ) ||
532
+ (isinf (z .real ) && z .real > 0 )))
533
533
errno = EDOM ;
534
534
else
535
535
errno = 0 ;
@@ -546,7 +546,7 @@ cmath_exp_impl(PyObject *module, Py_complex z)
546
546
r .imag = l * sin (z .imag );
547
547
}
548
548
/* detect overflow, and set errno accordingly */
549
- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
549
+ if (isinf (r .real ) || isinf (r .imag ))
550
550
errno = ERANGE ;
551
551
else
552
552
errno = 0 ;
@@ -686,8 +686,8 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
686
686
687
687
/* special treatment for sinh(+/-inf + iy) if y is finite and
688
688
nonzero */
689
- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
690
- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
689
+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
690
+ if (isinf (z .real ) && isfinite (z .imag )
691
691
&& (z .imag != 0. )) {
692
692
if (z .real > 0 ) {
693
693
r .real = copysign (INF , cos (z .imag ));
@@ -704,7 +704,7 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
704
704
}
705
705
/* need to set errno = EDOM if y is +/- infinity and x is not
706
706
a NaN */
707
- if (Py_IS_INFINITY (z .imag ) && !Py_IS_NAN (z .real ))
707
+ if (isinf (z .imag ) && !isnan (z .real ))
708
708
errno = EDOM ;
709
709
else
710
710
errno = 0 ;
@@ -720,7 +720,7 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
720
720
r .imag = sin (z .imag ) * cosh (z .real );
721
721
}
722
722
/* detect overflow, and set errno accordingly */
723
- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
723
+ if (isinf (r .real ) || isinf (r .imag ))
724
724
errno = ERANGE ;
725
725
else
726
726
errno = 0 ;
@@ -856,8 +856,8 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
856
856
857
857
/* special treatment for tanh(+/-inf + iy) if y is finite and
858
858
nonzero */
859
- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
860
- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
859
+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
860
+ if (isinf (z .real ) && isfinite (z .imag )
861
861
&& (z .imag != 0. )) {
862
862
if (z .real > 0 ) {
863
863
r .real = 1.0 ;
@@ -876,7 +876,7 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
876
876
}
877
877
/* need to set errno = EDOM if z.imag is +/-infinity and
878
878
z.real is finite */
879
- if (Py_IS_INFINITY (z .imag ) && Py_IS_FINITE (z .real ))
879
+ if (isinf (z .imag ) && isfinite (z .real ))
880
880
errno = EDOM ;
881
881
else
882
882
errno = 0 ;
@@ -1030,11 +1030,11 @@ cmath_rect_impl(PyObject *module, double r, double phi)
1030
1030
errno = 0 ;
1031
1031
1032
1032
/* deal with special values */
1033
- if (!Py_IS_FINITE (r ) || !Py_IS_FINITE (phi )) {
1033
+ if (!isfinite (r ) || !isfinite (phi )) {
1034
1034
/* if r is +/-infinity and phi is finite but nonzero then
1035
1035
result is (+-INF +-INF i), but we need to compute cos(phi)
1036
1036
and sin(phi) to figure out the signs. */
1037
- if (Py_IS_INFINITY (r ) && (Py_IS_FINITE (phi )
1037
+ if (isinf (r ) && (isfinite (phi )
1038
1038
&& (phi != 0. ))) {
1039
1039
if (r > 0 ) {
1040
1040
z .real = copysign (INF , cos (phi ));
@@ -1051,7 +1051,7 @@ cmath_rect_impl(PyObject *module, double r, double phi)
1051
1051
}
1052
1052
/* need to set errno = EDOM if r is a nonzero number and phi
1053
1053
is infinite */
1054
- if (r != 0. && !Py_IS_NAN (r ) && Py_IS_INFINITY (phi ))
1054
+ if (r != 0. && !isnan (r ) && isinf (phi ))
1055
1055
errno = EDOM ;
1056
1056
else
1057
1057
errno = 0 ;
@@ -1085,7 +1085,7 @@ static PyObject *
1085
1085
cmath_isfinite_impl (PyObject * module , Py_complex z )
1086
1086
/*[clinic end generated code: output=ac76611e2c774a36 input=848e7ee701895815]*/
1087
1087
{
1088
- return PyBool_FromLong (Py_IS_FINITE (z .real ) && Py_IS_FINITE (z .imag ));
1088
+ return PyBool_FromLong (isfinite (z .real ) && isfinite (z .imag ));
1089
1089
}
1090
1090
1091
1091
/*[clinic input]
@@ -1098,7 +1098,7 @@ static PyObject *
1098
1098
cmath_isnan_impl (PyObject * module , Py_complex z )
1099
1099
/*[clinic end generated code: output=e7abf6e0b28beab7 input=71799f5d284c9baf]*/
1100
1100
{
1101
- return PyBool_FromLong (Py_IS_NAN (z .real ) || Py_IS_NAN (z .imag ));
1101
+ return PyBool_FromLong (isnan (z .real ) || isnan (z .imag ));
1102
1102
}
1103
1103
1104
1104
/*[clinic input]
@@ -1111,8 +1111,7 @@ static PyObject *
1111
1111
cmath_isinf_impl (PyObject * module , Py_complex z )
1112
1112
/*[clinic end generated code: output=502a75a79c773469 input=363df155c7181329]*/
1113
1113
{
1114
- return PyBool_FromLong (Py_IS_INFINITY (z .real ) ||
1115
- Py_IS_INFINITY (z .imag ));
1114
+ return PyBool_FromLong (isinf (z .real ) || isinf (z .imag ));
1116
1115
}
1117
1116
1118
1117
/*[clinic input]
@@ -1167,8 +1166,7 @@ cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b,
1167
1166
above.
1168
1167
*/
1169
1168
1170
- if (Py_IS_INFINITY (a .real ) || Py_IS_INFINITY (a .imag ) ||
1171
- Py_IS_INFINITY (b .real ) || Py_IS_INFINITY (b .imag )) {
1169
+ if (isinf (a .real ) || isinf (a .imag ) || isinf (b .real ) || isinf (b .imag )) {
1172
1170
return 0 ;
1173
1171
}
1174
1172
0 commit comments