if (equal < 0 || !equal)
return equal;
+ if (!isl_local_space_divs_known(ls1))
+ return 0;
+ if (!isl_local_space_divs_known(ls2))
+ return 0;
+
return isl_mat_is_equal(ls1->div, ls2->div);
}
isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
"index out of bounds", return NULL);
+ if (isl_int_is_zero(ls->div->row[pos][0]))
+ isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
+ "expression of div unknown", return NULL);
+
bmap = isl_basic_map_from_local_space(isl_local_space_copy(ls));
return isl_basic_map_div(bmap, pos);
}
return ls;
}
-__isl_give isl_local_space *isl_local_space_add_dim(
+__isl_give isl_local_space *isl_local_space_add_dims(
__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned n)
{
int pos;
- if (n == 0)
- return ls;
-
- ls = isl_local_space_cow(ls);
if (!ls)
return NULL;
-
- pos = isl_local_space_offset(ls, type);
- pos += isl_local_space_dim(ls, type);
-
- ls->div = isl_mat_insert_zero_cols(ls->div, 1 + pos, n);
-
- if (type == isl_dim_div) {
- ls->div = isl_mat_add_zero_rows(ls->div, n);
- } else {
- ls->dim = isl_dim_add(ls->dim, type, n);
- if (!ls->dim)
- return isl_local_space_free(ls);
- }
-
- if (!ls->div)
- return isl_local_space_free(ls);
-
- return ls;
+ pos = isl_local_space_dim(ls, type);
+ return isl_local_space_insert_dims(ls, type, pos, n);
}
/* Remove common factor of non-constant terms and denominator.
isl_local_space_free(ls);
return NULL;
}
+
+int isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
+ enum isl_dim_type type)
+{
+ if (!ls)
+ return -1;
+ return isl_dim_is_named_or_nested(ls->dim, type);
+}
+
+__isl_give isl_local_space *isl_local_space_drop_dims(
+ __isl_take isl_local_space *ls,
+ enum isl_dim_type type, unsigned first, unsigned n)
+{
+ isl_ctx *ctx;
+
+ if (!ls)
+ return NULL;
+ if (n == 0 && !isl_local_space_is_named_or_nested(ls, type))
+ return ls;
+
+ ctx = isl_local_space_get_ctx(ls);
+ if (first + n > isl_local_space_dim(ls, type))
+ isl_die(ctx, isl_error_invalid, "range out of bounds",
+ return isl_local_space_free(ls));
+
+ ls = isl_local_space_cow(ls);
+ if (!ls)
+ return NULL;
+
+ if (type == isl_dim_div) {
+ ls->div = isl_mat_drop_rows(ls->div, first, n);
+ } else {
+ ls->dim = isl_dim_drop(ls->dim, type, first, n);
+ if (!ls->dim)
+ return isl_local_space_free(ls);
+ }
+
+ first += 1 + isl_local_space_offset(ls, type);
+ ls->div = isl_mat_drop_cols(ls->div, first, n);
+ if (!ls->div)
+ return isl_local_space_free(ls);
+
+ return ls;
+}
+
+__isl_give isl_local_space *isl_local_space_insert_dims(
+ __isl_take isl_local_space *ls,
+ enum isl_dim_type type, unsigned first, unsigned n)
+{
+ isl_ctx *ctx;
+
+ if (!ls)
+ return NULL;
+ if (n == 0 && !isl_local_space_is_named_or_nested(ls, type))
+ return ls;
+
+ ctx = isl_local_space_get_ctx(ls);
+ if (first > isl_local_space_dim(ls, type))
+ isl_die(ctx, isl_error_invalid, "position out of bounds",
+ return isl_local_space_free(ls));
+
+ ls = isl_local_space_cow(ls);
+ if (!ls)
+ return NULL;
+
+ if (type == isl_dim_div) {
+ ls->div = isl_mat_insert_zero_rows(ls->div, first, n);
+ } else {
+ ls->dim = isl_dim_insert(ls->dim, type, first, n);
+ if (!ls->dim)
+ return isl_local_space_free(ls);
+ }
+
+ first += 1 + isl_local_space_offset(ls, type);
+ ls->div = isl_mat_insert_zero_cols(ls->div, first, n);
+ if (!ls->div)
+ return isl_local_space_free(ls);
+
+ return ls;
+}