From: Dag Sverre Seljebotn Date: Mon, 10 Nov 2008 12:37:08 +0000 (+0100) Subject: Include complex float structs in numpy.pxd X-Git-Tag: 0.10.1~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28baecd50d9bdbcbff315823ac750e861ccd3305;p=cython.git Include complex float structs in numpy.pxd --- diff --git a/Cython/Includes/numpy.pxd b/Cython/Includes/numpy.pxd index e494c684..5b86a6fc 100644 --- a/Cython/Includes/numpy.pxd +++ b/Cython/Includes/numpy.pxd @@ -241,6 +241,18 @@ cdef extern from "numpy/arrayobject.h": ctypedef float npy_float96 ctypedef float npy_float128 + ctypedef struct npy_cfloat: + float real + float imag + + ctypedef struct npy_cdouble: + double real + double imag + + ctypedef struct npy_clongdouble: + long double real + long double imag + # Typedefs that matches the runtime dtype objects in # the numpy module. @@ -274,7 +286,10 @@ ctypedef npy_longlong long_t ctypedef npy_ulong uint_t ctypedef npy_ulonglong ulong_t -ctypedef npy_double float_t +ctypedef npy_double float_t ctypedef npy_double double_t ctypedef npy_longdouble longdouble_t +ctypedef npy_cfloat cfloat_t +ctypedef npy_cdouble cdouble_t +ctypedef npy_clongdouble clongdouble_t diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx index fb2113c6..88b47d99 100644 --- a/tests/run/numpy_test.pyx +++ b/tests/run/numpy_test.pyx @@ -202,18 +202,6 @@ def test_f_contig(np.ndarray[int, ndim=2, mode='fortran'] arr): for i in range(arr.shape[0]): print " ".join([str(arr[i, j]) for j in range(arr.shape[1])]) -cdef struct cfloat: - float real - float imag - -cdef struct cdouble: - double real - double imag - -cdef struct clongdouble: - long double real - long double imag - # Exhaustive dtype tests -- increments element [1] by 1 (or 1+1j) for all dtypes def inc1_byte(np.ndarray[char] arr): arr[1] += 1 def inc1_ubyte(np.ndarray[unsigned char] arr): arr[1] += 1 @@ -230,15 +218,15 @@ def inc1_float(np.ndarray[float] arr): arr[1] += 1 def inc1_double(np.ndarray[double] arr): arr[1] += 1 def inc1_longdouble(np.ndarray[long double] arr): arr[1] += 1 -def inc1_cfloat(np.ndarray[cfloat] arr): +def inc1_cfloat(np.ndarray[np.cfloat_t] arr): arr[1].real += 1 arr[1].imag += 1 -def inc1_cdouble(np.ndarray[cdouble] arr): +def inc1_cdouble(np.ndarray[np.cdouble_t] arr): arr[1].real += 1 arr[1].imag += 1 -def inc1_clongdouble(np.ndarray[clongdouble] arr): +def inc1_clongdouble(np.ndarray[np.clongdouble_t] arr): cdef long double x x = arr[1].real + 1 arr[1].real = x