From 07279b64e6328b02317769f5b6e1ec18e9743600 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 25 May 2016 13:23:22 +0200 Subject: [PATCH] add isl_{set,map}_drop_constraints_not_involving_dims Signed-off-by: Sven Verdoolaege --- doc/user.pod | 10 ++++++++++ include/isl/map.h | 3 +++ include/isl/set.h | 3 +++ isl_affine_hull.c | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index 7689b244..f0a07691 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4926,6 +4926,11 @@ per space. __isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_set * + isl_set_drop_constraints_not_involving_dims( + __isl_take isl_set *set, + enum isl_dim_type type, + unsigned first, unsigned n); #include __isl_give isl_basic_map * @@ -4943,6 +4948,11 @@ per space. __isl_take isl_map *map, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_map * + isl_map_drop_constraints_not_involving_dims( + __isl_take isl_map *map, + enum isl_dim_type type, + unsigned first, unsigned n); These functions drop any constraints (not) involving the specified dimensions. Note that the result depends on the representation of the input. diff --git a/include/isl/map.h b/include/isl/map.h index 142979b6..43de1de9 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -579,6 +579,9 @@ __isl_give isl_basic_map *isl_basic_map_drop_constraints_not_involving_dims( __isl_give isl_map *isl_map_drop_constraints_involving_dims( __isl_take isl_map *map, enum isl_dim_type type, unsigned first, unsigned n); +__isl_give isl_map *isl_map_drop_constraints_not_involving_dims( + __isl_take isl_map *map, + enum isl_dim_type type, unsigned first, unsigned n); isl_bool isl_basic_map_involves_dims(__isl_keep isl_basic_map *bmap, enum isl_dim_type type, unsigned first, unsigned n); diff --git a/include/isl/set.h b/include/isl/set.h index 185fa3d0..2d5901ba 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -357,6 +357,9 @@ __isl_give isl_basic_set *isl_basic_set_drop_constraints_not_involving_dims( __isl_give isl_set *isl_set_drop_constraints_involving_dims( __isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n); +__isl_give isl_set *isl_set_drop_constraints_not_involving_dims( + __isl_take isl_set *set, + enum isl_dim_type type, unsigned first, unsigned n); isl_bool isl_basic_set_involves_dims(__isl_keep isl_basic_set *bset, enum isl_dim_type type, unsigned first, unsigned n); diff --git a/isl_affine_hull.c b/isl_affine_hull.c index fdf75706..f1214a36 100644 --- a/isl_affine_hull.c +++ b/isl_affine_hull.c @@ -621,20 +621,18 @@ __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving_dims( type, first, n); } -/* Drop all constraints in map that involve any of the dimensions - * first to first + n - 1 of the given type. +/* Drop constraints from "map" by applying "drop" to each basic map. */ -__isl_give isl_map *isl_map_drop_constraints_involving_dims( - __isl_take isl_map *map, - enum isl_dim_type type, unsigned first, unsigned n) +__isl_give isl_map *drop_constraints(__isl_take isl_map *map, + enum isl_dim_type type, unsigned first, unsigned n, + __isl_give isl_basic_map *(*drop)(__isl_take isl_basic_map *bmap, + enum isl_dim_type type, unsigned first, unsigned n)) { int i; unsigned dim; if (!map) return NULL; - if (n == 0) - return map; dim = isl_map_dim(map, type); if (first + n > dim || first + n < first) @@ -646,8 +644,7 @@ __isl_give isl_map *isl_map_drop_constraints_involving_dims( return NULL; for (i = 0; i < map->n; ++i) { - map->p[i] = isl_basic_map_drop_constraints_involving_dims( - map->p[i], type, first, n); + map->p[i] = drop(map->p[i], type, first, n); if (!map->p[i]) return isl_map_free(map); } @@ -658,6 +655,35 @@ __isl_give isl_map *isl_map_drop_constraints_involving_dims( return map; } +/* Drop all constraints in map that involve any of the dimensions + * first to first + n - 1 of the given type. + */ +__isl_give isl_map *isl_map_drop_constraints_involving_dims( + __isl_take isl_map *map, + enum isl_dim_type type, unsigned first, unsigned n) +{ + if (n == 0) + return map; + return drop_constraints(map, type, first, n, + &isl_basic_map_drop_constraints_involving_dims); +} + +/* Drop all constraints in "map" that do not involve any of the dimensions + * first to first + n - 1 of the given type. + */ +__isl_give isl_map *isl_map_drop_constraints_not_involving_dims( + __isl_take isl_map *map, + enum isl_dim_type type, unsigned first, unsigned n) +{ + if (n == 0) { + isl_space *space = isl_map_get_space(map); + isl_map_free(map); + return isl_map_universe(space); + } + return drop_constraints(map, type, first, n, + &isl_basic_map_drop_constraints_not_involving_dims); +} + /* Drop all constraints in set that involve any of the dimensions * first to first + n - 1 of the given type. */ @@ -668,6 +694,16 @@ __isl_give isl_set *isl_set_drop_constraints_involving_dims( return isl_map_drop_constraints_involving_dims(set, type, first, n); } +/* Drop all constraints in "set" that do not involve any of the dimensions + * first to first + n - 1 of the given type. + */ +__isl_give isl_set *isl_set_drop_constraints_not_involving_dims( + __isl_take isl_set *set, + enum isl_dim_type type, unsigned first, unsigned n) +{ + return isl_map_drop_constraints_not_involving_dims(set, type, first, n); +} + /* Construct an initial underapproximation of the hull of "bset" * from "sample" and any of its adjacent points that also belong to "bset". */ -- 2.11.4.GIT