diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-08 18:43:41 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-08 18:43:41 +0100 |
| commit | 30f8e07f61c40fc3371445251972f36e1474b2b3 (patch) | |
| tree | 96748f4ad61b60e3fe51ef448a51a056f8fe0a2c /match | |
| parent | 809b43cb3bac52ad87228a458dcd3dbf11180c97 (diff) | |
oops in vector-to-bit conversion
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'match')
| -rw-r--r-- | match/match.c | 21 | ||||
| -rw-r--r-- | match/test.c | 35 |
2 files changed, 40 insertions, 16 deletions
diff --git a/match/match.c b/match/match.c index 44297d9..551e2f6 100644 --- a/match/match.c +++ b/match/match.c | |||
| @@ -43,7 +43,7 @@ static void step5 (int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mp | |||
| 43 | static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) | 43 | static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) |
| 44 | { | 44 | { |
| 45 | float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; | 45 | float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; |
| 46 | int nelem, dmin, row, col; | 46 | int dmin, row, col; |
| 47 | col_t ccol,crow, mstar[DIM_FINGER],mprime[DIM_FINGER],nmstar[DIM_FINGER]; | 47 | col_t ccol,crow, mstar[DIM_FINGER],mprime[DIM_FINGER],nmstar[DIM_FINGER]; |
| 48 | 48 | ||
| 49 | ccol = crow = 0; | 49 | ccol = crow = 0; |
| @@ -56,8 +56,7 @@ static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) | |||
| 56 | for(row=0; row<nrows; row++) | 56 | for(row=0; row<nrows; row++) |
| 57 | ix[row] = -1; | 57 | ix[row] = -1; |
| 58 | 58 | ||
| 59 | nelem = nrows * ncols; | 59 | mdistEnd = mdist + nrows * ncols; |
| 60 | mdistEnd = mdist + nelem; | ||
| 61 | 60 | ||
| 62 | /* preliminary steps */ | 61 | /* preliminary steps */ |
| 63 | if(nrows <= ncols) { | 62 | if(nrows <= ncols) { |
| @@ -141,7 +140,7 @@ static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) | |||
| 141 | 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) | 140 | 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) |
| 142 | { | 141 | { |
| 143 | int col, row; | 142 | int col, row; |
| 144 | 143 | ||
| 145 | /* cover every column containing a starred zero */ | 144 | /* cover every column containing a starred zero */ |
| 146 | for(col=0; col<ncols; col++) { | 145 | for(col=0; col<ncols; col++) { |
| 147 | for(row=col;row<nrows;row++) { | 146 | for(row=col;row<nrows;row++) { |
| @@ -227,11 +226,9 @@ static void step3(int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mpr | |||
| 227 | 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) | 226 | 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) |
| 228 | { | 227 | { |
| 229 | int n, rstar, cstar, primeRow, primeCol; | 228 | int n, rstar, cstar, primeRow, primeCol; |
| 230 | int nelem = nrows*ncols; | ||
| 231 | 229 | ||
| 232 | /* generate temporary copy of mstar */ | 230 | /* generate temporary copy of mstar */ |
| 233 | for(n=0; n<nelem; n++) | 231 | memcpy(nmstar, mstar, sizeof(mstar)); |
| 234 | nmstar[n] = mstar[n]; | ||
| 235 | 232 | ||
| 236 | /* star current zero */ | 233 | /* star current zero */ |
| 237 | SETBIT2(nmstar, row, col); | 234 | SETBIT2(nmstar, row, col); |
| @@ -265,13 +262,9 @@ static void step4(int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mpr | |||
| 265 | 262 | ||
| 266 | /* use temporary copy as new mstar */ | 263 | /* use temporary copy as new mstar */ |
| 267 | /* delete all primes, uncover all rows */ | 264 | /* delete all primes, uncover all rows */ |
| 268 | for(n=0; n<nelem; n++) | 265 | memset(mprime, 0, sizeof(mprime)); |
| 269 | { | 266 | memcpy(mstar, nmstar, sizeof(nmstar)); |
| 270 | mprime[n] = 0; | 267 | crow = 0; |
| 271 | mstar[n] = nmstar[n]; | ||
| 272 | } | ||
| 273 | for(n=0; n<nrows; n++) | ||
| 274 | CLEARBIT(crow, n); | ||
| 275 | 268 | ||
| 276 | /* move to step 2a */ | 269 | /* move to step 2a */ |
| 277 | step2a(ix, mdist, mstar, nmstar, mprime, ccol, crow, nrows, ncols, dmin); | 270 | step2a(ix, mdist, mstar, nmstar, mprime, ccol, crow, nrows, ncols, dmin); |
diff --git a/match/test.c b/match/test.c index 1544765..ad39370 100644 --- a/match/test.c +++ b/match/test.c | |||
| @@ -4,7 +4,31 @@ | |||
| 4 | 4 | ||
| 5 | #define ITS 1000000 | 5 | #define ITS 1000000 |
| 6 | 6 | ||
| 7 | int main(int argc,char* argv[]) | 7 | static void test1() |
| 8 | { | ||
| 9 | float A[] = { | ||
| 10 | 1013.000000, | ||
| 11 | 3030660.000000, | ||
| 12 | 3559354.000000, | ||
| 13 | 12505925.000000, | ||
| 14 | 19008450.000000, | ||
| 15 | 6946421.000000, | ||
| 16 | 6118613.000000, | ||
| 17 | 698020.000000, | ||
| 18 | 3021800.000000, | ||
| 19 | 1017.000000, | ||
| 20 | 37573.000000, | ||
| 21 | 3242018.000000, | ||
| 22 | 8152794.000000, | ||
| 23 | 1266053.000000, | ||
| 24 | 942941.000000, | ||
| 25 | 462820.000000, | ||
| 26 | }; | ||
| 27 | int index[DIM_FINGER]; | ||
| 28 | match_fingers(index, A, 4, 4); | ||
| 29 | } | ||
| 30 | |||
| 31 | static void speed1() | ||
| 8 | { | 32 | { |
| 9 | // column-by-column matrix | 33 | // column-by-column matrix |
| 10 | float A[DIM2_FINGER]; | 34 | float A[DIM2_FINGER]; |
| @@ -31,10 +55,17 @@ int main(int argc,char* argv[]) | |||
| 31 | match_fingers(index, A, n1, n2); | 55 | match_fingers(index, A, n1, n2); |
| 32 | clock_t t2 = clock(); | 56 | clock_t t2 = clock(); |
| 33 | 57 | ||
| 34 | printf("%lf matches per second\n", ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); | 58 | printf("%lf matches per second\n", |
| 59 | ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); | ||
| 35 | 60 | ||
| 36 | for (i = 0; i < n1; i++) | 61 | for (i = 0; i < n1; i++) |
| 37 | printf("match[%d] = %d\n", i, index[i]); | 62 | printf("match[%d] = %d\n", i, index[i]); |
| 38 | 63 | ||
| 64 | } | ||
| 65 | |||
| 66 | int main(int argc,char* argv[]) | ||
| 67 | { | ||
| 68 | test1(); | ||
| 69 | speed1(); | ||
| 39 | return 0; | 70 | return 0; |
| 40 | } | 71 | } |
