title: Pass a 2d numpy array to c using ctypes
body: <p>What is the correct way to pass a numpy 2d - array  to a c function using ctypes ?
  My current approach so far (leads to a segfault):</p>
  
  <p>C code :</p>
  
  <pre><code>void test(double **in_array, int N) {
      int i, j;
      for(i = 0; i&lt;N; i++) {
          for(j = 0; j&lt;N; j++) {
              printf("%e \t", in_array[i][j]);
          }
          printf("\n");
      }
  }
  </code></pre>
  
  <p>Python code:</p>
  
  <pre><code>from ctypes import *
  import numpy.ctypeslib as npct
  
  array_2d_double = npct.ndpointer(dtype=np.double,ndim=2, flags='CONTIGUOUS')
  liblr = npct.load_library('libtest.so', './src')
  
  liblr.test.restype = None
  liblr.test.argtypes = [array_2d_double, c_int]
  
  x = np.arange(100).reshape((10,10)).astype(np.double)
  liblr.test(x, 10)
  </code></pre>