*bmap = isl_basic_map_set_to_empty(*bmap);
return 0;
}
- isl_int_addmul(*opt_n, *opt_d, c[0]);
+ if (opt_d)
+ isl_int_addmul(*opt_n, *opt_d, c[0]);
+ else
+ isl_int_add(*opt_n, *opt_n, c[0]);
return !isl_int_is_neg(*opt_n);
}
+int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
+ isl_int *c, isl_int *opt_n, isl_int *opt_d)
+{
+ return isl_basic_map_constraint_is_redundant(
+ (struct isl_basic_map **)bset, c, opt_n, opt_d);
+}
+
/* Compute the convex hull of a basic map, by removing the redundant
* constraints. If the minimal value along the normal of a constraint
* is the same if the constraint is removed, then the constraint is redundant.
isl_int opt;
struct isl_basic_set *combined;
struct isl_ctx *ctx;
- enum isl_lp_result res = isl_lp_ok;
if (!bset || !context)
goto error;
ctx = context->ctx;
isl_int_init(opt);
for (i = bset->n_ineq-1; i >= 0; --i) {
+ int redundant;
set_swap_inequality(context, i, context->n_ineq-1);
context->n_ineq--;
- res = isl_solve_lp((struct isl_basic_map *)context, 0,
- context->ineq[context->n_ineq]+1, ctx->one, &opt, NULL);
- context->n_ineq++;
- set_swap_inequality(context, i, context->n_ineq-1);
- if (res == isl_lp_unbounded)
- continue;
- if (res == isl_lp_error)
- break;
- if (res == isl_lp_empty) {
+ redundant = isl_basic_set_constraint_is_redundant(&context,
+ context->ineq[context->n_ineq], &opt, NULL);
+ if (redundant == -1) {
+ isl_int_clear(opt);
+ goto error;
+ }
+ if (F_ISSET(context, ISL_BASIC_MAP_EMPTY)) {
bset = isl_basic_set_set_to_empty(bset);
break;
}
- isl_int_add(opt, opt, context->ineq[i][0]);
- if (!isl_int_is_neg(opt)) {
+ context->n_ineq++;
+ set_swap_inequality(context, i, context->n_ineq-1);
+ if (redundant) {
isl_basic_set_drop_inequality(context, i);
isl_basic_set_drop_inequality(bset, i);
}
}
isl_int_clear(opt);
- if (res == isl_lp_error)
- goto error;
done:
isl_basic_set_free(context);
return bset;
struct isl_basic_set *isl_basic_set_eliminate_vars(
struct isl_basic_set *bset, unsigned pos, unsigned n);
+
+int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
+ isl_int *c, isl_int *opt_n, isl_int *opt_d);