[C++-sig] Accessing 2D array from python in C++
shahmi
alfarobi0161 at yahoo.com
Tue Aug 14 13:25:25 CEST 2012
Hi,
I have tried to access/expose 2D array from python in C++ using
boost::multi_array. Nevertheless, it seems that the
boost::multi_array<double, 2> datatype is not supported. Is there
any way to resolve this? My way of accessing it as below:
boost::python::object Vp = main_namespace["Vp"];
Vp_cpp = boost::python::extract<boost::multi_array<double, 2> >(Vp);
I've also tried to try to use 2D vector as below, nonetheless, it still doesn't work:
boost::python::object Vp = main_namespace["Vp"];
Vp_cpp = boost::python::extract<std::vector<std::vector<double> > >(Vp);
The error message I received is "TypeError: No registered converter was able to produce a C++ rvalue of type std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > from this Python object of type matrix"
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20120814/0fb0bd43/attachment.html>
More information about the Cplusplus-sig
mailing list