summaryrefslogtreecommitdiff
path: root/match/match.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-03-20 14:18:16 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-03-21 14:56:15 +0100
commite9dcbeaba956e84d1e591e9b520f3b7bb4fa6354 (patch)
tree19b4d548127766862a79f5521f75a590b90090b1 /match/match.c
parentea6cfa421b7cef91eba85c5144eec14288c41c4c (diff)
Matcher: convert distance matrix to integer
In order to reduce the requirements on the cpu environment running the matcher, the floating-point operations are converted to integer. Care is taken as to not overflow the distance matrix. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'match/match.c')
-rw-r--r--match/match.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/match/match.c b/match/match.c
index a3f4deb..4cb4495 100644
--- a/match/match.c
+++ b/match/match.c
@@ -64,25 +64,25 @@ static void buildixvector(int *ix, mat_t mstar, int nrows, int ncols)
64 64
65/********************************************************/ 65/********************************************************/
66 66
67static void step2a(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 67static void step2a(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
68 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 68 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
69 int dmin); 69 int dmin);
70static void step2b(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 70static void step2b(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
71 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 71 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
72 int dmin); 72 int dmin);
73static void step3(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 73static void step3(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
74 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 74 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
75 int dmin); 75 int dmin);
76static void step4(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 76static void step4(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
77 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 77 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
78 int dmin, int row, int col); 78 int dmin, int row, int col);
79static void step5(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 79static void step5(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
80 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 80 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
81 int dmin); 81 int dmin);
82 82
83static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) 83static void ixoptimal(int *ix, int *mdist, int nrows, int ncols)
84{ 84{
85 float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; 85 int *mdistTemp, *mdistEnd, *columnEnd, value, minValue;
86 int dmin, row, col; 86 int dmin, row, col;
87 col_t ccol, crow; 87 col_t ccol, crow;
88 mat_t mstar, mprime, nmstar; 88 mat_t mstar, mprime, nmstar;
@@ -181,7 +181,7 @@ static void ixoptimal(int *ix, float *mdist, int nrows, int ncols)
181} 181}
182 182
183/********************************************************/ 183/********************************************************/
184static void step2a(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 184static void step2a(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
185 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 185 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
186 int dmin) 186 int dmin)
187{ 187{
@@ -204,7 +204,7 @@ static void step2a(int *ix, float *mdist, mat_t mstar, mat_t nmstar,
204} 204}
205 205
206/********************************************************/ 206/********************************************************/
207static void step2b(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 207static void step2b(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
208 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 208 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
209 int dmin) 209 int dmin)
210{ 210{
@@ -229,7 +229,7 @@ static void step2b(int *ix, float *mdist, mat_t mstar, mat_t nmstar,
229} 229}
230 230
231/********************************************************/ 231/********************************************************/
232static void step3(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 232static void step3(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
233 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 233 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
234 int dmin) 234 int dmin)
235{ 235{
@@ -279,7 +279,7 @@ static void step3(int *ix, float *mdist, mat_t mstar, mat_t nmstar,
279} 279}
280 280
281/********************************************************/ 281/********************************************************/
282static void step4(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 282static void step4(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
283 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 283 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
284 int dmin, int row, int col) 284 int dmin, int row, int col)
285{ 285{
@@ -330,11 +330,11 @@ static void step4(int *ix, float *mdist, mat_t mstar, mat_t nmstar,
330} 330}
331 331
332/********************************************************/ 332/********************************************************/
333static void step5(int *ix, float *mdist, mat_t mstar, mat_t nmstar, 333static void step5(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
334 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols, 334 mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
335 int dmin) 335 int dmin)
336{ 336{
337 float h = 0, value; 337 int h = 0, value;
338 int row, col, found = 0; 338 int row, col, found = 0;
339 339
340 /* find smallest uncovered element h */ 340 /* find smallest uncovered element h */
@@ -378,15 +378,8 @@ static void step5(int *ix, float *mdist, mat_t mstar, mat_t nmstar,
378 dmin); 378 dmin);
379} 379}
380 380
381void match_fingers(int ix[DIM_FINGER], float A[DIM2_FINGER], int nrow, int ncol) 381void match_fingers(int ix[DIM_FINGER], int A[DIM2_FINGER], int nrow, int ncol)
382{ 382{
383 int i;
384 float max = 1;
385 for (i = 0; i < nrow * ncol; i++)
386 if (A[i] > max)
387 max = A[i];
388 for (i = 0; i < nrow * ncol; i++)
389 A[i] /= max;
390 ixoptimal(ix, A, nrow, ncol); 383 ixoptimal(ix, A, nrow, ncol);
391} 384}
392 385