fix isl_map_lex_ge and isl_map_lex_le in the zero-dimensional case
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 23 Jul 2010 11:51:33 +0000 (13:51 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 23 Jul 2010 12:00:46 +0000 (14:00 +0200)
The first zero dimensions are always equal, so these functions
should return a universe map in the zero-dimensional case rather
than an empty map.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map.c
isl_test.c

index 62eb108..5a38cd5 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -3016,6 +3016,9 @@ static __isl_give isl_map *map_lex_lte_first(__isl_take isl_dim *dims,
        struct isl_map *map;
        int i;
 
+       if (n == 0 && equal)
+               return isl_map_universe(dims);
+
        map = isl_map_alloc_dim(isl_dim_copy(dims), n, ISL_MAP_DISJOINT);
 
        for (i = 0; i + 1 < n; ++i)
@@ -3067,6 +3070,9 @@ static __isl_give isl_map *map_lex_gte_first(__isl_take isl_dim *dims,
        struct isl_map *map;
        int i;
 
+       if (n == 0 && equal)
+               return isl_map_universe(dims);
+
        map = isl_map_alloc_dim(isl_dim_copy(dims), n, ISL_MAP_DISJOINT);
 
        for (i = 0; i + 1 < n; ++i)
index 5b7a9ea..68b9fb3 100644 (file)
@@ -1034,6 +1034,18 @@ void test_closure(struct isl_ctx *ctx)
        isl_map_free(map2);
 }
 
+void test_lex(struct isl_ctx *ctx)
+{
+       isl_dim *dim;
+       isl_map *map;
+
+       dim = isl_dim_alloc(ctx, 0, 0, 0);
+       map = isl_map_lex_le(dim);
+       isl_map_print(map, stderr, 0, 0); fprintf(stderr, "\n");
+       assert(!isl_map_is_empty(map));
+       isl_map_free(map);
+}
+
 void test_lexmin(struct isl_ctx *ctx)
 {
        const char *str;
@@ -1348,6 +1360,7 @@ int main()
        assert(srcdir);
 
        ctx = isl_ctx_alloc();
+       test_lex(ctx);
        test_sv(ctx);
        test_bijective(ctx);
        test_dep(ctx);