added conversion helpers for matlab

added examples for using the python wrappers in matlab


Former-commit-id: 4e4cadbbcf
This commit is contained in:
Daniele Panozzo
2015-10-07 01:49:58 +02:00
parent c861e80a05
commit 6cfbe683d7
12 changed files with 220 additions and 186 deletions
+19
View File
@@ -47,6 +47,25 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
return;
})
.def("__init__", [](Type &m, std::vector<Scalar>& b) {
if (b.size() == 0)
{
new (&m) Type(0, 0);
return;
}
// Size checks
unsigned rows = b.size();
unsigned cols = 1;
new (&m) Type(rows, cols);
m.resize(rows,cols);
for (unsigned i=0;i<rows;++i)
m(i,0) = b[i];
return;
})
.def("__init__", [](Type &m, py::buffer b) {
py::buffer_info info = b.request();
if (info.format != py::format_descriptor<Scalar>::value())