numpy 2d int array to C array of int pointers using ctypes
0
I have a function in C that accepts a nxm integer matrix as an array of n int pointers. Each pointer points to the first element of an integer array of size m, so they these arrays can be seen as the rows of the matrix. So for example: void func(int **matrix, int n, int m); And in memory, the array looks like array 1 from this page: http://c-faq.com/aryptr/dynmuldimary.html I want to use this C function from within Python using ctypes. So I imported it and gave it the following argtypes: func.argtypes = [ctypes.POINTER(ctypes.POINTER(ctypes.c_int)), ctypes.c_int, ctypes.c_int] Now I want to give the function a numpy 2d array... Lets say I have a 2d numpy int array: a = np.random.rand(2,3) * 100 a = a.astype("int") How can I convert the numpy matrix a to the proper format and vice ...