complexobject.h 1.8 KB

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