Merged revisions 78965 via svnmerge from
[python/dscho.git] / Include / complexobject.h
blob8290a6dc4f5eb7d1069f35c90d2d9973002fd6e9
1 /* Complex number structure */
3 #ifndef Py_COMPLEXOBJECT_H
4 #define Py_COMPLEXOBJECT_H
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
9 typedef struct {
10 double real;
11 double imag;
12 } Py_complex;
14 /* Operations on complex numbers from complexmodule.c */
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 #define c_abs _Py_c_abs
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);
30 PyAPI_FUNC(double) c_abs(Py_complex);
33 /* Complex object interface */
36 PyComplexObject represents a complex number with double-precision
37 real and imaginary parts.
40 typedef struct {
41 PyObject_HEAD
42 Py_complex cval;
43 } PyComplexObject;
45 PyAPI_DATA(PyTypeObject) PyComplex_Type;
47 #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
48 #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
50 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
51 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
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);
57 /* Format the object based on the format_spec, as defined in PEP 3101
58 (Advanced String Formatting). */
59 PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
60 Py_UNICODE *format_spec,
61 Py_ssize_t format_spec_len);
63 #ifdef __cplusplus
65 #endif
66 #endif /* !Py_COMPLEXOBJECT_H */