Discussion:
[Pyublas] Returning pyublas numpy_matrix from C++ function
Александров Петр
2013-03-19 17:24:25 UTC
Permalink
Is it safe to return a numpy_matrix from a C++ function? For example:

pyublas::numpy_matrix<double> some_function(const int n) {
pyublas::numpy_matrix<double> result(n, n);
for (int i = 0; i < n; i++) {
result(i, i) = 1.23;
}
return result;
}

BOOST_PYTHON_MODULE(TestModule) {
def("some_function", &some_function);
}
Andreas Kloeckner
2013-03-19 19:12:29 UTC
Permalink
Post by Александров Петр
pyublas::numpy_matrix<double> some_function(const int n) {
pyublas::numpy_matrix<double> result(n, n);
for (int i = 0; i < n; i++) {
result(i, i) = 1.23;
}
return result;
}
BOOST_PYTHON_MODULE(TestModule) {
def("some_function", &some_function);
}
Yes, that's fine.

Andreas

Loading...