[SciPy-user] Need very simple example showing how to return numpy array from C/C++ function

Matthieu Brucher matthieu.brucher@gmail....
Thu Dec 27 16:04:11 CST 2007


The problem is that you will have to copy yout data anyway. One of the best
solutions is to pass an already created Numpy array (as argument or with a
callback function) that you will be able to use (this is what I do with a
custom C++ array class that wraps the Python object).


2007/12/27, Jeremy Conlin <jeremit0@gmail.com>:
> I have a class member function that looks like this:
> std::vector<double> discretize(...);
> I would like to return a numpy array instead of a std::vector<double>.  I
> could (of course) rewrite my function to return a pointer to the first
> element of an array if needed.  I am currently using SWIG for wrapping my
> code for Python.
> I have searched far and wide for a simple example of how I should do this.
>  Everything I find is *far* too complicated for someone doing this for the
> first time.  Does someone have a simple example they would like to share?  I
> have the "Guide to Numpy"; it has lots of information about the different
> functions, it doesn't have any examples.
> Thanks,
> Jeremy Conlin
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071227/a412d545/attachment.html 

More information about the SciPy-user mailing list