complexobject.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef Py_CPYTHON_COMPLEXOBJECT_H
  2. # error "this header file must not be included directly"
  3. #endif
  4. typedef struct {
  5. double real;
  6. double imag;
  7. } Py_complex;
  8. /* Operations on complex numbers from complexmodule.c */
  9. PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
  10. PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
  11. PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
  12. PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
  13. PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
  14. PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
  15. PyAPI_FUNC(double) _Py_c_abs(Py_complex);
  16. /* Complex object interface */
  17. /*
  18. PyComplexObject represents a complex number with double-precision
  19. real and imaginary parts.
  20. */
  21. typedef struct {
  22. PyObject_HEAD
  23. Py_complex cval;
  24. } PyComplexObject;
  25. PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
  26. PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
  27. #ifdef Py_BUILD_CORE
  28. /* Format the object based on the format_spec, as defined in PEP 3101
  29. (Advanced String Formatting). */
  30. extern int _PyComplex_FormatAdvancedWriter(
  31. _PyUnicodeWriter *writer,
  32. PyObject *obj,
  33. PyObject *format_spec,
  34. Py_ssize_t start,
  35. Py_ssize_t end);
  36. #endif // Py_BUILD_CORE