add isl_map_order_gt
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 29 Mar 2012 12:38:27 +0000 (14:38 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 6 May 2012 12:33:05 +0000 (14:33 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/map.h
isl_map.c

index e1bc06d..f98927e 100644 (file)
@@ -1921,6 +1921,13 @@ dimensions are equal to each other.
 Intersect the relation with the hyperplane where the given
 dimensions have opposite values.
 
+       __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
+               enum isl_dim_type type1, int pos1,
+               enum isl_dim_type type2, int pos2);
+
+Intersect the relation with the half-space where the given
+dimensions satisfy the given ordering.
+
 =item * Identity
 
        __isl_give isl_map *isl_set_identity(
index b33a9fd..7248194 100644 (file)
@@ -419,6 +419,8 @@ __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
        enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
        enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
+       enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
 
 __isl_export
 __isl_give isl_map *isl_set_identity(__isl_take isl_set *set);
index 878519d..6276119 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -10029,6 +10029,46 @@ error:
        return NULL;
 }
 
+/* Add a constraint imposing that the value of the first dimension is
+ * greater than that of the second.
+ */
+__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
+       enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
+{
+       isl_basic_map *bmap = NULL;
+       int i;
+
+       if (!map)
+               return NULL;
+
+       if (pos1 >= isl_map_dim(map, type1))
+               isl_die(map->ctx, isl_error_invalid,
+                       "index out of bounds", goto error);
+       if (pos2 >= isl_map_dim(map, type2))
+               isl_die(map->ctx, isl_error_invalid,
+                       "index out of bounds", goto error);
+
+       bmap = isl_basic_map_alloc_space(isl_map_get_space(map), 0, 0, 1);
+       i = isl_basic_map_alloc_inequality(bmap);
+       if (i < 0)
+               goto error;
+       isl_seq_clr(bmap->ineq[i], 1 + isl_basic_map_total_dim(bmap));
+       pos1 += isl_basic_map_offset(bmap, type1);
+       pos2 += isl_basic_map_offset(bmap, type2);
+       isl_int_set_si(bmap->ineq[i][pos1], 1);
+       isl_int_set_si(bmap->ineq[i][pos2], -1);
+       isl_int_set_si(bmap->ineq[i][0], -1);
+       bmap = isl_basic_map_finalize(bmap);
+
+       map = isl_map_intersect(map, isl_map_from_basic_map(bmap));
+
+       return map;
+error:
+       isl_basic_map_free(bmap);
+       isl_map_free(map);
+       return NULL;
+}
+
 __isl_give isl_aff *isl_basic_map_get_div(__isl_keep isl_basic_map *bmap,
        int pos)
 {