From: Dag Sverre Seljebotn Date: Wed, 29 Jul 2009 20:10:31 +0000 (+0200) Subject: #347 fix: Make numpy.complexX_t use Cython complex X-Git-Tag: 0.12.alpha0~224^2~1^2^2~1^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1c0020cbf878402e16ee6964d4d2969ea9a096f4;p=cython.git #347 fix: Make numpy.complexX_t use Cython complex --- diff --git a/Cython/Includes/numpy.pxd b/Cython/Includes/numpy.pxd index ea8cde18..3fb343d8 100644 --- a/Cython/Includes/numpy.pxd +++ b/Cython/Includes/numpy.pxd @@ -665,8 +665,8 @@ ctypedef npy_float64 float64_t #ctypedef npy_float80 float80_t #ctypedef npy_float128 float128_t -ctypedef npy_complex64 complex64_t -ctypedef npy_complex128 complex128_t +ctypedef float complex complex64_t +ctypedef double complex complex128_t # The int types are mapped a bit surprising -- # numpy.int corresponds to 'l' and numpy.long to 'q' diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx index a5cf19d0..ec3909c4 100644 --- a/tests/run/numpy_test.pyx +++ b/tests/run/numpy_test.pyx @@ -194,6 +194,11 @@ try: Traceback (most recent call last): ... ValueError: Item size of buffer (1 byte) does not match size of 'int' (4 bytes) + + >>> test_complextypes() + 1,1 + 1,1 + 8,16 """ except: @@ -376,3 +381,15 @@ def test_unpacked_align(np.ndarray[UnpackedStruct] arr): arr[0].a = 22 arr[0].b = 23 return repr(arr).replace('<', '!').replace('>', '!') + +def test_complextypes(): + cdef np.complex64_t x64 = 1, y64 = 1j + cdef np.complex128_t x128 = 1, y128 = 1j + x64 = x64 + y64 + print "%.0f,%.0f" % (x64.real, x64.imag) + x128 = x128 + y128 + print "%.0f,%.0f" % (x128.real, x128.imag) + print "%d,%d" % (sizeof(x64), sizeof(x128)) + + +