Joshua
unread,Dec 20, 2010, 8:34:19 PM12/20/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cython-users
I feel like this should be a fairly straightforward application of
Cython, but I'm stumped and can't seem to find the proper example or
piece of documentation to do this. I'm trying to wrap a small amount
of existing c code that does a bunch of operations on arrays. I want
to be able to set up a number of numpy arrays, and then pass those
arrays as arguments to the C code whose functions take standard c
arrays (1d and 2d). I'm a little stuck in terms of figuring out how to
write the proper .pyx code to properly handle things.
There are a handful of functions, but a typical function in the file
funcs.h looks something like:
double func1(double *A, double **coords1, double **coords2, const int
len)
I have a .pyx file that has a corresponding line:
cdef extern from "funcs.h":
double func1(double *A, double **coords1, double **coords2, int
len)
where I got rid of the const because cython doesn't support it
(correct?). Where I'm stuck is what the wrapper code should then look
like to pass a MxN numpy array to the **coords1 and **coords2
arguments and a Kx1 numpy array to *A.
Any suggestions or pointers to concrete examples would be most
appreciated.