add isl_basic_set_remove_divs
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 24 Oct 2008 08:32:55 +0000 (10:32 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 24 Oct 2008 08:32:55 +0000 (10:32 +0200)
include/isl_set.h
isl_map.c

index b99f790..2e36a43 100644 (file)
@@ -151,10 +151,12 @@ struct isl_set *isl_set_lower_bound_dim(struct isl_set *set,
                unsigned dim, isl_int value);
 struct isl_basic_set *isl_basic_set_remove_dims(struct isl_basic_set *bset,
                unsigned first, unsigned n);
+struct isl_basic_set *isl_basic_set_remove_divs(struct isl_basic_set *bset);
 struct isl_set *isl_set_eliminate_dims(struct isl_set *set,
                unsigned first, unsigned n);
 struct isl_set *isl_set_remove_dims(struct isl_set *set,
                unsigned first, unsigned n);
+struct isl_set *isl_set_remove_divs(struct isl_set *set);
 
 void isl_set_dump(struct isl_set *set, FILE *out, int indent);
 struct isl_set *isl_set_swap_vars(struct isl_set *set, unsigned n);
index f70202b..d573eb5 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -1432,6 +1432,8 @@ struct isl_basic_map *isl_basic_map_eliminate_vars(
        int i, j, k;
        unsigned total;
 
+       if (n == 0)
+               return bmap;
        if (!bmap)
                return NULL;
        total = bmap->nparam + bmap->n_in + bmap->n_out + bmap->n_div;
@@ -1518,6 +1520,8 @@ struct isl_set *isl_set_eliminate_dims(struct isl_set *set,
 {
        int i;
 
+       if (!set)
+               return NULL;
        if (n == 0)
                return set;
 
@@ -1547,6 +1551,40 @@ struct isl_set *isl_set_remove_dims(struct isl_set *set,
        return set;
 }
 
+struct isl_basic_set *isl_basic_set_remove_divs(struct isl_basic_set *bset)
+{
+       bset = isl_basic_set_eliminate_vars(bset, bset->nparam + bset->dim,
+                                               bset->n_div);
+       if (!bset)
+               return NULL;
+       bset->n_div = 0;
+       return bset;
+}
+
+struct isl_set *isl_set_remove_divs(struct isl_set *set)
+{
+       int i;
+
+       if (!set)
+               return NULL;
+       if (set->n == 0)
+               return set;
+
+       set = isl_set_cow(set);
+       if (!set)
+               return NULL;
+       
+       for (i = 0; i < set->n; ++i) {
+               set->p[i] = isl_basic_set_remove_divs(set->p[i]);
+               if (!set->p[i])
+                       goto error;
+       }
+       return set;
+error:
+       isl_set_free(set);
+       return NULL;
+}
+
 /* Project out n inputs starting at first using Fourier-Motzkin */
 struct isl_map *isl_map_remove_inputs(struct isl_map *map,
        unsigned first, unsigned n)