add isl_map_remove
authorSven Verdoolaege <sven@nestor.cs.kuleuven.be>
Fri, 20 Feb 2009 16:12:30 +0000 (17:12 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 22 Feb 2009 17:01:13 +0000 (18:01 +0100)
include/isl_map.h
isl_map.c
isl_map_private.h
isl_map_simplify.c

index 8425d83..7f628fe 100644 (file)
@@ -237,6 +237,8 @@ struct isl_basic_set *isl_basic_map_deltas(struct isl_basic_map *bmap);
 struct isl_set *isl_map_deltas(struct isl_map *map);
 struct isl_set *isl_map_range(struct isl_map *map);
 struct isl_basic_map *isl_map_affine_hull(struct isl_map *map);
+struct isl_map *isl_map_remove(struct isl_map *map,
+       enum isl_dim_type type, unsigned first, unsigned n);
 struct isl_map *isl_map_remove_inputs(struct isl_map *map,
        unsigned first, unsigned n);
 
index 0928b59..02470ae 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -1119,9 +1119,8 @@ error:
        return NULL;
 }
 
-/* Project out n inputs starting at first using Fourier-Motzkin */
-struct isl_map *isl_map_remove_inputs(struct isl_map *map,
-       unsigned first, unsigned n)
+struct isl_map *isl_map_remove(struct isl_map *map,
+       enum isl_dim_type type, unsigned first, unsigned n)
 {
        int i;
        unsigned nparam;
@@ -1132,22 +1131,28 @@ struct isl_map *isl_map_remove_inputs(struct isl_map *map,
        map = isl_map_cow(map);
        if (!map)
                return NULL;
-       nparam = isl_map_n_param(map);
-       isl_assert(map->ctx, first+n <= isl_map_n_in(map), goto error);
+       isl_assert(map->ctx, first + n <= isl_map_dim(map, type), goto error);
        
        for (i = 0; i < map->n; ++i) {
                map->p[i] = isl_basic_map_eliminate_vars(map->p[i],
-                                                           nparam + first, n);
+                       isl_basic_map_offset(map->p[i], type) - 1 + first, n);
                if (!map->p[i])
                        goto error;
        }
-       map = isl_map_drop_inputs(map, first, n);
+       map = isl_map_drop(map, type, first, n);
        return map;
 error:
        isl_map_free(map);
        return NULL;
 }
 
+/* Project out n inputs starting at first using Fourier-Motzkin */
+struct isl_map *isl_map_remove_inputs(struct isl_map *map,
+       unsigned first, unsigned n)
+{
+       return isl_map_remove(map, isl_dim_in, first, n);
+}
+
 /* Project out n dimensions starting at first using Fourier-Motzkin */
 struct isl_basic_set *isl_basic_set_remove_dims(struct isl_basic_set *bset,
        unsigned first, unsigned n)
index ac426ed..1784882 100644 (file)
@@ -75,6 +75,8 @@ struct isl_set *isl_set_drop_dims(
                struct isl_set *set, unsigned first, unsigned n);
 struct isl_map *isl_map_drop_inputs(
                struct isl_map *map, unsigned first, unsigned n);
+struct isl_map *isl_map_drop(struct isl_map *map,
+       enum isl_dim_type type, unsigned first, unsigned n);
 
 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
index 8302ed4..93c799b 100644 (file)
@@ -166,27 +166,27 @@ struct isl_basic_map *isl_basic_map_drop_inputs(
        return isl_basic_map_drop(bmap, isl_dim_in, first, n);
 }
 
-struct isl_map *isl_map_drop_inputs(
-               struct isl_map *map, unsigned first, unsigned n)
+struct isl_map *isl_map_drop(struct isl_map *map,
+       enum isl_dim_type type, unsigned first, unsigned n)
 {
        int i;
 
        if (!map)
                goto error;
 
-       isl_assert(map->ctx, first + n <= map->dim->n_in, goto error);
+       isl_assert(map->ctx, first + n <= isl_map_dim(map, type), goto error);
 
        if (n == 0)
                return map;
        map = isl_map_cow(map);
        if (!map)
                goto error;
-       map->dim = isl_dim_drop_inputs(map->dim, first, n);
+       map->dim = isl_dim_drop(map->dim, type, first, n);
        if (!map->dim)
                goto error;
 
        for (i = 0; i < map->n; ++i) {
-               map->p[i] = isl_basic_map_drop_inputs(map->p[i], first, n);
+               map->p[i] = isl_basic_map_drop(map->p[i], type, first, n);
                if (!map->p[i])
                        goto error;
        }
@@ -198,6 +198,12 @@ error:
        return NULL;
 }
 
+struct isl_map *isl_map_drop_inputs(
+               struct isl_map *map, unsigned first, unsigned n)
+{
+       return isl_map_drop(map, isl_dim_in, first, n);
+}
+
 /*
  * We don't cow, as the div is assumed to be redundant.
  */