I am trying to write a function in cython which should receive a list argument from python manipulate it in some way by generating a 2D array of it in C/C++ and then return it to python as a 2D list. I simplified the code to ask my question:
I expect c_Func
to do the procedure which I can compile it without error. The second function is the callable function but obviously it doesn't work. First I have to deal with the problem that a list cannot be replaced by a double*
and second it the problem that py_Func
can't return a double*
. So how should I change these two?
cdef double** c_Func(int dim,double* init_val):
cdef double** frozen_ans= <double**> malloc(dim*sizeof(double))
frozen_ans[0]=init_val
return frozen_ans
def py_Func(int dim, double* init_val):
return c_Func(dim,init_val)