[Cython] how to get a double** from np.ndarray[double, ndim=2]

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Mon Sep 5 19:28:15 CEST 2011

NumPy does not have a double** anywhere, what you did is the correct solution (as long as you make sure the array is C-contiguous). 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

"Adrian Martínez Vargas" <adriangeologo at yahoo.es> wrote:

Hi, I would like to get a double** from a 2d numpy array in cython in order to call properly some function written in C++. Can some one to give a pure cython solution? From now I have a double* from the np.ndarray[double, ndim=2] .data. I'm getting the double array in C++ with: array2D_=new double* [nrows]; for (int i=0; i<nrows; ++i) { array2D_[i]=ptr1D; ptr1D+=ncols; } with that I'm responsible to delete the array from C++ // delete [] this->array2D_[0]; // delete the memory pool delete [] this->array2D_; // delete the row pointers but this->array2D_[0]; is shared with the numpy array. I think that it may be more elegant to get directly a double** from numpy and let to python the responsibility of managing the memory. Regards Adrian Martínez Vargas_____________________________________________
cython-devel mailing list cython-devel at python.org http://mail.python.org/mailman/listinfo/cython-devel 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20110905/b20746d6/attachment.html>

More information about the cython-devel mailing list