[Numpy-discussion] Pass 2d ndarray into C **double using ctypes
Sturla Molden
sturla.molden at gmail.com
Thu Jan 1 14:52:23 EST 2015
On 01/01/15 19:56, Nathaniel Smith wrote:
> However, I suspect that this question can't really be answered in a
> useful way without more information about why exactly the C code wants
> a **double (instead of a *double) and what it expects to do with it.
> E.g., is it going to throw away the passed in array and return a new
> one?
That is an important question.
The solution I provided only allows a 2D array to be passed in and
possibly modified inplace. It does not allow the C function pass back a
freshly allocated array.
The problem is of course that the meaning of double** is ambiguous. It
could mean a pointer to an array of pointers. But it could also mean a
double* passed by reference, in which case the function would modify the
pointer instead of the data it points to.
Sturla
More information about the NumPy-Discussion
mailing list