#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<<(row))) #define CLEARBIT2(m, row, col) (m[col]&=~(1U<<(row))) /********************************************************/ static void buildixvector(int *ix, col_t *mstar, int nrows, int ncols) { int row, col; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { if (GETBIT2(mstar, row, col)) { ix[row] = col; break; } } } } /********************************************************/ 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); static void step2b(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); static void step3 (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); 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); static void step5 (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); static void ixoptimal(int *ix, float *mdist, int nrows, int ncols) { float *mdistTemp, *mdistEnd, *columnEnd, value, minValue; int dmin, row, col; col_t ccol,crow, mstar[DIM_FINGER],mprime[DIM_FINGER],nmstar[DIM_FINGER]; ccol = crow = 0; memset(mstar, 0, sizeof(mstar)); memset(mprime, 0, sizeof(mprime)); memset(nmstar, 0, sizeof(nmstar)); /* initialization */ for(row=0; row ncols) */ { dmin = ncols; for(col=0; col