Commit 28baecd5 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Include complex float structs in numpy.pxd

parent 21d383ad
...@@ -241,6 +241,18 @@ cdef extern from "numpy/arrayobject.h": ...@@ -241,6 +241,18 @@ cdef extern from "numpy/arrayobject.h":
ctypedef float npy_float96 ctypedef float npy_float96
ctypedef float npy_float128 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 # Typedefs that matches the runtime dtype objects in
# the numpy module. # the numpy module.
...@@ -278,3 +290,6 @@ ctypedef npy_double float_t ...@@ -278,3 +290,6 @@ ctypedef npy_double float_t
ctypedef npy_double double_t ctypedef npy_double double_t
ctypedef npy_longdouble longdouble_t ctypedef npy_longdouble longdouble_t
ctypedef npy_cfloat cfloat_t
ctypedef npy_cdouble cdouble_t
ctypedef npy_clongdouble clongdouble_t
...@@ -202,18 +202,6 @@ def test_f_contig(np.ndarray[int, ndim=2, mode='fortran'] arr): ...@@ -202,18 +202,6 @@ def test_f_contig(np.ndarray[int, ndim=2, mode='fortran'] arr):
for i in range(arr.shape[0]): for i in range(arr.shape[0]):
print " ".join([str(arr[i, j]) for j in range(arr.shape[1])]) 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 # 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_byte(np.ndarray[char] arr): arr[1] += 1
def inc1_ubyte(np.ndarray[unsigned 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 ...@@ -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_double(np.ndarray[double] arr): arr[1] += 1
def inc1_longdouble(np.ndarray[long 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].real += 1
arr[1].imag += 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].real += 1
arr[1].imag += 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 cdef long double x
x = arr[1].real + 1 x = arr[1].real + 1
arr[1].real = x arr[1].real = x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment