2021-08-08 04:08:33 +00:00
|
|
|
#ifndef Py_COMPLEXOBJECT_H
|
|
|
|
#define Py_COMPLEXOBJECT_H
|
2021-08-12 07:42:14 +00:00
|
|
|
#include "third_party/python/Include/object.h"
|
|
|
|
#include "third_party/python/Include/unicodeobject.h"
|
2021-08-10 17:26:13 +00:00
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
/* clang-format off */
|
2021-08-08 04:08:33 +00:00
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
typedef struct {
|
|
|
|
double real;
|
|
|
|
double imag;
|
|
|
|
} Py_complex;
|
|
|
|
|
|
|
|
/* Operations on complex numbers from complexmodule.c */
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
Py_complex _Py_c_sum(Py_complex, Py_complex);
|
|
|
|
Py_complex _Py_c_diff(Py_complex, Py_complex);
|
|
|
|
Py_complex _Py_c_neg(Py_complex);
|
|
|
|
Py_complex _Py_c_prod(Py_complex, Py_complex);
|
|
|
|
Py_complex _Py_c_quot(Py_complex, Py_complex);
|
|
|
|
Py_complex _Py_c_pow(Py_complex, Py_complex);
|
|
|
|
double _Py_c_abs(Py_complex);
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Complex object interface */
|
|
|
|
|
|
|
|
/*
|
|
|
|
PyComplexObject represents a complex number with double-precision
|
|
|
|
real and imaginary parts.
|
|
|
|
*/
|
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
Py_complex cval;
|
|
|
|
} PyComplexObject;
|
|
|
|
#endif
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
extern PyTypeObject PyComplex_Type;
|
2021-08-08 04:08:33 +00:00
|
|
|
|
|
|
|
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
|
|
|
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
|
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
2021-08-12 07:42:14 +00:00
|
|
|
PyObject * PyComplex_FromCComplex(Py_complex);
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif
|
2021-08-12 07:42:14 +00:00
|
|
|
PyObject * PyComplex_FromDoubles(double real, double imag);
|
2021-08-08 04:08:33 +00:00
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
double PyComplex_RealAsDouble(PyObject *op);
|
|
|
|
double PyComplex_ImagAsDouble(PyObject *op);
|
2021-08-08 04:08:33 +00:00
|
|
|
#ifndef Py_LIMITED_API
|
2021-08-12 07:42:14 +00:00
|
|
|
Py_complex PyComplex_AsCComplex(PyObject *op);
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Format the object based on the format_spec, as defined in PEP 3101
|
|
|
|
(Advanced String Formatting). */
|
|
|
|
#ifndef Py_LIMITED_API
|
2021-08-12 07:42:14 +00:00
|
|
|
int _PyComplex_FormatAdvancedWriter(
|
2021-08-08 04:08:33 +00:00
|
|
|
_PyUnicodeWriter *writer,
|
|
|
|
PyObject *obj,
|
|
|
|
PyObject *format_spec,
|
|
|
|
Py_ssize_t start,
|
|
|
|
Py_ssize_t end);
|
|
|
|
#endif
|
|
|
|
|
2021-08-10 17:26:13 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif /* !Py_COMPLEXOBJECT_H */
|