|
1 | 1 | /* Math module -- standard C math library functions, pi and e */ |
2 | 2 |
|
3 | | -/* |
| 3 | +/* |
4 | 4 | Here are some comments from Tim Peters, extracted from the |
5 | 5 | discussion attached to http://bugs.python.org/issue1640. They |
6 | 6 | describe the general aims of the math module with respect to |
@@ -192,7 +192,7 @@ tl_to_d(TripleLength total) |
192 | 192 | static const double pi = 3.141592653589793238462643383279502884197; |
193 | 193 | static const double logpi = 1.144729885849400174143427351353058711647; |
194 | 194 |
|
195 | | -/* |
| 195 | +/* |
196 | 196 | Version of PyFloat_AsDouble() with in-line fast paths |
197 | 197 | for exact floats and integers. Gives a substantial |
198 | 198 | speed improvement for extracting float arguments. |
@@ -249,7 +249,7 @@ m_sinpi(double x) |
249 | 249 | return copysign(1.0, x)*r; |
250 | 250 | } |
251 | 251 |
|
252 | | -/* |
| 252 | +/* |
253 | 253 | Implementation of the real gamma function. Kept here to work around |
254 | 254 | issues (see e.g. gh-70309) with quality of libm's tgamma/lgamma implementations |
255 | 255 | on various platforms (Windows, MacOS). In extensive but non-exhaustive |
@@ -834,7 +834,7 @@ math_lcm_impl(PyObject *module, PyObject * const *args, |
834 | 834 | return res; |
835 | 835 | } |
836 | 836 |
|
837 | | -/* |
| 837 | +/* |
838 | 838 | Call is_error when errno != 0, and where x is the result libm |
839 | 839 | returned. is_error will usually set up an exception and return |
840 | 840 | true (1), but may return false (0) without setting up an exception. |
@@ -945,14 +945,14 @@ math_1(PyObject *arg, double (*func) (double), int can_overflow, |
945 | 945 | PyErr_Format(PyExc_ValueError, err_msg, buf); |
946 | 946 | PyMem_Free(buf); |
947 | 947 | } |
948 | | - } |
949 | | - else { |
950 | | - PyErr_SetString(PyExc_ValueError, "math domain error"); |
951 | | - } |
| 948 | + } |
| 949 | + else { |
| 950 | + PyErr_SetString(PyExc_ValueError, "math domain error"); |
| 951 | + } |
952 | 952 | return NULL; |
953 | 953 | } |
954 | 954 |
|
955 | | -/* |
| 955 | +/* |
956 | 956 | Variant of math_1, to be used when the function being wrapped is known to |
957 | 957 | set errno properly (that is, errno = EDOM for invalid or divide-by-zero, |
958 | 958 | errno = ERANGE for overflow). |
@@ -1300,7 +1300,7 @@ FUNC1(tanh, tanh, 0, |
1300 | 1300 | "tanh($module, x, /)\n--\n\n" |
1301 | 1301 | "Return the hyperbolic tangent of x.") |
1302 | 1302 |
|
1303 | | -/* |
| 1303 | +/* |
1304 | 1304 | Precision summation function as msum() by Raymond Hettinger in |
1305 | 1305 | <https://code.activestate.com/recipes/393090-binary-floating-point-summation-accurate-to-full-p/>, |
1306 | 1306 | enhanced with the exact partials sum and roundoff from Mark |
@@ -1714,7 +1714,7 @@ static const uint8_t _approximate_isqrt_tab[192] = { |
1714 | 1714 | 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, 255, |
1715 | 1715 | }; |
1716 | 1716 |
|
1717 | | -/* |
| 1717 | +/* |
1718 | 1718 | Approximate square root of a large 64-bit integer. |
1719 | 1719 |
|
1720 | 1720 | Given `n` satisfying `2**62 <= n < 2**64`, return `a` |
@@ -1865,7 +1865,7 @@ math_isqrt(PyObject *module, PyObject *n) |
1865 | 1865 | return NULL; |
1866 | 1866 | } |
1867 | 1867 |
|
1868 | | -/* |
| 1868 | +/* |
1869 | 1869 | Divide-and-conquer factorial algorithm |
1870 | 1870 |
|
1871 | 1871 | Based on the formula and pseudo-code provided at: |
@@ -1931,7 +1931,7 @@ math_isqrt(PyObject *module, PyObject *n) |
1931 | 1931 | '1'-bits in the binary expansion of n. |
1932 | 1932 | */ |
1933 | 1933 |
|
1934 | | -/* |
| 1934 | +/* |
1935 | 1935 | factorial_partial_product: Compute product(range(start, stop, 2)) using |
1936 | 1936 | divide and conquer. Assumes start and stop are odd and stop > start. |
1937 | 1937 | max_bits must be >= bit_length(stop - 2). |
@@ -3290,9 +3290,9 @@ math_isclose_impl(PyObject *module, double a, double b, double rel_tol, |
3290 | 3290 |
|
3291 | 3291 | diff = fabs(b - a); |
3292 | 3292 |
|
3293 | | - return (((diff <= fabs(rel_tol * b)) || |
3294 | | - (diff <= fabs(rel_tol * a))) || |
3295 | | - (diff <= abs_tol)); |
| 3293 | + return (diff <= fabs(rel_tol * b)) || |
| 3294 | + (diff <= fabs(rel_tol * a)) || |
| 3295 | + (diff <= abs_tol); |
3296 | 3296 | } |
3297 | 3297 |
|
3298 | 3298 | static inline int |
|
0 commit comments