From 2ad16c30db17648772cc397cc6dd29a7ba3e440a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 27 Jul 2014 17:23:26 +0200 Subject: [PATCH] add isl_basic_set_list_intersect Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/set.h | 2 ++ isl_map.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 78483729..9eb4b241 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3037,6 +3037,8 @@ the same (number of) parameters. __isl_give isl_basic_set *isl_basic_set_intersect( __isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2); + __isl_give isl_basic_set *isl_basic_set_list_intersect( + __isl_take struct isl_basic_set_list *list); __isl_give isl_set *isl_set_intersect_params( __isl_take isl_set *set, __isl_take isl_set *params); @@ -3093,6 +3095,8 @@ The second argument to the C<_params> functions needs to be a parametric (basic) set. For the other functions, a parametric set for either argument is only allowed if the other argument is a parametric set as well. +The list passed to C needs to have +at least one element and all elements need to live in the same space. =item * Union diff --git a/include/isl/set.h b/include/isl/set.h index a73a1aa4..69cfa891 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -139,6 +139,8 @@ __isl_give isl_basic_set *isl_basic_set_detect_equalities( __isl_give isl_basic_set *isl_basic_set_remove_redundancies( __isl_take isl_basic_set *bset); __isl_give isl_set *isl_set_remove_redundancies(__isl_take isl_set *set); +__isl_give isl_basic_set *isl_basic_set_list_intersect( + __isl_take struct isl_basic_set_list *list); __isl_give isl_basic_set *isl_basic_set_list_product( __isl_take struct isl_basic_set_list *list); diff --git a/isl_map.c b/isl_map.c index 573fb241..e16a5722 100644 --- a/isl_map.c +++ b/isl_map.c @@ -2,6 +2,7 @@ * Copyright 2008-2009 Katholieke Universiteit Leuven * Copyright 2010 INRIA Saclay * Copyright 2012-2014 Ecole Normale Superieure + * Copyright 2014 INRIA Rocquencourt * * Use of this software is governed by the MIT license * @@ -10,6 +11,8 @@ * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France + * and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt, + * B.P. 105 - 78153 Le Chesnay, France */ #include @@ -9158,6 +9161,37 @@ error: return NULL; } +/* Return the intersection of the elements in the non-empty list "list". + * All elements are assumed to live in the same space. + */ +__isl_give isl_basic_set *isl_basic_set_list_intersect( + __isl_take struct isl_basic_set_list *list) +{ + int i, n; + isl_basic_set *bset; + + if (!list) + return NULL; + n = isl_basic_set_list_n_basic_set(list); + if (n < 1) + isl_die(isl_basic_set_list_get_ctx(list), isl_error_invalid, + "expecting non-empty list", goto error); + + bset = isl_basic_set_list_get_basic_set(list, 0); + for (i = 1; i < n; ++i) { + isl_basic_set *bset_i; + + bset_i = isl_basic_set_list_get_basic_set(list, i); + bset = isl_basic_set_intersect(bset, bset_i); + } + + isl_basic_set_list_free(list); + return bset; +error: + isl_basic_set_list_free(list); + return NULL; +} + /* Return the Cartesian product of the basic sets in list (in the given order). */ __isl_give isl_basic_set *isl_basic_set_list_product( -- 2.11.4.GIT