title: Passing a numpy array to C++
body: <p>I have some code writen in Python for which the output is a numpy array, and now I want to send that output to <code>C++</code> code, where the heavy part of the calculations will be performed.</p>
  
  <p>I have tried using cython's <code>public cdef</code>, but I am running on some issues. I would appreciate your help! Here goes my code:</p>
  
  <p><code>pymodule.pyx</code>:</p>
  
  <pre><code>from pythonmodule import result # result is my numpy array
  import numpy as np
  cimport numpy as np
  cimport cython
  
  @cython.boundscheck(False)
  @cython.wraparound(False)
  cdef public void cfunc():
      print 'I am in here!!!'
      cdef np.ndarray[np.float64_t, ndim=2, mode='c'] res = result
      print res
  </code></pre>
  
  <p>Once this is cythonized, I call:</p>
  
  <p><code>pymain.c</code>:</p>
  
  <pre><code>#include &lt;Python.h&gt;
  #include &lt;numpy/arrayobject.h&gt;
  #include "pymodule.h"
  
  int main() {
    Py_Initialize();
    initpymodule();
    test(2);
    Py_Finalize();
  }
  
  int test(int a)
  {
      Py_Initialize();
      initpymodule();
      cfunc();
      return 0;
  }
  </code></pre>
  
  <p>I am getting a <code>NameError</code> for the <code>result</code> variable at <code>C++</code>. I have tried defining it with pointers and calling it indirectly from other functions, but the array remains invisible. I am pretty sure the answer is quite simple, but I just do not get it. Thanks for your help!</p>