complex.pxd 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. cdef extern from "Python.h":
  2. ctypedef struct Py_complex:
  3. double imag
  4. double real
  5. ############################################################################
  6. # 7.2.5.2 Complex Numbers as Python Objects
  7. ############################################################################
  8. # PyComplexObject
  9. # This subtype of PyObject represents a Python complex number object.
  10. ctypedef class __builtin__.complex [object PyComplexObject]:
  11. cdef Py_complex cval
  12. # not making these available to keep them read-only:
  13. #cdef double imag "cval.imag"
  14. #cdef double real "cval.real"
  15. # PyTypeObject PyComplex_Type
  16. # This instance of PyTypeObject represents the Python complex
  17. # number type. It is the same object as complex and
  18. # types.ComplexType.
  19. bint PyComplex_Check(object p)
  20. # Return true if its argument is a PyComplexObject or a subtype of
  21. # PyComplexObject.
  22. bint PyComplex_CheckExact(object p)
  23. # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
  24. object PyComplex_FromCComplex(Py_complex v)
  25. # Return value: New reference.
  26. # Create a new Python complex number object from a C Py_complex value.
  27. object PyComplex_FromDoubles(double real, double imag)
  28. # Return value: New reference.
  29. # Return a new PyComplexObject object from real and imag.
  30. double PyComplex_RealAsDouble(object op) except? -1
  31. # Return the real part of op as a C double.
  32. double PyComplex_ImagAsDouble(object op) except? -1
  33. # Return the imaginary part of op as a C double.
  34. Py_complex PyComplex_AsCComplex(object op)
  35. # Return the Py_complex value of the complex number op.
  36. #
  37. # Returns (-1+0i) in case of an error