From 8067766b3ac97f48152f95d8b1f62aeb97b11301 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 24 Oct 2008 10:32:55 +0200 Subject: [PATCH] add isl_basic_set_remove_divs --- include/isl_set.h | 2 ++ isl_map.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/isl_set.h b/include/isl_set.h index b99f790..2e36a43 100644 --- a/include/isl_set.h +++ b/include/isl_set.h @@ -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); diff --git a/isl_map.c b/isl_map.c index f70202b..d573eb5 100644 --- 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) -- 2.7.4