I am trying to do complex number calculations using cython. In the example code I would like to calculate the complex exponential function of a complex number. The problem is that I do not know how to multiply my integer by the imaginary unit. Multiplying by python's imaginary unit 1.0j raises errors while executing cython.
Here is my code:
cdef extern from "math.h":
double complex cexp(double complex)
def testfunction():
cdef double n
n=3
cdef double complex res
res=cexp(n*1.0j)
return res
And here is the error message:
complex.c:678:3: note: expected ‘complex double’ but argument is of type ‘__pyx_t_double_complex’