<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Hi John,<br><br>I'm sorry, I'm a bit confused because previously you said that the relevant implementation resides in "c++/myrrh/myrrh/python/multi_array_to_numpy.h"but now, you point to "src/python/man_module.cpp and src/python/multi_array_to_numpy.cpp". Hope you understand my problem of having 2D array in python that needs to be exposed/converted to C++. It would be great If I know any method/function that I can invoke from any of your implementations.<br><br>Thanks in advance.<br><div><span><br></span></div><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> John Reid
<j.reid@mail.cryst.bbk.ac.uk><br> <b><span style="font-weight: bold;">To:</span></b> cplusplus-sig@python.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, August 22, 2012 12:28 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [C++-sig] Accessing 2D array from python in C++<br> </font> </div> <br>
On 22/08/12 11:13, alfa wrote:<br>> Hi John,<br>> <br>> Thanks a lot for your implementation. In multi_array_to_numpy.h, can<br>> you give more hints on which method/function that I can possibly use if<br>> I can include it in my implementation as a header file.<br>> <br>> Thanks in advance.<br>> <br>src/python/man_module.cpp and src/python/multi_array_to_numpy.cpp<br>implement a boost.python module that exposes the multi-array classes.<br>You have choose which data types you expose multiarrays for.<br><br>HTH,<br>John.<br><br><br>> <br>> ------------------------------------------------------------------------<br>> *From:* John Reid <<a ymailto="mailto:j.reid@mail.cryst.bbk.ac.uk" href="mailto:j.reid@mail.cryst.bbk.ac.uk">j.reid@mail.cryst.bbk.ac.uk</a>><br>> *To:* <a ymailto="mailto:cplusplus-sig@python.org" href="mailto:cplusplus-sig@python.org">cplusplus-sig@python.org</a><br>> *Sent:* Thursday,
August 16, 2012 5:02 PM<br>> *Subject:* Re: [C++-sig] Accessing 2D array from python in C++<br>> <br>> If you don't mind digging around in my code, you could download the<br>> source code for the STEME python package from pypi and look in the<br>> c++/myrrh directory. There is code to access multi_arrays from python in<br>> there.<br>> <br>> http://pypi.python.org/pypi/STEME/<br>> <br>> In particular the file<br>> c++/myrrh/myrrh/python/multi_array_to_numpy.h contains the bulk of the<br>> implementation.<br>> <br>> HTH,<br>> John.<br>> <br>> <br>> <br>> On 16/08/12 09:29, alfa wrote:<br>>> Hi,<br>>><br>>> Could you give more hints on this or any code snippet that I can<br>>> implement this. I'm a bit naive in applying this. Please consider my 2D<br>>> array of Vp_cpp(Vp equivalent in Python) is as below:<br>>><br>>> typedef
boost::multi_array<double, 2> array_type;<br>>> typedef array_type::index index;<br>>> array_type Vp_cpp(boost::extents[X_cpp][X_cpp]);<br>>><br>>><br>>> I'm still puzzled how to "manually wrap the features" in the last<br>> "..." in:<br>>> boost::python::class_< boost::multi_array<...> >(...)<br>>><br>>> Thanks in advance.<br>>><br>>> ------------------------------------------------------------------------<br>>> *From:* Jim Bosch <<a ymailto="mailto:talljimbo@gmail.com" href="mailto:talljimbo@gmail.com">talljimbo@gmail.com</a> <mailto:<a ymailto="mailto:talljimbo@gmail.com" href="mailto:talljimbo@gmail.com">talljimbo@gmail.com</a>>><br>>> *To:* alfa <<a ymailto="mailto:alfarobi0161@yahoo.com" href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a> <mailto:<a ymailto="mailto:alfarobi0161@yahoo.com"
href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a>>><br>>> *Cc:* Development of Python/C++ integration <<a ymailto="mailto:cplusplus-sig@python.org" href="mailto:cplusplus-sig@python.org">cplusplus-sig@python.org</a><br>> <mailto:<a ymailto="mailto:cplusplus-sig@python.org" href="mailto:cplusplus-sig@python.org">cplusplus-sig@python.org</a>>><br>>> *Sent:* Wednesday, August 15, 2012 5:34 PM<br>>> *Subject:* Re: [C++-sig] Accessing 2D array from python in C++<br>>><br>>> On Aug 15, 2012 1:57 AM, "alfa" <<a ymailto="mailto:alfarobi0161@yahoo.com" href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a><br>> <mailto:<a ymailto="mailto:alfarobi0161@yahoo.com" href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a>><br>>> <mailto:<a ymailto="mailto:alfarobi0161@yahoo.com" href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a> <mailto:<a
ymailto="mailto:alfarobi0161@yahoo.com" href="mailto:alfarobi0161@yahoo.com">alfarobi0161@yahoo.com</a>>>> wrote:<br>>>><br>>>> I apologize for double posting this because it was spammed before.<br>>>><br>>>> Hi Jim,<br>>>><br>>>> Do you mean, "you could wrap multi_array itself using class_", I<br>>> should do as below:<br>>>><br>>>> boost::python::class_<std::vector<std::vector<double> ><br>>>>("PyVec").def(boost::python::vector_indexing_suite<std::vector<std::vector<double><br>>>> >());<br>>>><br>>> No, I don't think that will work; I meant something like this:<br>>> boost::python::class_< boost::multi_array<...> >(...)<br>>> ...;<br>>> Where the last "..." is where you have to manually wrap the features of<br>>> multi_array you want to use. I'm
afraid there's nothing as easy as<br>>> vector_indexing_suite.<br>>> Jim<br>>><br>>><br>>><br>>><br>>> _______________________________________________<br>>> Cplusplus-sig mailing list<br>>> <a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a> <mailto:<a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a>><br>>> http://mail.python.org/mailman/listinfo/cplusplus-sig<br>>><br>> <br>> _______________________________________________<br>> Cplusplus-sig mailing list<br>> <a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a> <mailto:<a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a>><br>> <a
href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br>> <br>> <br>> <br>> <br>> _______________________________________________<br>> Cplusplus-sig mailing list<br>> <a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br>> <a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br>> <br><br>_______________________________________________<br>Cplusplus-sig mailing list<br><a ymailto="mailto:Cplusplus-sig@python.org" href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br><br><br> </div> </div> </div></body></html>