blob: e59bf2ca957e5221d5a4f64c382511c271ce9558 [file] [log] [blame]
Fred Drakeea9cb5a2000-07-09 00:20:36 +00001/* Complex number structure */
2
Neal Norwitz638437f2002-10-04 12:43:02 +00003#ifndef Py_COMPLEXOBJECT_H
4#define Py_COMPLEXOBJECT_H
Guido van Rossumf9fca921996-01-12 00:47:05 +00005#ifdef __cplusplus
6extern "C" {
7#endif
8
Guido van Rossumf9fca921996-01-12 00:47:05 +00009typedef struct {
Fred Drakeea9cb5a2000-07-09 00:20:36 +000010 double real;
11 double imag;
Guido van Rossum519b4331996-07-21 02:24:22 +000012} Py_complex;
Guido van Rossumf9fca921996-01-12 00:47:05 +000013
14/* Operations on complex numbers from complexmodule.c */
15
Guido van Rossum652f1081996-05-24 21:01:36 +000016#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
Mark Hammond91a681d2002-08-12 07:21:58 +000023PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
24PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
25PyAPI_FUNC(Py_complex) c_neg(Py_complex);
26PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
27PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
28PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
Guido van Rossumf9fca921996-01-12 00:47:05 +000029
30
31/* Complex object interface */
32
33/*
34PyComplexObject represents a complex number with double-precision
35real and imaginary parts.
36*/
37
38typedef struct {
Fred Drakeea9cb5a2000-07-09 00:20:36 +000039 PyObject_HEAD
40 Py_complex cval;
Guido van Rossumf9fca921996-01-12 00:47:05 +000041} PyComplexObject;
42
Mark Hammond91a681d2002-08-12 07:21:58 +000043PyAPI_DATA(PyTypeObject) PyComplex_Type;
Guido van Rossumf9fca921996-01-12 00:47:05 +000044
Guido van Rossumc16fcdf2001-08-29 15:45:32 +000045#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
Tim Peters2400fa42001-09-12 19:12:49 +000046#define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type)
Guido van Rossumf9fca921996-01-12 00:47:05 +000047
Mark Hammond91a681d2002-08-12 07:21:58 +000048PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
49PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
Guido van Rossumf9fca921996-01-12 00:47:05 +000050
Mark Hammond91a681d2002-08-12 07:21:58 +000051PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
52PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
53PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
Guido van Rossumf9fca921996-01-12 00:47:05 +000054
55#ifdef __cplusplus
56}
57#endif
Neal Norwitz638437f2002-10-04 12:43:02 +000058#endif /* !Py_COMPLEXOBJECT_H */