Include complex float structs in numpy.pxd
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 10 Nov 2008 12:37:08 +0000 (13:37 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 10 Nov 2008 12:37:08 +0000 (13:37 +0100)
Cython/Includes/numpy.pxd
tests/run/numpy_test.pyx

index e494c6840b5deb5c40f6e7f4a688b0a290cd39d9..5b86a6fc42537ac3b57479bbd5b47293b5a165b3 100644 (file)
@@ -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
index fb2113c68c9cb2764dc4b36639796504fb6ff758..88b47d994bb1c775451b45cd82b90e74341d5c8b 100644 (file)
@@ -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