where
class CVector: public ublas::vector<TReal> {
public:
…
CVector(const list &l) { … }
};
doesn't works. The python program exits with the following message
Boost.Python.ArgumentError: Python argument types in
some_function(some_class, vector)
did not match C++ signature:
some_function(…, boost::numeric::ublas::vector<…>)
I think that boost doesn't understand that CVector is practically the ublas::vector. Inheriting CVector from "wrapper<ublas::vector<TReal> >" solves this problem. But I need to add "boost::noncopyable" to class_<CVector> while I want to use a function that returns ublas::vector in python. Is it possible not to add "boost::noncopyable" in such case?
Numpy bindings are not appropriate because I use ublas::vector with custom type for real numbers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How can I add a constructor (from python list) to python interface for ublas::vector? The following approach:
class_<CVector>("vector")
.def(init<size_t>())
.def(init<list>())
.def("__getitem__", &vector_get_item)
.def("__setitem__", &vector_set_item)
.def("resize", &CVector::resize)
.def("size", &CVector::size);
where
class CVector: public ublas::vector<TReal> {
public:
…
CVector(const list &l) { … }
};
doesn't works. The python program exits with the following message
Boost.Python.ArgumentError: Python argument types in
some_function(some_class, vector)
did not match C++ signature:
some_function(…, boost::numeric::ublas::vector<…>)
I think that boost doesn't understand that CVector is practically the ublas::vector. Inheriting CVector from "wrapper<ublas::vector<TReal> >" solves this problem. But I need to add "boost::noncopyable" to class_<CVector> while I want to use a function that returns ublas::vector in python. Is it possible not to add "boost::noncopyable" in such case?
Numpy bindings are not appropriate because I use ublas::vector with custom type for real numbers.