change isl_basic_map_foreach_lexmin prototype
[platform/upstream/isl.git] / isl_map_simplify.c
index 984d6ef..7a24c5b 100644 (file)
@@ -7,6 +7,7 @@
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
  */
 
+#include <strings.h>
 #include <isl_ctx_private.h>
 #include <isl_map_private.h>
 #include "isl_equalities.h"
@@ -1019,12 +1020,14 @@ static struct isl_basic_map *remove_duplicate_constraints(
        int bits;
        unsigned total = isl_basic_map_total_dim(bmap);
        isl_int sum;
+       isl_ctx *ctx;
 
        if (!bmap || bmap->n_ineq <= 1)
                return bmap;
 
        size = round_up(4 * (bmap->n_ineq+1) / 3 - 1);
        bits = ffs(size) - 1;
+       ctx = isl_basic_map_get_ctx(bmap);
        index = isl_calloc_array(ctx, isl_int **, size);
        if (!index)
                return bmap;
@@ -1461,12 +1464,14 @@ static struct isl_basic_set *remove_shifted_constraints(
        isl_int ***index;
        int bits;
        int k, h, l;
+       isl_ctx *ctx;
 
        if (!bset)
                return NULL;
 
        size = round_up(4 * (context->n_ineq+1) / 3 - 1);
        bits = ffs(size) - 1;
+       ctx = isl_basic_set_get_ctx(bset);
        index = isl_calloc_array(ctx, isl_int **, size);
        if (!index)
                return bset;
@@ -1495,94 +1500,6 @@ error:
        return bset;
 }
 
-/* Tighten (decrease) the constant terms of the inequalities based
- * on the equalities, without removing any integer points.
- * For example, if there is an equality
- *
- *             i = 3 * j
- *
- * and an inequality
- *
- *             i >= 1
- *
- * then we want to replace the inequality by
- *
- *             i >= 3
- *
- * We do this by computing a variable compression and translating
- * the constraints to the compressed space.
- * If any constraint has coefficients (except the contant term)
- * with a common factor "f", then we can replace the constant term "c"
- * by
- *
- *             f * floor(c/f)
- *
- * That is, we add
- *
- *             f * floor(c/f) - c = -fract(c/f)
- *
- * and we can add the same value to the original constraint.
- *
- * In the example, the compressed space only contains "j",
- * and the inequality translates to
- *
- *             3 * j - 1 >= 0
- *
- * We add -fract(-1/3) = -2 to the original constraint to obtain
- *
- *             i - 3 >= 0
- */
-static struct isl_basic_set *normalize_constraints_in_compressed_space(
-       struct isl_basic_set *bset)
-{
-       int i;
-       unsigned total;
-       struct isl_mat *B, *C;
-       isl_int gcd;
-
-       if (!bset)
-               return NULL;
-
-       if (ISL_F_ISSET(bset, ISL_BASIC_SET_RATIONAL))
-               return bset;
-
-       if (!bset->n_ineq)
-               return bset;
-
-       bset = isl_basic_set_cow(bset);
-       if (!bset)
-               return NULL;
-
-       total = isl_basic_set_total_dim(bset);
-       B = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + total);
-       C = isl_mat_variable_compression(B, NULL);
-       if (!C)
-               return bset;
-       if (C->n_col == 0) {
-               isl_mat_free(C);
-               return isl_basic_set_set_to_empty(bset);
-       }
-       B = isl_mat_sub_alloc6(bset->ctx, bset->ineq,
-                                               0, bset->n_ineq, 0, 1 + total);
-       C = isl_mat_product(B, C);
-       if (!C)
-               return bset;
-
-       isl_int_init(gcd);
-       for (i = 0; i < bset->n_ineq; ++i) {
-               isl_seq_gcd(C->row[i] + 1, C->n_col - 1, &gcd);
-               if (isl_int_is_one(gcd))
-                       continue;
-               isl_int_fdiv_r(C->row[i][0], C->row[i][0], gcd);
-               isl_int_sub(bset->ineq[i][0], bset->ineq[i][0], C->row[i][0]);
-       }
-       isl_int_clear(gcd);
-
-       isl_mat_free(C);
-
-       return bset;
-}
-
 /* Remove all information from bset that is redundant in the context
  * of context.  Both bset and context are assumed to be full-dimensional.
  *