complexobject.h 1.5 KB
Newer Older
1 2
/* Complex number structure */

3 4
#ifndef Py_COMPLEXOBJECT_H
#define Py_COMPLEXOBJECT_H
5 6 7 8 9
#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
10 11
    double real;
    double imag;
12
} Py_complex;
13 14 15

/* Operations on complex numbers from complexmodule.c */

16 17 18 19 20 21
#define c_sum _Py_c_sum
#define c_diff _Py_c_diff
#define c_neg _Py_c_neg
#define c_prod _Py_c_prod
#define c_quot _Py_c_quot
#define c_pow _Py_c_pow
22
#define c_abs _Py_c_abs
23

24 25 26 27 28 29
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
30
PyAPI_FUNC(double) c_abs(Py_complex);
31 32 33 34 35 36 37 38 39 40


/* Complex object interface */

/*
PyComplexObject represents a complex number with double-precision
real and imaginary parts.
*/

typedef struct {
41 42
    PyObject_HEAD
    Py_complex cval;
43 44
} PyComplexObject;     

45
PyAPI_DATA(PyTypeObject) PyComplex_Type;
46

47
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
48
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
49

50 51
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
52

53 54 55
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
56 57 58 59

#ifdef __cplusplus
}
#endif
60
#endif /* !Py_COMPLEXOBJECT_H */