From 2d96d426e063a4c2c33cabf9c6ebf570db1fcf1b Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Nov 2008 22:00:50 +0100 Subject: culprit: step2a row should start at zero plus cleanup Signed-off-by: Henrik Rydberg --- match/match.c | 189 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 94 insertions(+), 95 deletions(-) (limited to 'match/match.c') diff --git a/match/match.c b/match/match.c index 551e2f6..3c5ea0c 100644 --- a/match/match.c +++ b/match/match.c @@ -8,22 +8,25 @@ * modified by Henrik Rydberg (2008) */ -const float BIG_VALUE = 1e20; +typedef unsigned short col_t[1]; +typedef unsigned short mat_t[DIM_FINGER]; -typedef unsigned short col_t; +#define GET1(m, x) ((m[0]>>(x))&1U) +#define SET1(m, x) (m[0]|=(1U<<(x))) +#define CLEAR1(m, x) (m[0]&=~(1U<<(x))) -#define GETBIT2(m, row, col) ((m[col]>>(row))&1U) -#define SETBIT2(m, row, col) (m[col]|=(1U<<(row))) -#define CLEARBIT2(m, row, col) (m[col]&=~(1U<<(row))) +#define GET2(m, row, col) ((m[col]>>(row))&1U) +#define SET2(m, row, col) (m[col]|=(1U<<(row))) +#define CLEAR2(m, row, col) (m[col]&=~(1U<<(row))) /********************************************************/ -static void buildixvector(int *ix, col_t *mstar, int nrows, int ncols) +static void buildixvector(int *ix, mat_t mstar, int nrows, int ncols) { int row, col; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { - if (GETBIT2(mstar, row, col)) { + if (GET2(mstar, row, col)) { ix[row] = col; break; } @@ -34,24 +37,25 @@ static void buildixvector(int *ix, col_t *mstar, int nrows, int ncols) /********************************************************/ -static void step2a(int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); -static void step2b(int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); -static void step3 (int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); -static void step4 (int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin, int row, int col); -static void step5 (int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); +static void step2a(int *ix, float *mdist, mat_t mstar, mat_t nmstar, mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); +static void step2b(int *ix, float *mdist, mat_t mstar, mat_t nmstar, mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); +static void step3(int *ix, float *mdist, mat_t mstar, mat_t nmstar, mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); +static void step4(int *ix, float *mdist, mat_t mstar, mat_t nmstar, mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin, int row, int col); +static void step5(int *ix, float *mdist, mat_t mstar, mat_t nmstar, mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, int dmin); static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) { float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; int dmin, row, col; - col_t ccol,crow, mstar[DIM_FINGER],mprime[DIM_FINGER],nmstar[DIM_FINGER]; + col_t ccol, crow; + mat_t mstar, mprime, nmstar; - ccol = crow = 0; - memset(mstar, 0, sizeof(mstar)); - memset(mprime, 0, sizeof(mprime)); - memset(nmstar, 0, sizeof(nmstar)); + memset(ccol, 0, sizeof(col_t)); + memset(crow, 0, sizeof(col_t)); + memset(mstar, 0, sizeof(mat_t)); + memset(mprime, 0, sizeof(mat_t)); + memset(nmstar, 0, sizeof(mat_t)); - /* initialization */ for(row=0; row ncols) */ - { + } else { dmin = ncols; - for(col=0; col max) + max = A[i]; + for (i = 0; i < nrow * ncol; i++) + A[i] /= max; ixoptimal(ix, A, nrow, ncol); } -- cgit v1.2.3