Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #ifndef Py_COMPLEXOBJECT_H |
2 | #define Py_COMPLEXOBJECT_H | |
3 | #ifdef __cplusplus | |
4 | extern "C" { | |
5 | #endif | |
6 | ||
7 | typedef struct { | |
8 | double real; | |
9 | double imag; | |
10 | } Py_complex; | |
11 | ||
12 | /* Operations on complex numbers from complexmodule.c */ | |
13 | ||
14 | #define c_sum _Py_c_sum | |
15 | #define c_diff _Py_c_diff | |
16 | #define c_neg _Py_c_neg | |
17 | #define c_prod _Py_c_prod | |
18 | #define c_quot _Py_c_quot | |
19 | #define c_pow _Py_c_pow | |
20 | ||
21 | PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); | |
22 | PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); | |
23 | PyAPI_FUNC(Py_complex) c_neg(Py_complex); | |
24 | PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); | |
25 | PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); | |
26 | PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); | |
27 | ||
28 | ||
29 | /* Complex object interface */ | |
30 | ||
31 | /* | |
32 | PyComplexObject represents a complex number with double-precision | |
33 | real and imaginary parts. | |
34 | */ | |
35 | ||
36 | typedef struct { | |
37 | PyObject_HEAD | |
38 | Py_complex cval; | |
39 | } PyComplexObject; | |
40 | ||
41 | PyAPI_DATA(PyTypeObject) PyComplex_Type; | |
42 | ||
43 | #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) | |
44 | #define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type) | |
45 | ||
46 | PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); | |
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 | PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); | |
52 | ||
53 | #ifdef __cplusplus | |
54 | } | |
55 | #endif | |
56 | #endif /* !Py_COMPLEXOBJECT_H */ |