isl_basic_map_affine_hull: fix search for integer points
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 22 Feb 2009 15:12:53 +0000 (16:12 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 22 Feb 2009 17:01:11 +0000 (18:01 +0100)
Before, we would mistakenly only look for integer points
in adjacent hyperplanes.  This would be sufficient if we
were looking instead for rational points, although we could
then obtain an over-approximation of the integer affine hull.

isl_affine_hull.c
isl_test.c
test_inputs/affine3.polylib [new file with mode: 0644]

index ef37303..323255d 100644 (file)
@@ -255,6 +255,13 @@ error:
        return NULL;
 }
 
+/* Find an integer point in "bset" that lies outside of the equality
+ * "eq" e(x) = 0.
+ * If "up" is true, look for a point satisfying e(x) - 1 >= 0.
+ * Otherwise, look for a point satisfying -e(x) - 1 >= 0 (i.e., e(x) <= -1).
+ * The point, if found, is returned as a singleton set.
+ * If no point can be found, the empty set is returned.
+ */
 static struct isl_basic_set *outside_point(struct isl_ctx *ctx,
        struct isl_basic_set *bset, isl_int *eq, int up)
 {
@@ -268,15 +275,15 @@ static struct isl_basic_set *outside_point(struct isl_ctx *ctx,
        if (!slice)
                goto error;
        dim = isl_basic_set_n_dim(slice);
-       slice = isl_basic_set_extend(slice, 0, dim, 0, 1, 0);
-       k = isl_basic_set_alloc_equality(slice);
+       slice = isl_basic_set_extend(slice, 0, dim, 0, 0, 1);
+       k = isl_basic_set_alloc_inequality(slice);
        if (k < 0)
                goto error;
-       isl_seq_cpy(slice->eq[k], eq, 1 + dim);
        if (up)
-               isl_int_add_ui(slice->eq[k][0], slice->eq[k][0], 1);
+               isl_seq_cpy(slice->ineq[k], eq, 1 + dim);
        else
-               isl_int_sub_ui(slice->eq[k][0], slice->eq[k][0], 1);
+               isl_seq_neg(slice->ineq[k], eq, 1 + dim);
+       isl_int_sub_ui(slice->ineq[k][0], slice->ineq[k][0], 1);
 
        sample = isl_basic_set_sample(slice);
        if (!sample)
index 37510f7..b13e294 100644 (file)
@@ -412,6 +412,7 @@ void test_affine_hull(struct isl_ctx *ctx)
 {
        test_affine_hull_case(ctx, "affine2");
        test_affine_hull_case(ctx, "affine");
+       test_affine_hull_case(ctx, "affine3");
 }
 
 void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
diff --git a/test_inputs/affine3.polylib b/test_inputs/affine3.polylib
new file mode 100644 (file)
index 0000000..f2bc9a2
--- /dev/null
@@ -0,0 +1,7 @@
+3 4
+1 1 0 0
+1 -7 4 2
+1 5 -4 2
+
+1 4
+0 3 -2 0