#include "isl_map_private.h"
#include "isl_seq.h"
#include "isl_tab.h"
+#include <isl_dim_private.h>
+#include <isl_mat_private.h>
static void swap_equality(struct isl_basic_map *bmap, int a, int b)
{
isl_assert(bset->ctx, first + n <= bset->dim->n_out, goto error);
- if (n == 0)
+ if (n == 0 && !isl_dim_get_tuple_name(bset->dim, isl_dim_set))
return bset;
bset = isl_basic_set_cow(bset);
isl_assert(set->ctx, first + n <= set->dim->n_out, goto error);
- if (n == 0)
+ if (n == 0 && !isl_dim_get_tuple_name(set->dim, isl_dim_set))
return set;
set = isl_set_cow(set);
if (!set)
dim = isl_basic_map_dim(bmap, type);
isl_assert(bmap->ctx, first + n <= dim, goto error);
- if (n == 0)
+ if (n == 0 && !isl_dim_get_tuple_name(bmap->dim, type))
return bmap;
bmap = isl_basic_map_cow(bmap);
isl_assert(map->ctx, first + n <= isl_map_dim(map, type), goto error);
- if (n == 0)
+ if (n == 0 && !isl_dim_get_tuple_name(map->dim, type))
return map;
map = isl_map_cow(map);
if (!map)
if (progress)
*progress = 1;
isl_seq_elim(bmap->eq[k], eq, 1+pos, 1+total, NULL);
+ isl_seq_normalize(bmap->ctx, bmap->eq[k], 1 + total);
}
for (k = 0; k < bmap->n_ineq; ++k) {
if (progress)
*progress = 1;
isl_seq_elim(bmap->ineq[k], eq, 1+pos, 1+total, NULL);
+ isl_seq_normalize(bmap->ctx, bmap->ineq[k], 1 + total);
ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED);
}
}
+int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
+ isl_int *constraint, unsigned div)
+{
+ unsigned pos;
+
+ if (!bmap)
+ return -1;
+
+ pos = 1 + isl_dim_total(bmap->dim) + div;
+
+ if (isl_int_eq(constraint[pos], bmap->div[div][0])) {
+ int neg;
+ isl_int_sub(bmap->div[div][1],
+ bmap->div[div][1], bmap->div[div][0]);
+ isl_int_add_ui(bmap->div[div][1], bmap->div[div][1], 1);
+ neg = isl_seq_is_neg(constraint, bmap->div[div]+1, pos);
+ isl_int_sub_ui(bmap->div[div][1], bmap->div[div][1], 1);
+ isl_int_add(bmap->div[div][1],
+ bmap->div[div][1], bmap->div[div][0]);
+ if (!neg)
+ return 0;
+ if (isl_seq_first_non_zero(constraint+pos+1,
+ bmap->n_div-div-1) != -1)
+ return 0;
+ } else if (isl_int_abs_eq(constraint[pos], bmap->div[div][0])) {
+ if (!isl_seq_eq(constraint, bmap->div[div]+1, pos))
+ return 0;
+ if (isl_seq_first_non_zero(constraint+pos+1,
+ bmap->n_div-div-1) != -1)
+ return 0;
+ } else
+ return 0;
+
+ return 1;
+}
+
+
/* If the only constraints a div d=floor(f/m)
* appears in are its two defining constraints
*
for (i = 0; i < bmap->n_ineq; ++i) {
if (isl_int_is_zero(bmap->ineq[i][pos]))
continue;
- if (isl_int_eq(bmap->ineq[i][pos], bmap->div[div][0])) {
- int neg;
- isl_int_sub(bmap->div[div][1],
- bmap->div[div][1], bmap->div[div][0]);
- isl_int_add_ui(bmap->div[div][1], bmap->div[div][1], 1);
- neg = isl_seq_is_neg(bmap->ineq[i], bmap->div[div]+1, pos);
- isl_int_sub_ui(bmap->div[div][1], bmap->div[div][1], 1);
- isl_int_add(bmap->div[div][1],
- bmap->div[div][1], bmap->div[div][0]);
- if (!neg)
- return 0;
- if (isl_seq_first_non_zero(bmap->ineq[i]+pos+1,
- bmap->n_div-div-1) != -1)
- return 0;
- } else if (isl_int_abs_eq(bmap->ineq[i][pos], bmap->div[div][0])) {
- if (!isl_seq_eq(bmap->ineq[i], bmap->div[div]+1, pos))
- return 0;
- if (isl_seq_first_non_zero(bmap->ineq[i]+pos+1,
- bmap->n_div-div-1) != -1)
- return 0;
- } else
+ if (!isl_basic_map_is_div_constraint(bmap, bmap->ineq[i], div))
return 0;
}
if (!bmap || !context)
goto error;
- if (isl_basic_map_is_universe(context)) {
- isl_basic_map_free(context);
- return bmap;
- }
if (isl_basic_map_is_universe(bmap)) {
isl_basic_map_free(context);
return bmap;
if (!map || !context)
goto error;;
- if (isl_basic_map_is_universe(context)) {
- isl_basic_map_free(context);
- return map;
- }
if (isl_basic_map_fast_is_empty(context)) {
struct isl_dim *dim = isl_dim_copy(map->dim);
isl_basic_map_free(context);
__isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
__isl_take isl_map *context)
{
- return isl_map_gist_basic_map(map, isl_map_convex_hull(context));
+ return isl_map_gist_basic_map(map, isl_map_simple_hull(context));
}
struct isl_basic_set *isl_basic_set_gist(struct isl_basic_set *bset,