I am trying to use Cython to speed up some calculation with complex
numpy arrays and I am getting this error:
C:>python setup_post.py build_ext --inplace
running build_ext
cythoning SVDc_post.pyx to SVDc_post.c
Error converting Pyrex file to C:
------------------------------------------------------------
...
# static inline Real csq(cComplex x) { return creal(x*conj(x)); }
cdef inline double csq(x): return real(x*x.conjugate())
def SVDc2(int m, int n,
^
------------------------------------------------------------
C:\SVDc_post.pyx:11:0: Compiler crash in IntroduceBufferAuxiliaryVars
ModuleNode.body = StatListNode(SVDc_post.pyx:2:0)
StatListNode.stats[4] = StatListNode(SVDc_post.pyx:11:0)
StatListNode.stats[0] = DefNode(SVDc_post.pyx:11:0,
modifiers = [...]/0,
name = u'SVDc2',
num_required_args = 7,
reqd_kw_flags_cname = '0')
The code is below (I removed all the code not relevant to this error):
import numpy as np
cimport numpy as np
ctypedef np.float64_t dtype_t
cdef inline double csq(x): return real(x*x.conjugate())
def SVDc2(int m, int n,
np.ndarray[np.complex128_t, ndim = 2] Ao,
np.ndarray[np.float64_t, ndim = 1] d,
np.ndarray[np.complex128_t, ndim = 2] Vo,
np.ndarray[np.complex128_t, ndim = 2] Wo,
int sort):
cdef dtype_t EPS = 1.5e-31
cdef dtype_t DBL_EPS = 2.2204460492503131e-16
cdef int maxsweeps = 50
cdef int err = True
cdef int rev = ((m - n) >> 15) & 1
cdef int nm = min(m, n)
cdef int nx = max(m, n)
cdef dtype_t red = .01 / (nx * nx * nx * nx)
cdef int ldV = nx
cdef int ldW = nx
cdef int ldA = nx
cdef dtype_t thresh = 0.0
cdef np.ndarray[np.complex128_t, ndim=3] VW = zeros((3, nx, nx),
dtype=complex128_t)
cdef np.ndarray[np.int32, ndim=1] ppi = empty(nm, dtype=int32)
for p in range(0, nx): VW[0, p, p] = 1
for p in range(0, nx): VW[1, p, p] = 1
if rev:
for q in range(0, m):
for p in range(0, n):
VW[2, p, q] = Ao[q, p]
else:
for q in range(0,m):
for p in range(0,n):
VW[2, q, p] = Ao[q, p]
return
I was wondering if I need a special setup.py when using numpy arrays.
Any ideas?
Thanks,
-Arrigo