simplify hungarian interface
authorMatthias Braun <matze@braunis.de>
Mon, 2 Mar 2009 00:12:32 +0000 (00:12 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 2 Mar 2009 00:12:32 +0000 (00:12 +0000)
[r25579]

include/libfirm/adt/hungarian.h
ir/adt/hungarian.c
ir/be/beschedrss.c

index 1c5851a..8a65361 100644 (file)
@@ -47,13 +47,12 @@ typedef struct _hungarian_problem_t hungarian_problem_t;
  *
  * @param rows       Number of rows 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:
  *                   HUNGARIAN_MATCH_PERFECT - every nodes matches another node
  *                   HUNGARIAN_MATCH_NORMAL  - matchings of nodes having no edge getting removed
  * @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.
@@ -92,6 +91,6 @@ int hungarian_solve(hungarian_problem_t *p, int *assignment, int *final_cost, in
  * Print the cost matrix.
  * @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_ */
index 32f1d68..c38cb47 100644 (file)
@@ -49,7 +49,6 @@ struct _hungarian_problem_t {
        int      num_rows;          /**< number of rows */
        int      num_cols;          /**< number of columns */
        int      **cost;            /**< the cost matrix */
-       int      width;             /**< the width for cost matrix dumper */
        int      max_cost;          /**< the maximal costs in the matrix */
        int      match_type;        /**< PERFECT or NORMAL matching */
        bitset_t *missing_left;     /**< left side nodes having no edge to the right side */
@@ -58,7 +57,7 @@ struct _hungarian_problem_t {
        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);
        memset(p, 0, sz);
        return p;
@@ -78,14 +77,14 @@ static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) {
        fprintf(f, "\n");
 }
 
-void hungarian_print_costmatrix(hungarian_problem_t *p) {
-       hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, p->width);
+void hungarian_print_costmatrix(hungarian_problem_t *p, int width) {
+       hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, width);
 }
 
 /**
  * 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;
        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
 
        p->num_rows   = rows;
        p->num_cols   = cols;
-       p->width      = width;
        p->match_type = match_type;
 
        /*
index 38503ce..8521d6a 100644 (file)
@@ -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)
                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,