From 7645981d149fe5e4301ee0a99197c407d09dec82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 20 Aug 2010 17:19:37 +0000 Subject: [PATCH] Adjust for M's 1-based indexing in the 'neighbours' connection array [%] Assign results to plhs[0] (and print diagnostic). --- mex_partition_process.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mex_partition_process.c b/mex_partition_process.c index 376136c2..5eb29b79 100644 --- a/mex_partition_process.c +++ b/mex_partition_process.c @@ -76,15 +76,15 @@ extract_neighbour(const mxArray *M_neigh, int *neigh) pd = mxGetPr(M_neigh); for (e = 0; e < ne; e++) { - neigh[2*e + 0] = pd[e + 0*ne]; - neigh[2*e + 1] = pd[e + 1*ne]; + neigh[2*e + 0] = pd[e + 0*ne] - 1; + neigh[2*e + 1] = pd[e + 1*ne] - 1; } } else { pi = mxGetData(M_neigh); for (e = 0; e < ne; e++) { - neigh[2*e + 0] = pi[e + 0*ne]; - neigh[2*e + 1] = pi[e + 1*ne]; + neigh[2*e + 0] = pi[e + 0*ne] - 1; + neigh[2*e + 1] = pi[e + 1*ne] - 1; } } } @@ -164,7 +164,7 @@ mexFunction(int nlhs, mxArray *plhs[], extract_neighbour(prhs[1], neigh); nextra = partition_split_disconnected(nc, nneigh, neigh, p); -#if 0 + if (nextra == 0) { mexPrintf("Partition processing complete. No extra blocks.\n"); @@ -177,7 +177,7 @@ mexFunction(int nlhs, mxArray *plhs[], } else { mexPrintf("Partition processing failed. Insufficient memory?\n"); } -#endif + deallocate_aux_arrays(p, neigh); } } else {