| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | preserve | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 15:25:49 -06:00
										 |  |  | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 | 
					
						
							|  |  |  | #  include "pycore_gc.h"            // PyGC_Head
 | 
					
						
							|  |  |  | #  include "pycore_runtime.h"       // _Py_ID()
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | PyDoc_STRVAR(cmath_acos__doc__, | 
					
						
							|  |  |  | "acos($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the arc cosine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ACOS_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"acos", (PyCFunction)cmath_acos, METH_O, cmath_acos__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_acos_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_acos(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_acos_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_acosh__doc__, | 
					
						
							|  |  |  | "acosh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2015-01-11 13:22:44 +00:00
										 |  |  | "Return the inverse hyperbolic cosine of z."); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ACOSH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"acosh", (PyCFunction)cmath_acosh, METH_O, cmath_acosh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_acosh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_acosh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_acosh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_asin__doc__, | 
					
						
							|  |  |  | "asin($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the arc sine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ASIN_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"asin", (PyCFunction)cmath_asin, METH_O, cmath_asin__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_asin_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_asin(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_asin_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_asinh__doc__, | 
					
						
							|  |  |  | "asinh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2015-01-11 13:22:44 +00:00
										 |  |  | "Return the inverse hyperbolic sine of z."); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ASINH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"asinh", (PyCFunction)cmath_asinh, METH_O, cmath_asinh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_asinh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_asinh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_asinh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_atan__doc__, | 
					
						
							|  |  |  | "atan($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the arc tangent of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ATAN_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"atan", (PyCFunction)cmath_atan, METH_O, cmath_atan__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_atan_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_atan(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_atan_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_atanh__doc__, | 
					
						
							|  |  |  | "atanh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2015-01-11 13:22:44 +00:00
										 |  |  | "Return the inverse hyperbolic tangent of z."); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ATANH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"atanh", (PyCFunction)cmath_atanh, METH_O, cmath_atanh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_atanh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_atanh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_atanh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_cos__doc__, | 
					
						
							|  |  |  | "cos($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the cosine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_COS_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"cos", (PyCFunction)cmath_cos, METH_O, cmath_cos__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_cos_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_cos(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_cos_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_cosh__doc__, | 
					
						
							|  |  |  | "cosh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the hyperbolic cosine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_COSH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"cosh", (PyCFunction)cmath_cosh, METH_O, cmath_cosh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_cosh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_cosh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_cosh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_exp__doc__, | 
					
						
							|  |  |  | "exp($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the exponential value e**z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_EXP_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"exp", (PyCFunction)cmath_exp, METH_O, cmath_exp__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_exp_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_exp(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_exp_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_log10__doc__, | 
					
						
							|  |  |  | "log10($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the base-10 logarithm of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_LOG10_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"log10", (PyCFunction)cmath_log10, METH_O, cmath_log10__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_log10_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_log10(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_log10_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_sin__doc__, | 
					
						
							|  |  |  | "sin($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the sine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_SIN_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"sin", (PyCFunction)cmath_sin, METH_O, cmath_sin__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sin_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sin(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_sin_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_sinh__doc__, | 
					
						
							|  |  |  | "sinh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the hyperbolic sine of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_SINH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"sinh", (PyCFunction)cmath_sinh, METH_O, cmath_sinh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sinh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sinh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_sinh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_sqrt__doc__, | 
					
						
							|  |  |  | "sqrt($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the square root of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_SQRT_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"sqrt", (PyCFunction)cmath_sqrt, METH_O, cmath_sqrt__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sqrt_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_sqrt(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_sqrt_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_tan__doc__, | 
					
						
							|  |  |  | "tan($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the tangent of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_TAN_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"tan", (PyCFunction)cmath_tan, METH_O, cmath_tan__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_tan_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_tan(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_tan_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_tanh__doc__, | 
					
						
							|  |  |  | "tanh($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return the hyperbolic tangent of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_TANH_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"tanh", (PyCFunction)cmath_tanh, METH_O, cmath_tanh__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Py_complex | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_tanh_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_tanh(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  |     Py_complex _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     /* modifications for z */ | 
					
						
							| 
									
										
										
										
											2019-11-20 02:51:30 +01:00
										 |  |  |     errno = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     _return_value = cmath_tanh_impl(module, z); | 
					
						
							|  |  |  |     if (errno == EDOM) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_ValueError, "math domain error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (errno == ERANGE) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_OverflowError, "math range error"); | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         return_value = PyComplex_FromCComplex(_return_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_log__doc__, | 
					
						
							| 
									
										
										
										
											2019-09-14 12:24:05 +03:00
										 |  |  | "log($module, z, base=<unrepresentable>, /)\n" | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2019-09-14 12:24:05 +03:00
										 |  |  | "log(z[, base]) -> the logarithm of z to the given base.\n" | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | "\n" | 
					
						
							|  |  |  | "If the base not specified, returns the natural logarithm (base e) of z."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_LOG_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"log", _PyCFunction_CAST(cmath_log), METH_FASTCALL, cmath_log__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex x; | 
					
						
							|  |  |  |     PyObject *y_obj = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     if (!_PyArg_CheckPositional("log", nargs, 1, 2)) { | 
					
						
							| 
									
										
										
										
											2017-01-17 01:35:17 +01:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     x = PyComplex_AsCComplex(args[0]); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (nargs < 2) { | 
					
						
							|  |  |  |         goto skip_optional; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     y_obj = args[1]; | 
					
						
							|  |  |  | skip_optional: | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_log_impl(module, x, y_obj); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_phase__doc__, | 
					
						
							|  |  |  | "phase($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return argument, also known as the phase angle, of a complex."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_PHASE_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"phase", (PyCFunction)cmath_phase, METH_O, cmath_phase__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_phase_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_phase(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_phase_impl(module, z); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_polar__doc__, | 
					
						
							|  |  |  | "polar($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Convert a complex from rectangular coordinates to polar coordinates.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "r is the distance from 0 and phi the phase angle."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_POLAR_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"polar", (PyCFunction)cmath_polar, METH_O, cmath_polar__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_polar_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_polar(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_polar_impl(module, z); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_rect__doc__, | 
					
						
							|  |  |  | "rect($module, r, phi, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Convert from polar coordinates to rectangular coordinates."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_RECT_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"rect", _PyCFunction_CAST(cmath_rect), METH_FASTCALL, cmath_rect__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_rect_impl(PyObject *module, double r, double phi); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     double r; | 
					
						
							|  |  |  |     double phi; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-24 19:10:39 -07:00
										 |  |  |     if (PyFloat_CheckExact(args[0])) { | 
					
						
							|  |  |  |         r = PyFloat_AS_DOUBLE(args[0]); | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-24 19:10:39 -07:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         r = PyFloat_AsDouble(args[0]); | 
					
						
							|  |  |  |         if (r == -1.0 && PyErr_Occurred()) { | 
					
						
							|  |  |  |             goto exit; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyFloat_CheckExact(args[1])) { | 
					
						
							|  |  |  |         phi = PyFloat_AS_DOUBLE(args[1]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         phi = PyFloat_AsDouble(args[1]); | 
					
						
							|  |  |  |         if (phi == -1.0 && PyErr_Occurred()) { | 
					
						
							|  |  |  |             goto exit; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-01-17 01:35:17 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_rect_impl(module, r, phi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_isfinite__doc__, | 
					
						
							|  |  |  | "isfinite($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return True if both the real and imaginary parts of z are finite, else False."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ISFINITE_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"isfinite", (PyCFunction)cmath_isfinite, METH_O, cmath_isfinite__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isfinite_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isfinite(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_isfinite_impl(module, z); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_isnan__doc__, | 
					
						
							|  |  |  | "isnan($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Checks if the real or imaginary part of z not a number (NaN)."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ISNAN_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"isnan", (PyCFunction)cmath_isnan, METH_O, cmath_isnan__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isnan_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isnan(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_isnan_impl(module, z); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_isinf__doc__, | 
					
						
							|  |  |  | "isinf($module, z, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Checks if the real or imaginary part of z is infinite."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ISINF_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"isinf", (PyCFunction)cmath_isinf, METH_O, cmath_isinf__doc__}, | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isinf_impl(PyObject *module, Py_complex z); | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isinf(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_complex z; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     z = PyComplex_AsCComplex(arg); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 17:37:02 -04:00
										 |  |  |     return_value = cmath_isinf_impl(module, z); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(cmath_isclose__doc__, | 
					
						
							|  |  |  | "isclose($module, /, a, b, *, rel_tol=1e-09, abs_tol=0.0)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Determine whether two complex numbers are close in value.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "  rel_tol\n" | 
					
						
							|  |  |  | "    maximum difference for being considered \"close\", relative to the\n" | 
					
						
							|  |  |  | "    magnitude of the input values\n" | 
					
						
							|  |  |  | "  abs_tol\n" | 
					
						
							|  |  |  | "    maximum difference for being considered \"close\", regardless of the\n" | 
					
						
							|  |  |  | "    magnitude of the input values\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Return True if a is close in value to b, and False otherwise.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "For the values to be considered close, the difference between them must be\n" | 
					
						
							|  |  |  | "smaller than at least one of the tolerances.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "-inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is\n" | 
					
						
							|  |  |  | "not close to anything, even itself. inf and -inf are only close to themselves."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CMATH_ISCLOSE_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"isclose", _PyCFunction_CAST(cmath_isclose), METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__}, | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b, | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |                    double rel_tol, double abs_tol); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2022-08-13 12:09:40 +02:00
										 |  |  |     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
 | 
					
						
							| 
									
										
										
										
											2022-08-11 15:25:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 12:09:40 +02:00
										 |  |  |     #define NUM_KEYWORDS 4
 | 
					
						
							| 
									
										
										
										
											2022-08-11 15:25:49 -06:00
										 |  |  |     static struct { | 
					
						
							|  |  |  |         PyGC_Head _this_is_not_used; | 
					
						
							|  |  |  |         PyObject_VAR_HEAD | 
					
						
							|  |  |  |         PyObject *ob_item[NUM_KEYWORDS]; | 
					
						
							|  |  |  |     } _kwtuple = { | 
					
						
							|  |  |  |         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) | 
					
						
							|  |  |  |         .ob_item = { &_Py_ID(a), &_Py_ID(b), &_Py_ID(rel_tol), &_Py_ID(abs_tol), }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     #undef NUM_KEYWORDS
 | 
					
						
							| 
									
										
										
										
											2022-08-13 12:09:40 +02:00
										 |  |  |     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #else  // !Py_BUILD_CORE
 | 
					
						
							|  |  |  |     #  define KWTUPLE NULL
 | 
					
						
							|  |  |  |     #endif  // !Py_BUILD_CORE
 | 
					
						
							| 
									
										
										
										
											2022-08-11 15:25:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 10:52:18 +03:00
										 |  |  |     static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; | 
					
						
							| 
									
										
										
										
											2022-08-11 15:25:49 -06:00
										 |  |  |     static _PyArg_Parser _parser = { | 
					
						
							|  |  |  |         .keywords = _keywords, | 
					
						
							|  |  |  |         .fname = "isclose", | 
					
						
							|  |  |  |         .kwtuple = KWTUPLE, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     #undef KWTUPLE
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     PyObject *argsbuf[4]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |     Py_complex a; | 
					
						
							|  |  |  |     Py_complex b; | 
					
						
							|  |  |  |     double rel_tol = 1e-09; | 
					
						
							|  |  |  |     double abs_tol = 0.0; | 
					
						
							|  |  |  |     int _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     a = PyComplex_AsCComplex(args[0]); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     b = PyComplex_AsCComplex(args[1]); | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_kwonly; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (args[2]) { | 
					
						
							| 
									
										
										
										
											2019-08-24 19:10:39 -07:00
										 |  |  |         if (PyFloat_CheckExact(args[2])) { | 
					
						
							|  |  |  |             rel_tol = PyFloat_AS_DOUBLE(args[2]); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             rel_tol = PyFloat_AsDouble(args[2]); | 
					
						
							|  |  |  |             if (rel_tol == -1.0 && PyErr_Occurred()) { | 
					
						
							|  |  |  |                 goto exit; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         if (!--noptargs) { | 
					
						
							|  |  |  |             goto skip_optional_kwonly; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-24 19:10:39 -07:00
										 |  |  |     if (PyFloat_CheckExact(args[3])) { | 
					
						
							|  |  |  |         abs_tol = PyFloat_AS_DOUBLE(args[3]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         abs_tol = PyFloat_AsDouble(args[3]); | 
					
						
							|  |  |  |         if (abs_tol == -1.0 && PyErr_Occurred()) { | 
					
						
							|  |  |  |             goto exit; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | skip_optional_kwonly: | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |     _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if ((_return_value == -1) && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-31 22:05:00 +03:00
										 |  |  |     return_value = PyBool_FromLong((long)_return_value); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-08-13 12:09:40 +02:00
										 |  |  | /*[clinic end generated code: output=0146c656e67f5d5f input=a9049054013a1b77]*/ |