#define PY_SSIZE_T_CLEAN #include #include "symnmf.h" /** * @brief Convert a PyObject list of lists (matrix) into a flattened matrix. * * @param py_mat Pointer to a PyObject which is a list of lists (matrix). * @param numRows Number of rows in the matrix. * @param numCols Number of columns in the matrix. * @return Pointer to the matrix (flattened), or NULL if memory allocation fails. */ static double *pyobj_to_matrix(PyObject *py_mat, Py_ssize_t numRows, Py_ssize_t numCols){ double *mat; PyObject *inner; int i, j; mat = malloc((size_t)numRows*numCols*sizeof(double)); if(!mat) return NULL; for(i=0; i