1#ifndef Py_CPYTHON_COMPLEXOBJECT_H
2#  error "this header file must not be included directly"
3#endif
4
5typedef struct {
6    double real;
7    double imag;
8} Py_complex;
9
10/* Operations on complex numbers from complexmodule.c */
11
12PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
13PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
14PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
15PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
16PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
17PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
18PyAPI_FUNC(double) _Py_c_abs(Py_complex);
19
20/* Complex object interface */
21
22/*
23PyComplexObject represents a complex number with double-precision
24real and imaginary parts.
25*/
26typedef struct {
27    PyObject_HEAD
28    Py_complex cval;
29} PyComplexObject;
30
31PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
32
33PyAPI_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). */
38extern 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