add map_lex_*_first
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 2 May 2010 08:14:37 +0000 (10:14 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 4 May 2010 06:23:28 +0000 (08:23 +0200)
doc/user.pod
include/isl_map.h
isl_map.c

index 9f0a89d..b183859 100644 (file)
@@ -586,13 +586,27 @@ and return an identity relation between two such sets.
                __isl_take isl_dim *set_dim);
        __isl_give isl_map *isl_map_lex_ge(
                __isl_take isl_dim *set_dim);
-
-These functions take a dimension specification for a B<set>
+       __isl_give isl_map *isl_map_lex_lt_first(
+               __isl_take isl_dim *dim, unsigned n);
+       __isl_give isl_map *isl_map_lex_le_first(
+               __isl_take isl_dim *dim, unsigned n);
+       __isl_give isl_map *isl_map_lex_gt_first(
+               __isl_take isl_dim *dim, unsigned n);
+       __isl_give isl_map *isl_map_lex_ge_first(
+               __isl_take isl_dim *dim, unsigned n);
+
+The first four functions take a dimension specification for a B<set>
 and return relations that express that the elements in the domain
 are lexicographically less
 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
 than the elements in the range.
+The last four functions take a dimension specification for a map
+and return relations that express that the first C<n> dimensions
+in the domain are lexicographically less
+(C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
+greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
+than the first C<n> dimensions in the range.
 
 =back
 
index c0166ab..caa9983 100644 (file)
@@ -270,8 +270,12 @@ __isl_give isl_map *isl_map_add_basic_map(__isl_take isl_map *map,
 __isl_give isl_map *isl_map_identity(__isl_take isl_dim *set_dim);
 struct isl_map *isl_map_identity_like(struct isl_map *model);
 struct isl_map *isl_map_identity_like_basic_map(struct isl_basic_map *model);
+__isl_give isl_map *isl_map_lex_lt_first(__isl_take isl_dim *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_le_first(__isl_take isl_dim *dim, unsigned n);
 __isl_give isl_map *isl_map_lex_lt(__isl_take isl_dim *set_dim);
 __isl_give isl_map *isl_map_lex_le(__isl_take isl_dim *set_dim);
+__isl_give isl_map *isl_map_lex_gt_first(__isl_take isl_dim *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_dim *dim, unsigned n);
 __isl_give isl_map *isl_map_lex_gt(__isl_take isl_dim *set_dim);
 __isl_give isl_map *isl_map_lex_ge(__isl_take isl_dim *set_dim);
 struct isl_map *isl_map_finalize(struct isl_map *map);
index f868ffe..a2d33d3 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -2936,33 +2936,47 @@ __isl_give isl_basic_map *isl_basic_map_more_or_equal_at(
        return isl_basic_map_finalize(bmap);
 }
 
-static __isl_give isl_map *map_lex_lte(__isl_take isl_dim *dims, int equal)
+static __isl_give isl_map *map_lex_lte_first(__isl_take isl_dim *dims,
+       unsigned n, int equal)
 {
        struct isl_map *map;
-       unsigned dim;
        int i;
 
-       if (!dims)
-               return NULL;
-       dim = dims->n_out;
-       map = isl_map_alloc_dim(isl_dim_copy(dims), dim, ISL_MAP_DISJOINT);
+       map = isl_map_alloc_dim(isl_dim_copy(dims), n, ISL_MAP_DISJOINT);
 
-       for (i = 0; i + 1 < dim; ++i)
+       for (i = 0; i + 1 < n; ++i)
                map = isl_map_add_basic_map(map,
                                  isl_basic_map_less_at(isl_dim_copy(dims), i));
-       if (dim > 0) {
+       if (n > 0) {
                if (equal)
                        map = isl_map_add_basic_map(map,
-                             isl_basic_map_less_or_equal_at(dims, dim - 1));
+                             isl_basic_map_less_or_equal_at(dims, n - 1));
                else
                        map = isl_map_add_basic_map(map,
-                             isl_basic_map_less_at(dims, dim - 1));
+                             isl_basic_map_less_at(dims, n - 1));
        } else
                isl_dim_free(dims);
 
        return map;
 }
 
+static __isl_give isl_map *map_lex_lte(__isl_take isl_dim *dims, int equal)
+{
+       if (!dims)
+               return NULL;
+       return map_lex_lte_first(dims, dims->n_out, equal);
+}
+
+__isl_give isl_map *isl_map_lex_lt_first(__isl_take isl_dim *dim, unsigned n)
+{
+       return map_lex_lte_first(dim, n, 0);
+}
+
+__isl_give isl_map *isl_map_lex_le_first(__isl_take isl_dim *dim, unsigned n)
+{
+       return map_lex_lte_first(dim, n, 1);
+}
+
 __isl_give isl_map *isl_map_lex_lt(__isl_take isl_dim *set_dim)
 {
        return map_lex_lte(isl_dim_map(set_dim), 0);
@@ -2973,33 +2987,47 @@ __isl_give isl_map *isl_map_lex_le(__isl_take isl_dim *set_dim)
        return map_lex_lte(isl_dim_map(set_dim), 1);
 }
 
-static __isl_give isl_map *map_lex_gte(__isl_take isl_dim *dims, int equal)
+static __isl_give isl_map *map_lex_gte_first(__isl_take isl_dim *dims,
+       unsigned n, int equal)
 {
        struct isl_map *map;
-       unsigned dim;
        int i;
 
-       if (!dims)
-               return NULL;
-       dim = dims->n_out;
-       map = isl_map_alloc_dim(isl_dim_copy(dims), dim, ISL_MAP_DISJOINT);
+       map = isl_map_alloc_dim(isl_dim_copy(dims), n, ISL_MAP_DISJOINT);
 
-       for (i = 0; i + 1 < dim; ++i)
+       for (i = 0; i + 1 < n; ++i)
                map = isl_map_add_basic_map(map,
                                  isl_basic_map_more_at(isl_dim_copy(dims), i));
-       if (dim > 0) {
+       if (n > 0) {
                if (equal)
                        map = isl_map_add_basic_map(map,
-                             isl_basic_map_more_or_equal_at(dims, dim - 1));
+                             isl_basic_map_more_or_equal_at(dims, n - 1));
                else
                        map = isl_map_add_basic_map(map,
-                             isl_basic_map_more_at(dims, dim - 1));
+                             isl_basic_map_more_at(dims, n - 1));
        } else
                isl_dim_free(dims);
 
        return map;
 }
 
+static __isl_give isl_map *map_lex_gte(__isl_take isl_dim *dims, int equal)
+{
+       if (!dims)
+               return NULL;
+       return map_lex_gte_first(dims, dims->n_out, equal);
+}
+
+__isl_give isl_map *isl_map_lex_gt_first(__isl_take isl_dim *dim, unsigned n)
+{
+       return map_lex_gte_first(dim, n, 0);
+}
+
+__isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_dim *dim, unsigned n)
+{
+       return map_lex_gte_first(dim, n, 1);
+}
+
 __isl_give isl_map *isl_map_lex_gt(__isl_take isl_dim *set_dim)
 {
        return map_lex_gte(isl_dim_map(set_dim), 0);