diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-06 23:01:41 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-06 23:01:41 +0100 |
| commit | d44b4794c679141a08fd802475bb542ecf5b7c51 (patch) | |
| tree | 74251970cfbcc58d0252366be6e5e668149b8a48 /match/test.c | |
| parent | 63de72d8d810e3692c96c7385b497bb4d68ef54a (diff) | |
ok, fast (but not fastest) matcher in place, no check output...
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'match/test.c')
| -rw-r--r-- | match/test.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/match/test.c b/match/test.c new file mode 100644 index 0000000..1544765 --- /dev/null +++ b/match/test.c | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <time.h> | ||
| 3 | #include "match.c" | ||
| 4 | |||
| 5 | #define ITS 1000000 | ||
| 6 | |||
| 7 | int main(int argc,char* argv[]) | ||
| 8 | { | ||
| 9 | // column-by-column matrix | ||
| 10 | float A[DIM2_FINGER]; | ||
| 11 | float x1[DIM_FINGER]={1,5,2,3,4,5,6,7,8}; | ||
| 12 | float y1[DIM_FINGER]={1,5,2,3,4,5.1,6,7,8}; | ||
| 13 | float x2[DIM_FINGER]={1.1,3,2,4,5,6,7,8}; | ||
| 14 | float y2[DIM_FINGER]={1,3,2,4,5,6,7,8}; | ||
| 15 | int index[DIM_FINGER]; | ||
| 16 | int n1 = 4; | ||
| 17 | int n2 = 7; | ||
| 18 | |||
| 19 | int i, j; | ||
| 20 | |||
| 21 | for (i = 0; i < n1; i++) { | ||
| 22 | for (j = 0; j < n2; j++) { | ||
| 23 | A[i + n1 * j] = | ||
| 24 | (x1[i] - x2[j]) * (x1[i] - x2[j]) + | ||
| 25 | (y1[i] - y2[j]) * (y1[i] - y2[j]); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | clock_t t1 = clock(); | ||
| 30 | for (i = 0; i < ITS; i++) | ||
| 31 | match_fingers(index, A, n1, n2); | ||
| 32 | clock_t t2 = clock(); | ||
| 33 | |||
| 34 | printf("%lf matches per second\n", ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); | ||
| 35 | |||
| 36 | for (i = 0; i < n1; i++) | ||
| 37 | printf("match[%d] = %d\n", i, index[i]); | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
