From 09e98fa1ce67cd0a53056fe71507f23733536696 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 6 Nov 2010 15:36:38 +0100 Subject: [PATCH] add isl_union_set_polyhedral_hull Signed-off-by: Sven Verdoolaege --- doc/user.pod | 17 +++++++++++++++++ include/isl_map.h | 1 + include/isl_set.h | 1 + include/isl_union_map.h | 2 ++ include/isl_union_set.h | 2 ++ isl_convex_hull.c | 13 +++++++++++++ isl_union_map.c | 21 +++++++++++++++++++++ 7 files changed, 57 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 1217e37..28e33cc 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1298,6 +1298,23 @@ of the constraints describing the basic sets or relations in the input. In case of union sets and relations, the affine hull is computed per space. +=item * Polyhedral hull + + __isl_give isl_basic_set *isl_set_polyhedral_hull( + __isl_take isl_set *set); + __isl_give isl_basic_map *isl_map_polyhedral_hull( + __isl_take isl_map *map); + __isl_give isl_union_set *isl_union_set_polyhedral_hull( + __isl_take isl_union_set *uset); + __isl_give isl_union_map *isl_union_map_polyhedral_hull( + __isl_take isl_union_map *umap); + +These functions compute a single basic set or relation +not involving any existentially quantified variables +that contains the whole input set or relation. +In case of union sets and relations, the polyhedral hull is computed +per space. + =item * Power __isl_give isl_map *isl_map_power(__isl_take isl_map *map, diff --git a/include/isl_map.h b/include/isl_map.h index 8b96dd8..38058d3 100644 --- a/include/isl_map.h +++ b/include/isl_map.h @@ -349,6 +349,7 @@ __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map); struct isl_map *isl_map_detect_equalities(struct isl_map *map); __isl_give isl_basic_map *isl_map_affine_hull(__isl_take isl_map *map); __isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map); +__isl_give isl_basic_map *isl_map_polyhedral_hull(__isl_take isl_map *map); __isl_give isl_basic_map *isl_basic_map_add(__isl_take isl_basic_map *bmap, enum isl_dim_type type, unsigned n); __isl_give isl_map *isl_map_add_dims(__isl_take isl_map *map, diff --git a/include/isl_set.h b/include/isl_set.h index b67f837..5e81b19 100644 --- a/include/isl_set.h +++ b/include/isl_set.h @@ -232,6 +232,7 @@ __isl_give isl_point *isl_set_sample_point(__isl_take isl_set *set); __isl_give isl_set *isl_set_detect_equalities(__isl_take isl_set *set); __isl_give isl_basic_set *isl_set_affine_hull(__isl_take isl_set *set); __isl_give isl_basic_set *isl_set_convex_hull(__isl_take isl_set *set); +__isl_give isl_basic_set *isl_set_polyhedral_hull(__isl_take isl_set *set); __isl_give isl_basic_set *isl_set_simple_hull(__isl_take isl_set *set); struct isl_basic_set *isl_set_bounded_simple_hull(struct isl_set *set); __isl_give isl_set *isl_set_recession_cone(__isl_take isl_set *set); diff --git a/include/isl_union_map.h b/include/isl_union_map.h index 7dfe160..306ac2f 100644 --- a/include/isl_union_map.h +++ b/include/isl_union_map.h @@ -33,6 +33,8 @@ __isl_give isl_union_map *isl_union_map_range_map( __isl_give isl_union_map *isl_union_map_affine_hull( __isl_take isl_union_map *umap); +__isl_give isl_union_map *isl_union_map_polyhedral_hull( + __isl_take isl_union_map *umap); __isl_give isl_union_map *isl_union_map_coalesce( __isl_take isl_union_map *umap); __isl_give isl_union_map *isl_union_map_compute_divs( diff --git a/include/isl_union_set.h b/include/isl_union_set.h index ecd5491..010a4a9 100644 --- a/include/isl_union_set.h +++ b/include/isl_union_set.h @@ -18,6 +18,8 @@ __isl_give isl_dim *isl_union_set_get_dim(__isl_keep isl_union_set *uset); __isl_give isl_union_set *isl_union_set_affine_hull( __isl_take isl_union_set *uset); +__isl_give isl_union_set *isl_union_set_polyhedral_hull( + __isl_take isl_union_set *uset); __isl_give isl_union_set *isl_union_set_coalesce( __isl_take isl_union_set *uset); __isl_give isl_union_set *isl_union_set_compute_divs( diff --git a/isl_convex_hull.c b/isl_convex_hull.c index 8c51986..1552492 100644 --- a/isl_convex_hull.c +++ b/isl_convex_hull.c @@ -1956,6 +1956,19 @@ struct isl_basic_set *isl_set_convex_hull(struct isl_set *set) isl_map_convex_hull((struct isl_map *)set); } +__isl_give isl_basic_map *isl_map_polyhedral_hull(__isl_take isl_map *map) +{ + isl_basic_map *hull; + + hull = isl_map_convex_hull(map); + return isl_basic_map_remove_divs(hull); +} + +__isl_give isl_basic_set *isl_set_polyhedral_hull(__isl_take isl_set *set) +{ + return (isl_basic_set *)isl_map_polyhedral_hull((isl_map *)set); +} + struct sh_data_entry { struct isl_hash_table *table; struct isl_tab *tab; diff --git a/isl_union_map.c b/isl_union_map.c index 836f23f..c7cb827 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -934,6 +934,27 @@ __isl_give isl_union_set *isl_union_set_affine_hull( return isl_union_map_affine_hull(uset); } +static int polyhedral_entry(void **entry, void *user) +{ + isl_map **map = (isl_map **)entry; + + *map = isl_map_from_basic_map(isl_map_polyhedral_hull(*map)); + + return *map ? 0 : -1; +} + +__isl_give isl_union_map *isl_union_map_polyhedral_hull( + __isl_take isl_union_map *umap) +{ + return un_op(umap, &polyhedral_entry, 1); +} + +__isl_give isl_union_set *isl_union_set_polyhedral_hull( + __isl_take isl_union_set *uset) +{ + return isl_union_map_polyhedral_hull(uset); +} + static int coalesce_entry(void **entry, void *user) { isl_map **map = (isl_map **)entry; -- 2.7.4