add isl_set_is_disjoint
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 12 Sep 2012 10:30:46 +0000 (12:30 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 13 Sep 2012 08:54:41 +0000 (10:54 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/map.h
include/isl/set.h
isl_map_simplify.c

index b637d82..a2892a9 100644 (file)
@@ -1903,6 +1903,10 @@ Check whether the range of the (basic) relation is a wrapped relation.
 
        int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
                __isl_keep isl_set *set2);
+       int isl_set_is_disjoint(__isl_keep isl_set *set1,
+               __isl_keep isl_set *set2);
+       int isl_map_is_disjoint(__isl_keep isl_map *map1,
+               __isl_keep isl_map *map2);
 
 =item * Subset
 
index 5aee7b2..1b7d413 100644 (file)
@@ -515,6 +515,8 @@ __isl_export
 int isl_map_is_strict_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
 __isl_export
 int isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+__isl_export
+int isl_map_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
 int isl_basic_map_is_single_valued(__isl_keep isl_basic_map *bmap);
 int isl_map_plain_is_single_valued(__isl_keep isl_map *map);
 __isl_export
index 64d502e..bf2440e 100644 (file)
@@ -366,6 +366,8 @@ __isl_export
 int isl_set_is_strict_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
 __isl_export
 int isl_set_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+__isl_export
+int isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
 int isl_set_is_singleton(__isl_keep isl_set *set);
 int isl_set_is_box(__isl_keep isl_set *set);
 int isl_set_has_equal_space(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
index 2582d08..2a36652 100644 (file)
@@ -2199,6 +2199,46 @@ int isl_map_plain_is_disjoint(__isl_keep isl_map *map1,
        return 1;
 }
 
+/* Are "map1" and "map2" disjoint?
+ *
+ * They are disjoint if they are "obviously disjoint" or if one of them
+ * is empty.  Otherwise, they are not disjoint if one of them is universal.
+ * If none of these cases apply, we compute the intersection and see if
+ * the result is empty.
+ */
+int isl_map_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
+{
+       int disjoint;
+       int intersect;
+       isl_map *test;
+
+       disjoint = isl_map_plain_is_disjoint(map1, map2);
+       if (disjoint < 0 || disjoint)
+               return disjoint;
+
+       disjoint = isl_map_is_empty(map1);
+       if (disjoint < 0 || disjoint)
+               return disjoint;
+
+       disjoint = isl_map_is_empty(map2);
+       if (disjoint < 0 || disjoint)
+               return disjoint;
+
+       intersect = isl_map_plain_is_universe(map1);
+       if (intersect < 0 || intersect)
+               return intersect < 0 ? -1 : 0;
+
+       intersect = isl_map_plain_is_universe(map2);
+       if (intersect < 0 || intersect)
+               return intersect < 0 ? -1 : 0;
+
+       test = isl_map_intersect(isl_map_copy(map1), isl_map_copy(map2));
+       disjoint = isl_map_is_empty(test);
+       isl_map_free(test);
+
+       return disjoint;
+}
+
 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
        __isl_keep isl_set *set2)
 {
@@ -2206,6 +2246,13 @@ int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
                                        (struct isl_map *)set2);
 }
 
+/* Are "set1" and "set2" disjoint?
+ */
+int isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
+{
+       return isl_map_is_disjoint(set1, set2);
+}
+
 int isl_set_fast_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
 {
        return isl_set_plain_is_disjoint(set1, set2);