• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_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    \
12     {"acos", (PyCFunction)cmath_acos, METH_O, cmath_acos__doc__},
13 
14 static Py_complex
15 cmath_acos_impl(PyObject *module, Py_complex z);
16 
17 static PyObject *
cmath_acos(PyObject * module,PyObject * arg)18 cmath_acos(PyObject *module, PyObject *arg)
19 {
20     PyObject *return_value = NULL;
21     Py_complex z;
22     Py_complex _return_value;
23 
24     if (!PyArg_Parse(arg, "D:acos", &z)) {
25         goto exit;
26     }
27     /* modifications for z */
28     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
29     _return_value = cmath_acos_impl(module, z);
30     PyFPE_END_PROTECT(_return_value);
31     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 
43 exit:
44     return return_value;
45 }
46 
47 PyDoc_STRVAR(cmath_acosh__doc__,
48 "acosh($module, z, /)\n"
49 "--\n"
50 "\n"
51 "Return the inverse hyperbolic cosine of z.");
52 
53 #define CMATH_ACOSH_METHODDEF    \
54     {"acosh", (PyCFunction)cmath_acosh, METH_O, cmath_acosh__doc__},
55 
56 static Py_complex
57 cmath_acosh_impl(PyObject *module, Py_complex z);
58 
59 static PyObject *
cmath_acosh(PyObject * module,PyObject * arg)60 cmath_acosh(PyObject *module, PyObject *arg)
61 {
62     PyObject *return_value = NULL;
63     Py_complex z;
64     Py_complex _return_value;
65 
66     if (!PyArg_Parse(arg, "D:acosh", &z)) {
67         goto exit;
68     }
69     /* modifications for z */
70     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
71     _return_value = cmath_acosh_impl(module, z);
72     PyFPE_END_PROTECT(_return_value);
73     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 
85 exit:
86     return return_value;
87 }
88 
89 PyDoc_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    \
96     {"asin", (PyCFunction)cmath_asin, METH_O, cmath_asin__doc__},
97 
98 static Py_complex
99 cmath_asin_impl(PyObject *module, Py_complex z);
100 
101 static PyObject *
cmath_asin(PyObject * module,PyObject * arg)102 cmath_asin(PyObject *module, PyObject *arg)
103 {
104     PyObject *return_value = NULL;
105     Py_complex z;
106     Py_complex _return_value;
107 
108     if (!PyArg_Parse(arg, "D:asin", &z)) {
109         goto exit;
110     }
111     /* modifications for z */
112     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
113     _return_value = cmath_asin_impl(module, z);
114     PyFPE_END_PROTECT(_return_value);
115     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 
127 exit:
128     return return_value;
129 }
130 
131 PyDoc_STRVAR(cmath_asinh__doc__,
132 "asinh($module, z, /)\n"
133 "--\n"
134 "\n"
135 "Return the inverse hyperbolic sine of z.");
136 
137 #define CMATH_ASINH_METHODDEF    \
138     {"asinh", (PyCFunction)cmath_asinh, METH_O, cmath_asinh__doc__},
139 
140 static Py_complex
141 cmath_asinh_impl(PyObject *module, Py_complex z);
142 
143 static PyObject *
cmath_asinh(PyObject * module,PyObject * arg)144 cmath_asinh(PyObject *module, PyObject *arg)
145 {
146     PyObject *return_value = NULL;
147     Py_complex z;
148     Py_complex _return_value;
149 
150     if (!PyArg_Parse(arg, "D:asinh", &z)) {
151         goto exit;
152     }
153     /* modifications for z */
154     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
155     _return_value = cmath_asinh_impl(module, z);
156     PyFPE_END_PROTECT(_return_value);
157     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 
169 exit:
170     return return_value;
171 }
172 
173 PyDoc_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    \
180     {"atan", (PyCFunction)cmath_atan, METH_O, cmath_atan__doc__},
181 
182 static Py_complex
183 cmath_atan_impl(PyObject *module, Py_complex z);
184 
185 static PyObject *
cmath_atan(PyObject * module,PyObject * arg)186 cmath_atan(PyObject *module, PyObject *arg)
187 {
188     PyObject *return_value = NULL;
189     Py_complex z;
190     Py_complex _return_value;
191 
192     if (!PyArg_Parse(arg, "D:atan", &z)) {
193         goto exit;
194     }
195     /* modifications for z */
196     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
197     _return_value = cmath_atan_impl(module, z);
198     PyFPE_END_PROTECT(_return_value);
199     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 
211 exit:
212     return return_value;
213 }
214 
215 PyDoc_STRVAR(cmath_atanh__doc__,
216 "atanh($module, z, /)\n"
217 "--\n"
218 "\n"
219 "Return the inverse hyperbolic tangent of z.");
220 
221 #define CMATH_ATANH_METHODDEF    \
222     {"atanh", (PyCFunction)cmath_atanh, METH_O, cmath_atanh__doc__},
223 
224 static Py_complex
225 cmath_atanh_impl(PyObject *module, Py_complex z);
226 
227 static PyObject *
cmath_atanh(PyObject * module,PyObject * arg)228 cmath_atanh(PyObject *module, PyObject *arg)
229 {
230     PyObject *return_value = NULL;
231     Py_complex z;
232     Py_complex _return_value;
233 
234     if (!PyArg_Parse(arg, "D:atanh", &z)) {
235         goto exit;
236     }
237     /* modifications for z */
238     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
239     _return_value = cmath_atanh_impl(module, z);
240     PyFPE_END_PROTECT(_return_value);
241     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 
253 exit:
254     return return_value;
255 }
256 
257 PyDoc_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    \
264     {"cos", (PyCFunction)cmath_cos, METH_O, cmath_cos__doc__},
265 
266 static Py_complex
267 cmath_cos_impl(PyObject *module, Py_complex z);
268 
269 static PyObject *
cmath_cos(PyObject * module,PyObject * arg)270 cmath_cos(PyObject *module, PyObject *arg)
271 {
272     PyObject *return_value = NULL;
273     Py_complex z;
274     Py_complex _return_value;
275 
276     if (!PyArg_Parse(arg, "D:cos", &z)) {
277         goto exit;
278     }
279     /* modifications for z */
280     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
281     _return_value = cmath_cos_impl(module, z);
282     PyFPE_END_PROTECT(_return_value);
283     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 
295 exit:
296     return return_value;
297 }
298 
299 PyDoc_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    \
306     {"cosh", (PyCFunction)cmath_cosh, METH_O, cmath_cosh__doc__},
307 
308 static Py_complex
309 cmath_cosh_impl(PyObject *module, Py_complex z);
310 
311 static PyObject *
cmath_cosh(PyObject * module,PyObject * arg)312 cmath_cosh(PyObject *module, PyObject *arg)
313 {
314     PyObject *return_value = NULL;
315     Py_complex z;
316     Py_complex _return_value;
317 
318     if (!PyArg_Parse(arg, "D:cosh", &z)) {
319         goto exit;
320     }
321     /* modifications for z */
322     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
323     _return_value = cmath_cosh_impl(module, z);
324     PyFPE_END_PROTECT(_return_value);
325     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 
337 exit:
338     return return_value;
339 }
340 
341 PyDoc_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    \
348     {"exp", (PyCFunction)cmath_exp, METH_O, cmath_exp__doc__},
349 
350 static Py_complex
351 cmath_exp_impl(PyObject *module, Py_complex z);
352 
353 static PyObject *
cmath_exp(PyObject * module,PyObject * arg)354 cmath_exp(PyObject *module, PyObject *arg)
355 {
356     PyObject *return_value = NULL;
357     Py_complex z;
358     Py_complex _return_value;
359 
360     if (!PyArg_Parse(arg, "D:exp", &z)) {
361         goto exit;
362     }
363     /* modifications for z */
364     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
365     _return_value = cmath_exp_impl(module, z);
366     PyFPE_END_PROTECT(_return_value);
367     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 
379 exit:
380     return return_value;
381 }
382 
383 PyDoc_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    \
390     {"log10", (PyCFunction)cmath_log10, METH_O, cmath_log10__doc__},
391 
392 static Py_complex
393 cmath_log10_impl(PyObject *module, Py_complex z);
394 
395 static PyObject *
cmath_log10(PyObject * module,PyObject * arg)396 cmath_log10(PyObject *module, PyObject *arg)
397 {
398     PyObject *return_value = NULL;
399     Py_complex z;
400     Py_complex _return_value;
401 
402     if (!PyArg_Parse(arg, "D:log10", &z)) {
403         goto exit;
404     }
405     /* modifications for z */
406     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
407     _return_value = cmath_log10_impl(module, z);
408     PyFPE_END_PROTECT(_return_value);
409     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 
421 exit:
422     return return_value;
423 }
424 
425 PyDoc_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    \
432     {"sin", (PyCFunction)cmath_sin, METH_O, cmath_sin__doc__},
433 
434 static Py_complex
435 cmath_sin_impl(PyObject *module, Py_complex z);
436 
437 static PyObject *
cmath_sin(PyObject * module,PyObject * arg)438 cmath_sin(PyObject *module, PyObject *arg)
439 {
440     PyObject *return_value = NULL;
441     Py_complex z;
442     Py_complex _return_value;
443 
444     if (!PyArg_Parse(arg, "D:sin", &z)) {
445         goto exit;
446     }
447     /* modifications for z */
448     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
449     _return_value = cmath_sin_impl(module, z);
450     PyFPE_END_PROTECT(_return_value);
451     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 
463 exit:
464     return return_value;
465 }
466 
467 PyDoc_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    \
474     {"sinh", (PyCFunction)cmath_sinh, METH_O, cmath_sinh__doc__},
475 
476 static Py_complex
477 cmath_sinh_impl(PyObject *module, Py_complex z);
478 
479 static PyObject *
cmath_sinh(PyObject * module,PyObject * arg)480 cmath_sinh(PyObject *module, PyObject *arg)
481 {
482     PyObject *return_value = NULL;
483     Py_complex z;
484     Py_complex _return_value;
485 
486     if (!PyArg_Parse(arg, "D:sinh", &z)) {
487         goto exit;
488     }
489     /* modifications for z */
490     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
491     _return_value = cmath_sinh_impl(module, z);
492     PyFPE_END_PROTECT(_return_value);
493     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 
505 exit:
506     return return_value;
507 }
508 
509 PyDoc_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    \
516     {"sqrt", (PyCFunction)cmath_sqrt, METH_O, cmath_sqrt__doc__},
517 
518 static Py_complex
519 cmath_sqrt_impl(PyObject *module, Py_complex z);
520 
521 static PyObject *
cmath_sqrt(PyObject * module,PyObject * arg)522 cmath_sqrt(PyObject *module, PyObject *arg)
523 {
524     PyObject *return_value = NULL;
525     Py_complex z;
526     Py_complex _return_value;
527 
528     if (!PyArg_Parse(arg, "D:sqrt", &z)) {
529         goto exit;
530     }
531     /* modifications for z */
532     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
533     _return_value = cmath_sqrt_impl(module, z);
534     PyFPE_END_PROTECT(_return_value);
535     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 
547 exit:
548     return return_value;
549 }
550 
551 PyDoc_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    \
558     {"tan", (PyCFunction)cmath_tan, METH_O, cmath_tan__doc__},
559 
560 static Py_complex
561 cmath_tan_impl(PyObject *module, Py_complex z);
562 
563 static PyObject *
cmath_tan(PyObject * module,PyObject * arg)564 cmath_tan(PyObject *module, PyObject *arg)
565 {
566     PyObject *return_value = NULL;
567     Py_complex z;
568     Py_complex _return_value;
569 
570     if (!PyArg_Parse(arg, "D:tan", &z)) {
571         goto exit;
572     }
573     /* modifications for z */
574     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
575     _return_value = cmath_tan_impl(module, z);
576     PyFPE_END_PROTECT(_return_value);
577     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 
589 exit:
590     return return_value;
591 }
592 
593 PyDoc_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    \
600     {"tanh", (PyCFunction)cmath_tanh, METH_O, cmath_tanh__doc__},
601 
602 static Py_complex
603 cmath_tanh_impl(PyObject *module, Py_complex z);
604 
605 static PyObject *
cmath_tanh(PyObject * module,PyObject * arg)606 cmath_tanh(PyObject *module, PyObject *arg)
607 {
608     PyObject *return_value = NULL;
609     Py_complex z;
610     Py_complex _return_value;
611 
612     if (!PyArg_Parse(arg, "D:tanh", &z)) {
613         goto exit;
614     }
615     /* modifications for z */
616     errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
617     _return_value = cmath_tanh_impl(module, z);
618     PyFPE_END_PROTECT(_return_value);
619     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 
631 exit:
632     return return_value;
633 }
634 
635 PyDoc_STRVAR(cmath_log__doc__,
636 "log($module, x, y_obj=None, /)\n"
637 "--\n"
638 "\n"
639 "The logarithm of z to the given base.\n"
640 "\n"
641 "If the base not specified, returns the natural logarithm (base e) of z.");
642 
643 #define CMATH_LOG_METHODDEF    \
644     {"log", (PyCFunction)cmath_log, METH_FASTCALL, cmath_log__doc__},
645 
646 static PyObject *
647 cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj);
648 
649 static PyObject *
cmath_log(PyObject * module,PyObject * const * args,Py_ssize_t nargs)650 cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
651 {
652     PyObject *return_value = NULL;
653     Py_complex x;
654     PyObject *y_obj = NULL;
655 
656     if (!_PyArg_ParseStack(args, nargs, "D|O:log",
657         &x, &y_obj)) {
658         goto exit;
659     }
660     return_value = cmath_log_impl(module, x, y_obj);
661 
662 exit:
663     return return_value;
664 }
665 
666 PyDoc_STRVAR(cmath_phase__doc__,
667 "phase($module, z, /)\n"
668 "--\n"
669 "\n"
670 "Return argument, also known as the phase angle, of a complex.");
671 
672 #define CMATH_PHASE_METHODDEF    \
673     {"phase", (PyCFunction)cmath_phase, METH_O, cmath_phase__doc__},
674 
675 static PyObject *
676 cmath_phase_impl(PyObject *module, Py_complex z);
677 
678 static PyObject *
cmath_phase(PyObject * module,PyObject * arg)679 cmath_phase(PyObject *module, PyObject *arg)
680 {
681     PyObject *return_value = NULL;
682     Py_complex z;
683 
684     if (!PyArg_Parse(arg, "D:phase", &z)) {
685         goto exit;
686     }
687     return_value = cmath_phase_impl(module, z);
688 
689 exit:
690     return return_value;
691 }
692 
693 PyDoc_STRVAR(cmath_polar__doc__,
694 "polar($module, z, /)\n"
695 "--\n"
696 "\n"
697 "Convert a complex from rectangular coordinates to polar coordinates.\n"
698 "\n"
699 "r is the distance from 0 and phi the phase angle.");
700 
701 #define CMATH_POLAR_METHODDEF    \
702     {"polar", (PyCFunction)cmath_polar, METH_O, cmath_polar__doc__},
703 
704 static PyObject *
705 cmath_polar_impl(PyObject *module, Py_complex z);
706 
707 static PyObject *
cmath_polar(PyObject * module,PyObject * arg)708 cmath_polar(PyObject *module, PyObject *arg)
709 {
710     PyObject *return_value = NULL;
711     Py_complex z;
712 
713     if (!PyArg_Parse(arg, "D:polar", &z)) {
714         goto exit;
715     }
716     return_value = cmath_polar_impl(module, z);
717 
718 exit:
719     return return_value;
720 }
721 
722 PyDoc_STRVAR(cmath_rect__doc__,
723 "rect($module, r, phi, /)\n"
724 "--\n"
725 "\n"
726 "Convert from polar coordinates to rectangular coordinates.");
727 
728 #define CMATH_RECT_METHODDEF    \
729     {"rect", (PyCFunction)cmath_rect, METH_FASTCALL, cmath_rect__doc__},
730 
731 static PyObject *
732 cmath_rect_impl(PyObject *module, double r, double phi);
733 
734 static PyObject *
cmath_rect(PyObject * module,PyObject * const * args,Py_ssize_t nargs)735 cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
736 {
737     PyObject *return_value = NULL;
738     double r;
739     double phi;
740 
741     if (!_PyArg_ParseStack(args, nargs, "dd:rect",
742         &r, &phi)) {
743         goto exit;
744     }
745     return_value = cmath_rect_impl(module, r, phi);
746 
747 exit:
748     return return_value;
749 }
750 
751 PyDoc_STRVAR(cmath_isfinite__doc__,
752 "isfinite($module, z, /)\n"
753 "--\n"
754 "\n"
755 "Return True if both the real and imaginary parts of z are finite, else False.");
756 
757 #define CMATH_ISFINITE_METHODDEF    \
758     {"isfinite", (PyCFunction)cmath_isfinite, METH_O, cmath_isfinite__doc__},
759 
760 static PyObject *
761 cmath_isfinite_impl(PyObject *module, Py_complex z);
762 
763 static PyObject *
cmath_isfinite(PyObject * module,PyObject * arg)764 cmath_isfinite(PyObject *module, PyObject *arg)
765 {
766     PyObject *return_value = NULL;
767     Py_complex z;
768 
769     if (!PyArg_Parse(arg, "D:isfinite", &z)) {
770         goto exit;
771     }
772     return_value = cmath_isfinite_impl(module, z);
773 
774 exit:
775     return return_value;
776 }
777 
778 PyDoc_STRVAR(cmath_isnan__doc__,
779 "isnan($module, z, /)\n"
780 "--\n"
781 "\n"
782 "Checks if the real or imaginary part of z not a number (NaN).");
783 
784 #define CMATH_ISNAN_METHODDEF    \
785     {"isnan", (PyCFunction)cmath_isnan, METH_O, cmath_isnan__doc__},
786 
787 static PyObject *
788 cmath_isnan_impl(PyObject *module, Py_complex z);
789 
790 static PyObject *
cmath_isnan(PyObject * module,PyObject * arg)791 cmath_isnan(PyObject *module, PyObject *arg)
792 {
793     PyObject *return_value = NULL;
794     Py_complex z;
795 
796     if (!PyArg_Parse(arg, "D:isnan", &z)) {
797         goto exit;
798     }
799     return_value = cmath_isnan_impl(module, z);
800 
801 exit:
802     return return_value;
803 }
804 
805 PyDoc_STRVAR(cmath_isinf__doc__,
806 "isinf($module, z, /)\n"
807 "--\n"
808 "\n"
809 "Checks if the real or imaginary part of z is infinite.");
810 
811 #define CMATH_ISINF_METHODDEF    \
812     {"isinf", (PyCFunction)cmath_isinf, METH_O, cmath_isinf__doc__},
813 
814 static PyObject *
815 cmath_isinf_impl(PyObject *module, Py_complex z);
816 
817 static PyObject *
cmath_isinf(PyObject * module,PyObject * arg)818 cmath_isinf(PyObject *module, PyObject *arg)
819 {
820     PyObject *return_value = NULL;
821     Py_complex z;
822 
823     if (!PyArg_Parse(arg, "D:isinf", &z)) {
824         goto exit;
825     }
826     return_value = cmath_isinf_impl(module, z);
827 
828 exit:
829     return return_value;
830 }
831 
832 PyDoc_STRVAR(cmath_isclose__doc__,
833 "isclose($module, /, a, b, *, rel_tol=1e-09, abs_tol=0.0)\n"
834 "--\n"
835 "\n"
836 "Determine whether two complex numbers are close in value.\n"
837 "\n"
838 "  rel_tol\n"
839 "    maximum difference for being considered \"close\", relative to the\n"
840 "    magnitude of the input values\n"
841 "  abs_tol\n"
842 "    maximum difference for being considered \"close\", regardless of the\n"
843 "    magnitude of the input values\n"
844 "\n"
845 "Return True if a is close in value to b, and False otherwise.\n"
846 "\n"
847 "For the values to be considered close, the difference between them must be\n"
848 "smaller than at least one of the tolerances.\n"
849 "\n"
850 "-inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is\n"
851 "not close to anything, even itself. inf and -inf are only close to themselves.");
852 
853 #define CMATH_ISCLOSE_METHODDEF    \
854     {"isclose", (PyCFunction)cmath_isclose, METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__},
855 
856 static int
857 cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b,
858                    double rel_tol, double abs_tol);
859 
860 static PyObject *
cmath_isclose(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)861 cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
862 {
863     PyObject *return_value = NULL;
864     static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL};
865     static _PyArg_Parser _parser = {"DD|$dd:isclose", _keywords, 0};
866     Py_complex a;
867     Py_complex b;
868     double rel_tol = 1e-09;
869     double abs_tol = 0.0;
870     int _return_value;
871 
872     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
873         &a, &b, &rel_tol, &abs_tol)) {
874         goto exit;
875     }
876     _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol);
877     if ((_return_value == -1) && PyErr_Occurred()) {
878         goto exit;
879     }
880     return_value = PyBool_FromLong((long)_return_value);
881 
882 exit:
883     return return_value;
884 }
885 /*[clinic end generated code: output=dd93c3a6aeb42ebb input=a9049054013a1b77]*/
886