File: complex.pxd

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (60 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
cimport cython as _cython

cdef extern from "Python.h":

    ctypedef struct Py_complex:
        double imag
        double real

    ############################################################################
    # 7.2.5.2 Complex Numbers as Python Objects
    ############################################################################

    # PyComplexObject
    # This subtype of PyObject represents a Python complex number object.

    ctypedef class __builtin__.complex [object PyComplexObject]:
        cdef Py_complex cval

        # unavailable in limited API
        @property
        @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API")
        cdef inline double real(self) noexcept:
            return self.cval.real

        # unavailable in limited API
        @property
        @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API")
        cdef inline double imag(self) noexcept:
            return self.cval.imag

    # PyTypeObject PyComplex_Type
    # This instance of PyTypeObject represents the Python complex
    # number type. It is the same object as complex and
    # types.ComplexType.

    bint PyComplex_Check(object p)
    # Return true if its argument is a PyComplexObject or a subtype of
    # PyComplexObject.

    bint PyComplex_CheckExact(object p)
    # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.

    object PyComplex_FromCComplex(Py_complex v)
    # Return value: New reference.
    # Create a new Python complex number object from a C Py_complex value.

    object PyComplex_FromDoubles(double real, double imag)
    # Return value: New reference.
    # Return a new PyComplexObject object from real and imag.

    double PyComplex_RealAsDouble(object op) except? -1
    # Return the real part of op as a C double.

    double PyComplex_ImagAsDouble(object op) except? -1
    # Return the imaginary part of op as a C double.

    Py_complex PyComplex_AsCComplex(object op)
    # Return the Py_complex value of the complex number op.
    #
    # Returns (-1+0i) in case of an error