Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 1 | /* Complex number structure */ |
| 2 | |
Neal Norwitz | 638437f | 2002-10-04 12:43:02 +0000 | [diff] [blame] | 3 | #ifndef Py_COMPLEXOBJECT_H |
| 4 | #define Py_COMPLEXOBJECT_H |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 5 | #ifdef __cplusplus |
| 6 | extern "C" { |
| 7 | #endif |
| 8 | |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 9 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 10 | double real; |
| 11 | double imag; |
Guido van Rossum | 519b433 | 1996-07-21 02:24:22 +0000 | [diff] [blame] | 12 | } Py_complex; |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 13 | |
| 14 | /* Operations on complex numbers from complexmodule.c */ |
| 15 | |
Guido van Rossum | 652f108 | 1996-05-24 21:01:36 +0000 | [diff] [blame] | 16 | #define c_sum _Py_c_sum |
| 17 | #define c_diff _Py_c_diff |
| 18 | #define c_neg _Py_c_neg |
| 19 | #define c_prod _Py_c_prod |
| 20 | #define c_quot _Py_c_quot |
| 21 | #define c_pow _Py_c_pow |
Christian Heimes | 53876d9 | 2008-04-19 00:31:39 +0000 | [diff] [blame] | 22 | #define c_abs _Py_c_abs |
Guido van Rossum | 652f108 | 1996-05-24 21:01:36 +0000 | [diff] [blame] | 23 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 24 | PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); |
| 25 | PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); |
| 26 | PyAPI_FUNC(Py_complex) c_neg(Py_complex); |
| 27 | PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); |
| 28 | PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); |
| 29 | PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); |
Christian Heimes | 53876d9 | 2008-04-19 00:31:39 +0000 | [diff] [blame] | 30 | PyAPI_FUNC(double) c_abs(Py_complex); |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 31 | |
| 32 | |
| 33 | /* Complex object interface */ |
| 34 | |
| 35 | /* |
| 36 | PyComplexObject represents a complex number with double-precision |
| 37 | real and imaginary parts. |
| 38 | */ |
| 39 | |
| 40 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 41 | PyObject_HEAD |
| 42 | Py_complex cval; |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 43 | } PyComplexObject; |
| 44 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 45 | PyAPI_DATA(PyTypeObject) PyComplex_Type; |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 46 | |
Guido van Rossum | c16fcdf | 2001-08-29 15:45:32 +0000 | [diff] [blame] | 47 | #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) |
Christian Heimes | 90aa764 | 2007-12-19 02:45:37 +0000 | [diff] [blame] | 48 | #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 49 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 50 | PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); |
| 51 | PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 52 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 53 | PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); |
| 54 | PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); |
| 55 | PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 56 | |
| 57 | #ifdef __cplusplus |
| 58 | } |
| 59 | #endif |
Neal Norwitz | 638437f | 2002-10-04 12:43:02 +0000 | [diff] [blame] | 60 | #endif /* !Py_COMPLEXOBJECT_H */ |