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 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 9 | #ifndef Py_LIMITED_API |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 10 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 11 | double real; |
| 12 | double imag; |
Guido van Rossum | 519b433 | 1996-07-21 02:24:22 +0000 | [diff] [blame] | 13 | } Py_complex; |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 14 | |
| 15 | /* Operations on complex numbers from complexmodule.c */ |
| 16 | |
Antoine Pitrou | 1eee8e5 | 2014-07-07 18:49:30 -0400 | [diff] [blame] | 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); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 24 | #endif |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 25 | |
| 26 | /* Complex object interface */ |
| 27 | |
| 28 | /* |
| 29 | PyComplexObject represents a complex number with double-precision |
| 30 | real and imaginary parts. |
| 31 | */ |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 32 | #ifndef Py_LIMITED_API |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 33 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 34 | PyObject_HEAD |
| 35 | Py_complex cval; |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 36 | } PyComplexObject; |
| 37 | #endif |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 38 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 39 | PyAPI_DATA(PyTypeObject) PyComplex_Type; |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 40 | |
Guido van Rossum | c16fcdf | 2001-08-29 15:45:32 +0000 | [diff] [blame] | 41 | #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) |
Christian Heimes | 90aa764 | 2007-12-19 02:45:37 +0000 | [diff] [blame] | 42 | #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 43 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 44 | #ifndef Py_LIMITED_API |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 45 | PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 46 | #endif |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 47 | PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 48 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 49 | PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); |
| 50 | PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 51 | #ifndef Py_LIMITED_API |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 52 | PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 53 | #endif |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 54 | |
Eric Smith | 58a4224 | 2009-04-30 01:00:33 +0000 | [diff] [blame] | 55 | /* Format the object based on the format_spec, as defined in PEP 3101 |
| 56 | (Advanced String Formatting). */ |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 57 | #ifndef Py_LIMITED_API |
Victor Stinner | d3f0882 | 2012-05-29 12:57:52 +0200 | [diff] [blame] | 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); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 64 | #endif |
Eric Smith | 58a4224 | 2009-04-30 01:00:33 +0000 | [diff] [blame] | 65 | |
Guido van Rossum | f9fca92 | 1996-01-12 00:47:05 +0000 | [diff] [blame] | 66 | #ifdef __cplusplus |
| 67 | } |
| 68 | #endif |
Neal Norwitz | 638437f | 2002-10-04 12:43:02 +0000 | [diff] [blame] | 69 | #endif /* !Py_COMPLEXOBJECT_H */ |