-static __isl_give isl_mat *drop_redundant_rows(__isl_take isl_mat *rows)
-{
- struct isl_mat *H = NULL;
- int col;
- int row;
- int last_row;
-
- if (!rows)
- return NULL;
-
- isl_assert(rows->ctx, rows->n_row >= rows->n_col, goto error);
-
- if (rows->n_row == rows->n_col)
- return rows;
-
- H = isl_mat_left_hermite(isl_mat_copy(rows), 0, NULL, NULL);
- if (!H)
- goto error;
-
- last_row = rows->n_row;
- for (col = rows->n_col - 1; col >= 0; --col) {
- for (row = col; row < last_row; ++row)
- if (!isl_int_is_zero(H->row[row][col]))
- break;
- isl_assert(rows->ctx, row < last_row, goto error);
- if (row + 1 < last_row) {
- rows = isl_mat_drop_rows(rows, row + 1, last_row - (row + 1));
- if (rows->n_row == rows->n_col)
- break;
- }
- last_row = row;
- }
-
- isl_mat_free(H);
-
- return rows;
-error:
- isl_mat_free(H);
- isl_mat_free(rows);
- return NULL;
-}
-
-/* Given a set of d linearly independent bounding constraints of the
- * convex hull of "set", compute the constraint of a facet of "set".
- *
- * We first compute the intersection with the first bounding hyperplane
- * and remove the component corresponding to this hyperplane from
- * other bounds (in homogeneous space).
- * We then wrap around one of the remaining bounding constraints
- * and continue the process until all bounding constraints have been
- * taken into account.
- * The resulting linear combination of the bounding constraints will
- * correspond to a facet of the convex hull.
- */
-static struct isl_mat *initial_facet_constraint(struct isl_set *set,
- struct isl_mat *bounds)