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

dg : update windows script to python3

parent 1b5ebbb6
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,27 @@ ...@@ -124,6 +124,27 @@
} }
return array; return array;
} }
PyObject *fullMatrix2PyArrayConst(const fullMatrix<double> &fm)
{
npy_intp dims[2] = {fm.size1(), fm.size2()};
double *data = (double*)fm.getDataPtr();
/*PyObject *array = PyArray_New(&PyArray_Type, 2, dims, NPY_DOUBLE, NULL, NULL, 0, NPY_ARRAY_F_CONTIGUOUS, NULL);
// copy data
memcpy((void*)PyArray_DATA(array), data, dims[0] * dims[1] * sizeof(double));*/
// do not copy data
PyObject *array = PyArray_New(&PyArray_Type, 2, dims, NPY_DOUBLE, NULL, (void*)data, 0, NPY_ARRAY_F_CONTIGUOUS, NULL);
PyArray_UpdateFlags((PyArrayObject*)array, NPY_ARRAY_ALIGNED);
/*if (fm.getOwnData()) {
fm.setOwnData(false);
%#if PY_MAJOR_VERSION==2 && PY_MINOR_VERSION==6
PyObject *capsule = PyCObject_FromVoidPtr((void*)data, deleteCapsuleArray);
%#else
PyObject *capsule = PyCapsule_New((void*) data, NULL, deleteCapsuleArray);
%#endif
PyArray_SetBaseObject((PyArrayObject*)array, capsule);
}*/
return array;
}
PyObject *fullVector2PyArrayProxy(fullVector<double> &fv) PyObject *fullVector2PyArrayProxy(fullVector<double> &fv)
{ {
npy_intp dims[1] = {fv.size()}; npy_intp dims[1] = {fv.size()};
...@@ -186,6 +207,10 @@ ...@@ -186,6 +207,10 @@
$result = fullMatrix2PyArray($1); $result = fullMatrix2PyArray($1);
} }
%typemap(out, fragment="fullMatrixConversion") const fullMatrix<double>& {
$result = fullMatrix2PyArrayConst(*$1);
}
%typemap(out, fragment="fullMatrixConversion") fullVector<double>& { %typemap(out, fragment="fullMatrixConversion") fullVector<double>& {
$result = fullVector2PyArrayProxy(*$1); $result = fullVector2PyArrayProxy(*$1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment