Hi All,
I am new to Cython. I have tried a couple of different approaches, yet I still failed to allocate an array of vectors.
The first method I have tried is
"cdef vector[int] stack[10]"
The cython compiler showed:
#Error compiling Cython file:
#------------------------------------------------------------
#...
# void* malloc(size_t size)
# void* realloc(void* ptr, size_t size)
#
#def vecTest(self):
# cdef int n = 10
# cdef vector[int] stack[10]
# ^
#------------------------------------------------------------
# arrOfVec.pyx:10:27: Template parameter not a type.
The second method which I also tried is:
arr = <vector[int] *> malloc(sizeof(vector[int])*n)
It still cannot pass the compilation. The error message is shown below:
#Error compiling Cython file:
#------------------------------------------------------------
# arr = <vector[int] *> malloc(sizeof(vector[int])*n)
# ^
#------------------------------------------------------------
#
#arrOfVec.pyx:27:23: Unknown type
The minimal code reproducing the error is attached as "arrOfVec.pyx", the setup file is attached as well.
Could you guys show me some hints on how to fix this issue? Many thanks in advance.
- Wenxiang