On http://www.scipy.org/JorisDeRidder I've just put an example how I passed multidimensional Numpy arrays to C++ using ctypes. Perhaps it's helpful for your application. I didn't put it in the cookbook yet, because I would first like to test it a bit more. Up to now I didn't experience any bugs though.

Joris



On 22 Apr 2008, at 23:38, Thomas Hrabe wrote:

Hi all!

I am currently developing a python module in C/C++ which is supposed to access nd arrays as defined by the following command in python

a = numpy.array([1,1,1])

I want to access the array the following way and use the nd array data for further processing in C.

mymod.doSthg(a)

The example code on
http://numpy.sourceforge.net/numdoc/HTML/numdoc.htm#pgfId-36721

 (!PyArg_ParseTuple(args, "O!",&PyArray_Type, &array))

does not work for nd arrays. I always get
TypeError: argument 1 must be array, not numpy.ndarray

I assume the error is the constant provided as the third parameter, saying that the imput is of PyArray_Type and no nd array.

So here are my questions:
1. is there any good tutorial / example code for acessing nd arrays in C?
2. what is the difference between both (arrays and nd arrays? - I am new to python and heard there were different approaches to arrays and that nd arrays work better for multi dimensional applications. Is this right?)
3. which one of both will be used in the future?

Thank you in advance for your help,
Thomas

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm for more information.