add isl_set_from_pw_aff
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 29 Aug 2011 11:04:10 +0000 (13:04 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 3 Sep 2011 10:04:54 +0000 (12:04 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_aff.c
isl_test.c

index 45e6a98..efa9e2a 100644 (file)
@@ -1128,11 +1128,14 @@ C<isl_dim_set> and C<isl_dim_div> for sets and
 of C<isl_dim_cst>, C<isl_dim_param>,
 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
 
-A (basic) relation can also be constructed from a (piecewise) affine expression
+A (basic) set or relation can also be constructed from a (piecewise)
+affine expression
 or a list of affine expressions (See L<"Piecewise Quasi Affine Expressions">).
 
        __isl_give isl_basic_map *isl_basic_map_from_aff(
                __isl_take isl_aff *aff);
+       __isl_give isl_set *isl_set_from_pw_aff(
+               __isl_take isl_pw_aff *pwaff);
        __isl_give isl_map *isl_map_from_pw_aff(
                __isl_take isl_pw_aff *pwaff);
        __isl_give isl_basic_map *isl_basic_map_from_aff_list(
index 3a67e96..84a33f5 100644 (file)
@@ -162,6 +162,7 @@ int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
        int (*fn)(__isl_take isl_set *set, __isl_take isl_aff *aff,
                    void *user), void *user);
 
+__isl_give isl_set *isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff);
 __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff);
 
 __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff);
index b2a7189..a10789e 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -1306,6 +1306,15 @@ __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff)
        return map;
 }
 
+/* Construct a one-dimensional set with as parameter domain
+ * the domain of pwaff and the single set dimension
+ * corresponding to the affine expressions.
+ */
+__isl_give isl_set *isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff)
+{
+       return isl_map_from_pw_aff(pwaff);
+}
+
 /* Return a set containing those elements in the domain
  * of pwaff where it is non-negative.
  */
index 22e6aae..77d5cb9 100644 (file)
@@ -2294,19 +2294,20 @@ int test_dim_max(isl_ctx *ctx)
 {
        int equal;
        const char *str;
-       isl_map *map, *map2;
+       isl_set *set1, *set2;
        isl_set *set;
+       isl_map *map;
        isl_pw_aff *pwaff;
 
        str = "[N] -> { [i] : 0 <= i <= min(N,10) }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [10] : N >= 10; [] -> [N] : N <= 9 and N >= 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [10] : N >= 10; [N] : N <= 9 and N >= 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2315,12 +2316,12 @@ int test_dim_max(isl_ctx *ctx)
        str = "[N] -> { [i] : 0 <= i <= max(2N,N+6) }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [6 + N] : -6 <= N <= 5; [] -> [2N] : N >= 6 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2329,12 +2330,12 @@ int test_dim_max(isl_ctx *ctx)
        str = "[N] -> { [i] : 0 <= i <= 2N or 0 <= i <= N+6 }";
        set = isl_set_read_from_str(ctx, str, -1);
        pwaff = isl_set_dim_max(set, 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N] -> { [] -> [6 + N] : -6 <= N <= 5; [] -> [2N] : N >= 6 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
        if (equal < 0)
                return -1;
        if (!equal)
@@ -2346,21 +2347,21 @@ int test_dim_max(isl_ctx *ctx)
        set = isl_map_range(map);
 
        pwaff = isl_set_dim_max(isl_set_copy(set), 0);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N,M] -> { [] -> [([(N-1)/16])] : M,N > 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
-       equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N,M] -> { [([(N-1)/16])] : M,N > 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
+       equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
 
        pwaff = isl_set_dim_max(isl_set_copy(set), 3);
-       map = isl_map_from_pw_aff(pwaff);
-       str = "[N,M] -> { [] -> [t] : t = min(M-1,15) and M,N > 0 }";
-       map2 = isl_map_read_from_str(ctx, str, -1);
+       set1 = isl_set_from_pw_aff(pwaff);
+       str = "[N,M] -> { [t] : t = min(M-1,15) and M,N > 0 }";
+       set2 = isl_set_read_from_str(ctx, str, -1);
        if (equal >= 0 && equal)
-               equal = isl_map_is_equal(map, map2);
-       isl_map_free(map);
-       isl_map_free(map2);
+               equal = isl_set_is_equal(set1, set2);
+       isl_set_free(set1);
+       isl_set_free(set2);
 
        isl_set_free(set);