Commit e718abad authored by Matthias Braun's avatar Matthias Braun
Browse files

simplify hungarian interface

[r25579]
parent f250d98f
...@@ -47,13 +47,12 @@ typedef struct _hungarian_problem_t hungarian_problem_t; ...@@ -47,13 +47,12 @@ typedef struct _hungarian_problem_t hungarian_problem_t;
* *
* @param rows Number of rows in the given matrix * @param rows Number of rows in the given matrix
* @param cols Number of cols in the given matrix * @param cols Number of cols in the given matrix
* @param width Element width for matrix dumping
* @param match_type The type of matching: * @param match_type The type of matching:
* HUNGARIAN_MATCH_PERFECT - every nodes matches another node * HUNGARIAN_MATCH_PERFECT - every nodes matches another node
* HUNGARIAN_MATCH_NORMAL - matchings of nodes having no edge getting removed * HUNGARIAN_MATCH_NORMAL - matchings of nodes having no edge getting removed
* @return The problem object. * @return The problem object.
*/ */
hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type); hungarian_problem_t *hungarian_new(int rows, int cols, int match_type);
/** /**
* Adds an edge from left to right with some costs. * Adds an edge from left to right with some costs.
...@@ -92,6 +91,6 @@ int hungarian_solve(hungarian_problem_t *p, int *assignment, int *final_cost, in ...@@ -92,6 +91,6 @@ int hungarian_solve(hungarian_problem_t *p, int *assignment, int *final_cost, in
* Print the cost matrix. * Print the cost matrix.
* @param p The hungarian object * @param p The hungarian object
*/ */
void hungarian_print_costmatrix(hungarian_problem_t *p); void hungarian_print_costmatrix(hungarian_problem_t *p, int cost_width);
#endif /* _HUNGARIAN_H_ */ #endif /* _HUNGARIAN_H_ */
...@@ -49,7 +49,6 @@ struct _hungarian_problem_t { ...@@ -49,7 +49,6 @@ struct _hungarian_problem_t {
int num_rows; /**< number of rows */ int num_rows; /**< number of rows */
int num_cols; /**< number of columns */ int num_cols; /**< number of columns */
int **cost; /**< the cost matrix */ int **cost; /**< the cost matrix */
int width; /**< the width for cost matrix dumper */
int max_cost; /**< the maximal costs in the matrix */ int max_cost; /**< the maximal costs in the matrix */
int match_type; /**< PERFECT or NORMAL matching */ int match_type; /**< PERFECT or NORMAL matching */
bitset_t *missing_left; /**< left side nodes having no edge to the right side */ bitset_t *missing_left; /**< left side nodes having no edge to the right side */
...@@ -58,7 +57,7 @@ struct _hungarian_problem_t { ...@@ -58,7 +57,7 @@ struct _hungarian_problem_t {
DEBUG_ONLY(firm_dbg_module_t *dbg); DEBUG_ONLY(firm_dbg_module_t *dbg);
}; };
static inline void *get_init_mem(struct obstack *obst, long sz) { static inline void *get_init_mem(struct obstack *obst, size_t sz) {
void *p = obstack_alloc(obst, sz); void *p = obstack_alloc(obst, sz);
memset(p, 0, sz); memset(p, 0, sz);
return p; return p;
...@@ -78,14 +77,14 @@ static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) { ...@@ -78,14 +77,14 @@ static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) {
fprintf(f, "\n"); fprintf(f, "\n");
} }
void hungarian_print_costmatrix(hungarian_problem_t *p) { void hungarian_print_costmatrix(hungarian_problem_t *p, int width) {
hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, p->width); hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, width);
} }
/** /**
* Create the object and allocate memory for the data structures. * Create the object and allocate memory for the data structures.
*/ */
hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type) { hungarian_problem_t *hungarian_new(int rows, int cols, int match_type) {
int i; int i;
hungarian_problem_t *p = XMALLOCZ(hungarian_problem_t); hungarian_problem_t *p = XMALLOCZ(hungarian_problem_t);
...@@ -102,7 +101,6 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type ...@@ -102,7 +101,6 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type
p->num_rows = rows; p->num_rows = rows;
p->num_cols = cols; p->num_cols = cols;
p->width = width;
p->match_type = match_type; p->match_type = match_type;
/* /*
......
...@@ -1469,7 +1469,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera ...@@ -1469,7 +1469,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
if (pset_count(dvg->edges) == 0) if (pset_count(dvg->edges) == 0)
return NULL; return NULL;
bp = hungarian_new(n, n, 1, HUNGARIAN_MATCH_NORMAL); bp = hungarian_new(n, n, HUNGARIAN_MATCH_NORMAL);
/* /*
At first, we build an index map for the nodes in the DVG, At first, we build an index map for the nodes in the DVG,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment