From 97e5983c70da7f124c9e67ceb9b991b877cd1cc6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 7 Sep 2012 15:46:54 +0200 Subject: [PATCH] add isl_basic_set_drop_constraints_not_involving_dims Signed-off-by: Sven Verdoolaege --- doc/user.pod | 7 ++++++- include/isl/set.h | 3 +++ isl_affine_hull.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/doc/user.pod b/doc/user.pod index bd7c5b9b..d696d9f8 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2309,6 +2309,11 @@ per space. __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_basic_set * + isl_basic_set_drop_constraints_not_involving_dims( + __isl_take isl_basic_set *bset, + enum isl_dim_type type, + unsigned first, unsigned n); __isl_give isl_set * isl_set_drop_constraints_involving_dims( __isl_take isl_set *set, @@ -2320,7 +2325,7 @@ per space. enum isl_dim_type type, unsigned first, unsigned n); -These functions drop any constraints involving the specified dimensions. +These functions drop any constraints (not) involving the specified dimensions. Note that the result depends on the representation of the input. =item * Feasibility diff --git a/include/isl/set.h b/include/isl/set.h index 582dc67f..3e41d0e8 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -353,6 +353,9 @@ __isl_give isl_set *isl_set_split_dims(__isl_take isl_set *set, __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving_dims( __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first, unsigned n); +__isl_give isl_basic_set *isl_basic_set_drop_constraints_not_involving_dims( + __isl_take isl_basic_set *bset, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_set *isl_set_drop_constraints_involving_dims( __isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n); diff --git a/isl_affine_hull.c b/isl_affine_hull.c index 655eb40a..d3d3b7de 100644 --- a/isl_affine_hull.c +++ b/isl_affine_hull.c @@ -527,6 +527,55 @@ __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving( return isl_basic_map_drop_constraints_involving(bset, first, n); } +/* Drop all constraints in bmap that do not involve any of the dimensions + * first to first + n - 1 of the given type. + */ +__isl_give isl_basic_map *isl_basic_map_drop_constraints_not_involving_dims( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type, unsigned first, unsigned n) +{ + int i; + unsigned dim; + + if (n == 0) + return isl_basic_map_set_to_empty(bmap); + bmap = isl_basic_map_cow(bmap); + if (!bmap) + return NULL; + + dim = isl_basic_map_dim(bmap, type); + if (first + n > dim || first + n < first) + isl_die(isl_basic_map_get_ctx(bmap), isl_error_invalid, + "index out of bounds", return isl_basic_map_free(bmap)); + + first += isl_basic_map_offset(bmap, type) - 1; + + for (i = bmap->n_eq - 1; i >= 0; --i) { + if (isl_seq_first_non_zero(bmap->eq[i] + 1 + first, n) != -1) + continue; + isl_basic_map_drop_equality(bmap, i); + } + + for (i = bmap->n_ineq - 1; i >= 0; --i) { + if (isl_seq_first_non_zero(bmap->ineq[i] + 1 + first, n) != -1) + continue; + isl_basic_map_drop_inequality(bmap, i); + } + + return bmap; +} + +/* Drop all constraints in bset that do not involve any of the dimensions + * first to first + n - 1 of the given type. + */ +__isl_give isl_basic_set *isl_basic_set_drop_constraints_not_involving_dims( + __isl_take isl_basic_set *bset, + enum isl_dim_type type, unsigned first, unsigned n) +{ + return isl_basic_map_drop_constraints_not_involving_dims(bset, + type, first, n); +} + /* Drop all constraints in bmap that involve any of the dimensions * first to first + n - 1 of the given type. */ -- 2.11.4.GIT