From d44b4794c679141a08fd802475bb542ecf5b7c51 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 6 Nov 2008 23:01:41 +0100 Subject: ok, fast (but not fastest) matcher in place, no check output... Signed-off-by: Henrik Rydberg --- match/match.c | 326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ match/match.h | 25 +++++ match/test.c | 40 +++++++ 3 files changed, 391 insertions(+) create mode 100644 match/match.c create mode 100644 match/match.h create mode 100644 match/test.c (limited to 'match') diff --git a/match/match.c b/match/match.c new file mode 100644 index 0000000..604faaf --- /dev/null +++ b/match/match.c @@ -0,0 +1,326 @@ +#include "match.h" +#include +#include + +/** + * MATLAB implementation of the hungarian algorithm (2008) + * + * modified by Henrik Rydberg (2008) + */ + +const float BIG_VALUE = 1e20; + +typedef unsigned short col_t; + +#define GETBIT2(m, row, col) ((m[col]>>row)&1U) +#define SETBIT2(m, row, col) (m[col]|=(1U<>x)&1U) +#define SETBIT(m, x) (m|=(1U< ncols) */ + { + dmin = ncols; + + for(col=0; col +#include +#include "match.c" + +#define ITS 1000000 + +int main(int argc,char* argv[]) +{ + // column-by-column matrix + float A[DIM2_FINGER]; + float x1[DIM_FINGER]={1,5,2,3,4,5,6,7,8}; + float y1[DIM_FINGER]={1,5,2,3,4,5.1,6,7,8}; + float x2[DIM_FINGER]={1.1,3,2,4,5,6,7,8}; + float y2[DIM_FINGER]={1,3,2,4,5,6,7,8}; + int index[DIM_FINGER]; + int n1 = 4; + int n2 = 7; + + int i, j; + + for (i = 0; i < n1; i++) { + for (j = 0; j < n2; j++) { + A[i + n1 * j] = + (x1[i] - x2[j]) * (x1[i] - x2[j]) + + (y1[i] - y2[j]) * (y1[i] - y2[j]); + } + } + + clock_t t1 = clock(); + for (i = 0; i < ITS; i++) + match_fingers(index, A, n1, n2); + clock_t t2 = clock(); + + 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]); + + return 0; +} -- cgit v1.2.3