Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16878
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Subject | Re: Numpy ndarray to C array |
| Date | 2011-12-08 21:31 +0000 |
| References | <4ee07a56-50f9-4784-a52e-31553f0d3dc8@v29g2000yqv.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3455.1323379916.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Numpy ndarray to C array Enrico <enricong@gmail.com> - 2011-12-08 11:56 -0800 Re: Numpy ndarray to C array Robert Kern <robert.kern@gmail.com> - 2011-12-08 21:31 +0000
csiph-web