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 | |
parent | 809b43cb3bac52ad87228a458dcd3dbf11180c97 (diff) | |
download | xorg-input-kobomultitouch-30f8e07f61c40fc3371445251972f36e1474b2b3.tar.gz xorg-input-kobomultitouch-30f8e07f61c40fc3371445251972f36e1474b2b3.tar.bz2 xorg-input-kobomultitouch-30f8e07f61c40fc3371445251972f36e1474b2b3.zip |
oops in vector-to-bit conversion
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-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 static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) { float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; - int nelem, dmin, row, col; + int dmin, row, col; col_t ccol,crow, mstar[DIM_FINGER],mprime[DIM_FINGER],nmstar[DIM_FINGER]; ccol = crow = 0; @@ -56,8 +56,7 @@ static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) for(row=0; row<nrows; row++) ix[row] = -1; - nelem = nrows * ncols; - mdistEnd = mdist + nelem; + mdistEnd = mdist + nrows * ncols; /* preliminary steps */ if(nrows <= ncols) { @@ -141,7 +140,7 @@ static void ixoptimal(int *ix, float *mdist, 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) { int col, row; - + /* cover every column containing a starred zero */ for(col=0; col<ncols; col++) { 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 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) { int n, rstar, cstar, primeRow, primeCol; - int nelem = nrows*ncols; /* generate temporary copy of mstar */ - for(n=0; n<nelem; n++) - nmstar[n] = mstar[n]; + memcpy(nmstar, mstar, sizeof(mstar)); /* star current zero */ SETBIT2(nmstar, row, col); @@ -265,13 +262,9 @@ static void step4(int *ix, float *mdist, col_t *mstar, col_t *nmstar, col_t *mpr /* use temporary copy as new mstar */ /* delete all primes, uncover all rows */ - for(n=0; n<nelem; n++) - { - mprime[n] = 0; - mstar[n] = nmstar[n]; - } - for(n=0; n<nrows; n++) - CLEARBIT(crow, n); + memset(mprime, 0, sizeof(mprime)); + memcpy(mstar, nmstar, sizeof(nmstar)); + crow = 0; /* move to step 2a */ 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 @@ #define ITS 1000000 -int main(int argc,char* argv[]) +static void test1() +{ + float A[] = { + 1013.000000, + 3030660.000000, + 3559354.000000, + 12505925.000000, + 19008450.000000, + 6946421.000000, + 6118613.000000, + 698020.000000, + 3021800.000000, + 1017.000000, + 37573.000000, + 3242018.000000, + 8152794.000000, + 1266053.000000, + 942941.000000, + 462820.000000, + }; + int index[DIM_FINGER]; + match_fingers(index, A, 4, 4); +} + +static void speed1() { // column-by-column matrix float A[DIM2_FINGER]; @@ -31,10 +55,17 @@ int main(int argc,char* argv[]) match_fingers(index, A, n1, n2); clock_t t2 = clock(); - printf("%lf matches per second\n", ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); + printf("%lf matches per second\n", + ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); for (i = 0; i < n1; i++) printf("match[%d] = %d\n", i, index[i]); +} + +int main(int argc,char* argv[]) +{ + test1(); + speed1(); return 0; } |