jpayne@69
|
1 /* Complex number structure */
|
jpayne@69
|
2
|
jpayne@69
|
3 #ifndef Py_COMPLEXOBJECT_H
|
jpayne@69
|
4 #define Py_COMPLEXOBJECT_H
|
jpayne@69
|
5 #ifdef __cplusplus
|
jpayne@69
|
6 extern "C" {
|
jpayne@69
|
7 #endif
|
jpayne@69
|
8
|
jpayne@69
|
9 #ifndef Py_LIMITED_API
|
jpayne@69
|
10 typedef struct {
|
jpayne@69
|
11 double real;
|
jpayne@69
|
12 double imag;
|
jpayne@69
|
13 } Py_complex;
|
jpayne@69
|
14
|
jpayne@69
|
15 /* Operations on complex numbers from complexmodule.c */
|
jpayne@69
|
16
|
jpayne@69
|
17 PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
|
jpayne@69
|
18 PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
|
jpayne@69
|
19 PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
|
jpayne@69
|
20 PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
|
jpayne@69
|
21 PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
|
jpayne@69
|
22 PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
|
jpayne@69
|
23 PyAPI_FUNC(double) _Py_c_abs(Py_complex);
|
jpayne@69
|
24 #endif
|
jpayne@69
|
25
|
jpayne@69
|
26 /* Complex object interface */
|
jpayne@69
|
27
|
jpayne@69
|
28 /*
|
jpayne@69
|
29 PyComplexObject represents a complex number with double-precision
|
jpayne@69
|
30 real and imaginary parts.
|
jpayne@69
|
31 */
|
jpayne@69
|
32 #ifndef Py_LIMITED_API
|
jpayne@69
|
33 typedef struct {
|
jpayne@69
|
34 PyObject_HEAD
|
jpayne@69
|
35 Py_complex cval;
|
jpayne@69
|
36 } PyComplexObject;
|
jpayne@69
|
37 #endif
|
jpayne@69
|
38
|
jpayne@69
|
39 PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
jpayne@69
|
40
|
jpayne@69
|
41 #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
jpayne@69
|
42 #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
|
jpayne@69
|
43
|
jpayne@69
|
44 #ifndef Py_LIMITED_API
|
jpayne@69
|
45 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
jpayne@69
|
46 #endif
|
jpayne@69
|
47 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
jpayne@69
|
48
|
jpayne@69
|
49 PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
|
jpayne@69
|
50 PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
|
jpayne@69
|
51 #ifndef Py_LIMITED_API
|
jpayne@69
|
52 PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
|
jpayne@69
|
53 #endif
|
jpayne@69
|
54
|
jpayne@69
|
55 /* Format the object based on the format_spec, as defined in PEP 3101
|
jpayne@69
|
56 (Advanced String Formatting). */
|
jpayne@69
|
57 #ifndef Py_LIMITED_API
|
jpayne@69
|
58 PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
|
jpayne@69
|
59 _PyUnicodeWriter *writer,
|
jpayne@69
|
60 PyObject *obj,
|
jpayne@69
|
61 PyObject *format_spec,
|
jpayne@69
|
62 Py_ssize_t start,
|
jpayne@69
|
63 Py_ssize_t end);
|
jpayne@69
|
64 #endif
|
jpayne@69
|
65
|
jpayne@69
|
66 #ifdef __cplusplus
|
jpayne@69
|
67 }
|
jpayne@69
|
68 #endif
|
jpayne@69
|
69 #endif /* !Py_COMPLEXOBJECT_H */
|