Skip to content

Commit 19be0ee

Browse files
authored
gh-122681: remove m_atan2()/c_atan2() helpers (#122715)
1 parent e6d5ff5 commit 19be0ee

File tree

3 files changed

+3
-42
lines changed

3 files changed

+3
-42
lines changed

Modules/_math.h

-39
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,3 @@ _Py_log1p(double x)
2323
}
2424

2525
#define m_log1p _Py_log1p
26-
27-
/*
28-
wrapper for atan2 that deals directly with special cases before
29-
delegating to the platform libm for the remaining cases. This
30-
is necessary to get consistent behaviour across platforms.
31-
Windows, FreeBSD and alpha Tru64 are amongst platforms that don't
32-
always follow C99. Windows screws up atan2 for inf and nan, and
33-
alpha Tru64 5.1 doesn't follow C99 for atan2(0., 0.).
34-
*/
35-
36-
static double
37-
_Py_atan2(double y, double x)
38-
{
39-
if (isnan(x) || isnan(y))
40-
return Py_NAN;
41-
if (isinf(y)) {
42-
if (isinf(x)) {
43-
if (copysign(1., x) == 1.)
44-
/* atan2(+-inf, +inf) == +-pi/4 */
45-
return copysign(0.25*Py_MATH_PI, y);
46-
else
47-
/* atan2(+-inf, -inf) == +-pi*3/4 */
48-
return copysign(0.75*Py_MATH_PI, y);
49-
}
50-
/* atan2(+-inf, x) == +-pi/2 for finite x */
51-
return copysign(0.5*Py_MATH_PI, y);
52-
}
53-
if (isinf(x) || y == 0.) {
54-
if (copysign(1., x) == 1.)
55-
/* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
56-
return copysign(0., y);
57-
else
58-
/* atan2(+-y, -inf) = atan2(+-0., -x) = +-pi. */
59-
return copysign(Py_MATH_PI, y);
60-
}
61-
return atan2(y, x);
62-
}
63-
64-
#define m_atan2 _Py_atan2

Modules/cmathmodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ cmath_phase_impl(PyObject *module, Py_complex z)
925925
double phi;
926926

927927
errno = 0;
928-
phi = m_atan2(z.imag, z.real); /* should not cause any exception */
928+
phi = atan2(z.imag, z.real); /* should not cause any exception */
929929
if (errno != 0)
930930
return math_error();
931931
else
@@ -950,7 +950,7 @@ cmath_polar_impl(PyObject *module, Py_complex z)
950950
double r, phi;
951951

952952
errno = 0;
953-
phi = m_atan2(z.imag, z.real); /* should not cause any exception */
953+
phi = atan2(z.imag, z.real); /* should not cause any exception */
954954
r = _Py_c_abs(z); /* sets errno to ERANGE on overflow */
955955
if (errno != 0)
956956
return math_error();

Modules/mathmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ FUNC1(atan, atan, 0,
10661066
"atan($module, x, /)\n--\n\n"
10671067
"Return the arc tangent (measured in radians) of x.\n\n"
10681068
"The result is between -pi/2 and pi/2.")
1069-
FUNC2(atan2, m_atan2,
1069+
FUNC2(atan2, atan2,
10701070
"atan2($module, y, x, /)\n--\n\n"
10711071
"Return the arc tangent (measured in radians) of y/x.\n\n"
10721072
"Unlike atan(y/x), the signs of both x and y are considered.")

0 commit comments

Comments
 (0)