add isl_{set,map}_drop_constraints_involving_dims
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 20 Aug 2012 12:51:55 +0000 (14:51 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 17 Sep 2012 15:15:48 +0000 (17:15 +0200)
We implement these functions on top of the existing
isl_basic_set_drop_constraints_involving which handles dimensions
in terms of absolute positions.  We may want to convert the users
of this old function over to the new functions at some point.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/map.h
include/isl/set.h
isl_affine_hull.c

index b5c98de..bd7c5b9 100644 (file)
@@ -2302,6 +2302,27 @@ that contains the whole input set or relation.
 In case of union sets and relations, the polyhedral hull is computed
 per space.
 
+=item * Other approximations
+
+       __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_set *
+       isl_set_drop_constraints_involving_dims(
+               __isl_take isl_set *set,
+               enum isl_dim_type type,
+               unsigned first, unsigned n);
+       __isl_give isl_map *
+       isl_map_drop_constraints_involving_dims(
+               __isl_take isl_map *map,
+               enum isl_dim_type type,
+               unsigned first, unsigned n);
+
+These functions drop any constraints involving the specified dimensions.
+Note that the result depends on the representation of the input.
+
 =item * Feasibility
 
        __isl_give isl_basic_set *isl_basic_set_sample(
index 50aa1f7..1386e34 100644 (file)
@@ -551,6 +551,10 @@ __isl_give isl_map *isl_basic_map_compute_divs(__isl_take isl_basic_map *bmap);
 __isl_give isl_map *isl_map_compute_divs(__isl_take isl_map *map);
 __isl_give isl_map *isl_map_align_divs(__isl_take isl_map *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);
+
 int isl_basic_map_involves_dims(__isl_keep isl_basic_map *bmap,
        enum isl_dim_type type, unsigned first, unsigned n);
 int isl_map_involves_dims(__isl_keep isl_map *map,
index f38ffe0..582dc67 100644 (file)
@@ -350,6 +350,13 @@ __isl_give isl_set *isl_set_remove_divs(__isl_take isl_set *set);
 __isl_give isl_set *isl_set_split_dims(__isl_take isl_set *set,
        enum isl_dim_type type, unsigned first, unsigned n);
 
+__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_set *isl_set_drop_constraints_involving_dims(
+       __isl_take isl_set *set,
+       enum isl_dim_type type, unsigned first, unsigned n);
+
 int isl_basic_set_involves_dims(__isl_keep isl_basic_set *bset,
        enum isl_dim_type type, unsigned first, unsigned n);
 int isl_set_involves_dims(__isl_keep isl_set *set,
index 91bb365..655eb40 100644 (file)
@@ -487,35 +487,123 @@ error:
        return NULL;
 }
 
-/* Drop all constraints in bset that involve any of the dimensions
+/* Drop all constraints in bmap that involve any of the dimensions
  * first to first+n-1.
  */
-__isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
-       __isl_take isl_basic_set *bset, unsigned first, unsigned n)
+static __isl_give isl_basic_map *isl_basic_map_drop_constraints_involving(
+       __isl_take isl_basic_map *bmap, unsigned first, unsigned n)
 {
        int i;
 
        if (n == 0)
-               return bset;
+               return bmap;
 
-       bset = isl_basic_set_cow(bset);
+       bmap = isl_basic_map_cow(bmap);
 
-       if (!bset)
+       if (!bmap)
                return NULL;
 
-       for (i = bset->n_eq - 1; i >= 0; --i) {
-               if (isl_seq_first_non_zero(bset->eq[i] + 1 + first, n) == -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_set_drop_equality(bset, i);
+               isl_basic_map_drop_equality(bmap, i);
        }
 
-       for (i = bset->n_ineq - 1; i >= 0; --i) {
-               if (isl_seq_first_non_zero(bset->ineq[i] + 1 + first, n) == -1)
+       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_set_drop_inequality(bset, i);
+               isl_basic_map_drop_inequality(bmap, i);
        }
 
-       return bset;
+       return bmap;
+}
+
+/* Drop all constraints in bset that involve any of the dimensions
+ * first to first+n-1.
+ */
+__isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
+       __isl_take isl_basic_set *bset, unsigned first, unsigned n)
+{
+       return isl_basic_map_drop_constraints_involving(bset, first, n);
+}
+
+/* Drop all constraints in bmap that involve any of the dimensions
+ * first to first + n - 1 of the given type.
+ */
+__isl_give isl_basic_map *isl_basic_map_drop_constraints_involving_dims(
+       __isl_take isl_basic_map *bmap,
+       enum isl_dim_type type, unsigned first, unsigned n)
+{
+       unsigned dim;
+
+       if (!bmap)
+               return NULL;
+       if (n == 0)
+               return bmap;
+
+       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));
+
+       bmap = isl_basic_map_remove_divs_involving_dims(bmap, type, first, n);
+       first += isl_basic_map_offset(bmap, type) - 1;
+       return isl_basic_map_drop_constraints_involving(bmap, first, n);
+}
+
+/* Drop all constraints in bset that involve any of the dimensions
+ * first to first + n - 1 of the given type.
+ */
+__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)
+{
+       return isl_basic_map_drop_constraints_involving_dims(bset,
+                                                           type, first, n);
+}
+
+/* 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)
+{
+       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)
+               isl_die(isl_map_get_ctx(map), isl_error_invalid,
+                       "index out of bounds", return isl_map_free(map));
+
+       map = isl_map_cow(map);
+       if (!map)
+               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);
+               if (!map->p[i])
+                       return isl_map_free(map);
+       }
+
+       return map;
+}
+
+/* Drop all constraints in set that involve any of the dimensions
+ * first to first + n - 1 of the given type.
+ */
+__isl_give isl_set *isl_set_drop_constraints_involving_dims(
+       __isl_take isl_set *set,
+       enum isl_dim_type type, unsigned first, unsigned n)
+{
+       return isl_map_drop_constraints_involving_dims(set, type, first, n);
 }
 
 /* Construct an initial underapproximatino of the hull of "bset"