On 12/8/11 7:56 PM, Enrico wrote:
I am trying to pass a multi-dimensional ndarray to C as a multi- dimensional C array for the purposes of passing it to mathematica. They already have a wrapper for a 1-D Python list. where the list is copied to "list". Shown below:
I would like to create a similar wrapper which accepts an ndarray and provides the array laid out in memory like a C array declared explicitly as "int a[m][n]...". I also need to pass the length of the array at each level i as dim[i]. Since this is pretty much the only function I plan to wrap, I'd like to avoid using boost, swig, etc.
You will find it better to ask numpy questions on the numpy mailing list: http://www.scipy.org/Mailing_Lists In this case, you are looking for the PyArray_AsCArray() function: http://docs.scipy.org/doc/numpy/reference/c-api.array.html#PyArray_AsCArray -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list