+/* Compute a superset of the convex hull of map that is described
+ * by only translates of the constraints in the constituents of map.
+ *
+ * The implementation is not very efficient. In particular, if
+ * constraints with the same normal appear in more than one
+ * basic map, they will be (re)examined each time.
+ */
+struct isl_basic_map *isl_map_simple_hull(struct isl_map *map)
+{
+ struct isl_set *set = NULL;
+ struct isl_basic_map *model = NULL;
+ struct isl_basic_map *hull;
+ struct isl_basic_set *bset = NULL;
+
+ if (!map)
+ return NULL;
+ if (map->n == 0) {
+ hull = isl_basic_map_empty_like_map(map);
+ isl_map_free(map);
+ return hull;
+ }
+ if (map->n == 1) {
+ hull = isl_basic_map_copy(map->p[0]);
+ isl_map_free(map);
+ return hull;
+ }
+
+ map = isl_map_align_divs(map);
+ model = isl_basic_map_copy(map->p[0]);
+
+ set = isl_map_underlying_set(map);
+
+ bset = uset_simple_hull(set);
+
+ hull = isl_basic_map_overlying_set(bset, model);
+
+ return hull;
+}
+