I have a C code that has the following declaration:
int myfunc(int m, int n, const double **a, double **b, double *c);
So ais a constant 2D array, bis a 2D array, and cis a 1D array, all dynamically distributed. band cshould not be anything specific before they are transferred to myfuncand should be understood as output. For the purposes of this question, I am not allowed to modify the announcement myfunc.
Question 1: How to convert a given numpy array a_npto an array awith the format required by this C function so that I can call this C function in Cython with a?
Question 2: Are the declarations for band cbelow correct, or do they need to be in a different format so that the C function understands them as an array of 2D and 1D (respectively)?
My attempt:
myfile.pxd
cdef extern from "myfile.h":
int myfunc(int p, int q, const double **a, double **b, double *c)
mytest.pyx
cimport cython
cimport myfile
import numpy as np
cimport numpy as np
p = 3
q = 4
cdef:
double** a = np.random.random([p,q])
double** b
double* c
myfile.myfunc(p, q, a, b, c)
Then in iPython I launched
import pyximport; pyximport.install()
import mytest
The definition line agives an error message Cannot convert Python object to 'double **'. I do not get any error messages against bor c, but because I can not run a C function at this time, I'm not sure that the ads band cspelled correctly (that is, so that the C function can display 2D and 1D-array, respectively).
: , , myfunc . , myfunc.