2 namespace py = boost::python;
5 py::list toPyList(
const std::vector<int>& x) {
7 for (
int i=0; i < x.size(); ++i) out.append(x[i]);
13 static const char* npname;
21 T* getPointer(
const py::object& arr) {
22 long int i = py::extract<long int>(arr.attr(
"ctypes").attr(
"data"));
28 py::object toNdarray1(
const T* data,
size_t dim0) {
30 T* p = getPointer<T>(out);
31 memcpy(p, data, dim0*
sizeof(T));
35 py::object toNdarray2(
const T* data,
size_t dim0,
size_t dim1) {
37 T* pout = getPointer<T>(out);
38 memcpy(pout, data, dim0*dim1*
sizeof(T));
42 py::object toNdarray3(
const T* data,
size_t dim0,
size_t dim1,
size_t dim2) {
44 T* pout = getPointer<T>(out);
45 memcpy(pout, data, dim0*dim1*dim2*
sizeof(T));