1/* Complex number structure */
2
3#ifndef Py_COMPLEXOBJECT_H
4#define Py_COMPLEXOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#ifndef Py_LIMITED_API
10typedef struct {
11 double real;
12 double imag;
13} Py_complex;
14
15/* Operations on complex numbers from complexmodule.c */
16
17PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
18PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
19PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
20PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
21PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
22PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
23PyAPI_FUNC(double) _Py_c_abs(Py_complex);
24#endif
25
26/* Complex object interface */
27
28/*
29PyComplexObject represents a complex number with double-precision
30real and imaginary parts.
31*/
32#ifndef Py_LIMITED_API
33typedef struct {
34 PyObject_HEAD
35 Py_complex cval;
36} PyComplexObject;
37#endif
38
39PyAPI_DATA(PyTypeObject) PyComplex_Type;
40
41#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
42#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
43
44#ifndef Py_LIMITED_API
45PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
46#endif
47PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
48
49PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
50PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
51#ifndef Py_LIMITED_API
52PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
53#endif
54
55/* Format the object based on the format_spec, as defined in PEP 3101
56 (Advanced String Formatting). */
57#ifndef Py_LIMITED_API
58PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
59 _PyUnicodeWriter *writer,
60 PyObject *obj,
61 PyObject *format_spec,
62 Py_ssize_t start,
63 Py_ssize_t end);
64#endif
65
66#ifdef __cplusplus
67}
68#endif
69#endif /* !Py_COMPLEXOBJECT_H */
70

source code of include/python3.10/complexobject.h