#include <isl_local_space_private.h>
#include <isl_space_private.h>
#include <isl_mat_private.h>
+#include <isl_aff_private.h>
#include <isl/seq.h>
isl_ctx *isl_local_space_get_ctx(__isl_keep isl_local_space *ls)
return NULL;
}
+/* Is the local space that of a set?
+ */
+int isl_local_space_is_set(__isl_keep isl_local_space *ls)
+{
+ return ls ? isl_space_is_set(ls->dim) : -1;
+}
+
/* Return true if the two local spaces are identical, with identical
* expressions for the integer divisions.
*/
return ls ? isl_space_get_dim_name(ls->dim, type, pos) : NULL;
}
-__isl_give isl_div *isl_local_space_get_div(__isl_keep isl_local_space *ls,
+__isl_give isl_aff *isl_local_space_get_div(__isl_keep isl_local_space *ls,
int pos)
{
- isl_basic_map *bmap;
+ isl_aff *aff;
if (!ls)
return NULL;
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);
+ aff = isl_aff_alloc(isl_local_space_copy(ls));
+ if (!aff)
+ return NULL;
+ isl_seq_cpy(aff->v->el, ls->div->row[pos], aff->v->size);
+ return aff;
}
__isl_give isl_space *isl_local_space_get_space(__isl_keep isl_local_space *ls)
return 1;
}
+__isl_give isl_local_space *isl_local_space_domain(
+ __isl_take isl_local_space *ls)
+{
+ ls = isl_local_space_drop_dims(ls, isl_dim_out,
+ 0, isl_local_space_dim(ls, isl_dim_out));
+ ls = isl_local_space_cow(ls);
+ if (!ls)
+ return NULL;
+ ls->dim = isl_space_domain(ls->dim);
+ if (!ls->dim)
+ return isl_local_space_free(ls);
+ return ls;
+}
+
/* Construct a local space for a map that has the given local
* space as domain and that has a zero-dimensional range.
*/
return 1;
}
+
+/*
+ * Set active[i] to 1 if the dimension at position i is involved
+ * in the linear expression l.
+ */
+int *isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l)
+{
+ int i, j;
+ isl_ctx *ctx;
+ int *active = NULL;
+ unsigned total;
+ unsigned offset;
+
+ ctx = isl_local_space_get_ctx(ls);
+ total = isl_local_space_dim(ls, isl_dim_all);
+ active = isl_calloc_array(ctx, int, total);
+ if (!active)
+ return NULL;
+
+ for (i = 0; i < total; ++i)
+ active[i] = !isl_int_is_zero(l[i]);
+
+ offset = isl_local_space_offset(ls, isl_dim_div) - 1;
+ for (i = ls->div->n_row - 1; i >= 0; --i) {
+ if (!active[offset + i])
+ continue;
+ for (j = 0; j < total; ++j)
+ active[j] |= !isl_int_is_zero(ls->div->row[i][2 + j]);
+ }
+
+ return active;
+}