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