From 7957adffd907dcf32cdbcce122aa1bbfed8961ef Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 2 May 2010 10:14:37 +0200 Subject: [PATCH] add map_lex_*_first --- doc/user.pod | 18 +++++++++++++-- include/isl_map.h | 4 ++++ isl_map.c | 68 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index 9f0a89d..b183859 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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 + __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 and return relations that express that the elements in the domain are lexicographically less (C), less or equal (C), greater (C) or greater or equal (C) 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 dimensions +in the domain are lexicographically less +(C), less or equal (C), +greater (C) or greater or equal (C) +than the first C dimensions in the range. =back diff --git a/include/isl_map.h b/include/isl_map.h index c0166ab..caa9983 100644 --- a/include/isl_map.h +++ b/include/isl_map.h @@ -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); diff --git a/isl_map.c b/isl_map.c index f868ffe..a2d33d3 100644 --- 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); -- 2.7.4