LCOV - code coverage report
Current view: top level - Modules/clinic - cmathmodule.c.h (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 297 348 85.3 %
Date: 2022-07-07 18:19:46 Functions: 23 23 100.0 %

          Line data    Source code
       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 *
      18         210 : cmath_acos(PyObject *module, PyObject *arg)
      19             : {
      20         210 :     PyObject *return_value = NULL;
      21             :     Py_complex z;
      22             :     Py_complex _return_value;
      23             : 
      24         210 :     z = PyComplex_AsCComplex(arg);
      25         210 :     if (PyErr_Occurred()) {
      26          24 :         goto exit;
      27             :     }
      28             :     /* modifications for z */
      29         186 :     errno = 0;
      30         186 :     _return_value = cmath_acos_impl(module, z);
      31         186 :     if (errno == EDOM) {
      32           0 :         PyErr_SetString(PyExc_ValueError, "math domain error");
      33           0 :         goto exit;
      34             :     }
      35         186 :     else if (errno == ERANGE) {
      36           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
      37           0 :         goto exit;
      38             :     }
      39             :     else {
      40         186 :         return_value = PyComplex_FromCComplex(_return_value);
      41             :     }
      42             : 
      43         210 : exit:
      44         210 :     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 *
      60         195 : cmath_acosh(PyObject *module, PyObject *arg)
      61             : {
      62         195 :     PyObject *return_value = NULL;
      63             :     Py_complex z;
      64             :     Py_complex _return_value;
      65             : 
      66         195 :     z = PyComplex_AsCComplex(arg);
      67         195 :     if (PyErr_Occurred()) {
      68          24 :         goto exit;
      69             :     }
      70             :     /* modifications for z */
      71         171 :     errno = 0;
      72         171 :     _return_value = cmath_acosh_impl(module, z);
      73         171 :     if (errno == EDOM) {
      74           0 :         PyErr_SetString(PyExc_ValueError, "math domain error");
      75           0 :         goto exit;
      76             :     }
      77         171 :     else if (errno == ERANGE) {
      78           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
      79           0 :         goto exit;
      80             :     }
      81             :     else {
      82         171 :         return_value = PyComplex_FromCComplex(_return_value);
      83             :     }
      84             : 
      85         195 : exit:
      86         195 :     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 *
     102         198 : cmath_asin(PyObject *module, PyObject *arg)
     103             : {
     104         198 :     PyObject *return_value = NULL;
     105             :     Py_complex z;
     106             :     Py_complex _return_value;
     107             : 
     108         198 :     z = PyComplex_AsCComplex(arg);
     109         198 :     if (PyErr_Occurred()) {
     110          24 :         goto exit;
     111             :     }
     112             :     /* modifications for z */
     113         174 :     errno = 0;
     114         174 :     _return_value = cmath_asin_impl(module, z);
     115         174 :     if (errno == EDOM) {
     116           0 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     117           0 :         goto exit;
     118             :     }
     119         174 :     else if (errno == ERANGE) {
     120           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     121           0 :         goto exit;
     122             :     }
     123             :     else {
     124         174 :         return_value = PyComplex_FromCComplex(_return_value);
     125             :     }
     126             : 
     127         198 : exit:
     128         198 :     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 *
     144         195 : cmath_asinh(PyObject *module, PyObject *arg)
     145             : {
     146         195 :     PyObject *return_value = NULL;
     147             :     Py_complex z;
     148             :     Py_complex _return_value;
     149             : 
     150         195 :     z = PyComplex_AsCComplex(arg);
     151         195 :     if (PyErr_Occurred()) {
     152          24 :         goto exit;
     153             :     }
     154             :     /* modifications for z */
     155         171 :     errno = 0;
     156         171 :     _return_value = cmath_asinh_impl(module, z);
     157         171 :     if (errno == EDOM) {
     158           0 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     159           0 :         goto exit;
     160             :     }
     161         171 :     else if (errno == ERANGE) {
     162           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     163           0 :         goto exit;
     164             :     }
     165             :     else {
     166         171 :         return_value = PyComplex_FromCComplex(_return_value);
     167             :     }
     168             : 
     169         195 : exit:
     170         195 :     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 *
     186         225 : cmath_atan(PyObject *module, PyObject *arg)
     187             : {
     188         225 :     PyObject *return_value = NULL;
     189             :     Py_complex z;
     190             :     Py_complex _return_value;
     191             : 
     192         225 :     z = PyComplex_AsCComplex(arg);
     193         225 :     if (PyErr_Occurred()) {
     194          24 :         goto exit;
     195             :     }
     196             :     /* modifications for z */
     197         201 :     errno = 0;
     198         201 :     _return_value = cmath_atan_impl(module, z);
     199         201 :     if (errno == EDOM) {
     200           4 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     201           4 :         goto exit;
     202             :     }
     203         197 :     else if (errno == ERANGE) {
     204           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     205           0 :         goto exit;
     206             :     }
     207             :     else {
     208         197 :         return_value = PyComplex_FromCComplex(_return_value);
     209             :     }
     210             : 
     211         225 : exit:
     212         225 :     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 *
     228         200 : cmath_atanh(PyObject *module, PyObject *arg)
     229             : {
     230         200 :     PyObject *return_value = NULL;
     231             :     Py_complex z;
     232             :     Py_complex _return_value;
     233             : 
     234         200 :     z = PyComplex_AsCComplex(arg);
     235         200 :     if (PyErr_Occurred()) {
     236          24 :         goto exit;
     237             :     }
     238             :     /* modifications for z */
     239         176 :     errno = 0;
     240         176 :     _return_value = cmath_atanh_impl(module, z);
     241         176 :     if (errno == EDOM) {
     242           4 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     243           4 :         goto exit;
     244             :     }
     245         172 :     else if (errno == ERANGE) {
     246           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     247           0 :         goto exit;
     248             :     }
     249             :     else {
     250         172 :         return_value = PyComplex_FromCComplex(_return_value);
     251             :     }
     252             : 
     253         200 : exit:
     254         200 :     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 *
     270         160 : cmath_cos(PyObject *module, PyObject *arg)
     271             : {
     272         160 :     PyObject *return_value = NULL;
     273             :     Py_complex z;
     274             :     Py_complex _return_value;
     275             : 
     276         160 :     z = PyComplex_AsCComplex(arg);
     277         160 :     if (PyErr_Occurred()) {
     278          24 :         goto exit;
     279             :     }
     280             :     /* modifications for z */
     281         136 :     errno = 0;
     282         136 :     _return_value = cmath_cos_impl(module, z);
     283         136 :     if (errno == EDOM) {
     284          12 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     285          12 :         goto exit;
     286             :     }
     287         124 :     else if (errno == ERANGE) {
     288           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     289           0 :         goto exit;
     290             :     }
     291             :     else {
     292         124 :         return_value = PyComplex_FromCComplex(_return_value);
     293             :     }
     294             : 
     295         160 : exit:
     296         160 :     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 *
     312         163 : cmath_cosh(PyObject *module, PyObject *arg)
     313             : {
     314         163 :     PyObject *return_value = NULL;
     315             :     Py_complex z;
     316             :     Py_complex _return_value;
     317             : 
     318         163 :     z = PyComplex_AsCComplex(arg);
     319         163 :     if (PyErr_Occurred()) {
     320          24 :         goto exit;
     321             :     }
     322             :     /* modifications for z */
     323         139 :     errno = 0;
     324         139 :     _return_value = cmath_cosh_impl(module, z);
     325         139 :     if (errno == EDOM) {
     326          12 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     327          12 :         goto exit;
     328             :     }
     329         127 :     else if (errno == ERANGE) {
     330           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     331           0 :         goto exit;
     332             :     }
     333             :     else {
     334         127 :         return_value = PyComplex_FromCComplex(_return_value);
     335             :     }
     336             : 
     337         163 : exit:
     338         163 :     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 *
     354         172 : cmath_exp(PyObject *module, PyObject *arg)
     355             : {
     356         172 :     PyObject *return_value = NULL;
     357             :     Py_complex z;
     358             :     Py_complex _return_value;
     359             : 
     360         172 :     z = PyComplex_AsCComplex(arg);
     361         172 :     if (PyErr_Occurred()) {
     362          24 :         goto exit;
     363             :     }
     364             :     /* modifications for z */
     365         148 :     errno = 0;
     366         148 :     _return_value = cmath_exp_impl(module, z);
     367         148 :     if (errno == EDOM) {
     368          10 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     369          10 :         goto exit;
     370             :     }
     371         138 :     else if (errno == ERANGE) {
     372           5 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     373           5 :         goto exit;
     374             :     }
     375             :     else {
     376         133 :         return_value = PyComplex_FromCComplex(_return_value);
     377             :     }
     378             : 
     379         172 : exit:
     380         172 :     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 *
     396         206 : cmath_log10(PyObject *module, PyObject *arg)
     397             : {
     398         206 :     PyObject *return_value = NULL;
     399             :     Py_complex z;
     400             :     Py_complex _return_value;
     401             : 
     402         206 :     z = PyComplex_AsCComplex(arg);
     403         206 :     if (PyErr_Occurred()) {
     404          24 :         goto exit;
     405             :     }
     406             :     /* modifications for z */
     407         182 :     errno = 0;
     408         182 :     _return_value = cmath_log10_impl(module, z);
     409         182 :     if (errno == EDOM) {
     410           4 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     411           4 :         goto exit;
     412             :     }
     413         178 :     else if (errno == ERANGE) {
     414           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     415           0 :         goto exit;
     416             :     }
     417             :     else {
     418         178 :         return_value = PyComplex_FromCComplex(_return_value);
     419             :     }
     420             : 
     421         206 : exit:
     422         206 :     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 *
     438         160 : cmath_sin(PyObject *module, PyObject *arg)
     439             : {
     440         160 :     PyObject *return_value = NULL;
     441             :     Py_complex z;
     442             :     Py_complex _return_value;
     443             : 
     444         160 :     z = PyComplex_AsCComplex(arg);
     445         160 :     if (PyErr_Occurred()) {
     446          24 :         goto exit;
     447             :     }
     448             :     /* modifications for z */
     449         136 :     errno = 0;
     450         136 :     _return_value = cmath_sin_impl(module, z);
     451         136 :     if (errno == EDOM) {
     452          12 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     453          12 :         goto exit;
     454             :     }
     455         124 :     else if (errno == ERANGE) {
     456           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     457           0 :         goto exit;
     458             :     }
     459             :     else {
     460         124 :         return_value = PyComplex_FromCComplex(_return_value);
     461             :     }
     462             : 
     463         160 : exit:
     464         160 :     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 *
     480         164 : cmath_sinh(PyObject *module, PyObject *arg)
     481             : {
     482         164 :     PyObject *return_value = NULL;
     483             :     Py_complex z;
     484             :     Py_complex _return_value;
     485             : 
     486         164 :     z = PyComplex_AsCComplex(arg);
     487         164 :     if (PyErr_Occurred()) {
     488          24 :         goto exit;
     489             :     }
     490             :     /* modifications for z */
     491         140 :     errno = 0;
     492         140 :     _return_value = cmath_sinh_impl(module, z);
     493         140 :     if (errno == EDOM) {
     494          12 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     495          12 :         goto exit;
     496             :     }
     497         128 :     else if (errno == ERANGE) {
     498           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     499           0 :         goto exit;
     500             :     }
     501             :     else {
     502         128 :         return_value = PyComplex_FromCComplex(_return_value);
     503             :     }
     504             : 
     505         164 : exit:
     506         164 :     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 *
     522         190 : cmath_sqrt(PyObject *module, PyObject *arg)
     523             : {
     524         190 :     PyObject *return_value = NULL;
     525             :     Py_complex z;
     526             :     Py_complex _return_value;
     527             : 
     528         190 :     z = PyComplex_AsCComplex(arg);
     529         190 :     if (PyErr_Occurred()) {
     530          24 :         goto exit;
     531             :     }
     532             :     /* modifications for z */
     533         166 :     errno = 0;
     534         166 :     _return_value = cmath_sqrt_impl(module, z);
     535         166 :     if (errno == EDOM) {
     536           0 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     537           0 :         goto exit;
     538             :     }
     539         166 :     else if (errno == ERANGE) {
     540           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     541           0 :         goto exit;
     542             :     }
     543             :     else {
     544         166 :         return_value = PyComplex_FromCComplex(_return_value);
     545             :     }
     546             : 
     547         190 : exit:
     548         190 :     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 *
     564         163 : cmath_tan(PyObject *module, PyObject *arg)
     565             : {
     566         163 :     PyObject *return_value = NULL;
     567             :     Py_complex z;
     568             :     Py_complex _return_value;
     569             : 
     570         163 :     z = PyComplex_AsCComplex(arg);
     571         163 :     if (PyErr_Occurred()) {
     572          24 :         goto exit;
     573             :     }
     574             :     /* modifications for z */
     575         139 :     errno = 0;
     576         139 :     _return_value = cmath_tan_impl(module, z);
     577         139 :     if (errno == EDOM) {
     578           8 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     579           8 :         goto exit;
     580             :     }
     581         131 :     else if (errno == ERANGE) {
     582           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     583           0 :         goto exit;
     584             :     }
     585             :     else {
     586         131 :         return_value = PyComplex_FromCComplex(_return_value);
     587             :     }
     588             : 
     589         163 : exit:
     590         163 :     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 *
     606         166 : cmath_tanh(PyObject *module, PyObject *arg)
     607             : {
     608         166 :     PyObject *return_value = NULL;
     609             :     Py_complex z;
     610             :     Py_complex _return_value;
     611             : 
     612         166 :     z = PyComplex_AsCComplex(arg);
     613         166 :     if (PyErr_Occurred()) {
     614          24 :         goto exit;
     615             :     }
     616             :     /* modifications for z */
     617         142 :     errno = 0;
     618         142 :     _return_value = cmath_tanh_impl(module, z);
     619         142 :     if (errno == EDOM) {
     620           8 :         PyErr_SetString(PyExc_ValueError, "math domain error");
     621           8 :         goto exit;
     622             :     }
     623         134 :     else if (errno == ERANGE) {
     624           0 :         PyErr_SetString(PyExc_OverflowError, "math range error");
     625           0 :         goto exit;
     626             :     }
     627             :     else {
     628         134 :         return_value = PyComplex_FromCComplex(_return_value);
     629             :     }
     630             : 
     631         166 : exit:
     632         166 :     return return_value;
     633             : }
     634             : 
     635             : PyDoc_STRVAR(cmath_log__doc__,
     636             : "log($module, z, base=<unrepresentable>, /)\n"
     637             : "--\n"
     638             : "\n"
     639             : "log(z[, base]) -> 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_CAST(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 *
     650         329 : cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     651             : {
     652         329 :     PyObject *return_value = NULL;
     653             :     Py_complex x;
     654         329 :     PyObject *y_obj = NULL;
     655             : 
     656         329 :     if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
     657           0 :         goto exit;
     658             :     }
     659         329 :     x = PyComplex_AsCComplex(args[0]);
     660         329 :     if (PyErr_Occurred()) {
     661          48 :         goto exit;
     662             :     }
     663         281 :     if (nargs < 2) {
     664         182 :         goto skip_optional;
     665             :     }
     666          99 :     y_obj = args[1];
     667         281 : skip_optional:
     668         281 :     return_value = cmath_log_impl(module, x, y_obj);
     669             : 
     670         329 : exit:
     671         329 :     return return_value;
     672             : }
     673             : 
     674             : PyDoc_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    \
     681             :     {"phase", (PyCFunction)cmath_phase, METH_O, cmath_phase__doc__},
     682             : 
     683             : static PyObject *
     684             : cmath_phase_impl(PyObject *module, Py_complex z);
     685             : 
     686             : static PyObject *
     687          43 : cmath_phase(PyObject *module, PyObject *arg)
     688             : {
     689          43 :     PyObject *return_value = NULL;
     690             :     Py_complex z;
     691             : 
     692          43 :     z = PyComplex_AsCComplex(arg);
     693          43 :     if (PyErr_Occurred()) {
     694           0 :         goto exit;
     695             :     }
     696          43 :     return_value = cmath_phase_impl(module, z);
     697             : 
     698          43 : exit:
     699          43 :     return return_value;
     700             : }
     701             : 
     702             : PyDoc_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    \
     711             :     {"polar", (PyCFunction)cmath_polar, METH_O, cmath_polar__doc__},
     712             : 
     713             : static PyObject *
     714             : cmath_polar_impl(PyObject *module, Py_complex z);
     715             : 
     716             : static PyObject *
     717          78 : cmath_polar(PyObject *module, PyObject *arg)
     718             : {
     719          78 :     PyObject *return_value = NULL;
     720             :     Py_complex z;
     721             : 
     722          78 :     z = PyComplex_AsCComplex(arg);
     723          78 :     if (PyErr_Occurred()) {
     724           0 :         goto exit;
     725             :     }
     726          78 :     return_value = cmath_polar_impl(module, z);
     727             : 
     728          78 : exit:
     729          78 :     return return_value;
     730             : }
     731             : 
     732             : PyDoc_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    \
     739             :     {"rect", _PyCFunction_CAST(cmath_rect), METH_FASTCALL, cmath_rect__doc__},
     740             : 
     741             : static PyObject *
     742             : cmath_rect_impl(PyObject *module, double r, double phi);
     743             : 
     744             : static PyObject *
     745          58 : cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     746             : {
     747          58 :     PyObject *return_value = NULL;
     748             :     double r;
     749             :     double phi;
     750             : 
     751          58 :     if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) {
     752           0 :         goto exit;
     753             :     }
     754          58 :     if (PyFloat_CheckExact(args[0])) {
     755          53 :         r = PyFloat_AS_DOUBLE(args[0]);
     756             :     }
     757             :     else
     758             :     {
     759           5 :         r = PyFloat_AsDouble(args[0]);
     760           5 :         if (r == -1.0 && PyErr_Occurred()) {
     761           0 :             goto exit;
     762             :         }
     763             :     }
     764          58 :     if (PyFloat_CheckExact(args[1])) {
     765          56 :         phi = PyFloat_AS_DOUBLE(args[1]);
     766             :     }
     767             :     else
     768             :     {
     769           2 :         phi = PyFloat_AsDouble(args[1]);
     770           2 :         if (phi == -1.0 && PyErr_Occurred()) {
     771           0 :             goto exit;
     772             :         }
     773             :     }
     774          58 :     return_value = cmath_rect_impl(module, r, phi);
     775             : 
     776          58 : exit:
     777          58 :     return return_value;
     778             : }
     779             : 
     780             : PyDoc_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    \
     787             :     {"isfinite", (PyCFunction)cmath_isfinite, METH_O, cmath_isfinite__doc__},
     788             : 
     789             : static PyObject *
     790             : cmath_isfinite_impl(PyObject *module, Py_complex z);
     791             : 
     792             : static PyObject *
     793          49 : cmath_isfinite(PyObject *module, PyObject *arg)
     794             : {
     795          49 :     PyObject *return_value = NULL;
     796             :     Py_complex z;
     797             : 
     798          49 :     z = PyComplex_AsCComplex(arg);
     799          49 :     if (PyErr_Occurred()) {
     800           0 :         goto exit;
     801             :     }
     802          49 :     return_value = cmath_isfinite_impl(module, z);
     803             : 
     804          49 : exit:
     805          49 :     return return_value;
     806             : }
     807             : 
     808             : PyDoc_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    \
     815             :     {"isnan", (PyCFunction)cmath_isnan, METH_O, cmath_isnan__doc__},
     816             : 
     817             : static PyObject *
     818             : cmath_isnan_impl(PyObject *module, Py_complex z);
     819             : 
     820             : static PyObject *
     821           9 : cmath_isnan(PyObject *module, PyObject *arg)
     822             : {
     823           9 :     PyObject *return_value = NULL;
     824             :     Py_complex z;
     825             : 
     826           9 :     z = PyComplex_AsCComplex(arg);
     827           9 :     if (PyErr_Occurred()) {
     828           0 :         goto exit;
     829             :     }
     830           9 :     return_value = cmath_isnan_impl(module, z);
     831             : 
     832           9 : exit:
     833           9 :     return return_value;
     834             : }
     835             : 
     836             : PyDoc_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    \
     843             :     {"isinf", (PyCFunction)cmath_isinf, METH_O, cmath_isinf__doc__},
     844             : 
     845             : static PyObject *
     846             : cmath_isinf_impl(PyObject *module, Py_complex z);
     847             : 
     848             : static PyObject *
     849           9 : cmath_isinf(PyObject *module, PyObject *arg)
     850             : {
     851           9 :     PyObject *return_value = NULL;
     852             :     Py_complex z;
     853             : 
     854           9 :     z = PyComplex_AsCComplex(arg);
     855           9 :     if (PyErr_Occurred()) {
     856           0 :         goto exit;
     857             :     }
     858           9 :     return_value = cmath_isinf_impl(module, z);
     859             : 
     860           9 : exit:
     861           9 :     return return_value;
     862             : }
     863             : 
     864             : PyDoc_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    \
     886             :     {"isclose", _PyCFunction_CAST(cmath_isclose), METH_FASTCALL|METH_KEYWORDS, cmath_isclose__doc__},
     887             : 
     888             : static int
     889             : cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b,
     890             :                    double rel_tol, double abs_tol);
     891             : 
     892             : static PyObject *
     893          85 : cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     894             : {
     895          85 :     PyObject *return_value = NULL;
     896             :     static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL};
     897             :     static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0};
     898             :     PyObject *argsbuf[4];
     899          85 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
     900             :     Py_complex a;
     901             :     Py_complex b;
     902          85 :     double rel_tol = 1e-09;
     903          85 :     double abs_tol = 0.0;
     904             :     int _return_value;
     905             : 
     906          85 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
     907          85 :     if (!args) {
     908           0 :         goto exit;
     909             :     }
     910          85 :     a = PyComplex_AsCComplex(args[0]);
     911          85 :     if (PyErr_Occurred()) {
     912           0 :         goto exit;
     913             :     }
     914          85 :     b = PyComplex_AsCComplex(args[1]);
     915          85 :     if (PyErr_Occurred()) {
     916           0 :         goto exit;
     917             :     }
     918          85 :     if (!noptargs) {
     919           2 :         goto skip_optional_kwonly;
     920             :     }
     921          83 :     if (args[2]) {
     922          53 :         if (PyFloat_CheckExact(args[2])) {
     923          51 :             rel_tol = PyFloat_AS_DOUBLE(args[2]);
     924             :         }
     925             :         else
     926             :         {
     927           2 :             rel_tol = PyFloat_AsDouble(args[2]);
     928           2 :             if (rel_tol == -1.0 && PyErr_Occurred()) {
     929           2 :                 goto exit;
     930             :             }
     931             :         }
     932          51 :         if (!--noptargs) {
     933          44 :             goto skip_optional_kwonly;
     934             :         }
     935             :     }
     936          37 :     if (PyFloat_CheckExact(args[3])) {
     937          36 :         abs_tol = PyFloat_AS_DOUBLE(args[3]);
     938             :     }
     939             :     else
     940             :     {
     941           1 :         abs_tol = PyFloat_AsDouble(args[3]);
     942           1 :         if (abs_tol == -1.0 && PyErr_Occurred()) {
     943           1 :             goto exit;
     944             :         }
     945             :     }
     946           0 : skip_optional_kwonly:
     947          82 :     _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol);
     948          82 :     if ((_return_value == -1) && PyErr_Occurred()) {
     949           2 :         goto exit;
     950             :     }
     951          80 :     return_value = PyBool_FromLong((long)_return_value);
     952             : 
     953          85 : exit:
     954          85 :     return return_value;
     955             : }
     956             : /*[clinic end generated code: output=b8e445fcd2a3da65 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14