* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
-#include "isl_seq.h"
-#include "isl_set.h"
-#include "isl_map.h"
-#include "isl_map_private.h"
+#include <isl_map_private.h>
+#include <isl/seq.h>
+#include <isl/set.h>
+#include <isl/map.h>
#include "isl_tab.h"
+#include <isl_point_private.h>
static void expand_constraint(isl_vec *v, unsigned dim,
isl_int *c, int *div_map, unsigned n_div)
return -1;
v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
+ if (!v)
+ return -1;
for (i = 0; i < bmap->n_eq; ++i) {
expand_constraint(v, dim, bmap->eq[i], div_map, bmap->n_div);
* Put the indices of the redundant constraints in index
* and return the number of redundant constraints.
*/
-static int n_non_redundant(struct isl_tab *tab, int offset, int **index)
+static int n_non_redundant(isl_ctx *ctx, struct isl_tab *tab,
+ int offset, int **index)
{
int i, n;
int n_test = tab->n_con - offset;
return -1;
if (!*index)
- *index = isl_alloc_array(tab->mat->ctx, int, n_test);
+ *index = isl_alloc_array(ctx, int, n_test);
if (!*index)
return -1;
* a negative value is treated as an error, but the calling
* function can interpret the results based on the state of dc.
*
- * Assumes that both bmap and map have known divs.
+ * Assumes that map has known divs.
*
* The difference is computed by a backtracking algorithm.
* Each level corresponds to a basic map in "map".
int level;
int init;
int empty;
+ isl_ctx *ctx;
struct isl_tab *tab = NULL;
struct isl_tab_undo **snap = NULL;
int *k = NULL;
if (!bmap || !map)
goto error;
+ ctx = map->ctx;
snap = isl_alloc_array(map->ctx, struct isl_tab_undo *, map->n);
k = isl_alloc_array(map->ctx, int, map->n);
n = isl_alloc_array(map->ctx, int, map->n);
continue;
}
modified = 1;
- n[level] = n_non_redundant(tab, offset, &index[level]);
+ n[level] = n_non_redundant(ctx, tab, offset,
+ &index[level]);
if (n[level] < 0)
goto error;
if (n[level] == 0) {
/* Return the set difference between map1 and map2.
* (U_i A_i) \ (U_j B_j) is computed as U_i (A_i \ (U_j B_j))
*/
-struct isl_map *isl_map_subtract(struct isl_map *map1, struct isl_map *map2)
+static __isl_give isl_map *map_subtract( __isl_take isl_map *map1,
+ __isl_take isl_map *map2)
{
int i;
struct isl_map *diff;
return NULL;
}
+__isl_give isl_map *isl_map_subtract( __isl_take isl_map *map1,
+ __isl_take isl_map *map2)
+{
+ return isl_map_align_params_map_map_and(map1, map2, &map_subtract);
+}
+
struct isl_set *isl_set_subtract(struct isl_set *set1, struct isl_set *set2)
{
return (struct isl_set *)
int r;
struct isl_is_empty_diff_collector edc;
- r = isl_basic_map_fast_is_empty(bmap);
+ r = isl_basic_map_plain_is_empty(bmap);
if (r)
return r;
/* Return 1 if "bmap" contains a single element.
*/
-int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap)
+int isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
{
if (!bmap)
return -1;
/* Return 1 if "map" contains a single element.
*/
-int isl_map_is_singleton(__isl_keep isl_map *map)
+int isl_map_plain_is_singleton(__isl_keep isl_map *map)
{
if (!map)
return -1;
if (map->n != 1)
return 0;
- return isl_basic_map_is_singleton(map->p[0]);
+ return isl_basic_map_plain_is_singleton(map->p[0]);
}
/* Given a singleton basic map, extract the single element
- * as an isl_vec.
+ * as an isl_point.
*/
-static __isl_give isl_vec *singleton_extract_point(__isl_keep isl_basic_map *bmap)
+static __isl_give isl_point *singleton_extract_point(
+ __isl_keep isl_basic_map *bmap)
{
- int i, j;
+ int j;
unsigned dim;
struct isl_vec *point;
isl_int m;
isl_int_set_si(point->el[0], 1);
for (j = 0; j < bmap->n_eq; ++j) {
- int s;
int i = dim - 1 - j;
isl_assert(bmap->ctx,
isl_seq_first_non_zero(bmap->eq[j] + 1, i) == -1,
}
isl_int_clear(m);
- return point;
+ return isl_point_alloc(isl_basic_map_get_dim(bmap), point);
error:
isl_int_clear(m);
isl_vec_free(point);
return NULL;
}
-/* Return 1 if "bmap" contains the point "point".
- * "bmap" is assumed to have known divs.
- * The point is first extended with the divs and then passed
- * to basic_map_contains.
- */
-static int basic_map_contains_point(__isl_keep isl_basic_map *bmap,
- __isl_keep isl_vec *point)
-{
- int i;
- struct isl_vec *vec;
- unsigned dim;
- int contains;
-
- if (!bmap || !point)
- return -1;
- if (bmap->n_div == 0)
- return isl_basic_map_contains(bmap, point);
-
- dim = isl_basic_map_total_dim(bmap) - bmap->n_div;
- vec = isl_vec_alloc(bmap->ctx, 1 + dim + bmap->n_div);
- if (!vec)
- return -1;
-
- isl_seq_cpy(vec->el, point->el, point->size);
- for (i = 0; i < bmap->n_div; ++i) {
- isl_seq_inner_product(bmap->div[i] + 1, vec->el,
- 1 + dim + i, &vec->el[1+dim+i]);
- isl_int_fdiv_q(vec->el[1+dim+i], vec->el[1+dim+i],
- bmap->div[i][0]);
- }
-
- contains = isl_basic_map_contains(bmap, vec);
-
- isl_vec_free(vec);
- return contains;
-}
-
/* Return 1 is the singleton map "map1" is a subset of "map2",
* i.e., if the single element of "map1" is also an element of "map2".
+ * Assumes "map2" has known divs.
*/
static int map_is_singleton_subset(__isl_keep isl_map *map1,
__isl_keep isl_map *map2)
{
int i;
int is_subset = 0;
- struct isl_vec *point;
+ struct isl_point *point;
if (!map1 || !map2)
return -1;
return -1;
for (i = 0; i < map2->n; ++i) {
- is_subset = basic_map_contains_point(map2->p[i], point);
+ is_subset = isl_basic_map_contains_point(map2->p[i], point);
if (is_subset)
break;
}
- isl_vec_free(point);
+ isl_point_free(point);
return is_subset;
}
int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2)
{
int is_subset = 0;
- struct isl_map *diff;
if (!map1 || !map2)
return -1;
if (isl_map_is_empty(map2))
return 0;
- if (isl_map_fast_is_universe(map2))
+ if (isl_map_plain_is_universe(map2))
return 1;
- map1 = isl_map_compute_divs(isl_map_copy(map1));
map2 = isl_map_compute_divs(isl_map_copy(map2));
- if (isl_map_is_singleton(map1)) {
+ if (isl_map_plain_is_singleton(map1)) {
is_subset = map_is_singleton_subset(map1, map2);
- isl_map_free(map1);
isl_map_free(map2);
return is_subset;
}
is_subset = map_diff_is_empty(map1, map2);
- isl_map_free(map1);
isl_map_free(map2);
return is_subset;