forked from omarocegueda/registration
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hungarian.h
39 lines (38 loc) · 1.01 KB
/
hungarian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef HUNGARIAN_H
#define HUNGARIAN_H
//-----ad-hoc implementation-----
#define HUNGARIAN_DATA_TYPE double
#define HUNGARIAN_EPSILON 1e-10
#define HUNGARIAN_IS_ZERO(x) (fabs(x)<HUNGARIAN_EPSILON)
#define HUNGARIAN_EQUALS(a,b) (fabs((a)-(b))<HUNGARIAN_EPSILON)
//------------------------
class Hungarian{
private:
bool *columnChecked;
bool *rowChecked;
int *starRowPosition;
int *starColumnPosition;
int *primeRowPosition;
int *primeColumnPosition;
HUNGARIAN_DATA_TYPE *A;
HUNGARIAN_DATA_TYPE *M;
protected:
int n;
int maxSize;
void hungarianStep1(void);
int hungarianStep2(void);
void hungarianStep4(void);
int hungarianStep5(void);
void hungarianStep6(void);
void free(void);
void allocate(int _n);
public:
Hungarian(int _n);
void setSize(int _n);
void setCost(int i, int j, HUNGARIAN_DATA_TYPE cost);
void setAllCosts(HUNGARIAN_DATA_TYPE val);
HUNGARIAN_DATA_TYPE solve(void);
void getAssignment(int *assignment);
~Hungarian();
};
#endif