How does one to return a malloc array pointer (or numpy array pointer) in cython back to python3, efficiently.
The cython code works perfectly as long as I don't return the array pointer
I would like:
def double complex* randn_zig(int n):
...
r = malloc(n*n*sizeof(double complex))
...
return r
The c11 (gcc 11) equivalent is:
double complex* randn_zig(int n){
r = malloc(n*n*sizeof(double complex))
return r
}
I have tried
<double complex*> randn_zig(int n):
and randn_zig(<double complex*> r, int n):
and other permutations without success so far. The c and cython code version is 5 times as fast as Numby/ pylab randn version if I can find a way to return a pointer to the large 10^6 to 10^10 double complex array.