From 5413ddb06bee414c156dd48dc34c6cf90bc5abb5 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 30 Sep 2011 17:24:36 +0200 Subject: [PATCH] add isl_basic_map_eliminate Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/map.h | 3 +++ isl_map_simplify.c | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index ad04919..c76cc84 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1728,6 +1728,10 @@ that maps (a wrapped version of) the input relation to its domain or range. __isl_give isl_set *isl_set_eliminate( __isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n); + __isl_give isl_basic_map *isl_basic_map_eliminate( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type, + unsigned first, unsigned n); Eliminate the coefficients for the given dimensions from the constraints, without removing the dimensions. diff --git a/include/isl/map.h b/include/isl/map.h index 6881353..f219f23 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -168,6 +168,9 @@ __isl_give isl_basic_map *isl_basic_map_range_map( __isl_give isl_basic_map *isl_basic_map_remove_dims( __isl_take isl_basic_map *bmap, enum isl_dim_type type, unsigned first, unsigned n); +__isl_give isl_basic_map *isl_basic_map_eliminate( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type, unsigned first, unsigned n); __isl_give isl_basic_map *isl_basic_map_from_basic_set( __isl_take isl_basic_set *bset, __isl_take isl_space *dim); struct isl_basic_set *isl_basic_set_from_basic_map(struct isl_basic_map *bmap); diff --git a/isl_map_simplify.c b/isl_map_simplify.c index 08c4eb8..1998b58 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -1369,6 +1369,30 @@ struct isl_basic_set *isl_basic_set_eliminate_vars( (struct isl_basic_map *)bset, pos, n); } +/* Eliminate the specified n dimensions starting at first from the + * constraints using Fourier-Motzkin. The dimensions themselves + * are not removed. + */ +__isl_give isl_basic_map *isl_basic_map_eliminate( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type, unsigned first, unsigned n) +{ + if (!bmap) + return NULL; + if (n == 0) + return bmap; + + if (first + n > isl_basic_map_dim(bmap, type)) + isl_die(bmap->ctx, isl_error_invalid, + "index out of bounds", goto error); + + first += isl_basic_map_offset(bmap, type) - 1; + return isl_basic_map_eliminate_vars(bmap, first, n); +error: + isl_basic_map_free(bmap); + return NULL; +} + /* Don't assume equalities are in order, because align_divs * may have changed the order of the divs. */ -- 2.7.4