| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 1 | /* Complex number structure */ | 
|  | 2 |  | 
| Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 3 | #ifndef COMPLEXOBJECT_H | 
|  | 4 | #define COMPLEXOBJECT_H | 
|  | 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 | 
|  | 22 |  | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 23 | extern DL_IMPORT(Py_complex) c_sum(Py_complex, Py_complex); | 
|  | 24 | extern DL_IMPORT(Py_complex) c_diff(Py_complex, Py_complex); | 
|  | 25 | extern DL_IMPORT(Py_complex) c_neg(Py_complex); | 
|  | 26 | extern DL_IMPORT(Py_complex) c_prod(Py_complex, Py_complex); | 
|  | 27 | extern DL_IMPORT(Py_complex) c_quot(Py_complex, Py_complex); | 
|  | 28 | extern DL_IMPORT(Py_complex) c_pow(Py_complex, Py_complex); | 
| Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 29 |  | 
|  | 30 |  | 
|  | 31 | /* Complex object interface */ | 
|  | 32 |  | 
|  | 33 | /* | 
|  | 34 | PyComplexObject represents a complex number with double-precision | 
|  | 35 | real and imaginary parts. | 
|  | 36 | */ | 
|  | 37 |  | 
|  | 38 | typedef struct { | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 39 | PyObject_HEAD | 
|  | 40 | Py_complex cval; | 
| Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 41 | } PyComplexObject; | 
|  | 42 |  | 
|  | 43 | extern DL_IMPORT(PyTypeObject) PyComplex_Type; | 
|  | 44 |  | 
|  | 45 | #define PyComplex_Check(op) ((op)->ob_type == &PyComplex_Type) | 
|  | 46 |  | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 47 | extern DL_IMPORT(PyObject *) PyComplex_FromCComplex(Py_complex); | 
|  | 48 | extern DL_IMPORT(PyObject *) PyComplex_FromDoubles(double real, double imag); | 
| Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 49 |  | 
| Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 50 | extern DL_IMPORT(double) PyComplex_RealAsDouble(PyObject *op); | 
|  | 51 | extern DL_IMPORT(double) PyComplex_ImagAsDouble(PyObject *op); | 
|  | 52 | extern DL_IMPORT(Py_complex) PyComplex_AsCComplex(PyObject *op); | 
| Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 53 |  | 
|  | 54 | #ifdef __cplusplus | 
|  | 55 | } | 
|  | 56 | #endif | 
|  | 57 | #endif /* !COMPLEXOBJECT_H */ |