-/* Drop rows in "rows" that are redundant with respect to earlier rows,
- * assuming that "rows" is of full column rank.
- *
- * We compute the column echelon form. The non-redundant rows are
- * those that are the first to contain a non-zero entry in a column.
- * All the other rows can be removed.
- */
-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.
+/* Compute the constraint of a facet of "set".
+ *
+ * We first compute the intersection with a bounding constraint
+ * that is orthogonal to one of the coordinate axes.
+ * If the affine hull of this intersection has only one equality,
+ * we have found a facet.
+ * Otherwise, we wrap the current bounding constraint around
+ * one of the equalities of the face (one that is not equal to
+ * the current bounding constraint).
+ * This process continues until we have found a facet.
+ * The dimension of the intersection increases by at least
+ * one on each iteration, so termination is guaranteed.