I am trying to write a Cython function which returns an array of mpz_t
(number type of integers from the gmpy2
library). I can successfully define a fixed-size array:
<code>cpdef void pows(mpz number):
cdef:
int x
mpz_t powers[10]
for 1 <= x <= 10:
# do stuff and store in powers
</code>
<code>cpdef void pows(mpz number):
cdef:
int x
mpz_t powers[10]
for 1 <= x <= 10:
# do stuff and store in powers
</code>
cpdef void pows(mpz number):
cdef:
int x
mpz_t powers[10]
for 1 <= x <= 10:
# do stuff and store in powers
however I want to be able to define a dynamic-size array of mpz_t
(i.e. to start with it empty and add values to it) and then return powers
from this function. When defining the return type, so far I have tried:
<code>cpdef mpt_t pows
cpdef mpz_t[:] pows
cpdef mpz_t * pows
</code>
<code>cpdef mpt_t pows
cpdef mpz_t[:] pows
cpdef mpz_t * pows
</code>
cpdef mpt_t pows
cpdef mpz_t[:] pows
cpdef mpz_t * pows
none of which have worked. Is this possible to do?