1 /* Complex number structure */ 2 3 #ifndef Py_COMPLEXOBJECT_H 4 #define Py_COMPLEXOBJECT_H 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 #ifndef Py_LIMITED_API 10 typedef struct { 11 double real; 12 double imag; 13 } Py_complex; 14 15 /* Operations on complex numbers from complexmodule.c */ 16 17 PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); 18 PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); 19 PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); 20 PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); 21 PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); 22 PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); 23 PyAPI_FUNC(double) _Py_c_abs(Py_complex); 24 #endif 25 26 /* Complex object interface */ 27 28 /* 29 PyComplexObject represents a complex number with double-precision 30 real and imaginary parts. 31 */ 32 #ifndef Py_LIMITED_API 33 typedef struct { 34 PyObject_HEAD 35 Py_complex cval; 36 } PyComplexObject; 37 #endif 38 39 PyAPI_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 45 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); 46 #endif 47 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); 48 49 PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); 50 PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); 51 #ifndef Py_LIMITED_API 52 PyAPI_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 58 PyAPI_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