add isl_basic_map_eliminate
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 30 Sep 2011 15:24:36 +0000 (17:24 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 2 Oct 2011 09:03:35 +0000 (11:03 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/map.h
isl_map_simplify.c

index ad04919..c76cc84 100644 (file)
@@ -1728,6 +1728,10 @@ that maps (a wrapped version of) the input relation to its domain or range.
        __isl_give isl_set *isl_set_eliminate(
                __isl_take isl_set *set, enum isl_dim_type type,
                unsigned first, unsigned n);
+       __isl_give isl_basic_map *isl_basic_map_eliminate(
+               __isl_take isl_basic_map *bmap,
+               enum isl_dim_type type,
+               unsigned first, unsigned n);
 
 Eliminate the coefficients for the given dimensions from the constraints,
 without removing the dimensions.
index 6881353..f219f23 100644 (file)
@@ -168,6 +168,9 @@ __isl_give isl_basic_map *isl_basic_map_range_map(
 __isl_give isl_basic_map *isl_basic_map_remove_dims(
        __isl_take isl_basic_map *bmap,
        enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_eliminate(
+       __isl_take isl_basic_map *bmap,
+       enum isl_dim_type type, unsigned first, unsigned n);
 __isl_give isl_basic_map *isl_basic_map_from_basic_set(
        __isl_take isl_basic_set *bset, __isl_take isl_space *dim);
 struct isl_basic_set *isl_basic_set_from_basic_map(struct isl_basic_map *bmap);
index 08c4eb8..1998b58 100644 (file)
@@ -1369,6 +1369,30 @@ struct isl_basic_set *isl_basic_set_eliminate_vars(
                        (struct isl_basic_map *)bset, pos, n);
 }
 
+/* Eliminate the specified n dimensions starting at first from the
+ * constraints using Fourier-Motzkin.  The dimensions themselves
+ * are not removed.
+ */
+__isl_give isl_basic_map *isl_basic_map_eliminate(
+       __isl_take isl_basic_map *bmap,
+       enum isl_dim_type type, unsigned first, unsigned n)
+{
+       if (!bmap)
+               return NULL;
+       if (n == 0)
+               return bmap;
+
+       if (first + n > isl_basic_map_dim(bmap, type))
+               isl_die(bmap->ctx, isl_error_invalid,
+                       "index out of bounds", goto error);
+
+       first += isl_basic_map_offset(bmap, type) - 1;
+       return isl_basic_map_eliminate_vars(bmap, first, n);
+error:
+       isl_basic_map_free(bmap);
+       return NULL;
+}
+
 /* Don't assume equalities are in order, because align_divs
  * may have changed the order of the divs.
  */