| 1 | #ifndef Py_CPYTHON_COMPLEXOBJECT_H |
| 2 | # error "this header file must not be included directly" |
| 3 | #endif |
| 4 | |
| 5 | typedef struct { |
| 6 | double real; |
| 7 | double imag; |
| 8 | } Py_complex; |
| 9 | |
| 10 | /* Operations on complex numbers from complexmodule.c */ |
| 11 | |
| 12 | PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); |
| 13 | PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); |
| 14 | PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); |
| 15 | PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); |
| 16 | PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); |
| 17 | PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); |
| 18 | PyAPI_FUNC(double) _Py_c_abs(Py_complex); |
| 19 | |
| 20 | /* Complex object interface */ |
| 21 | |
| 22 | /* |
| 23 | PyComplexObject represents a complex number with double-precision |
| 24 | real and imaginary parts. |
| 25 | */ |
| 26 | typedef struct { |
| 27 | PyObject_HEAD |
| 28 | Py_complex cval; |
| 29 | } PyComplexObject; |
| 30 | |
| 31 | PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); |
| 32 | |
| 33 | PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); |
| 34 | |
| 35 | #ifdef Py_BUILD_CORE |
| 36 | /* Format the object based on the format_spec, as defined in PEP 3101 |
| 37 | (Advanced String Formatting). */ |
| 38 | extern int _PyComplex_FormatAdvancedWriter( |
| 39 | _PyUnicodeWriter *writer, |
| 40 | PyObject *obj, |
| 41 | PyObject *format_spec, |
| 42 | Py_ssize_t start, |
| 43 | Py_ssize_t end); |
| 44 | #endif // Py_BUILD_CORE |
| 45 | |