Hello,
I know this topic has been discussed quite a few times in this mailing
list. I have read and tried many of the suggestions given on this list,
but nevertheless I'm still stuck.
Here's my problem: I want to use a C function that takes a two
dimensional array, float **a. How to I pass a numpy 2d array to **float?
For a 1D array case I have managed to make it work by passing <float
*>a.data to a C function (where a is a numpy 1D array). But for the 2D
case, if I pass <float **>a.data python either segfaults or gives Bus
Error. And if I try to pass only <float *>a.data, it says it can't
assign type 'float *' 'to float **'.
I have also used something of the kind (based on an example from this
mailing list):
cdef inline void iarray_d(ndarray a, float **data):
if a.dtype != float32:
raise TypeError("The array must have the dtype=float32.")
if data!=NULL: data[0] = <float *> (a.data)
But I still can't make it to work. Maybe this is because my ignorance in
C arrays and pointers. My function requires a **float, but is there any
way to pass the data as *float? Or shall I use another way in Cython to
convert a numpy 2D array to **float? Or this is not yet supported in
Cython? I remember a while ago using C directly to build some numpy
extensions, and to convert the numpy 2D array to C array pointers (I can
implement that in C, but I don't know how to do it in Cython...).
Any obvious thing I'm doing wrong?
Thanks!
Tiago
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev