Skip to content
Snippets Groups Projects
Commit bd3ab69d authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

python : add typemap to convert returned fullVector to numpy array

parent 3e214d57
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,14 @@
}
return array;
}
PyObject *fullVector2PyArrayProxy(fullVector<double> &fv)
{
npy_intp dims[1] = {fv.size()};
double *data = &fv.operator()(0);
PyObject *array = PyArray_New(&PyArray_Type, 1, dims, NPY_DOUBLE, NULL, (void*)data, 0, NPY_ARRAY_F_CONTIGUOUS, NULL);
PyArray_UpdateFlags((PyArrayObject*)array, NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE);
return array;
}
%#endif
}
......@@ -176,6 +184,10 @@
%typemap(out, fragment="fullMatrixConversion") fullMatrix<double> {
$result = fullMatrix2PyArray($1);
}
%typemap(out, fragment="fullMatrixConversion") fullVector<double>& {
$result = fullVector2PyArrayProxy(*$1);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment