title: convert numpy-C array to C double* [] and back
body: <p>After a long struggle I managed to succesfully import a numpy array into C, as well return an empty numpy array back with the same size. Now I would like to perform a convolution with a given 3x3 kernel. I am used to create a second C function which performs the operation, while the callable function from python just converts the input arguments to pass them to the function. so what I would like to do is:</p>
  
  <ol>
  <li>receive the numpy array from python </li>
  <li>convert it to a C-double array</li>
  <li>perform the convolution (leave this to me for now)</li>
  <li>convert the convoluted array back to C-numpy array</li>
  <li>return the C-numpy array back to python.</li>
  </ol>
  
  <p>So step 1 and 5 already done. code:</p>
  
  <pre class="lang-c prettyprint-override"><code>static PyObject *CPtest_convolute(PyObject *self, PyObject *args)
  {
      PyArrayObject *in_array;
      PyObject *out_array;
  
      /*extract input array, create output array*/
      if (!PyArg_ParseTuple(args, "O!", &amp;PyArray_Type, &amp;in_array))    return NULL;
  
      /*convert numpy to double*[]*/
      /*convArr = convolute(in_array, kernel);*/
  
      out_array = PyArray_NewLikeArray(in_array, NPY_ANYORDER, NULL, 0);
      if (out_array == NULL)
          /*for now, i am not going to throw an error, instead return 0.
            python can use that 0 to throw the error */
          return Py_BuildValue("i", 0); 
  
      /*convert convArr to out_array*/
  
      return out_array;
  };
  </code></pre>
  
  <p>further notes, I use Python 2.7 on Windows 8. the PyMODINIT_FUNC and PyMethodDef are properly initialize (which means, no errors and correct results). While I have found multiple results, they all used things like ctypes or SWIG, not C. Although I am somewhat new in C, I am familiar with the basics (from Arduino C).</p>
  
  <p>thanks in advance!</p>