From 9f3fa5a33d6bd92f7f37d8ce2dcf0fab2cc5840e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 16 Sep 2008 21:16:32 +0200 Subject: [PATCH] add isl_set_from_map --- include/isl_map.h | 1 + isl_map.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/isl_map.h b/include/isl_map.h index ad667a6..00fbeee 100644 --- a/include/isl_map.h +++ b/include/isl_map.h @@ -199,6 +199,7 @@ struct isl_set *isl_map_domain(struct isl_map *bmap); struct isl_map *isl_map_from_basic_map(struct isl_basic_map *bmap); struct isl_map *isl_map_from_set(struct isl_set *set, unsigned n_in, unsigned n_out); +struct isl_set *isl_set_from_map(struct isl_map *map); int isl_map_is_empty(struct isl_map *map); int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2); diff --git a/isl_map.c b/isl_map.c index 3b3e462..b1b280d 100644 --- a/isl_map.c +++ b/isl_map.c @@ -2174,6 +2174,30 @@ error: return NULL; } +struct isl_set *isl_set_from_map(struct isl_map *map) +{ + int i; + struct isl_set *set = NULL; + + if (!map) + return NULL; + map = isl_map_cow(map); + if (!map) + return NULL; + map->n_out += map->n_in; + map->n_in = 0; + set = (struct isl_set *)map; + for (i = 0; i < map->n; ++i) { + set->p[i] = isl_basic_set_from_basic_map(map->p[i]); + if (!set->p[i]) + goto error; + } + return set; +error: + isl_map_free(map); + return NULL; +} + struct isl_map *isl_map_alloc(struct isl_ctx *ctx, unsigned nparam, unsigned in, unsigned out, int n, unsigned flags) -- 2.7.4