C ++ Python converts data from vector to ndarray
I am creating a C ++ project that includes some python. I used to boost::python
, but now I'm stuck. I have some data stored in a std::vector
. The data needs to be sent to python in order to do some calculations. The Python NumPy functions I use need formatted data ndarray
, so I need a way to transform it. Since I want to do something else with the results in C ++, I want to convert the result back from ndarray
to std::vector
.
How to convert std::vector
to ndarray
and vice versa? Can anyone post some sample code? I know there is a lib called boost.numpy
, but are there any other ways because I was unable to build this library ...
Can I be used boost::python::numeric
for a job? Can anyone provide some sample code?
Is this possible without copying the data?
source to share