blob: 4b6653aa219422607f14cd32e3d57aeb94b06623 [file] [log] [blame]
Brett Cannonb0fc4902014-10-14 17:37:02 -04001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(cmath_acos__doc__,
6"acos($module, z, /)\n"
7"--\n"
8"\n"
9"Return the arc cosine of z.");
10
11#define CMATH_ACOS_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +030012 {"acos", (PyCFunction)cmath_acos, METH_O, cmath_acos__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -040013
14static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030015cmath_acos_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -040016
17static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030018cmath_acos(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -040019{
20 PyObject *return_value = NULL;
21 Py_complex z;
22 Py_complex _return_value;
23
Serhiy Storchaka32d96a22018-12-25 13:23:47 +020024 z = PyComplex_AsCComplex(arg);
25 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -040026 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030027 }
Brett Cannonb0fc4902014-10-14 17:37:02 -040028 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +010029 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -040030 _return_value = cmath_acos_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -040031 if (errno == EDOM) {
32 PyErr_SetString(PyExc_ValueError, "math domain error");
33 goto exit;
34 }
35 else if (errno == ERANGE) {
36 PyErr_SetString(PyExc_OverflowError, "math range error");
37 goto exit;
38 }
39 else {
40 return_value = PyComplex_FromCComplex(_return_value);
41 }
42
43exit:
44 return return_value;
45}
46
47PyDoc_STRVAR(cmath_acosh__doc__,
48"acosh($module, z, /)\n"
49"--\n"
50"\n"
Mark Dickinsoncc8617b2015-01-11 13:22:44 +000051"Return the inverse hyperbolic cosine of z.");
Brett Cannonb0fc4902014-10-14 17:37:02 -040052
53#define CMATH_ACOSH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +030054 {"acosh", (PyCFunction)cmath_acosh, METH_O, cmath_acosh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -040055
56static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030057cmath_acosh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -040058
59static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030060cmath_acosh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -040061{
62 PyObject *return_value = NULL;
63 Py_complex z;
64 Py_complex _return_value;
65
Serhiy Storchaka32d96a22018-12-25 13:23:47 +020066 z = PyComplex_AsCComplex(arg);
67 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -040068 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030069 }
Brett Cannonb0fc4902014-10-14 17:37:02 -040070 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +010071 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -040072 _return_value = cmath_acosh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -040073 if (errno == EDOM) {
74 PyErr_SetString(PyExc_ValueError, "math domain error");
75 goto exit;
76 }
77 else if (errno == ERANGE) {
78 PyErr_SetString(PyExc_OverflowError, "math range error");
79 goto exit;
80 }
81 else {
82 return_value = PyComplex_FromCComplex(_return_value);
83 }
84
85exit:
86 return return_value;
87}
88
89PyDoc_STRVAR(cmath_asin__doc__,
90"asin($module, z, /)\n"
91"--\n"
92"\n"
93"Return the arc sine of z.");
94
95#define CMATH_ASIN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +030096 {"asin", (PyCFunction)cmath_asin, METH_O, cmath_asin__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -040097
98static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030099cmath_asin_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400100
101static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300102cmath_asin(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400103{
104 PyObject *return_value = NULL;
105 Py_complex z;
106 Py_complex _return_value;
107
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200108 z = PyComplex_AsCComplex(arg);
109 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400110 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300111 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400112 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100113 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400114 _return_value = cmath_asin_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400115 if (errno == EDOM) {
116 PyErr_SetString(PyExc_ValueError, "math domain error");
117 goto exit;
118 }
119 else if (errno == ERANGE) {
120 PyErr_SetString(PyExc_OverflowError, "math range error");
121 goto exit;
122 }
123 else {
124 return_value = PyComplex_FromCComplex(_return_value);
125 }
126
127exit:
128 return return_value;
129}
130
131PyDoc_STRVAR(cmath_asinh__doc__,
132"asinh($module, z, /)\n"
133"--\n"
134"\n"
Mark Dickinsoncc8617b2015-01-11 13:22:44 +0000135"Return the inverse hyperbolic sine of z.");
Brett Cannonb0fc4902014-10-14 17:37:02 -0400136
137#define CMATH_ASINH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300138 {"asinh", (PyCFunction)cmath_asinh, METH_O, cmath_asinh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400139
140static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300141cmath_asinh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400142
143static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300144cmath_asinh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400145{
146 PyObject *return_value = NULL;
147 Py_complex z;
148 Py_complex _return_value;
149
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200150 z = PyComplex_AsCComplex(arg);
151 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400152 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300153 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400154 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100155 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400156 _return_value = cmath_asinh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400157 if (errno == EDOM) {
158 PyErr_SetString(PyExc_ValueError, "math domain error");
159 goto exit;
160 }
161 else if (errno == ERANGE) {
162 PyErr_SetString(PyExc_OverflowError, "math range error");
163 goto exit;
164 }
165 else {
166 return_value = PyComplex_FromCComplex(_return_value);
167 }
168
169exit:
170 return return_value;
171}
172
173PyDoc_STRVAR(cmath_atan__doc__,
174"atan($module, z, /)\n"
175"--\n"
176"\n"
177"Return the arc tangent of z.");
178
179#define CMATH_ATAN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300180 {"atan", (PyCFunction)cmath_atan, METH_O, cmath_atan__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400181
182static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300183cmath_atan_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400184
185static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300186cmath_atan(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400187{
188 PyObject *return_value = NULL;
189 Py_complex z;
190 Py_complex _return_value;
191
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200192 z = PyComplex_AsCComplex(arg);
193 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400194 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300195 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400196 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100197 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400198 _return_value = cmath_atan_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400199 if (errno == EDOM) {
200 PyErr_SetString(PyExc_ValueError, "math domain error");
201 goto exit;
202 }
203 else if (errno == ERANGE) {
204 PyErr_SetString(PyExc_OverflowError, "math range error");
205 goto exit;
206 }
207 else {
208 return_value = PyComplex_FromCComplex(_return_value);
209 }
210
211exit:
212 return return_value;
213}
214
215PyDoc_STRVAR(cmath_atanh__doc__,
216"atanh($module, z, /)\n"
217"--\n"
218"\n"
Mark Dickinsoncc8617b2015-01-11 13:22:44 +0000219"Return the inverse hyperbolic tangent of z.");
Brett Cannonb0fc4902014-10-14 17:37:02 -0400220
221#define CMATH_ATANH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300222 {"atanh", (PyCFunction)cmath_atanh, METH_O, cmath_atanh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400223
224static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300225cmath_atanh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400226
227static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300228cmath_atanh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400229{
230 PyObject *return_value = NULL;
231 Py_complex z;
232 Py_complex _return_value;
233
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200234 z = PyComplex_AsCComplex(arg);
235 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400236 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300237 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400238 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100239 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400240 _return_value = cmath_atanh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400241 if (errno == EDOM) {
242 PyErr_SetString(PyExc_ValueError, "math domain error");
243 goto exit;
244 }
245 else if (errno == ERANGE) {
246 PyErr_SetString(PyExc_OverflowError, "math range error");
247 goto exit;
248 }
249 else {
250 return_value = PyComplex_FromCComplex(_return_value);
251 }
252
253exit:
254 return return_value;
255}
256
257PyDoc_STRVAR(cmath_cos__doc__,
258"cos($module, z, /)\n"
259"--\n"
260"\n"
261"Return the cosine of z.");
262
263#define CMATH_COS_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300264 {"cos", (PyCFunction)cmath_cos, METH_O, cmath_cos__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400265
266static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300267cmath_cos_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400268
269static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300270cmath_cos(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400271{
272 PyObject *return_value = NULL;
273 Py_complex z;
274 Py_complex _return_value;
275
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200276 z = PyComplex_AsCComplex(arg);
277 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400278 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300279 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400280 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100281 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400282 _return_value = cmath_cos_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400283 if (errno == EDOM) {
284 PyErr_SetString(PyExc_ValueError, "math domain error");
285 goto exit;
286 }
287 else if (errno == ERANGE) {
288 PyErr_SetString(PyExc_OverflowError, "math range error");
289 goto exit;
290 }
291 else {
292 return_value = PyComplex_FromCComplex(_return_value);
293 }
294
295exit:
296 return return_value;
297}
298
299PyDoc_STRVAR(cmath_cosh__doc__,
300"cosh($module, z, /)\n"
301"--\n"
302"\n"
303"Return the hyperbolic cosine of z.");
304
305#define CMATH_COSH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300306 {"cosh", (PyCFunction)cmath_cosh, METH_O, cmath_cosh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400307
308static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300309cmath_cosh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400310
311static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300312cmath_cosh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400313{
314 PyObject *return_value = NULL;
315 Py_complex z;
316 Py_complex _return_value;
317
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200318 z = PyComplex_AsCComplex(arg);
319 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400320 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300321 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400322 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100323 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400324 _return_value = cmath_cosh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400325 if (errno == EDOM) {
326 PyErr_SetString(PyExc_ValueError, "math domain error");
327 goto exit;
328 }
329 else if (errno == ERANGE) {
330 PyErr_SetString(PyExc_OverflowError, "math range error");
331 goto exit;
332 }
333 else {
334 return_value = PyComplex_FromCComplex(_return_value);
335 }
336
337exit:
338 return return_value;
339}
340
341PyDoc_STRVAR(cmath_exp__doc__,
342"exp($module, z, /)\n"
343"--\n"
344"\n"
345"Return the exponential value e**z.");
346
347#define CMATH_EXP_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300348 {"exp", (PyCFunction)cmath_exp, METH_O, cmath_exp__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400349
350static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300351cmath_exp_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400352
353static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300354cmath_exp(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400355{
356 PyObject *return_value = NULL;
357 Py_complex z;
358 Py_complex _return_value;
359
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200360 z = PyComplex_AsCComplex(arg);
361 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400362 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300363 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400364 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100365 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400366 _return_value = cmath_exp_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400367 if (errno == EDOM) {
368 PyErr_SetString(PyExc_ValueError, "math domain error");
369 goto exit;
370 }
371 else if (errno == ERANGE) {
372 PyErr_SetString(PyExc_OverflowError, "math range error");
373 goto exit;
374 }
375 else {
376 return_value = PyComplex_FromCComplex(_return_value);
377 }
378
379exit:
380 return return_value;
381}
382
383PyDoc_STRVAR(cmath_log10__doc__,
384"log10($module, z, /)\n"
385"--\n"
386"\n"
387"Return the base-10 logarithm of z.");
388
389#define CMATH_LOG10_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300390 {"log10", (PyCFunction)cmath_log10, METH_O, cmath_log10__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400391
392static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300393cmath_log10_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400394
395static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300396cmath_log10(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400397{
398 PyObject *return_value = NULL;
399 Py_complex z;
400 Py_complex _return_value;
401
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200402 z = PyComplex_AsCComplex(arg);
403 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400404 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300405 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400406 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100407 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400408 _return_value = cmath_log10_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400409 if (errno == EDOM) {
410 PyErr_SetString(PyExc_ValueError, "math domain error");
411 goto exit;
412 }
413 else if (errno == ERANGE) {
414 PyErr_SetString(PyExc_OverflowError, "math range error");
415 goto exit;
416 }
417 else {
418 return_value = PyComplex_FromCComplex(_return_value);
419 }
420
421exit:
422 return return_value;
423}
424
425PyDoc_STRVAR(cmath_sin__doc__,
426"sin($module, z, /)\n"
427"--\n"
428"\n"
429"Return the sine of z.");
430
431#define CMATH_SIN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300432 {"sin", (PyCFunction)cmath_sin, METH_O, cmath_sin__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400433
434static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300435cmath_sin_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400436
437static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300438cmath_sin(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400439{
440 PyObject *return_value = NULL;
441 Py_complex z;
442 Py_complex _return_value;
443
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200444 z = PyComplex_AsCComplex(arg);
445 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400446 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300447 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400448 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100449 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400450 _return_value = cmath_sin_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400451 if (errno == EDOM) {
452 PyErr_SetString(PyExc_ValueError, "math domain error");
453 goto exit;
454 }
455 else if (errno == ERANGE) {
456 PyErr_SetString(PyExc_OverflowError, "math range error");
457 goto exit;
458 }
459 else {
460 return_value = PyComplex_FromCComplex(_return_value);
461 }
462
463exit:
464 return return_value;
465}
466
467PyDoc_STRVAR(cmath_sinh__doc__,
468"sinh($module, z, /)\n"
469"--\n"
470"\n"
471"Return the hyperbolic sine of z.");
472
473#define CMATH_SINH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300474 {"sinh", (PyCFunction)cmath_sinh, METH_O, cmath_sinh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400475
476static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300477cmath_sinh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400478
479static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300480cmath_sinh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400481{
482 PyObject *return_value = NULL;
483 Py_complex z;
484 Py_complex _return_value;
485
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200486 z = PyComplex_AsCComplex(arg);
487 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400488 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300489 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400490 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100491 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400492 _return_value = cmath_sinh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400493 if (errno == EDOM) {
494 PyErr_SetString(PyExc_ValueError, "math domain error");
495 goto exit;
496 }
497 else if (errno == ERANGE) {
498 PyErr_SetString(PyExc_OverflowError, "math range error");
499 goto exit;
500 }
501 else {
502 return_value = PyComplex_FromCComplex(_return_value);
503 }
504
505exit:
506 return return_value;
507}
508
509PyDoc_STRVAR(cmath_sqrt__doc__,
510"sqrt($module, z, /)\n"
511"--\n"
512"\n"
513"Return the square root of z.");
514
515#define CMATH_SQRT_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300516 {"sqrt", (PyCFunction)cmath_sqrt, METH_O, cmath_sqrt__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400517
518static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300519cmath_sqrt_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400520
521static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300522cmath_sqrt(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400523{
524 PyObject *return_value = NULL;
525 Py_complex z;
526 Py_complex _return_value;
527
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200528 z = PyComplex_AsCComplex(arg);
529 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400530 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300531 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400532 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100533 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400534 _return_value = cmath_sqrt_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400535 if (errno == EDOM) {
536 PyErr_SetString(PyExc_ValueError, "math domain error");
537 goto exit;
538 }
539 else if (errno == ERANGE) {
540 PyErr_SetString(PyExc_OverflowError, "math range error");
541 goto exit;
542 }
543 else {
544 return_value = PyComplex_FromCComplex(_return_value);
545 }
546
547exit:
548 return return_value;
549}
550
551PyDoc_STRVAR(cmath_tan__doc__,
552"tan($module, z, /)\n"
553"--\n"
554"\n"
555"Return the tangent of z.");
556
557#define CMATH_TAN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300558 {"tan", (PyCFunction)cmath_tan, METH_O, cmath_tan__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400559
560static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300561cmath_tan_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400562
563static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300564cmath_tan(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400565{
566 PyObject *return_value = NULL;
567 Py_complex z;
568 Py_complex _return_value;
569
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200570 z = PyComplex_AsCComplex(arg);
571 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400572 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300573 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400574 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100575 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400576 _return_value = cmath_tan_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400577 if (errno == EDOM) {
578 PyErr_SetString(PyExc_ValueError, "math domain error");
579 goto exit;
580 }
581 else if (errno == ERANGE) {
582 PyErr_SetString(PyExc_OverflowError, "math range error");
583 goto exit;
584 }
585 else {
586 return_value = PyComplex_FromCComplex(_return_value);
587 }
588
589exit:
590 return return_value;
591}
592
593PyDoc_STRVAR(cmath_tanh__doc__,
594"tanh($module, z, /)\n"
595"--\n"
596"\n"
597"Return the hyperbolic tangent of z.");
598
599#define CMATH_TANH_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300600 {"tanh", (PyCFunction)cmath_tanh, METH_O, cmath_tanh__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400601
602static Py_complex
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300603cmath_tanh_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400604
605static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300606cmath_tanh(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400607{
608 PyObject *return_value = NULL;
609 Py_complex z;
610 Py_complex _return_value;
611
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200612 z = PyComplex_AsCComplex(arg);
613 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400614 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300615 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400616 /* modifications for z */
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100617 errno = 0;
Brett Cannonb0fc4902014-10-14 17:37:02 -0400618 _return_value = cmath_tanh_impl(module, z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400619 if (errno == EDOM) {
620 PyErr_SetString(PyExc_ValueError, "math domain error");
621 goto exit;
622 }
623 else if (errno == ERANGE) {
624 PyErr_SetString(PyExc_OverflowError, "math range error");
625 goto exit;
626 }
627 else {
628 return_value = PyComplex_FromCComplex(_return_value);
629 }
630
631exit:
632 return return_value;
633}
634
635PyDoc_STRVAR(cmath_log__doc__,
Serhiy Storchaka279f4462019-09-14 12:24:05 +0300636"log($module, z, base=<unrepresentable>, /)\n"
Brett Cannonb0fc4902014-10-14 17:37:02 -0400637"--\n"
638"\n"
Serhiy Storchaka279f4462019-09-14 12:24:05 +0300639"log(z[, base]) -> the logarithm of z to the given base.\n"
Brett Cannonb0fc4902014-10-14 17:37:02 -0400640"\n"
641"If the base not specified, returns the natural logarithm (base e) of z.");
642
643#define CMATH_LOG_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200644 {"log", (PyCFunction)(void(*)(void))cmath_log, METH_FASTCALL, cmath_log__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400645
646static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300647cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400648
649static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200650cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400651{
652 PyObject *return_value = NULL;
653 Py_complex x;
654 PyObject *y_obj = NULL;
655
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200656 if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100657 goto exit;
658 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200659 x = PyComplex_AsCComplex(args[0]);
660 if (PyErr_Occurred()) {
661 goto exit;
662 }
663 if (nargs < 2) {
664 goto skip_optional;
665 }
666 y_obj = args[1];
667skip_optional:
Brett Cannonb0fc4902014-10-14 17:37:02 -0400668 return_value = cmath_log_impl(module, x, y_obj);
669
670exit:
671 return return_value;
672}
673
674PyDoc_STRVAR(cmath_phase__doc__,
675"phase($module, z, /)\n"
676"--\n"
677"\n"
678"Return argument, also known as the phase angle, of a complex.");
679
680#define CMATH_PHASE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300681 {"phase", (PyCFunction)cmath_phase, METH_O, cmath_phase__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400682
683static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300684cmath_phase_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400685
686static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300687cmath_phase(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400688{
689 PyObject *return_value = NULL;
690 Py_complex z;
691
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200692 z = PyComplex_AsCComplex(arg);
693 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400694 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300695 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400696 return_value = cmath_phase_impl(module, z);
697
698exit:
699 return return_value;
700}
701
702PyDoc_STRVAR(cmath_polar__doc__,
703"polar($module, z, /)\n"
704"--\n"
705"\n"
706"Convert a complex from rectangular coordinates to polar coordinates.\n"
707"\n"
708"r is the distance from 0 and phi the phase angle.");
709
710#define CMATH_POLAR_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300711 {"polar", (PyCFunction)cmath_polar, METH_O, cmath_polar__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400712
713static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300714cmath_polar_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400715
716static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300717cmath_polar(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400718{
719 PyObject *return_value = NULL;
720 Py_complex z;
721
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200722 z = PyComplex_AsCComplex(arg);
723 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400724 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300725 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400726 return_value = cmath_polar_impl(module, z);
727
728exit:
729 return return_value;
730}
731
732PyDoc_STRVAR(cmath_rect__doc__,
733"rect($module, r, phi, /)\n"
734"--\n"
735"\n"
736"Convert from polar coordinates to rectangular coordinates.");
737
738#define CMATH_RECT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200739 {"rect", (PyCFunction)(void(*)(void))cmath_rect, METH_FASTCALL, cmath_rect__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400740
741static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300742cmath_rect_impl(PyObject *module, double r, double phi);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400743
744static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200745cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400746{
747 PyObject *return_value = NULL;
748 double r;
749 double phi;
750
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200751 if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) {
752 goto exit;
753 }
Raymond Hettingeraef9ad82019-08-24 19:10:39 -0700754 if (PyFloat_CheckExact(args[0])) {
755 r = PyFloat_AS_DOUBLE(args[0]);
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200756 }
Raymond Hettingeraef9ad82019-08-24 19:10:39 -0700757 else
758 {
759 r = PyFloat_AsDouble(args[0]);
760 if (r == -1.0 && PyErr_Occurred()) {
761 goto exit;
762 }
763 }
764 if (PyFloat_CheckExact(args[1])) {
765 phi = PyFloat_AS_DOUBLE(args[1]);
766 }
767 else
768 {
769 phi = PyFloat_AsDouble(args[1]);
770 if (phi == -1.0 && PyErr_Occurred()) {
771 goto exit;
772 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100773 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400774 return_value = cmath_rect_impl(module, r, phi);
775
776exit:
777 return return_value;
778}
779
780PyDoc_STRVAR(cmath_isfinite__doc__,
781"isfinite($module, z, /)\n"
782"--\n"
783"\n"
784"Return True if both the real and imaginary parts of z are finite, else False.");
785
786#define CMATH_ISFINITE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300787 {"isfinite", (PyCFunction)cmath_isfinite, METH_O, cmath_isfinite__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400788
789static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300790cmath_isfinite_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400791
792static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300793cmath_isfinite(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400794{
795 PyObject *return_value = NULL;
796 Py_complex z;
797
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200798 z = PyComplex_AsCComplex(arg);
799 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400800 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300801 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400802 return_value = cmath_isfinite_impl(module, z);
803
804exit:
805 return return_value;
806}
807
808PyDoc_STRVAR(cmath_isnan__doc__,
809"isnan($module, z, /)\n"
810"--\n"
811"\n"
812"Checks if the real or imaginary part of z not a number (NaN).");
813
814#define CMATH_ISNAN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300815 {"isnan", (PyCFunction)cmath_isnan, METH_O, cmath_isnan__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400816
817static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300818cmath_isnan_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400819
820static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300821cmath_isnan(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400822{
823 PyObject *return_value = NULL;
824 Py_complex z;
825
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200826 z = PyComplex_AsCComplex(arg);
827 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400828 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300829 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400830 return_value = cmath_isnan_impl(module, z);
831
832exit:
833 return return_value;
834}
835
836PyDoc_STRVAR(cmath_isinf__doc__,
837"isinf($module, z, /)\n"
838"--\n"
839"\n"
840"Checks if the real or imaginary part of z is infinite.");
841
842#define CMATH_ISINF_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300843 {"isinf", (PyCFunction)cmath_isinf, METH_O, cmath_isinf__doc__},
Brett Cannonb0fc4902014-10-14 17:37:02 -0400844
845static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300846cmath_isinf_impl(PyObject *module, Py_complex z);
Brett Cannonb0fc4902014-10-14 17:37:02 -0400847
848static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300849cmath_isinf(PyObject *module, PyObject *arg)
Brett Cannonb0fc4902014-10-14 17:37:02 -0400850{
851 PyObject *return_value = NULL;
852 Py_complex z;
853
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200854 z = PyComplex_AsCComplex(arg);
855 if (PyErr_Occurred()) {
Brett Cannonb0fc4902014-10-14 17:37:02 -0400856 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300857 }
Brett Cannonb0fc4902014-10-14 17:37:02 -0400858 return_value = cmath_isinf_impl(module, z);
859
860exit:
861 return return_value;
862}
Tal Einatd5519ed2015-05-31 22:05:00 +0300863
864PyDoc_STRVAR(cmath_isclose__doc__,
865"isclose($module, /, a, b, *, rel_tol=1e-09, abs_tol=0.0)\n"
866"--\n"
867"\n"
868"Determine whether two complex numbers are close in value.\n"
869"\n"
870" rel_tol\n"
871" maximum difference for being considered \"close\", relative to the\n"
872" magnitude of the input values\n"
873" abs_tol\n"
874" maximum difference for being considered \"close\", regardless of the\n"
875" magnitude of the input values\n"
876"\n"
877"Return True if a is close in value to b, and False otherwise.\n"
878"\n"
879"For the values to be considered close, the difference between them must be\n"
880"smaller than at least one of the tolerances.\n"
881"\n"
882"-inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is\n"
883"not close to anything, even itself. inf and -inf are only close to themselves.");
884
885#define CMATH_ISCLOSE_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200886 {"isclose", (PyCFunction)(void(*)(void))cmath_isclose, METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__},
Tal Einatd5519ed2015-05-31 22:05:00 +0300887
888static int
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300889cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b,
Tal Einatd5519ed2015-05-31 22:05:00 +0300890 double rel_tol, double abs_tol);
891
892static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200893cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Tal Einatd5519ed2015-05-31 22:05:00 +0300894{
895 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300896 static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +0200897 static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0};
898 PyObject *argsbuf[4];
899 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
Tal Einatd5519ed2015-05-31 22:05:00 +0300900 Py_complex a;
901 Py_complex b;
902 double rel_tol = 1e-09;
903 double abs_tol = 0.0;
904 int _return_value;
905
Serhiy Storchaka31913912019-03-14 10:32:22 +0200906 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
907 if (!args) {
Tal Einatd5519ed2015-05-31 22:05:00 +0300908 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300909 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200910 a = PyComplex_AsCComplex(args[0]);
911 if (PyErr_Occurred()) {
912 goto exit;
913 }
914 b = PyComplex_AsCComplex(args[1]);
915 if (PyErr_Occurred()) {
916 goto exit;
917 }
918 if (!noptargs) {
919 goto skip_optional_kwonly;
920 }
921 if (args[2]) {
Raymond Hettingeraef9ad82019-08-24 19:10:39 -0700922 if (PyFloat_CheckExact(args[2])) {
923 rel_tol = PyFloat_AS_DOUBLE(args[2]);
924 }
925 else
926 {
927 rel_tol = PyFloat_AsDouble(args[2]);
928 if (rel_tol == -1.0 && PyErr_Occurred()) {
929 goto exit;
930 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200931 }
932 if (!--noptargs) {
933 goto skip_optional_kwonly;
934 }
935 }
Raymond Hettingeraef9ad82019-08-24 19:10:39 -0700936 if (PyFloat_CheckExact(args[3])) {
937 abs_tol = PyFloat_AS_DOUBLE(args[3]);
938 }
939 else
940 {
941 abs_tol = PyFloat_AsDouble(args[3]);
942 if (abs_tol == -1.0 && PyErr_Occurred()) {
943 goto exit;
944 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200945 }
946skip_optional_kwonly:
Tal Einatd5519ed2015-05-31 22:05:00 +0300947 _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300948 if ((_return_value == -1) && PyErr_Occurred()) {
Tal Einatd5519ed2015-05-31 22:05:00 +0300949 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300950 }
Tal Einatd5519ed2015-05-31 22:05:00 +0300951 return_value = PyBool_FromLong((long)_return_value);
952
953exit:
954 return return_value;
955}
Victor Stinnerbe143ec2019-11-20 02:51:30 +0100956/*[clinic end generated code: output=353347db2e808e0d input=a9049054013a1b77]*/