Polly 20.0.0git
isl_map_subtract.c
Go to the documentation of this file.
1/*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
9
10#include <isl_map_private.h>
11#include <isl_seq.h>
12#include <isl/set.h>
13#include <isl/map.h>
14#include "isl_tab.h"
15#include <isl_point_private.h>
16#include <isl_vec_private.h>
17
18#include <set_to_map.c>
19#include <set_from_map.c>
20
21/* Expand the constraint "c" into "v". The initial "dim" dimensions
22 * are the same, but "v" may have more divs than "c" and the divs of "c"
23 * may appear in different positions in "v".
24 * The number of divs in "c" is given by "n_div" and the mapping
25 * of divs in "c" to divs in "v" is given by "div_map".
26 *
27 * Although it shouldn't happen in practice, it is theoretically
28 * possible that two or more divs in "c" are mapped to the same div in "v".
29 * These divs are then necessarily the same, so we simply add their
30 * coefficients.
31 */
32static void expand_constraint(isl_vec *v, unsigned dim,
33 isl_int *c, int *div_map, unsigned n_div)
34{
35 int i;
36
37 isl_seq_cpy(v->el, c, 1 + dim);
38 isl_seq_clr(v->el + 1 + dim, v->size - (1 + dim));
39
40 for (i = 0; i < n_div; ++i) {
41 int pos = 1 + dim + div_map[i];
42 isl_int_add(v->el[pos], v->el[pos], c[1 + dim + i]);
43 }
44}
45
46/* Add all constraints of bmap to tab. The equalities of bmap
47 * are added as a pair of inequalities.
48 */
50 __isl_keep isl_basic_map *bmap, int *div_map)
51{
52 int i;
53 unsigned dim;
54 isl_size tab_total;
55 isl_size bmap_n_div;
56 isl_size bmap_total;
57 isl_vec *v;
58
59 if (!tab || !bmap)
60 return isl_stat_error;
61
62 tab_total = isl_basic_map_dim(tab->bmap, isl_dim_all);
63 bmap_total = isl_basic_map_dim(bmap, isl_dim_all);
64 bmap_n_div = isl_basic_map_dim(bmap, isl_dim_div);
65 dim = bmap_total - bmap_n_div;
66 if (tab_total < 0 || bmap_total < 0 || bmap_n_div < 0)
67 return isl_stat_error;
68
69 if (isl_tab_extend_cons(tab, 2 * bmap->n_eq + bmap->n_ineq) < 0)
70 return isl_stat_error;
71
72 v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
73 if (!v)
74 return isl_stat_error;
75
76 for (i = 0; i < bmap->n_eq; ++i) {
77 expand_constraint(v, dim, bmap->eq[i], div_map, bmap_n_div);
78 if (isl_tab_add_ineq(tab, v->el) < 0)
79 goto error;
80 isl_seq_neg(bmap->eq[i], bmap->eq[i], 1 + bmap_total);
81 expand_constraint(v, dim, bmap->eq[i], div_map, bmap_n_div);
82 if (isl_tab_add_ineq(tab, v->el) < 0)
83 goto error;
84 isl_seq_neg(bmap->eq[i], bmap->eq[i], 1 + bmap_total);
85 if (tab->empty)
86 break;
87 }
88
89 for (i = 0; i < bmap->n_ineq; ++i) {
90 expand_constraint(v, dim, bmap->ineq[i], div_map, bmap_n_div);
91 if (isl_tab_add_ineq(tab, v->el) < 0)
92 goto error;
93 if (tab->empty)
94 break;
95 }
96
97 isl_vec_free(v);
98 return isl_stat_ok;
99error:
100 isl_vec_free(v);
101 return isl_stat_error;
102}
103
104/* Add a specific constraint of bmap (or its opposite) to tab.
105 * The position of the constraint is specified by "c", where
106 * the equalities of bmap are counted twice, once for the inequality
107 * that is equal to the equality, and once for its negation.
108 *
109 * Each of these constraints has been added to "tab" before by
110 * tab_add_constraints (and later removed again), so there should
111 * already be a row available for the constraint.
112 */
114 __isl_keep isl_basic_map *bmap, int *div_map, int c, int oppose)
115{
116 unsigned dim;
117 isl_size tab_total;
118 isl_size bmap_n_div;
119 isl_size bmap_total;
120 isl_vec *v;
121 isl_stat r;
122
123 if (!tab || !bmap)
124 return isl_stat_error;
125
126 tab_total = isl_basic_map_dim(tab->bmap, isl_dim_all);
127 bmap_total = isl_basic_map_dim(bmap, isl_dim_all);
128 bmap_n_div = isl_basic_map_dim(bmap, isl_dim_div);
129 dim = bmap_total - bmap_n_div;
130 if (tab_total < 0 || bmap_total < 0 || bmap_n_div < 0)
131 return isl_stat_error;
132
133 v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
134 if (!v)
135 return isl_stat_error;
136
137 if (c < 2 * bmap->n_eq) {
138 if ((c % 2) != oppose)
139 isl_seq_neg(bmap->eq[c/2], bmap->eq[c/2],
140 1 + bmap_total);
141 if (oppose)
142 isl_int_sub_ui(bmap->eq[c/2][0], bmap->eq[c/2][0], 1);
143 expand_constraint(v, dim, bmap->eq[c/2], div_map, bmap_n_div);
144 r = isl_tab_add_ineq(tab, v->el);
145 if (oppose)
146 isl_int_add_ui(bmap->eq[c/2][0], bmap->eq[c/2][0], 1);
147 if ((c % 2) != oppose)
148 isl_seq_neg(bmap->eq[c/2], bmap->eq[c/2],
149 1 + bmap_total);
150 } else {
151 c -= 2 * bmap->n_eq;
152 if (oppose) {
153 isl_seq_neg(bmap->ineq[c], bmap->ineq[c],
154 1 + bmap_total);
155 isl_int_sub_ui(bmap->ineq[c][0], bmap->ineq[c][0], 1);
156 }
157 expand_constraint(v, dim, bmap->ineq[c], div_map, bmap_n_div);
158 r = isl_tab_add_ineq(tab, v->el);
159 if (oppose) {
160 isl_int_add_ui(bmap->ineq[c][0], bmap->ineq[c][0], 1);
161 isl_seq_neg(bmap->ineq[c], bmap->ineq[c],
162 1 + bmap_total);
163 }
164 }
165
166 isl_vec_free(v);
167 return r;
168}
169
170static isl_stat tab_add_divs(struct isl_tab *tab,
171 __isl_keep isl_basic_map *bmap, int **div_map)
172{
173 int i, j;
174 struct isl_vec *vec;
176 unsigned dim;
177
178 if (!bmap)
179 return isl_stat_error;
180 if (!bmap->n_div)
181 return isl_stat_ok;
182
183 if (!*div_map)
184 *div_map = isl_alloc_array(bmap->ctx, int, bmap->n_div);
185 if (!*div_map)
186 return isl_stat_error;
187
189 if (total < 0)
190 return isl_stat_error;
191 dim = total - tab->bmap->n_div;
192 vec = isl_vec_alloc(bmap->ctx, 2 + total + bmap->n_div);
193 if (!vec)
194 return isl_stat_error;
195
196 for (i = 0; i < bmap->n_div; ++i) {
197 isl_seq_cpy(vec->el, bmap->div[i], 2 + dim);
198 isl_seq_clr(vec->el + 2 + dim, tab->bmap->n_div);
199 for (j = 0; j < i; ++j)
200 isl_int_add(vec->el[2 + dim + (*div_map)[j]],
201 vec->el[2 + dim + (*div_map)[j]],
202 bmap->div[i][2 + dim + j]);
203 for (j = 0; j < tab->bmap->n_div; ++j)
204 if (isl_seq_eq(tab->bmap->div[j],
205 vec->el, 2 + dim + tab->bmap->n_div))
206 break;
207 (*div_map)[i] = j;
208 if (j == tab->bmap->n_div) {
209 vec->size = 2 + dim + tab->bmap->n_div;
210 if (isl_tab_add_div(tab, vec) < 0)
211 goto error;
212 }
213 }
214
215 isl_vec_free(vec);
216
217 return isl_stat_ok;
218error:
219 isl_vec_free(vec);
220
221 return isl_stat_error;
222}
223
224/* Freeze all constraints of tableau tab.
225 */
226static int tab_freeze_constraints(struct isl_tab *tab)
227{
228 int i;
229
230 for (i = 0; i < tab->n_con; ++i)
231 if (isl_tab_freeze_constraint(tab, i) < 0)
232 return -1;
233
234 return 0;
235}
236
237/* Check for redundant constraints starting at offset.
238 * Put the indices of the non-redundant constraints in index
239 * and return the number of non-redundant constraints.
240 */
241static int n_non_redundant(isl_ctx *ctx, struct isl_tab *tab,
242 int offset, int **index)
243{
244 int i, n;
245 int n_test = tab->n_con - offset;
246
247 if (isl_tab_detect_redundant(tab) < 0)
248 return -1;
249
250 if (n_test == 0)
251 return 0;
252 if (!*index)
253 *index = isl_alloc_array(ctx, int, n_test);
254 if (!*index)
255 return -1;
256
257 for (n = 0, i = 0; i < n_test; ++i) {
258 int r;
259 r = isl_tab_is_redundant(tab, offset + i);
260 if (r < 0)
261 return -1;
262 if (r)
263 continue;
264 (*index)[n++] = i;
265 }
266
267 return n;
268}
269
270/* basic_map_collect_diff calls add on each of the pieces of
271 * the set difference between bmap and map until the add method
272 * return a negative value.
273 */
277};
278
279/* Compute the set difference between bmap and map and call
280 * dc->add on each of the piece until this function returns
281 * a negative value.
282 * Return 0 on success and -1 on error. dc->add returning
283 * a negative value is treated as an error, but the calling
284 * function can interpret the results based on the state of dc.
285 *
286 * Assumes that map has known divs.
287 *
288 * The difference is computed by a backtracking algorithm.
289 * Each level corresponds to a basic map in "map".
290 * When a node in entered for the first time, we check
291 * if the corresonding basic map intersects the current piece
292 * of "bmap". If not, we move to the next level.
293 * Otherwise, we split the current piece into as many
294 * pieces as there are non-redundant constraints of the current
295 * basic map in the intersection. Each of these pieces is
296 * handled by a child of the current node.
297 * In particular, if there are n non-redundant constraints,
298 * then for each 0 <= i < n, a piece is cut off by adding
299 * constraints 0 <= j < i and adding the opposite of constraint i.
300 * If there are no non-redundant constraints, meaning that the current
301 * piece is a subset of the current basic map, then we simply backtrack.
302 *
303 * In the leaves, we check if the remaining piece has any integer points
304 * and if so, pass it along to dc->add. As a special case, if nothing
305 * has been removed when we end up in a leaf, we simply pass along
306 * the original basic map.
307 */
310{
311 int i;
312 int modified;
313 int level;
314 int init;
315 isl_bool empty;
316 isl_ctx *ctx;
317 struct isl_tab *tab = NULL;
318 struct isl_tab_undo **snap = NULL;
319 int *k = NULL;
320 int *n = NULL;
321 int **index = NULL;
322 int **div_map = NULL;
323
324 empty = isl_basic_map_is_empty(bmap);
325 if (empty) {
326 isl_basic_map_free(bmap);
328 return empty < 0 ? isl_stat_error : isl_stat_ok;
329 }
330
331 bmap = isl_basic_map_cow(bmap);
333
334 if (!bmap || !map)
335 goto error;
336
337 ctx = map->ctx;
338 snap = isl_alloc_array(map->ctx, struct isl_tab_undo *, map->n);
339 k = isl_alloc_array(map->ctx, int, map->n);
340 n = isl_alloc_array(map->ctx, int, map->n);
341 index = isl_calloc_array(map->ctx, int *, map->n);
342 div_map = isl_calloc_array(map->ctx, int *, map->n);
343 if (!snap || !k || !n || !index || !div_map)
344 goto error;
345
346 bmap = isl_basic_map_order_divs(bmap);
348
349 tab = isl_tab_from_basic_map(bmap, 1);
350 if (!tab)
351 goto error;
352
353 modified = 0;
354 level = 0;
355 init = 1;
356
357 while (level >= 0) {
358 if (level >= map->n) {
359 int empty;
360 struct isl_basic_map *bm;
361 if (!modified) {
362 if (dc->add(dc, isl_basic_map_copy(bmap)) < 0)
363 goto error;
364 break;
365 }
366 bm = isl_basic_map_copy(tab->bmap);
367 bm = isl_basic_map_cow(bm);
368 bm = isl_basic_map_update_from_tab(bm, tab);
369 bm = isl_basic_map_simplify(bm);
370 bm = isl_basic_map_finalize(bm);
371 empty = isl_basic_map_is_empty(bm);
372 if (empty)
374 else if (dc->add(dc, bm) < 0)
375 goto error;
376 if (empty < 0)
377 goto error;
378 level--;
379 init = 0;
380 continue;
381 }
382 if (init) {
383 int offset;
384 struct isl_tab_undo *snap2;
385 snap2 = isl_tab_snap(tab);
386 if (tab_add_divs(tab, map->p[level],
387 &div_map[level]) < 0)
388 goto error;
389 offset = tab->n_con;
390 snap[level] = isl_tab_snap(tab);
391 if (tab_freeze_constraints(tab) < 0)
392 goto error;
393 if (tab_add_constraints(tab, map->p[level],
394 div_map[level]) < 0)
395 goto error;
396 k[level] = 0;
397 n[level] = 0;
398 if (tab->empty) {
399 if (isl_tab_rollback(tab, snap2) < 0)
400 goto error;
401 level++;
402 continue;
403 }
404 modified = 1;
405 n[level] = n_non_redundant(ctx, tab, offset,
406 &index[level]);
407 if (n[level] < 0)
408 goto error;
409 if (n[level] == 0) {
410 level--;
411 init = 0;
412 continue;
413 }
414 if (isl_tab_rollback(tab, snap[level]) < 0)
415 goto error;
416 if (tab_add_constraint(tab, map->p[level],
417 div_map[level], index[level][0], 1) < 0)
418 goto error;
419 level++;
420 continue;
421 } else {
422 if (k[level] + 1 >= n[level]) {
423 level--;
424 continue;
425 }
426 if (isl_tab_rollback(tab, snap[level]) < 0)
427 goto error;
428 if (tab_add_constraint(tab, map->p[level],
429 div_map[level],
430 index[level][k[level]], 0) < 0)
431 goto error;
432 snap[level] = isl_tab_snap(tab);
433 k[level]++;
434 if (tab_add_constraint(tab, map->p[level],
435 div_map[level],
436 index[level][k[level]], 1) < 0)
437 goto error;
438 level++;
439 init = 1;
440 continue;
441 }
442 }
443
444 isl_tab_free(tab);
445 free(snap);
446 free(n);
447 free(k);
448 for (i = 0; index && i < map->n; ++i)
449 free(index[i]);
450 free(index);
451 for (i = 0; div_map && i < map->n; ++i)
452 free(div_map[i]);
453 free(div_map);
454
455 isl_basic_map_free(bmap);
457
458 return isl_stat_ok;
459error:
460 isl_tab_free(tab);
461 free(snap);
462 free(n);
463 free(k);
464 for (i = 0; index && i < map->n; ++i)
465 free(index[i]);
466 free(index);
467 for (i = 0; div_map && i < map->n; ++i)
468 free(div_map[i]);
469 free(div_map);
470 isl_basic_map_free(bmap);
472 return isl_stat_error;
473}
474
475/* A diff collector that actually collects all parts of the
476 * set difference in the field diff.
477 */
480 struct isl_map *diff;
481};
482
483/* isl_subtract_diff_collector callback.
484 */
487{
488 struct isl_subtract_diff_collector *sdc;
489 sdc = (struct isl_subtract_diff_collector *)dc;
490
491 sdc->diff = isl_map_union_disjoint(sdc->diff,
493
494 return sdc->diff ? isl_stat_ok : isl_stat_error;
495}
496
497/* Return the set difference between bmap and map.
498 */
501{
505 if (basic_map_collect_diff(bmap, map, &sdc.dc) < 0) {
506 isl_map_free(sdc.diff);
507 sdc.diff = NULL;
508 }
509 return sdc.diff;
510}
511
512/* Return an empty map living in the same space as "map1" and "map2".
513 */
516{
517 isl_space *space;
518
519 space = isl_map_get_space(map1);
522 return isl_map_empty(space);
523}
524
525/* Return the set difference between map1 and map2.
526 * (U_i A_i) \ (U_j B_j) is computed as U_i (A_i \ (U_j B_j))
527 *
528 * If "map1" and "map2" are obviously equal to each other,
529 * then return an empty map in the same space.
530 *
531 * If "map1" and "map2" are disjoint, then simply return "map1".
532 */
535{
536 int i;
537 int equal, disjoint;
538 struct isl_map *diff;
539
541 goto error;
543 goto error;
544
546 if (equal < 0)
547 goto error;
548 if (equal)
550
551 disjoint = isl_map_is_disjoint(map1, map2);
552 if (disjoint < 0)
553 goto error;
554 if (disjoint) {
556 return map1;
557 }
558
561 if (!map1 || !map2)
562 goto error;
563
566
568 for (i = 0; i < map1->n; ++i) {
569 struct isl_map *d;
573 diff = isl_map_union_disjoint(diff, d);
574 else
575 diff = isl_map_union(diff, d);
576 }
577
580
581 return diff;
582error:
585 return NULL;
586}
587
590{
592 set_to_map(set2)));
593}
594
595/* Remove the elements of "dom" from the domain of "map".
596 */
598 __isl_take isl_set *dom)
599{
600 isl_bool ok;
601 isl_map *ext_dom;
602
605 if (ok < 0)
606 goto error;
607 if (!ok)
609 "incompatible spaces", goto error);
610
612 ext_dom = isl_map_intersect_domain(ext_dom, dom);
613 return isl_map_subtract(map, ext_dom);
614error:
616 isl_set_free(dom);
617 return NULL;
618}
619
620/* Remove the elements of "dom" from the range of "map".
621 */
623 __isl_take isl_set *dom)
624{
625 isl_bool ok;
626 isl_map *ext_dom;
627
629 ok = isl_map_compatible_range(map, dom);
630 if (ok < 0)
631 goto error;
632 if (!ok)
634 "incompatible spaces", goto error);
635
637 ext_dom = isl_map_intersect_range(ext_dom, dom);
638 return isl_map_subtract(map, ext_dom);
639error:
641 isl_set_free(dom);
642 return NULL;
643}
644
645/* A diff collector that aborts as soon as its add function is called,
646 * setting empty to isl_false.
647 */
651};
652
653/* isl_is_empty_diff_collector callback.
654 */
657{
658 struct isl_is_empty_diff_collector *edc;
659 edc = (struct isl_is_empty_diff_collector *)dc;
660
661 edc->empty = isl_bool_false;
662
663 isl_basic_map_free(bmap);
664 return isl_stat_error;
665}
666
667/* Check if bmap \ map is empty by computing this set difference
668 * and breaking off as soon as the difference is known to be non-empty.
669 */
672{
674 isl_stat r;
676
678 if (empty)
679 return empty;
680
682 edc.empty = isl_bool_true;
684 isl_map_copy(map), &edc.dc);
685 if (!edc.empty)
686 return isl_bool_false;
687
688 return r < 0 ? isl_bool_error : isl_bool_true;
689}
690
691/* Check if map1 \ map2 is empty by checking if the set difference is empty
692 * for each of the basic maps in map1.
693 */
696{
697 int i;
698 isl_bool is_empty = isl_bool_true;
699
700 if (!map1 || !map2)
701 return isl_bool_error;
702
703 for (i = 0; i < map1->n; ++i) {
704 is_empty = basic_map_diff_is_empty(map1->p[i], map2);
705 if (is_empty < 0 || !is_empty)
706 break;
707 }
708
709 return is_empty;
710}
711
712/* Return true if "bmap" contains a single element.
713 */
715{
717
718 if (!bmap)
719 return isl_bool_error;
720 if (bmap->n_div)
721 return isl_bool_false;
722 if (bmap->n_ineq)
723 return isl_bool_false;
725 if (total < 0)
726 return isl_bool_error;
727 return bmap->n_eq == total;
728}
729
730/* Return true if "map" contains a single element.
731 */
733{
734 if (!map)
735 return isl_bool_error;
736 if (map->n != 1)
737 return isl_bool_false;
738
740}
741
742/* Given a singleton basic map, extract the single element
743 * as an isl_point.
744 */
747{
748 int j;
749 isl_size dim;
750 struct isl_vec *point;
751 isl_int m;
752
753 dim = isl_basic_map_dim(bmap, isl_dim_all);
754 if (dim < 0)
755 return NULL;
756
757 isl_assert(bmap->ctx, bmap->n_eq == dim, return NULL);
758 point = isl_vec_alloc(bmap->ctx, 1 + dim);
759 if (!point)
760 return NULL;
761
763
764 isl_int_set_si(point->el[0], 1);
765 for (j = 0; j < bmap->n_eq; ++j) {
766 int i = dim - 1 - j;
767 isl_assert(bmap->ctx,
768 isl_seq_first_non_zero(bmap->eq[j] + 1, i) == -1,
769 goto error);
770 isl_assert(bmap->ctx,
771 isl_int_is_one(bmap->eq[j][1 + i]) ||
772 isl_int_is_negone(bmap->eq[j][1 + i]),
773 goto error);
774 isl_assert(bmap->ctx,
775 isl_seq_first_non_zero(bmap->eq[j]+1+i+1, dim-i-1) == -1,
776 goto error);
777
778 isl_int_gcd(m, point->el[0], bmap->eq[j][1 + i]);
779 isl_int_divexact(m, bmap->eq[j][1 + i], m);
780 isl_int_abs(m, m);
781 isl_seq_scale(point->el, point->el, m, 1 + i);
782 isl_int_divexact(m, point->el[0], bmap->eq[j][1 + i]);
783 isl_int_neg(m, m);
784 isl_int_mul(point->el[1 + i], m, bmap->eq[j][0]);
785 }
786
789error:
792 return NULL;
793}
794
795/* Return isl_bool_true if the singleton map "map1" is a subset of "map2",
796 * i.e., if the single element of "map1" is also an element of "map2".
797 * Assumes "map2" has known divs.
798 */
801{
802 int i;
803 isl_bool is_subset = isl_bool_false;
804 struct isl_point *point;
805
806 if (!map1 || !map2)
807 return isl_bool_error;
808 if (map1->n != 1)
810 "expecting single-disjunct input",
811 return isl_bool_error);
812
814 if (!point)
815 return isl_bool_error;
816
817 for (i = 0; i < map2->n; ++i) {
818 is_subset = isl_basic_map_contains_point(map2->p[i], point);
819 if (is_subset)
820 break;
821 }
822
824 return is_subset;
825}
826
829{
830 isl_bool is_subset = isl_bool_false;
831 isl_bool empty, single;
832 isl_bool rat1, rat2;
833
834 if (!map1 || !map2)
835 return isl_bool_error;
836
838 return isl_bool_false;
839
840 empty = isl_map_is_empty(map1);
841 if (empty < 0)
842 return isl_bool_error;
843 if (empty)
844 return isl_bool_true;
845
846 empty = isl_map_is_empty(map2);
847 if (empty < 0)
848 return isl_bool_error;
849 if (empty)
850 return isl_bool_false;
851
854 if (rat1 < 0 || rat2 < 0)
855 return isl_bool_error;
856 if (rat1 && !rat2)
857 return isl_bool_false;
858
860 return isl_bool_true;
861
863 if (single < 0)
864 return isl_bool_error;
866 if (single) {
867 is_subset = map_is_singleton_subset(map1, map2);
869 return is_subset;
870 }
871 is_subset = map_diff_is_empty(map1, map2);
873
874 return is_subset;
875}
876
878{
881}
882
884{
886}
887
889{
890 int i;
893
894 if (!map)
895 return NULL;
897 return map;
898 if (map->n <= 1)
899 return map;
900
903
904 if (!map || map->n <= 1)
905 return map;
906
908
909 for (i = 1; i < map->n; ++i) {
910 struct isl_basic_map *bmap = isl_basic_map_copy(map->p[i]);
911 struct isl_map *copy = isl_map_copy(sdc.diff);
912 if (basic_map_collect_diff(bmap, copy, &sdc.dc) < 0) {
913 isl_map_free(sdc.diff);
914 sdc.diff = NULL;
915 break;
916 }
917 }
918
920
921 return sdc.diff;
922}
923
925{
927}
928
930{
932
933 if (!map)
934 return NULL;
935
937
939}
940
942{
943 return isl_map_complement(set);
944}
#define __isl_take
Definition: ctx.h:22
isl_stat
Definition: ctx.h:84
@ isl_stat_error
Definition: ctx.h:85
@ isl_stat_ok
Definition: ctx.h:86
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
#define isl_assert(ctx, test, code)
Definition: ctx.h:152
@ isl_error_invalid
Definition: ctx.h:80
#define isl_alloc_array(ctx, type, n)
Definition: ctx.h:131
#define isl_calloc_array(ctx, type, n)
Definition: ctx.h:132
#define ISL_F_ISSET(p, f)
Definition: ctx.h:117
#define __isl_keep
Definition: ctx.h:25
int isl_size
Definition: ctx.h:96
isl_bool
Definition: ctx.h:89
@ isl_bool_false
Definition: ctx.h:91
@ isl_bool_true
Definition: ctx.h:92
@ isl_bool_error
Definition: ctx.h:90
m
Definition: guard1-0.c:2
void GMPQAPI() init(mp_rat x)
#define isl_int_is_one(i)
Definition: isl_int.h:32
#define isl_int_is_negone(i)
Definition: isl_int.h:33
#define isl_int_gcd(r, i, j)
Definition: isl_int_gmp.h:42
#define isl_int_neg(r, i)
Definition: isl_int_gmp.h:24
#define isl_int_add_ui(r, i, j)
Definition: isl_int_gmp.h:27
#define isl_int_add(r, i, j)
Definition: isl_int_gmp.h:30
#define isl_int_divexact(r, i, j)
Definition: isl_int_gmp.h:44
#define isl_int_mul(r, i, j)
Definition: isl_int_gmp.h:32
#define isl_int_set_si(r, i)
Definition: isl_int_gmp.h:15
#define isl_int_sub_ui(r, i, j)
Definition: isl_int_gmp.h:28
#define isl_int_init(i)
Definition: isl_int_gmp.h:11
#define isl_int_abs(r, i)
Definition: isl_int_gmp.h:23
#define isl_int_clear(i)
Definition: isl_int_gmp.h:12
__isl_give isl_basic_map * isl_basic_map_order_divs(__isl_take isl_basic_map *bmap)
Definition: isl_map.c:9491
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition: isl_map.c:70
__isl_give isl_map * isl_map_order_divs(__isl_take isl_map *map)
Definition: isl_map.c:9521
__isl_give isl_map * isl_map_cow(__isl_take isl_map *map)
Definition: isl_map.c:2097
__isl_give isl_basic_map * isl_basic_map_cow(__isl_take isl_basic_map *bmap)
Definition: isl_map.c:2052
isl_bool isl_map_align_params_map_map_and_test(__isl_keep isl_map *map1, __isl_keep isl_map *map2, isl_bool(*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2))
Definition: isl_map.c:1607
isl_bool isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set)
Definition: isl_map.c:357
__isl_give isl_map * isl_map_remove_empty_parts(__isl_take isl_map *map)
Definition: isl_map.c:9842
isl_bool isl_map_has_rational(__isl_keep isl_map *map)
Definition: isl_map.c:1237
isl_bool isl_map_compatible_domain(__isl_keep isl_map *map, __isl_keep isl_set *set)
Definition: isl_map.c:333
isl_stat isl_map_align_params_bin(__isl_keep isl_map **map1, __isl_keep isl_map **map2)
__isl_give isl_basic_map * isl_basic_map_simplify(__isl_take isl_basic_map *bmap)
isl_stat isl_map_align_params_set(__isl_keep isl_map **map, __isl_keep isl_set **set)
__isl_give isl_basic_map * isl_basic_map_finalize(__isl_take isl_basic_map *bmap)
#define ISL_MAP_DISJOINT
isl_stat isl_map_check_equal_space(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
isl_bool isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap, __isl_keep isl_point *point)
Definition: isl_point.c:616
static int tab_freeze_constraints(struct isl_tab *tab)
isl_bool isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_give isl_map * isl_map_subtract(__isl_take isl_map *map1, __isl_take isl_map *map2)
__isl_give isl_map * isl_map_subtract_range(__isl_take isl_map *map, __isl_take isl_set *dom)
static isl_bool map_is_singleton_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
isl_bool isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
__isl_give isl_set * isl_set_make_disjoint(__isl_take isl_set *set)
__isl_give isl_map * isl_map_make_disjoint(__isl_take isl_map *map)
static __isl_give isl_map * replace_pair_by_empty(__isl_take isl_map *map1, __isl_take isl_map *map2)
static isl_bool map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
__isl_give isl_set * isl_set_subtract(__isl_take isl_set *set1, __isl_take isl_set *set2)
isl_bool isl_map_plain_is_singleton(__isl_keep isl_map *map)
static __isl_give isl_map * basic_map_subtract(__isl_take isl_basic_map *bmap, __isl_take isl_map *map)
static isl_stat basic_map_subtract_add(struct isl_diff_collector *dc, __isl_take isl_basic_map *bmap)
static void expand_constraint(isl_vec *v, unsigned dim, isl_int *c, int *div_map, unsigned n_div)
static isl_stat tab_add_constraint(struct isl_tab *tab, __isl_keep isl_basic_map *bmap, int *div_map, int c, int oppose)
__isl_give isl_map * isl_map_complement(__isl_take isl_map *map)
static isl_stat basic_map_is_empty_add(struct isl_diff_collector *dc, __isl_take isl_basic_map *bmap)
isl_bool isl_map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
static __isl_give isl_point * singleton_extract_point(__isl_keep isl_basic_map *bmap)
static int n_non_redundant(isl_ctx *ctx, struct isl_tab *tab, int offset, int **index)
__isl_give isl_set * isl_set_complement(__isl_take isl_set *set)
static isl_bool basic_map_diff_is_empty(__isl_keep isl_basic_map *bmap, __isl_keep isl_map *map)
static isl_bool map_diff_is_empty(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
__isl_give isl_map * isl_map_subtract_domain(__isl_take isl_map *map, __isl_take isl_set *dom)
static isl_stat tab_add_constraints(struct isl_tab *tab, __isl_keep isl_basic_map *bmap, int *div_map)
static isl_stat tab_add_divs(struct isl_tab *tab, __isl_keep isl_basic_map *bmap, int **div_map)
static isl_stat basic_map_collect_diff(__isl_take isl_basic_map *bmap, __isl_take isl_map *map, struct isl_diff_collector *dc)
static void oppose(__isl_keep isl_mat *M, __isl_keep isl_mat **U, __isl_keep isl_mat **Q, unsigned row, unsigned col)
Definition: isl_mat.c:615
__isl_give isl_point * isl_point_alloc(__isl_take isl_space *space, __isl_take isl_vec *vec)
Definition: isl_point.c:66
int isl_seq_first_non_zero(isl_int *p, unsigned len)
Definition: isl_seq.c:196
void isl_seq_clr(isl_int *p, unsigned len)
Definition: isl_seq.c:14
void isl_seq_scale(isl_int *dst, isl_int *src, isl_int m, unsigned len)
Definition: isl_seq.c:70
void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len)
Definition: isl_seq.c:42
int isl_seq_eq(isl_int *p1, isl_int *p2, unsigned len)
Definition: isl_seq.c:162
void isl_seq_neg(isl_int *dst, isl_int *src, unsigned len)
Definition: isl_seq.c:35
int isl_tab_detect_redundant(struct isl_tab *tab)
Definition: isl_tab.c:3261
void isl_tab_free(struct isl_tab *tab)
Definition: isl_tab.c:204
int isl_tab_is_redundant(struct isl_tab *tab, int con)
Definition: isl_tab.c:3425
struct isl_tab_undo * isl_tab_snap(struct isl_tab *tab)
Definition: isl_tab.c:3674
isl_stat isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq)
Definition: isl_tab.c:1896
int isl_tab_add_div(struct isl_tab *tab, __isl_keep isl_vec *div)
Definition: isl_tab.c:2372
__isl_give struct isl_tab * isl_tab_from_basic_map(__isl_keep isl_basic_map *bmap, int track)
Definition: isl_tab.c:2384
isl_stat isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap)
Definition: isl_tab.c:4014
int isl_tab_freeze_constraint(struct isl_tab *tab, int con)
Definition: isl_tab.c:1007
int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new)
Definition: isl_tab.c:105
__isl_give isl_basic_map * isl_basic_map_update_from_tab(__isl_take isl_basic_map *bmap, struct isl_tab *tab)
Definition: isl_tab.c:2624
const char * set
Definition: isl_test.c:1356
const char * map
Definition: isl_test.c:1783
int equal
Definition: isl_test.c:7868
const char * offset
Definition: isl_test.c:1569
const char * point
Definition: isl_test.c:10700
const char * map1
Definition: isl_test.c:360
const char * map2
Definition: isl_test.c:361
const char * set1
Definition: isl_test.c:4203
const char * set2
Definition: isl_test.c:4204
static __isl_give isl_union_map * total(__isl_take isl_union_map *umap, __isl_give isl_map *(*fn)(__isl_take isl_map *))
static __isl_give isl_map * universe(__isl_take isl_map *map)
__isl_export __isl_give isl_map * isl_map_intersect_range(__isl_take isl_map *map, __isl_take isl_set *set)
Definition: isl_map.c:8325
__isl_export isl_bool isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap)
Definition: isl_map.c:9379
__isl_export __isl_give isl_map * isl_map_union(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition: isl_map.c:8246
__isl_give isl_space * isl_basic_map_get_space(__isl_keep isl_basic_map *bmap)
Definition: isl_map.c:416
__isl_give isl_map * isl_map_union_disjoint(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition: isl_map.c:8227
__isl_export isl_bool isl_map_is_empty(__isl_keep isl_map *map)
Definition: isl_map.c:9136
__isl_export __isl_give isl_map * isl_map_universe(__isl_take isl_space *space)
Definition: isl_map.c:6348
isl_bool isl_map_has_equal_space(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
isl_bool isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap)
Definition: isl_map.c:9424
__isl_give isl_map * isl_map_copy(__isl_keep isl_map *map)
Definition: isl_map.c:1494
__isl_null isl_basic_map * isl_basic_map_free(__isl_take isl_basic_map *bmap)
Definition: isl_map.c:1503
__isl_export __isl_give isl_space * isl_map_get_space(__isl_keep isl_map *map)
Definition: isl_map.c:598
isl_size isl_basic_map_dim(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition: isl_map.c:80
isl_bool isl_map_plain_is_universe(__isl_keep isl_map *map)
Definition: isl_map.c:9358
isl_ctx * isl_map_get_ctx(__isl_keep isl_map *map)
Definition: isl_map.c:391
__isl_export __isl_give isl_map * isl_map_intersect_domain(__isl_take isl_map *map, __isl_take isl_set *set)
Definition: isl_map.c:8353
__isl_export __isl_give isl_map * isl_map_empty(__isl_take isl_space *space)
Definition: isl_map.c:6338
__isl_export isl_bool isl_map_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
Definition: isl_map.c:6421
__isl_constructor __isl_give isl_map * isl_map_from_basic_map(__isl_take isl_basic_map *bmap)
Definition: isl_map.c:3495
__isl_give isl_basic_map * isl_basic_map_copy(__isl_keep isl_basic_map *bmap)
Definition: isl_map.c:1479
isl_bool isl_map_plain_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
Definition: isl_map.c:10533
__isl_give isl_map * isl_map_compute_divs(__isl_take isl_map *map)
Definition: isl_map.c:8086
struct isl_set isl_set
Definition: map_type.h:26
__isl_null isl_point * isl_point_free(__isl_take isl_point *pnt)
Definition: isl_point.c:150
isl_ctx * isl_set_get_ctx(__isl_keep isl_set *set)
Definition: isl_map.c:396
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
Definition: isl_map.c:3513
static __isl_give isl_set * set_from_map(__isl_take isl_map *map)
Definition: set_from_map.c:5
@ isl_dim_all
Definition: space_type.h:20
@ isl_dim_div
Definition: space_type.h:19
isl_int ** div
isl_stat(* add)(struct isl_diff_collector *dc, __isl_take isl_basic_map *bmap)
struct isl_diff_collector dc
struct isl_diff_collector dc
unsigned n_con
Definition: isl_tab.h:147
unsigned empty
Definition: isl_tab.h:178
unsigned n_eq
Definition: isl_tab.h:148
struct isl_basic_map * bmap
Definition: isl_tab.h:160
isl_int * el
struct isl_ctx * ctx
unsigned size
static Signature set_to_map
__isl_null isl_vec * isl_vec_free(__isl_take isl_vec *vec)
Definition: isl_vec.c:234
__isl_give isl_vec * isl_vec_alloc(isl_ctx *ctx, unsigned size)
Definition: isl_vec.c:33
n
Definition: youcefn.c:8