You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.9 KiB

  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. #define c_sum _Py_c_sum
  14. #define c_diff _Py_c_diff
  15. #define c_neg _Py_c_neg
  16. #define c_prod _Py_c_prod
  17. #define c_quot _Py_c_quot
  18. #define c_pow _Py_c_pow
  19. #define c_abs _Py_c_abs
  20. PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
  21. PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
  22. PyAPI_FUNC(Py_complex) c_neg(Py_complex);
  23. PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
  24. PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
  25. PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
  26. PyAPI_FUNC(double) c_abs(Py_complex);
  27. #endif
  28. /* Complex object interface */
  29. /*
  30. PyComplexObject represents a complex number with double-precision
  31. real and imaginary parts.
  32. */
  33. #ifndef Py_LIMITED_API
  34. typedef struct {
  35. PyObject_HEAD
  36. Py_complex cval;
  37. } PyComplexObject;
  38. #endif
  39. PyAPI_DATA(PyTypeObject) PyComplex_Type;
  40. #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
  41. #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
  42. #ifndef Py_LIMITED_API
  43. PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
  44. #endif
  45. PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
  46. PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
  47. PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
  48. #ifndef Py_LIMITED_API
  49. PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
  50. #endif
  51. /* Format the object based on the format_spec, as defined in PEP 3101
  52. (Advanced String Formatting). */
  53. #ifndef Py_LIMITED_API
  54. PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
  55. _PyUnicodeWriter *writer,
  56. PyObject *obj,
  57. PyObject *format_spec,
  58. Py_ssize_t start,
  59. Py_ssize_t end);
  60. #endif
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif /* !Py_COMPLEXOBJECT_H */