2 * Copyright 2010-2011 INRIA Saclay
3 * Copyright 2013-2014 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
8 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
13 #include <isl_map_private.h>
19 #include <isl_space_private.h>
20 #include <isl_union_map_private.h>
21 #include <isl/union_set.h>
22 #include <isl/deprecated/union_map_int.h>
24 /* Is this union set a parameter domain?
26 int isl_union_set_is_params(__isl_keep isl_union_set
*uset
)
33 if (uset
->table
.n
!= 1)
36 set
= isl_set_from_union_set(isl_union_set_copy(uset
));
37 params
= isl_set_is_params(set
);
42 static __isl_give isl_union_map
*isl_union_map_alloc(__isl_take isl_space
*dim
,
47 dim
= isl_space_params(dim
);
51 umap
= isl_calloc_type(dim
->ctx
, isl_union_map
);
57 if (isl_hash_table_init(dim
->ctx
, &umap
->table
, size
) < 0)
58 return isl_union_map_free(umap
);
63 __isl_give isl_union_map
*isl_union_map_empty(__isl_take isl_space
*dim
)
65 return isl_union_map_alloc(dim
, 16);
68 __isl_give isl_union_set
*isl_union_set_empty(__isl_take isl_space
*dim
)
70 return isl_union_map_empty(dim
);
73 isl_ctx
*isl_union_map_get_ctx(__isl_keep isl_union_map
*umap
)
75 return umap
? umap
->dim
->ctx
: NULL
;
78 isl_ctx
*isl_union_set_get_ctx(__isl_keep isl_union_set
*uset
)
80 return uset
? uset
->dim
->ctx
: NULL
;
83 __isl_give isl_space
*isl_union_map_get_space(__isl_keep isl_union_map
*umap
)
87 return isl_space_copy(umap
->dim
);
90 __isl_give isl_space
*isl_union_set_get_space(__isl_keep isl_union_set
*uset
)
92 return isl_union_map_get_space(uset
);
95 static int free_umap_entry(void **entry
, void *user
)
97 isl_map
*map
= *entry
;
102 static int add_map(__isl_take isl_map
*map
, void *user
)
104 isl_union_map
**umap
= (isl_union_map
**)user
;
106 *umap
= isl_union_map_add_map(*umap
, map
);
111 __isl_give isl_union_map
*isl_union_map_dup(__isl_keep isl_union_map
*umap
)
118 dup
= isl_union_map_empty(isl_space_copy(umap
->dim
));
119 if (isl_union_map_foreach_map(umap
, &add_map
, &dup
) < 0)
123 isl_union_map_free(dup
);
127 __isl_give isl_union_map
*isl_union_map_cow(__isl_take isl_union_map
*umap
)
135 return isl_union_map_dup(umap
);
138 struct isl_union_align
{
143 static int align_entry(void **entry
, void *user
)
145 isl_map
*map
= *entry
;
147 struct isl_union_align
*data
= user
;
149 exp
= isl_reordering_extend_space(isl_reordering_copy(data
->exp
),
150 isl_map_get_space(map
));
152 data
->res
= isl_union_map_add_map(data
->res
,
153 isl_map_realign(isl_map_copy(map
), exp
));
158 /* Align the parameters of umap along those of model.
159 * The result has the parameters of model first, in the same order
160 * as they appear in model, followed by any remaining parameters of
161 * umap that do not appear in model.
163 __isl_give isl_union_map
*isl_union_map_align_params(
164 __isl_take isl_union_map
*umap
, __isl_take isl_space
*model
)
166 struct isl_union_align data
= { NULL
, NULL
};
171 if (isl_space_match(umap
->dim
, isl_dim_param
, model
, isl_dim_param
)) {
172 isl_space_free(model
);
176 model
= isl_space_params(model
);
177 data
.exp
= isl_parameter_alignment_reordering(umap
->dim
, model
);
181 data
.res
= isl_union_map_alloc(isl_space_copy(data
.exp
->dim
),
183 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
184 &align_entry
, &data
) < 0)
187 isl_reordering_free(data
.exp
);
188 isl_union_map_free(umap
);
189 isl_space_free(model
);
192 isl_reordering_free(data
.exp
);
193 isl_union_map_free(umap
);
194 isl_union_map_free(data
.res
);
195 isl_space_free(model
);
199 __isl_give isl_union_set
*isl_union_set_align_params(
200 __isl_take isl_union_set
*uset
, __isl_take isl_space
*model
)
202 return isl_union_map_align_params(uset
, model
);
205 __isl_give isl_union_map
*isl_union_map_union(__isl_take isl_union_map
*umap1
,
206 __isl_take isl_union_map
*umap2
)
208 umap1
= isl_union_map_align_params(umap1
, isl_union_map_get_space(umap2
));
209 umap2
= isl_union_map_align_params(umap2
, isl_union_map_get_space(umap1
));
211 umap1
= isl_union_map_cow(umap1
);
213 if (!umap1
|| !umap2
)
216 if (isl_union_map_foreach_map(umap2
, &add_map
, &umap1
) < 0)
219 isl_union_map_free(umap2
);
223 isl_union_map_free(umap1
);
224 isl_union_map_free(umap2
);
228 __isl_give isl_union_set
*isl_union_set_union(__isl_take isl_union_set
*uset1
,
229 __isl_take isl_union_set
*uset2
)
231 return isl_union_map_union(uset1
, uset2
);
234 __isl_give isl_union_map
*isl_union_map_copy(__isl_keep isl_union_map
*umap
)
243 __isl_give isl_union_set
*isl_union_set_copy(__isl_keep isl_union_set
*uset
)
245 return isl_union_map_copy(uset
);
248 void *isl_union_map_free(__isl_take isl_union_map
*umap
)
256 isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
257 &free_umap_entry
, NULL
);
258 isl_hash_table_clear(&umap
->table
);
259 isl_space_free(umap
->dim
);
264 void *isl_union_set_free(__isl_take isl_union_set
*uset
)
266 return isl_union_map_free(uset
);
269 static int has_dim(const void *entry
, const void *val
)
271 isl_map
*map
= (isl_map
*)entry
;
272 isl_space
*dim
= (isl_space
*)val
;
274 return isl_space_is_equal(map
->dim
, dim
);
277 __isl_give isl_union_map
*isl_union_map_add_map(__isl_take isl_union_map
*umap
,
278 __isl_take isl_map
*map
)
281 struct isl_hash_table_entry
*entry
;
286 if (isl_map_plain_is_empty(map
)) {
291 if (!isl_space_match(map
->dim
, isl_dim_param
, umap
->dim
, isl_dim_param
)) {
292 umap
= isl_union_map_align_params(umap
, isl_map_get_space(map
));
293 map
= isl_map_align_params(map
, isl_union_map_get_space(umap
));
296 umap
= isl_union_map_cow(umap
);
301 hash
= isl_space_get_hash(map
->dim
);
302 entry
= isl_hash_table_find(umap
->dim
->ctx
, &umap
->table
, hash
,
303 &has_dim
, map
->dim
, 1);
310 entry
->data
= isl_map_union(entry
->data
, isl_map_copy(map
));
319 isl_union_map_free(umap
);
323 __isl_give isl_union_set
*isl_union_set_add_set(__isl_take isl_union_set
*uset
,
324 __isl_take isl_set
*set
)
326 return isl_union_map_add_map(uset
, (isl_map
*)set
);
329 __isl_give isl_union_map
*isl_union_map_from_map(__isl_take isl_map
*map
)
337 dim
= isl_map_get_space(map
);
338 dim
= isl_space_params(dim
);
339 umap
= isl_union_map_empty(dim
);
340 umap
= isl_union_map_add_map(umap
, map
);
345 __isl_give isl_union_set
*isl_union_set_from_set(__isl_take isl_set
*set
)
347 return isl_union_map_from_map((isl_map
*)set
);
350 __isl_give isl_union_map
*isl_union_map_from_basic_map(
351 __isl_take isl_basic_map
*bmap
)
353 return isl_union_map_from_map(isl_map_from_basic_map(bmap
));
356 __isl_give isl_union_set
*isl_union_set_from_basic_set(
357 __isl_take isl_basic_set
*bset
)
359 return isl_union_map_from_basic_map(bset
);
362 struct isl_union_map_foreach_data
364 int (*fn
)(__isl_take isl_map
*map
, void *user
);
368 static int call_on_copy(void **entry
, void *user
)
370 isl_map
*map
= *entry
;
371 struct isl_union_map_foreach_data
*data
;
372 data
= (struct isl_union_map_foreach_data
*)user
;
374 return data
->fn(isl_map_copy(map
), data
->user
);
377 int isl_union_map_n_map(__isl_keep isl_union_map
*umap
)
379 return umap
? umap
->table
.n
: 0;
382 int isl_union_set_n_set(__isl_keep isl_union_set
*uset
)
384 return uset
? uset
->table
.n
: 0;
387 int isl_union_map_foreach_map(__isl_keep isl_union_map
*umap
,
388 int (*fn
)(__isl_take isl_map
*map
, void *user
), void *user
)
390 struct isl_union_map_foreach_data data
= { fn
, user
};
395 return isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
396 &call_on_copy
, &data
);
399 static int copy_map(void **entry
, void *user
)
401 isl_map
*map
= *entry
;
402 isl_map
**map_p
= user
;
404 *map_p
= isl_map_copy(map
);
409 __isl_give isl_map
*isl_map_from_union_map(__isl_take isl_union_map
*umap
)
416 ctx
= isl_union_map_get_ctx(umap
);
417 if (umap
->table
.n
!= 1)
418 isl_die(ctx
, isl_error_invalid
,
419 "union map needs to contain elements in exactly "
420 "one space", return isl_union_map_free(umap
));
422 isl_hash_table_foreach(ctx
, &umap
->table
, ©_map
, &map
);
424 isl_union_map_free(umap
);
429 __isl_give isl_set
*isl_set_from_union_set(__isl_take isl_union_set
*uset
)
431 return isl_map_from_union_map(uset
);
434 /* Extract the map in "umap" that lives in the given space (ignoring
437 __isl_give isl_map
*isl_union_map_extract_map(__isl_keep isl_union_map
*umap
,
438 __isl_take isl_space
*space
)
441 struct isl_hash_table_entry
*entry
;
443 space
= isl_space_drop_dims(space
, isl_dim_param
,
444 0, isl_space_dim(space
, isl_dim_param
));
445 space
= isl_space_align_params(space
, isl_union_map_get_space(umap
));
449 hash
= isl_space_get_hash(space
);
450 entry
= isl_hash_table_find(umap
->dim
->ctx
, &umap
->table
, hash
,
453 return isl_map_empty(space
);
454 isl_space_free(space
);
455 return isl_map_copy(entry
->data
);
457 isl_space_free(space
);
461 __isl_give isl_set
*isl_union_set_extract_set(__isl_keep isl_union_set
*uset
,
462 __isl_take isl_space
*dim
)
464 return (isl_set
*)isl_union_map_extract_map(uset
, dim
);
467 /* Check if umap contains a map in the given space.
469 __isl_give
int isl_union_map_contains(__isl_keep isl_union_map
*umap
,
470 __isl_keep isl_space
*dim
)
473 struct isl_hash_table_entry
*entry
;
478 hash
= isl_space_get_hash(dim
);
479 entry
= isl_hash_table_find(umap
->dim
->ctx
, &umap
->table
, hash
,
484 __isl_give
int isl_union_set_contains(__isl_keep isl_union_set
*uset
,
485 __isl_keep isl_space
*dim
)
487 return isl_union_map_contains(uset
, dim
);
490 int isl_union_set_foreach_set(__isl_keep isl_union_set
*uset
,
491 int (*fn
)(__isl_take isl_set
*set
, void *user
), void *user
)
493 return isl_union_map_foreach_map(uset
,
494 (int(*)(__isl_take isl_map
*, void*))fn
, user
);
497 struct isl_union_set_foreach_point_data
{
498 int (*fn
)(__isl_take isl_point
*pnt
, void *user
);
502 static int foreach_point(__isl_take isl_set
*set
, void *user
)
504 struct isl_union_set_foreach_point_data
*data
= user
;
507 r
= isl_set_foreach_point(set
, data
->fn
, data
->user
);
513 int isl_union_set_foreach_point(__isl_keep isl_union_set
*uset
,
514 int (*fn
)(__isl_take isl_point
*pnt
, void *user
), void *user
)
516 struct isl_union_set_foreach_point_data data
= { fn
, user
};
517 return isl_union_set_foreach_set(uset
, &foreach_point
, &data
);
520 struct isl_union_map_gen_bin_data
{
521 isl_union_map
*umap2
;
525 static int subtract_entry(void **entry
, void *user
)
527 struct isl_union_map_gen_bin_data
*data
= user
;
529 struct isl_hash_table_entry
*entry2
;
530 isl_map
*map
= *entry
;
532 hash
= isl_space_get_hash(map
->dim
);
533 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
534 hash
, &has_dim
, map
->dim
, 0);
535 map
= isl_map_copy(map
);
538 map
= isl_map_subtract(map
, isl_map_copy(entry2
->data
));
540 empty
= isl_map_is_empty(map
);
550 data
->res
= isl_union_map_add_map(data
->res
, map
);
555 static __isl_give isl_union_map
*gen_bin_op(__isl_take isl_union_map
*umap1
,
556 __isl_take isl_union_map
*umap2
, int (*fn
)(void **, void *))
558 struct isl_union_map_gen_bin_data data
= { NULL
, NULL
};
560 umap1
= isl_union_map_align_params(umap1
, isl_union_map_get_space(umap2
));
561 umap2
= isl_union_map_align_params(umap2
, isl_union_map_get_space(umap1
));
563 if (!umap1
|| !umap2
)
567 data
.res
= isl_union_map_alloc(isl_space_copy(umap1
->dim
),
569 if (isl_hash_table_foreach(umap1
->dim
->ctx
, &umap1
->table
,
573 isl_union_map_free(umap1
);
574 isl_union_map_free(umap2
);
577 isl_union_map_free(umap1
);
578 isl_union_map_free(umap2
);
579 isl_union_map_free(data
.res
);
583 __isl_give isl_union_map
*isl_union_map_subtract(
584 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
586 return gen_bin_op(umap1
, umap2
, &subtract_entry
);
589 __isl_give isl_union_set
*isl_union_set_subtract(
590 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
592 return isl_union_map_subtract(uset1
, uset2
);
595 struct isl_union_map_gen_bin_set_data
{
600 static int intersect_params_entry(void **entry
, void *user
)
602 struct isl_union_map_gen_bin_set_data
*data
= user
;
603 isl_map
*map
= *entry
;
606 map
= isl_map_copy(map
);
607 map
= isl_map_intersect_params(map
, isl_set_copy(data
->set
));
609 empty
= isl_map_is_empty(map
);
615 data
->res
= isl_union_map_add_map(data
->res
, map
);
620 static __isl_give isl_union_map
*gen_bin_set_op(__isl_take isl_union_map
*umap
,
621 __isl_take isl_set
*set
, int (*fn
)(void **, void *))
623 struct isl_union_map_gen_bin_set_data data
= { NULL
, NULL
};
625 umap
= isl_union_map_align_params(umap
, isl_set_get_space(set
));
626 set
= isl_set_align_params(set
, isl_union_map_get_space(umap
));
632 data
.res
= isl_union_map_alloc(isl_space_copy(umap
->dim
),
634 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
638 isl_union_map_free(umap
);
642 isl_union_map_free(umap
);
644 isl_union_map_free(data
.res
);
648 __isl_give isl_union_map
*isl_union_map_intersect_params(
649 __isl_take isl_union_map
*umap
, __isl_take isl_set
*set
)
651 return gen_bin_set_op(umap
, set
, &intersect_params_entry
);
654 __isl_give isl_union_set
*isl_union_set_intersect_params(
655 __isl_take isl_union_set
*uset
, __isl_take isl_set
*set
)
657 return isl_union_map_intersect_params(uset
, set
);
660 static __isl_give isl_union_map
*union_map_intersect_params(
661 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
663 return isl_union_map_intersect_params(umap
,
664 isl_set_from_union_set(uset
));
667 static __isl_give isl_union_map
*union_map_gist_params(
668 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
670 return isl_union_map_gist_params(umap
, isl_set_from_union_set(uset
));
673 struct isl_union_map_match_bin_data
{
674 isl_union_map
*umap2
;
676 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*, __isl_take isl_map
*);
679 static int match_bin_entry(void **entry
, void *user
)
681 struct isl_union_map_match_bin_data
*data
= user
;
683 struct isl_hash_table_entry
*entry2
;
684 isl_map
*map
= *entry
;
687 hash
= isl_space_get_hash(map
->dim
);
688 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
689 hash
, &has_dim
, map
->dim
, 0);
693 map
= isl_map_copy(map
);
694 map
= data
->fn(map
, isl_map_copy(entry2
->data
));
696 empty
= isl_map_is_empty(map
);
706 data
->res
= isl_union_map_add_map(data
->res
, map
);
711 static __isl_give isl_union_map
*match_bin_op(__isl_take isl_union_map
*umap1
,
712 __isl_take isl_union_map
*umap2
,
713 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*, __isl_take isl_map
*))
715 struct isl_union_map_match_bin_data data
= { NULL
, NULL
, fn
};
717 umap1
= isl_union_map_align_params(umap1
, isl_union_map_get_space(umap2
));
718 umap2
= isl_union_map_align_params(umap2
, isl_union_map_get_space(umap1
));
720 if (!umap1
|| !umap2
)
724 data
.res
= isl_union_map_alloc(isl_space_copy(umap1
->dim
),
726 if (isl_hash_table_foreach(umap1
->dim
->ctx
, &umap1
->table
,
727 &match_bin_entry
, &data
) < 0)
730 isl_union_map_free(umap1
);
731 isl_union_map_free(umap2
);
734 isl_union_map_free(umap1
);
735 isl_union_map_free(umap2
);
736 isl_union_map_free(data
.res
);
740 __isl_give isl_union_map
*isl_union_map_intersect(
741 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
743 return match_bin_op(umap1
, umap2
, &isl_map_intersect
);
746 /* Compute the intersection of the two union_sets.
747 * As a special case, if exactly one of the two union_sets
748 * is a parameter domain, then intersect the parameter domain
749 * of the other one with this set.
751 __isl_give isl_union_set
*isl_union_set_intersect(
752 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
756 p1
= isl_union_set_is_params(uset1
);
757 p2
= isl_union_set_is_params(uset2
);
758 if (p1
< 0 || p2
< 0)
761 return union_map_intersect_params(uset1
, uset2
);
763 return union_map_intersect_params(uset2
, uset1
);
764 return isl_union_map_intersect(uset1
, uset2
);
766 isl_union_set_free(uset1
);
767 isl_union_set_free(uset2
);
771 static int gist_params_entry(void **entry
, void *user
)
773 struct isl_union_map_gen_bin_set_data
*data
= user
;
774 isl_map
*map
= *entry
;
777 map
= isl_map_copy(map
);
778 map
= isl_map_gist_params(map
, isl_set_copy(data
->set
));
780 empty
= isl_map_is_empty(map
);
786 data
->res
= isl_union_map_add_map(data
->res
, map
);
791 __isl_give isl_union_map
*isl_union_map_gist_params(
792 __isl_take isl_union_map
*umap
, __isl_take isl_set
*set
)
794 return gen_bin_set_op(umap
, set
, &gist_params_entry
);
797 __isl_give isl_union_set
*isl_union_set_gist_params(
798 __isl_take isl_union_set
*uset
, __isl_take isl_set
*set
)
800 return isl_union_map_gist_params(uset
, set
);
803 __isl_give isl_union_map
*isl_union_map_gist(__isl_take isl_union_map
*umap
,
804 __isl_take isl_union_map
*context
)
806 return match_bin_op(umap
, context
, &isl_map_gist
);
809 __isl_give isl_union_set
*isl_union_set_gist(__isl_take isl_union_set
*uset
,
810 __isl_take isl_union_set
*context
)
812 if (isl_union_set_is_params(context
))
813 return union_map_gist_params(uset
, context
);
814 return isl_union_map_gist(uset
, context
);
817 static __isl_give isl_map
*lex_le_set(__isl_take isl_map
*set1
,
818 __isl_take isl_map
*set2
)
820 return isl_set_lex_le_set((isl_set
*)set1
, (isl_set
*)set2
);
823 static __isl_give isl_map
*lex_lt_set(__isl_take isl_map
*set1
,
824 __isl_take isl_map
*set2
)
826 return isl_set_lex_lt_set((isl_set
*)set1
, (isl_set
*)set2
);
829 __isl_give isl_union_map
*isl_union_set_lex_lt_union_set(
830 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
832 return match_bin_op(uset1
, uset2
, &lex_lt_set
);
835 __isl_give isl_union_map
*isl_union_set_lex_le_union_set(
836 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
838 return match_bin_op(uset1
, uset2
, &lex_le_set
);
841 __isl_give isl_union_map
*isl_union_set_lex_gt_union_set(
842 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
844 return isl_union_map_reverse(isl_union_set_lex_lt_union_set(uset2
, uset1
));
847 __isl_give isl_union_map
*isl_union_set_lex_ge_union_set(
848 __isl_take isl_union_set
*uset1
, __isl_take isl_union_set
*uset2
)
850 return isl_union_map_reverse(isl_union_set_lex_le_union_set(uset2
, uset1
));
853 __isl_give isl_union_map
*isl_union_map_lex_gt_union_map(
854 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
856 return isl_union_map_reverse(isl_union_map_lex_lt_union_map(umap2
, umap1
));
859 __isl_give isl_union_map
*isl_union_map_lex_ge_union_map(
860 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
862 return isl_union_map_reverse(isl_union_map_lex_le_union_map(umap2
, umap1
));
865 static int intersect_domain_entry(void **entry
, void *user
)
867 struct isl_union_map_gen_bin_data
*data
= user
;
869 struct isl_hash_table_entry
*entry2
;
871 isl_map
*map
= *entry
;
874 dim
= isl_map_get_space(map
);
875 dim
= isl_space_domain(dim
);
876 hash
= isl_space_get_hash(dim
);
877 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
878 hash
, &has_dim
, dim
, 0);
883 map
= isl_map_copy(map
);
884 map
= isl_map_intersect_domain(map
, isl_set_copy(entry2
->data
));
886 empty
= isl_map_is_empty(map
);
896 data
->res
= isl_union_map_add_map(data
->res
, map
);
901 /* Intersect the domain of "umap" with "uset".
902 * If "uset" is a parameters domain, then intersect the parameter
903 * domain of "umap" with this set.
905 __isl_give isl_union_map
*isl_union_map_intersect_domain(
906 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
908 if (isl_union_set_is_params(uset
))
909 return union_map_intersect_params(umap
, uset
);
910 return gen_bin_op(umap
, uset
, &intersect_domain_entry
);
913 /* Remove the elements of data->umap2 from the domain of *entry
914 * and add the result to data->res.
916 static int subtract_domain_entry(void **entry
, void *user
)
918 struct isl_union_map_gen_bin_data
*data
= user
;
920 struct isl_hash_table_entry
*entry2
;
922 isl_map
*map
= *entry
;
925 dim
= isl_map_get_space(map
);
926 dim
= isl_space_domain(dim
);
927 hash
= isl_space_get_hash(dim
);
928 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
929 hash
, &has_dim
, dim
, 0);
932 map
= isl_map_copy(map
);
935 data
->res
= isl_union_map_add_map(data
->res
, map
);
939 map
= isl_map_subtract_domain(map
, isl_set_copy(entry2
->data
));
941 empty
= isl_map_is_empty(map
);
951 data
->res
= isl_union_map_add_map(data
->res
, map
);
956 /* Remove the elements of "uset" from the domain of "umap".
958 __isl_give isl_union_map
*isl_union_map_subtract_domain(
959 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*dom
)
961 return gen_bin_op(umap
, dom
, &subtract_domain_entry
);
964 /* Remove the elements of data->umap2 from the range of *entry
965 * and add the result to data->res.
967 static int subtract_range_entry(void **entry
, void *user
)
969 struct isl_union_map_gen_bin_data
*data
= user
;
971 struct isl_hash_table_entry
*entry2
;
973 isl_map
*map
= *entry
;
976 space
= isl_map_get_space(map
);
977 space
= isl_space_range(space
);
978 hash
= isl_space_get_hash(space
);
979 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
980 hash
, &has_dim
, space
, 0);
981 isl_space_free(space
);
983 map
= isl_map_copy(map
);
986 data
->res
= isl_union_map_add_map(data
->res
, map
);
990 map
= isl_map_subtract_range(map
, isl_set_copy(entry2
->data
));
992 empty
= isl_map_is_empty(map
);
1002 data
->res
= isl_union_map_add_map(data
->res
, map
);
1007 /* Remove the elements of "uset" from the range of "umap".
1009 __isl_give isl_union_map
*isl_union_map_subtract_range(
1010 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*dom
)
1012 return gen_bin_op(umap
, dom
, &subtract_range_entry
);
1015 static int gist_domain_entry(void **entry
, void *user
)
1017 struct isl_union_map_gen_bin_data
*data
= user
;
1019 struct isl_hash_table_entry
*entry2
;
1021 isl_map
*map
= *entry
;
1024 dim
= isl_map_get_space(map
);
1025 dim
= isl_space_domain(dim
);
1026 hash
= isl_space_get_hash(dim
);
1027 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
1028 hash
, &has_dim
, dim
, 0);
1029 isl_space_free(dim
);
1033 map
= isl_map_copy(map
);
1034 map
= isl_map_gist_domain(map
, isl_set_copy(entry2
->data
));
1036 empty
= isl_map_is_empty(map
);
1042 data
->res
= isl_union_map_add_map(data
->res
, map
);
1047 /* Compute the gist of "umap" with respect to the domain "uset".
1048 * If "uset" is a parameters domain, then compute the gist
1049 * with respect to this parameter domain.
1051 __isl_give isl_union_map
*isl_union_map_gist_domain(
1052 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
1054 if (isl_union_set_is_params(uset
))
1055 return union_map_gist_params(umap
, uset
);
1056 return gen_bin_op(umap
, uset
, &gist_domain_entry
);
1059 static int gist_range_entry(void **entry
, void *user
)
1061 struct isl_union_map_gen_bin_data
*data
= user
;
1063 struct isl_hash_table_entry
*entry2
;
1065 isl_map
*map
= *entry
;
1068 space
= isl_map_get_space(map
);
1069 space
= isl_space_range(space
);
1070 hash
= isl_space_get_hash(space
);
1071 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
1072 hash
, &has_dim
, space
, 0);
1073 isl_space_free(space
);
1077 map
= isl_map_copy(map
);
1078 map
= isl_map_gist_range(map
, isl_set_copy(entry2
->data
));
1080 empty
= isl_map_is_empty(map
);
1086 data
->res
= isl_union_map_add_map(data
->res
, map
);
1091 /* Compute the gist of "umap" with respect to the range "uset".
1093 __isl_give isl_union_map
*isl_union_map_gist_range(
1094 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
1096 return gen_bin_op(umap
, uset
, &gist_range_entry
);
1099 static int intersect_range_entry(void **entry
, void *user
)
1101 struct isl_union_map_gen_bin_data
*data
= user
;
1103 struct isl_hash_table_entry
*entry2
;
1105 isl_map
*map
= *entry
;
1108 dim
= isl_map_get_space(map
);
1109 dim
= isl_space_range(dim
);
1110 hash
= isl_space_get_hash(dim
);
1111 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
1112 hash
, &has_dim
, dim
, 0);
1113 isl_space_free(dim
);
1117 map
= isl_map_copy(map
);
1118 map
= isl_map_intersect_range(map
, isl_set_copy(entry2
->data
));
1120 empty
= isl_map_is_empty(map
);
1130 data
->res
= isl_union_map_add_map(data
->res
, map
);
1135 __isl_give isl_union_map
*isl_union_map_intersect_range(
1136 __isl_take isl_union_map
*umap
, __isl_take isl_union_set
*uset
)
1138 return gen_bin_op(umap
, uset
, &intersect_range_entry
);
1141 struct isl_union_map_bin_data
{
1142 isl_union_map
*umap2
;
1145 int (*fn
)(void **entry
, void *user
);
1148 static int apply_range_entry(void **entry
, void *user
)
1150 struct isl_union_map_bin_data
*data
= user
;
1151 isl_map
*map2
= *entry
;
1154 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_out
,
1155 map2
->dim
, isl_dim_in
))
1158 map2
= isl_map_apply_range(isl_map_copy(data
->map
), isl_map_copy(map2
));
1160 empty
= isl_map_is_empty(map2
);
1170 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1175 static int bin_entry(void **entry
, void *user
)
1177 struct isl_union_map_bin_data
*data
= user
;
1178 isl_map
*map
= *entry
;
1181 if (isl_hash_table_foreach(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
1182 data
->fn
, data
) < 0)
1188 static __isl_give isl_union_map
*bin_op(__isl_take isl_union_map
*umap1
,
1189 __isl_take isl_union_map
*umap2
, int (*fn
)(void **entry
, void *user
))
1191 struct isl_union_map_bin_data data
= { NULL
, NULL
, NULL
, fn
};
1193 umap1
= isl_union_map_align_params(umap1
, isl_union_map_get_space(umap2
));
1194 umap2
= isl_union_map_align_params(umap2
, isl_union_map_get_space(umap1
));
1196 if (!umap1
|| !umap2
)
1200 data
.res
= isl_union_map_alloc(isl_space_copy(umap1
->dim
),
1202 if (isl_hash_table_foreach(umap1
->dim
->ctx
, &umap1
->table
,
1203 &bin_entry
, &data
) < 0)
1206 isl_union_map_free(umap1
);
1207 isl_union_map_free(umap2
);
1210 isl_union_map_free(umap1
);
1211 isl_union_map_free(umap2
);
1212 isl_union_map_free(data
.res
);
1216 __isl_give isl_union_map
*isl_union_map_apply_range(
1217 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1219 return bin_op(umap1
, umap2
, &apply_range_entry
);
1222 __isl_give isl_union_map
*isl_union_map_apply_domain(
1223 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1225 umap1
= isl_union_map_reverse(umap1
);
1226 umap1
= isl_union_map_apply_range(umap1
, umap2
);
1227 return isl_union_map_reverse(umap1
);
1230 __isl_give isl_union_set
*isl_union_set_apply(
1231 __isl_take isl_union_set
*uset
, __isl_take isl_union_map
*umap
)
1233 return isl_union_map_apply_range(uset
, umap
);
1236 static int map_lex_lt_entry(void **entry
, void *user
)
1238 struct isl_union_map_bin_data
*data
= user
;
1239 isl_map
*map2
= *entry
;
1241 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_out
,
1242 map2
->dim
, isl_dim_out
))
1245 map2
= isl_map_lex_lt_map(isl_map_copy(data
->map
), isl_map_copy(map2
));
1247 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1252 __isl_give isl_union_map
*isl_union_map_lex_lt_union_map(
1253 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1255 return bin_op(umap1
, umap2
, &map_lex_lt_entry
);
1258 static int map_lex_le_entry(void **entry
, void *user
)
1260 struct isl_union_map_bin_data
*data
= user
;
1261 isl_map
*map2
= *entry
;
1263 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_out
,
1264 map2
->dim
, isl_dim_out
))
1267 map2
= isl_map_lex_le_map(isl_map_copy(data
->map
), isl_map_copy(map2
));
1269 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1274 __isl_give isl_union_map
*isl_union_map_lex_le_union_map(
1275 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1277 return bin_op(umap1
, umap2
, &map_lex_le_entry
);
1280 static int product_entry(void **entry
, void *user
)
1282 struct isl_union_map_bin_data
*data
= user
;
1283 isl_map
*map2
= *entry
;
1285 map2
= isl_map_product(isl_map_copy(data
->map
), isl_map_copy(map2
));
1287 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1292 __isl_give isl_union_map
*isl_union_map_product(__isl_take isl_union_map
*umap1
,
1293 __isl_take isl_union_map
*umap2
)
1295 return bin_op(umap1
, umap2
, &product_entry
);
1298 static int set_product_entry(void **entry
, void *user
)
1300 struct isl_union_map_bin_data
*data
= user
;
1301 isl_set
*set2
= *entry
;
1303 set2
= isl_set_product(isl_set_copy(data
->map
), isl_set_copy(set2
));
1305 data
->res
= isl_union_set_add_set(data
->res
, set2
);
1310 __isl_give isl_union_set
*isl_union_set_product(__isl_take isl_union_set
*uset1
,
1311 __isl_take isl_union_set
*uset2
)
1313 return bin_op(uset1
, uset2
, &set_product_entry
);
1316 static int domain_product_entry(void **entry
, void *user
)
1318 struct isl_union_map_bin_data
*data
= user
;
1319 isl_map
*map2
= *entry
;
1321 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_out
,
1322 map2
->dim
, isl_dim_out
))
1325 map2
= isl_map_domain_product(isl_map_copy(data
->map
),
1326 isl_map_copy(map2
));
1328 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1333 /* Given two maps A -> B and C -> D, construct a map [A -> C] -> (B * D)
1335 __isl_give isl_union_map
*isl_union_map_domain_product(
1336 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1338 return bin_op(umap1
, umap2
, &domain_product_entry
);
1341 static int range_product_entry(void **entry
, void *user
)
1343 struct isl_union_map_bin_data
*data
= user
;
1344 isl_map
*map2
= *entry
;
1346 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_in
,
1347 map2
->dim
, isl_dim_in
))
1350 map2
= isl_map_range_product(isl_map_copy(data
->map
),
1351 isl_map_copy(map2
));
1353 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1358 __isl_give isl_union_map
*isl_union_map_range_product(
1359 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1361 return bin_op(umap1
, umap2
, &range_product_entry
);
1364 static int flat_range_product_entry(void **entry
, void *user
)
1366 struct isl_union_map_bin_data
*data
= user
;
1367 isl_map
*map2
= *entry
;
1369 if (!isl_space_tuple_match(data
->map
->dim
, isl_dim_in
,
1370 map2
->dim
, isl_dim_in
))
1373 map2
= isl_map_flat_range_product(isl_map_copy(data
->map
),
1374 isl_map_copy(map2
));
1376 data
->res
= isl_union_map_add_map(data
->res
, map2
);
1381 __isl_give isl_union_map
*isl_union_map_flat_range_product(
1382 __isl_take isl_union_map
*umap1
, __isl_take isl_union_map
*umap2
)
1384 return bin_op(umap1
, umap2
, &flat_range_product_entry
);
1387 static __isl_give isl_union_set
*cond_un_op(__isl_take isl_union_map
*umap
,
1388 int (*fn
)(void **, void *))
1395 res
= isl_union_map_alloc(isl_space_copy(umap
->dim
), umap
->table
.n
);
1396 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
, fn
, &res
) < 0)
1399 isl_union_map_free(umap
);
1402 isl_union_map_free(umap
);
1403 isl_union_set_free(res
);
1407 static int from_range_entry(void **entry
, void *user
)
1409 isl_map
*set
= *entry
;
1410 isl_union_set
**res
= user
;
1412 *res
= isl_union_map_add_map(*res
,
1413 isl_map_from_range(isl_set_copy(set
)));
1418 __isl_give isl_union_map
*isl_union_map_from_range(
1419 __isl_take isl_union_set
*uset
)
1421 return cond_un_op(uset
, &from_range_entry
);
1424 __isl_give isl_union_map
*isl_union_map_from_domain(
1425 __isl_take isl_union_set
*uset
)
1427 return isl_union_map_reverse(isl_union_map_from_range(uset
));
1430 __isl_give isl_union_map
*isl_union_map_from_domain_and_range(
1431 __isl_take isl_union_set
*domain
, __isl_take isl_union_set
*range
)
1433 return isl_union_map_apply_range(isl_union_map_from_domain(domain
),
1434 isl_union_map_from_range(range
));
1437 static __isl_give isl_union_map
*un_op(__isl_take isl_union_map
*umap
,
1438 int (*fn
)(void **, void *))
1440 umap
= isl_union_map_cow(umap
);
1444 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
, fn
, NULL
) < 0)
1449 isl_union_map_free(umap
);
1453 static int affine_entry(void **entry
, void *user
)
1455 isl_map
**map
= (isl_map
**)entry
;
1457 *map
= isl_map_from_basic_map(isl_map_affine_hull(*map
));
1459 return *map
? 0 : -1;
1462 __isl_give isl_union_map
*isl_union_map_affine_hull(
1463 __isl_take isl_union_map
*umap
)
1465 return un_op(umap
, &affine_entry
);
1468 __isl_give isl_union_set
*isl_union_set_affine_hull(
1469 __isl_take isl_union_set
*uset
)
1471 return isl_union_map_affine_hull(uset
);
1474 static int polyhedral_entry(void **entry
, void *user
)
1476 isl_map
**map
= (isl_map
**)entry
;
1478 *map
= isl_map_from_basic_map(isl_map_polyhedral_hull(*map
));
1480 return *map
? 0 : -1;
1483 __isl_give isl_union_map
*isl_union_map_polyhedral_hull(
1484 __isl_take isl_union_map
*umap
)
1486 return un_op(umap
, &polyhedral_entry
);
1489 __isl_give isl_union_set
*isl_union_set_polyhedral_hull(
1490 __isl_take isl_union_set
*uset
)
1492 return isl_union_map_polyhedral_hull(uset
);
1495 static int simple_entry(void **entry
, void *user
)
1497 isl_map
**map
= (isl_map
**)entry
;
1499 *map
= isl_map_from_basic_map(isl_map_simple_hull(*map
));
1501 return *map
? 0 : -1;
1504 __isl_give isl_union_map
*isl_union_map_simple_hull(
1505 __isl_take isl_union_map
*umap
)
1507 return un_op(umap
, &simple_entry
);
1510 __isl_give isl_union_set
*isl_union_set_simple_hull(
1511 __isl_take isl_union_set
*uset
)
1513 return isl_union_map_simple_hull(uset
);
1516 static int inplace_entry(void **entry
, void *user
)
1518 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*);
1519 isl_map
**map
= (isl_map
**)entry
;
1522 fn
= *(__isl_give isl_map
*(**)(__isl_take isl_map
*)) user
;
1523 copy
= fn(isl_map_copy(*map
));
1533 static __isl_give isl_union_map
*inplace(__isl_take isl_union_map
*umap
,
1534 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*))
1539 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
1540 &inplace_entry
, &fn
) < 0)
1545 isl_union_map_free(umap
);
1549 __isl_give isl_union_map
*isl_union_map_coalesce(
1550 __isl_take isl_union_map
*umap
)
1552 return inplace(umap
, &isl_map_coalesce
);
1555 __isl_give isl_union_set
*isl_union_set_coalesce(
1556 __isl_take isl_union_set
*uset
)
1558 return isl_union_map_coalesce(uset
);
1561 __isl_give isl_union_map
*isl_union_map_detect_equalities(
1562 __isl_take isl_union_map
*umap
)
1564 return inplace(umap
, &isl_map_detect_equalities
);
1567 __isl_give isl_union_set
*isl_union_set_detect_equalities(
1568 __isl_take isl_union_set
*uset
)
1570 return isl_union_map_detect_equalities(uset
);
1573 __isl_give isl_union_map
*isl_union_map_compute_divs(
1574 __isl_take isl_union_map
*umap
)
1576 return inplace(umap
, &isl_map_compute_divs
);
1579 __isl_give isl_union_set
*isl_union_set_compute_divs(
1580 __isl_take isl_union_set
*uset
)
1582 return isl_union_map_compute_divs(uset
);
1585 static int lexmin_entry(void **entry
, void *user
)
1587 isl_map
**map
= (isl_map
**)entry
;
1589 *map
= isl_map_lexmin(*map
);
1591 return *map
? 0 : -1;
1594 __isl_give isl_union_map
*isl_union_map_lexmin(
1595 __isl_take isl_union_map
*umap
)
1597 return un_op(umap
, &lexmin_entry
);
1600 __isl_give isl_union_set
*isl_union_set_lexmin(
1601 __isl_take isl_union_set
*uset
)
1603 return isl_union_map_lexmin(uset
);
1606 static int lexmax_entry(void **entry
, void *user
)
1608 isl_map
**map
= (isl_map
**)entry
;
1610 *map
= isl_map_lexmax(*map
);
1612 return *map
? 0 : -1;
1615 __isl_give isl_union_map
*isl_union_map_lexmax(
1616 __isl_take isl_union_map
*umap
)
1618 return un_op(umap
, &lexmax_entry
);
1621 __isl_give isl_union_set
*isl_union_set_lexmax(
1622 __isl_take isl_union_set
*uset
)
1624 return isl_union_map_lexmax(uset
);
1627 static int universe_entry(void **entry
, void *user
)
1629 isl_map
*map
= *entry
;
1630 isl_union_map
**res
= user
;
1632 map
= isl_map_universe(isl_map_get_space(map
));
1633 *res
= isl_union_map_add_map(*res
, map
);
1638 __isl_give isl_union_map
*isl_union_map_universe(__isl_take isl_union_map
*umap
)
1640 return cond_un_op(umap
, &universe_entry
);
1643 __isl_give isl_union_set
*isl_union_set_universe(__isl_take isl_union_set
*uset
)
1645 return isl_union_map_universe(uset
);
1648 static int reverse_entry(void **entry
, void *user
)
1650 isl_map
*map
= *entry
;
1651 isl_union_map
**res
= user
;
1653 *res
= isl_union_map_add_map(*res
, isl_map_reverse(isl_map_copy(map
)));
1658 __isl_give isl_union_map
*isl_union_map_reverse(__isl_take isl_union_map
*umap
)
1660 return cond_un_op(umap
, &reverse_entry
);
1663 static int params_entry(void **entry
, void *user
)
1665 isl_map
*map
= *entry
;
1666 isl_union_set
**res
= user
;
1668 *res
= isl_union_set_add_set(*res
, isl_map_params(isl_map_copy(map
)));
1673 /* Compute the parameter domain of the given union map.
1675 __isl_give isl_set
*isl_union_map_params(__isl_take isl_union_map
*umap
)
1679 empty
= isl_union_map_is_empty(umap
);
1681 return isl_union_map_free(umap
);
1684 space
= isl_union_map_get_space(umap
);
1685 isl_union_map_free(umap
);
1686 return isl_set_empty(space
);
1688 return isl_set_from_union_set(cond_un_op(umap
, ¶ms_entry
));
1691 /* Compute the parameter domain of the given union set.
1693 __isl_give isl_set
*isl_union_set_params(__isl_take isl_union_set
*uset
)
1695 return isl_union_map_params(uset
);
1698 static int domain_entry(void **entry
, void *user
)
1700 isl_map
*map
= *entry
;
1701 isl_union_set
**res
= user
;
1703 *res
= isl_union_set_add_set(*res
, isl_map_domain(isl_map_copy(map
)));
1708 __isl_give isl_union_set
*isl_union_map_domain(__isl_take isl_union_map
*umap
)
1710 return cond_un_op(umap
, &domain_entry
);
1713 static int range_entry(void **entry
, void *user
)
1715 isl_map
*map
= *entry
;
1716 isl_union_set
**res
= user
;
1718 *res
= isl_union_set_add_set(*res
, isl_map_range(isl_map_copy(map
)));
1723 __isl_give isl_union_set
*isl_union_map_range(__isl_take isl_union_map
*umap
)
1725 return cond_un_op(umap
, &range_entry
);
1728 static int domain_map_entry(void **entry
, void *user
)
1730 isl_map
*map
= *entry
;
1731 isl_union_set
**res
= user
;
1733 *res
= isl_union_map_add_map(*res
,
1734 isl_map_domain_map(isl_map_copy(map
)));
1739 __isl_give isl_union_map
*isl_union_map_domain_map(
1740 __isl_take isl_union_map
*umap
)
1742 return cond_un_op(umap
, &domain_map_entry
);
1745 static int range_map_entry(void **entry
, void *user
)
1747 isl_map
*map
= *entry
;
1748 isl_union_set
**res
= user
;
1750 *res
= isl_union_map_add_map(*res
,
1751 isl_map_range_map(isl_map_copy(map
)));
1756 __isl_give isl_union_map
*isl_union_map_range_map(
1757 __isl_take isl_union_map
*umap
)
1759 return cond_un_op(umap
, &range_map_entry
);
1762 static int deltas_entry(void **entry
, void *user
)
1764 isl_map
*map
= *entry
;
1765 isl_union_set
**res
= user
;
1767 if (!isl_space_tuple_match(map
->dim
, isl_dim_in
, map
->dim
, isl_dim_out
))
1770 *res
= isl_union_set_add_set(*res
, isl_map_deltas(isl_map_copy(map
)));
1775 __isl_give isl_union_set
*isl_union_map_deltas(__isl_take isl_union_map
*umap
)
1777 return cond_un_op(umap
, &deltas_entry
);
1780 static int deltas_map_entry(void **entry
, void *user
)
1782 isl_map
*map
= *entry
;
1783 isl_union_map
**res
= user
;
1785 if (!isl_space_tuple_match(map
->dim
, isl_dim_in
, map
->dim
, isl_dim_out
))
1788 *res
= isl_union_map_add_map(*res
,
1789 isl_map_deltas_map(isl_map_copy(map
)));
1794 __isl_give isl_union_map
*isl_union_map_deltas_map(
1795 __isl_take isl_union_map
*umap
)
1797 return cond_un_op(umap
, &deltas_map_entry
);
1800 static int identity_entry(void **entry
, void *user
)
1802 isl_set
*set
= *entry
;
1803 isl_union_map
**res
= user
;
1805 *res
= isl_union_map_add_map(*res
, isl_set_identity(isl_set_copy(set
)));
1810 __isl_give isl_union_map
*isl_union_set_identity(__isl_take isl_union_set
*uset
)
1812 return cond_un_op(uset
, &identity_entry
);
1815 static int unwrap_entry(void **entry
, void *user
)
1817 isl_set
*set
= *entry
;
1818 isl_union_set
**res
= user
;
1820 if (!isl_set_is_wrapping(set
))
1823 *res
= isl_union_map_add_map(*res
, isl_set_unwrap(isl_set_copy(set
)));
1828 __isl_give isl_union_map
*isl_union_set_unwrap(__isl_take isl_union_set
*uset
)
1830 return cond_un_op(uset
, &unwrap_entry
);
1833 static int wrap_entry(void **entry
, void *user
)
1835 isl_map
*map
= *entry
;
1836 isl_union_set
**res
= user
;
1838 *res
= isl_union_set_add_set(*res
, isl_map_wrap(isl_map_copy(map
)));
1843 __isl_give isl_union_set
*isl_union_map_wrap(__isl_take isl_union_map
*umap
)
1845 return cond_un_op(umap
, &wrap_entry
);
1848 struct isl_union_map_is_subset_data
{
1849 isl_union_map
*umap2
;
1853 static int is_subset_entry(void **entry
, void *user
)
1855 struct isl_union_map_is_subset_data
*data
= user
;
1857 struct isl_hash_table_entry
*entry2
;
1858 isl_map
*map
= *entry
;
1860 hash
= isl_space_get_hash(map
->dim
);
1861 entry2
= isl_hash_table_find(data
->umap2
->dim
->ctx
, &data
->umap2
->table
,
1862 hash
, &has_dim
, map
->dim
, 0);
1864 int empty
= isl_map_is_empty(map
);
1869 data
->is_subset
= 0;
1873 data
->is_subset
= isl_map_is_subset(map
, entry2
->data
);
1874 if (data
->is_subset
< 0 || !data
->is_subset
)
1880 int isl_union_map_is_subset(__isl_keep isl_union_map
*umap1
,
1881 __isl_keep isl_union_map
*umap2
)
1883 struct isl_union_map_is_subset_data data
= { NULL
, 1 };
1885 umap1
= isl_union_map_copy(umap1
);
1886 umap2
= isl_union_map_copy(umap2
);
1887 umap1
= isl_union_map_align_params(umap1
, isl_union_map_get_space(umap2
));
1888 umap2
= isl_union_map_align_params(umap2
, isl_union_map_get_space(umap1
));
1890 if (!umap1
|| !umap2
)
1894 if (isl_hash_table_foreach(umap1
->dim
->ctx
, &umap1
->table
,
1895 &is_subset_entry
, &data
) < 0 &&
1899 isl_union_map_free(umap1
);
1900 isl_union_map_free(umap2
);
1902 return data
.is_subset
;
1904 isl_union_map_free(umap1
);
1905 isl_union_map_free(umap2
);
1909 int isl_union_set_is_subset(__isl_keep isl_union_set
*uset1
,
1910 __isl_keep isl_union_set
*uset2
)
1912 return isl_union_map_is_subset(uset1
, uset2
);
1915 int isl_union_map_is_equal(__isl_keep isl_union_map
*umap1
,
1916 __isl_keep isl_union_map
*umap2
)
1920 if (!umap1
|| !umap2
)
1922 is_subset
= isl_union_map_is_subset(umap1
, umap2
);
1925 is_subset
= isl_union_map_is_subset(umap2
, umap1
);
1929 int isl_union_set_is_equal(__isl_keep isl_union_set
*uset1
,
1930 __isl_keep isl_union_set
*uset2
)
1932 return isl_union_map_is_equal(uset1
, uset2
);
1935 int isl_union_map_is_strict_subset(__isl_keep isl_union_map
*umap1
,
1936 __isl_keep isl_union_map
*umap2
)
1940 if (!umap1
|| !umap2
)
1942 is_subset
= isl_union_map_is_subset(umap1
, umap2
);
1945 is_subset
= isl_union_map_is_subset(umap2
, umap1
);
1946 if (is_subset
== -1)
1951 int isl_union_set_is_strict_subset(__isl_keep isl_union_set
*uset1
,
1952 __isl_keep isl_union_set
*uset2
)
1954 return isl_union_map_is_strict_subset(uset1
, uset2
);
1957 static int sample_entry(void **entry
, void *user
)
1959 isl_basic_map
**sample
= (isl_basic_map
**)user
;
1960 isl_map
*map
= *entry
;
1962 *sample
= isl_map_sample(isl_map_copy(map
));
1965 if (!isl_basic_map_plain_is_empty(*sample
))
1970 __isl_give isl_basic_map
*isl_union_map_sample(__isl_take isl_union_map
*umap
)
1972 isl_basic_map
*sample
= NULL
;
1977 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
1978 &sample_entry
, &sample
) < 0 &&
1983 sample
= isl_basic_map_empty(isl_union_map_get_space(umap
));
1985 isl_union_map_free(umap
);
1989 isl_union_map_free(umap
);
1993 __isl_give isl_basic_set
*isl_union_set_sample(__isl_take isl_union_set
*uset
)
1995 return (isl_basic_set
*)isl_union_map_sample(uset
);
1998 struct isl_forall_data
{
2000 int (*fn
)(__isl_keep isl_map
*map
);
2003 static int forall_entry(void **entry
, void *user
)
2005 struct isl_forall_data
*data
= user
;
2006 isl_map
*map
= *entry
;
2008 data
->res
= data
->fn(map
);
2018 static int union_map_forall(__isl_keep isl_union_map
*umap
,
2019 int (*fn
)(__isl_keep isl_map
*map
))
2021 struct isl_forall_data data
= { 1, fn
};
2026 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
2027 &forall_entry
, &data
) < 0 && data
.res
)
2033 struct isl_forall_user_data
{
2035 int (*fn
)(__isl_keep isl_map
*map
, void *user
);
2039 static int forall_user_entry(void **entry
, void *user
)
2041 struct isl_forall_user_data
*data
= user
;
2042 isl_map
*map
= *entry
;
2044 data
->res
= data
->fn(map
, data
->user
);
2054 /* Check if fn(map, user) returns true for all maps "map" in umap.
2056 static int union_map_forall_user(__isl_keep isl_union_map
*umap
,
2057 int (*fn
)(__isl_keep isl_map
*map
, void *user
), void *user
)
2059 struct isl_forall_user_data data
= { 1, fn
, user
};
2064 if (isl_hash_table_foreach(umap
->dim
->ctx
, &umap
->table
,
2065 &forall_user_entry
, &data
) < 0 && data
.res
)
2071 int isl_union_map_is_empty(__isl_keep isl_union_map
*umap
)
2073 return union_map_forall(umap
, &isl_map_is_empty
);
2076 int isl_union_set_is_empty(__isl_keep isl_union_set
*uset
)
2078 return isl_union_map_is_empty(uset
);
2081 static int is_subset_of_identity(__isl_keep isl_map
*map
)
2090 if (!isl_space_tuple_match(map
->dim
, isl_dim_in
, map
->dim
, isl_dim_out
))
2093 dim
= isl_map_get_space(map
);
2094 id
= isl_map_identity(dim
);
2096 is_subset
= isl_map_is_subset(map
, id
);
2103 /* Check if the given map is single-valued.
2108 * and check if the result is a subset of the identity mapping.
2110 int isl_union_map_is_single_valued(__isl_keep isl_union_map
*umap
)
2112 isl_union_map
*test
;
2115 if (isl_union_map_n_map(umap
) == 1) {
2117 umap
= isl_union_map_copy(umap
);
2118 map
= isl_map_from_union_map(umap
);
2119 sv
= isl_map_is_single_valued(map
);
2124 test
= isl_union_map_reverse(isl_union_map_copy(umap
));
2125 test
= isl_union_map_apply_range(test
, isl_union_map_copy(umap
));
2127 sv
= union_map_forall(test
, &is_subset_of_identity
);
2129 isl_union_map_free(test
);
2134 int isl_union_map_is_injective(__isl_keep isl_union_map
*umap
)
2138 umap
= isl_union_map_copy(umap
);
2139 umap
= isl_union_map_reverse(umap
);
2140 in
= isl_union_map_is_single_valued(umap
);
2141 isl_union_map_free(umap
);
2146 /* Represents a map that has a fixed value (v) for one of its
2148 * The map in this structure is not reference counted, so it
2149 * is only valid while the isl_union_map from which it was
2150 * obtained is still alive.
2152 struct isl_fixed_map
{
2157 static struct isl_fixed_map
*alloc_isl_fixed_map_array(isl_ctx
*ctx
,
2161 struct isl_fixed_map
*v
;
2163 v
= isl_calloc_array(ctx
, struct isl_fixed_map
, n
);
2166 for (i
= 0; i
< n
; ++i
)
2167 isl_int_init(v
[i
].v
);
2171 static void free_isl_fixed_map_array(struct isl_fixed_map
*v
, int n
)
2177 for (i
= 0; i
< n
; ++i
)
2178 isl_int_clear(v
[i
].v
);
2182 /* Compare the "v" field of two isl_fixed_map structs.
2184 static int qsort_fixed_map_cmp(const void *p1
, const void *p2
)
2186 const struct isl_fixed_map
*e1
= (const struct isl_fixed_map
*) p1
;
2187 const struct isl_fixed_map
*e2
= (const struct isl_fixed_map
*) p2
;
2189 return isl_int_cmp(e1
->v
, e2
->v
);
2192 /* Internal data structure used while checking whether all maps
2193 * in a union_map have a fixed value for a given output dimension.
2194 * v is the list of maps, with the fixed value for the dimension
2195 * n is the number of maps considered so far
2196 * pos is the output dimension under investigation
2198 struct isl_fixed_dim_data
{
2199 struct isl_fixed_map
*v
;
2204 static int fixed_at_pos(__isl_keep isl_map
*map
, void *user
)
2206 struct isl_fixed_dim_data
*data
= user
;
2208 data
->v
[data
->n
].map
= map
;
2209 return isl_map_plain_is_fixed(map
, isl_dim_out
, data
->pos
,
2210 &data
->v
[data
->n
++].v
);
2213 static int plain_injective_on_range(__isl_take isl_union_map
*umap
,
2214 int first
, int n_range
);
2216 /* Given a list of the maps, with their fixed values at output dimension "pos",
2217 * check whether the ranges of the maps form an obvious partition.
2219 * We first sort the maps according to their fixed values.
2220 * If all maps have a different value, then we know the ranges form
2222 * Otherwise, we collect the maps with the same fixed value and
2223 * check whether each such collection is obviously injective
2224 * based on later dimensions.
2226 static int separates(struct isl_fixed_map
*v
, int n
,
2227 __isl_take isl_space
*dim
, int pos
, int n_range
)
2234 qsort(v
, n
, sizeof(*v
), &qsort_fixed_map_cmp
);
2236 for (i
= 0; i
+ 1 < n
; ++i
) {
2238 isl_union_map
*part
;
2241 for (j
= i
+ 1; j
< n
; ++j
)
2242 if (isl_int_ne(v
[i
].v
, v
[j
].v
))
2248 part
= isl_union_map_alloc(isl_space_copy(dim
), j
- i
);
2249 for (k
= i
; k
< j
; ++k
)
2250 part
= isl_union_map_add_map(part
,
2251 isl_map_copy(v
[k
].map
));
2253 injective
= plain_injective_on_range(part
, pos
+ 1, n_range
);
2262 isl_space_free(dim
);
2263 free_isl_fixed_map_array(v
, n
);
2266 isl_space_free(dim
);
2267 free_isl_fixed_map_array(v
, n
);
2271 /* Check whether the maps in umap have obviously distinct ranges.
2272 * In particular, check for an output dimension in the range
2273 * [first,n_range) for which all maps have a fixed value
2274 * and then check if these values, possibly along with fixed values
2275 * at later dimensions, entail distinct ranges.
2277 static int plain_injective_on_range(__isl_take isl_union_map
*umap
,
2278 int first
, int n_range
)
2282 struct isl_fixed_dim_data data
= { NULL
};
2284 ctx
= isl_union_map_get_ctx(umap
);
2286 n
= isl_union_map_n_map(umap
);
2291 isl_union_map_free(umap
);
2295 if (first
>= n_range
) {
2296 isl_union_map_free(umap
);
2300 data
.v
= alloc_isl_fixed_map_array(ctx
, n
);
2304 for (data
.pos
= first
; data
.pos
< n_range
; ++data
.pos
) {
2310 fixed
= union_map_forall_user(umap
, &fixed_at_pos
, &data
);
2315 dim
= isl_union_map_get_space(umap
);
2316 injective
= separates(data
.v
, n
, dim
, data
.pos
, n_range
);
2317 isl_union_map_free(umap
);
2321 free_isl_fixed_map_array(data
.v
, n
);
2322 isl_union_map_free(umap
);
2326 free_isl_fixed_map_array(data
.v
, n
);
2327 isl_union_map_free(umap
);
2331 /* Check whether the maps in umap that map to subsets of "ran"
2332 * have obviously distinct ranges.
2334 static int plain_injective_on_range_wrap(__isl_keep isl_set
*ran
, void *user
)
2336 isl_union_map
*umap
= user
;
2338 umap
= isl_union_map_copy(umap
);
2339 umap
= isl_union_map_intersect_range(umap
,
2340 isl_union_set_from_set(isl_set_copy(ran
)));
2341 return plain_injective_on_range(umap
, 0, isl_set_dim(ran
, isl_dim_set
));
2344 /* Check if the given union_map is obviously injective.
2346 * In particular, we first check if all individual maps are obviously
2347 * injective and then check if all the ranges of these maps are
2348 * obviously disjoint.
2350 int isl_union_map_plain_is_injective(__isl_keep isl_union_map
*umap
)
2353 isl_union_map
*univ
;
2356 in
= union_map_forall(umap
, &isl_map_plain_is_injective
);
2362 univ
= isl_union_map_universe(isl_union_map_copy(umap
));
2363 ran
= isl_union_map_range(univ
);
2365 in
= union_map_forall_user(ran
, &plain_injective_on_range_wrap
, umap
);
2367 isl_union_set_free(ran
);
2372 int isl_union_map_is_bijective(__isl_keep isl_union_map
*umap
)
2376 sv
= isl_union_map_is_single_valued(umap
);
2380 return isl_union_map_is_injective(umap
);
2383 static int zip_entry(void **entry
, void *user
)
2385 isl_map
*map
= *entry
;
2386 isl_union_map
**res
= user
;
2388 if (!isl_map_can_zip(map
))
2391 *res
= isl_union_map_add_map(*res
, isl_map_zip(isl_map_copy(map
)));
2396 __isl_give isl_union_map
*isl_union_map_zip(__isl_take isl_union_map
*umap
)
2398 return cond_un_op(umap
, &zip_entry
);
2401 static int uncurry_entry(void **entry
, void *user
)
2403 isl_map
*map
= *entry
;
2404 isl_union_map
**res
= user
;
2406 if (!isl_map_can_uncurry(map
))
2409 *res
= isl_union_map_add_map(*res
, isl_map_uncurry(isl_map_copy(map
)));
2414 /* Given a union map, take the maps of the form A -> (B -> C) and
2415 * return the union of the corresponding maps (A -> B) -> C.
2417 __isl_give isl_union_map
*isl_union_map_uncurry(__isl_take isl_union_map
*umap
)
2419 return cond_un_op(umap
, &uncurry_entry
);
2422 static int curry_entry(void **entry
, void *user
)
2424 isl_map
*map
= *entry
;
2425 isl_union_map
**res
= user
;
2427 if (!isl_map_can_curry(map
))
2430 *res
= isl_union_map_add_map(*res
, isl_map_curry(isl_map_copy(map
)));
2435 /* Given a union map, take the maps of the form (A -> B) -> C and
2436 * return the union of the corresponding maps A -> (B -> C).
2438 __isl_give isl_union_map
*isl_union_map_curry(__isl_take isl_union_map
*umap
)
2440 return cond_un_op(umap
, &curry_entry
);
2443 static int lift_entry(void **entry
, void *user
)
2445 isl_set
*set
= *entry
;
2446 isl_union_set
**res
= user
;
2448 *res
= isl_union_set_add_set(*res
, isl_set_lift(isl_set_copy(set
)));
2453 __isl_give isl_union_set
*isl_union_set_lift(__isl_take isl_union_set
*uset
)
2455 return cond_un_op(uset
, &lift_entry
);
2458 static int coefficients_entry(void **entry
, void *user
)
2460 isl_set
*set
= *entry
;
2461 isl_union_set
**res
= user
;
2463 set
= isl_set_copy(set
);
2464 set
= isl_set_from_basic_set(isl_set_coefficients(set
));
2465 *res
= isl_union_set_add_set(*res
, set
);
2470 __isl_give isl_union_set
*isl_union_set_coefficients(
2471 __isl_take isl_union_set
*uset
)
2480 ctx
= isl_union_set_get_ctx(uset
);
2481 dim
= isl_space_set_alloc(ctx
, 0, 0);
2482 res
= isl_union_map_alloc(dim
, uset
->table
.n
);
2483 if (isl_hash_table_foreach(uset
->dim
->ctx
, &uset
->table
,
2484 &coefficients_entry
, &res
) < 0)
2487 isl_union_set_free(uset
);
2490 isl_union_set_free(uset
);
2491 isl_union_set_free(res
);
2495 static int solutions_entry(void **entry
, void *user
)
2497 isl_set
*set
= *entry
;
2498 isl_union_set
**res
= user
;
2500 set
= isl_set_copy(set
);
2501 set
= isl_set_from_basic_set(isl_set_solutions(set
));
2503 *res
= isl_union_set_from_set(set
);
2505 *res
= isl_union_set_add_set(*res
, set
);
2513 __isl_give isl_union_set
*isl_union_set_solutions(
2514 __isl_take isl_union_set
*uset
)
2516 isl_union_set
*res
= NULL
;
2521 if (uset
->table
.n
== 0) {
2522 res
= isl_union_set_empty(isl_union_set_get_space(uset
));
2523 isl_union_set_free(uset
);
2527 if (isl_hash_table_foreach(uset
->dim
->ctx
, &uset
->table
,
2528 &solutions_entry
, &res
) < 0)
2531 isl_union_set_free(uset
);
2534 isl_union_set_free(uset
);
2535 isl_union_set_free(res
);
2539 /* Is the domain space of "map" equal to "space"?
2541 static int domain_match(__isl_keep isl_map
*map
, __isl_keep isl_space
*space
)
2543 return isl_space_tuple_match(map
->dim
, isl_dim_in
, space
, isl_dim_out
);
2546 /* Is the range space of "map" equal to "space"?
2548 static int range_match(__isl_keep isl_map
*map
, __isl_keep isl_space
*space
)
2550 return isl_space_tuple_match(map
->dim
, isl_dim_out
, space
, isl_dim_out
);
2553 /* Is the set space of "map" equal to "space"?
2555 static int set_match(__isl_keep isl_map
*map
, __isl_keep isl_space
*space
)
2557 return isl_space_tuple_match(map
->dim
, isl_dim_set
, space
, isl_dim_out
);
2560 /* Internal data structure for preimage_pw_multi_aff.
2562 * "pma" is the function under which the preimage should be taken.
2563 * "space" is the space of "ma".
2564 * "res" collects the results.
2565 * "fn" computes the preimage for a given map.
2566 * "match" returns true if "fn" can be called.
2568 struct isl_union_map_preimage_data
{
2570 isl_pw_multi_aff
*pma
;
2572 int (*match
)(__isl_keep isl_map
*map
, __isl_keep isl_space
*space
);
2573 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*map
,
2574 __isl_take isl_pw_multi_aff
*pma
);
2577 /* Call data->fn to compute the preimage of the domain or range of *entry
2578 * under the function represented by data->pma, provided the domain/range
2579 * space of *entry matches the target space of data->pma
2580 * (as given by data->match), and add the result to data->res.
2582 static int preimage_entry(void **entry
, void *user
)
2585 isl_map
*map
= *entry
;
2586 struct isl_union_map_preimage_data
*data
= user
;
2589 m
= data
->match(map
, data
->space
);
2595 map
= isl_map_copy(map
);
2596 map
= data
->fn(map
, isl_pw_multi_aff_copy(data
->pma
));
2598 empty
= isl_map_is_empty(map
);
2599 if (empty
< 0 || empty
) {
2601 return empty
< 0 ? -1 : 0;
2604 data
->res
= isl_union_map_add_map(data
->res
, map
);
2609 /* Compute the preimage of the domain or range of "umap" under the function
2610 * represented by "pma".
2611 * In other words, plug in "pma" in the domain or range of "umap".
2612 * The function "fn" performs the actual preimage computation on a map,
2613 * while "match" determines to which maps the function should be applied.
2615 static __isl_give isl_union_map
*preimage_pw_multi_aff(
2616 __isl_take isl_union_map
*umap
, __isl_take isl_pw_multi_aff
*pma
,
2617 int (*match
)(__isl_keep isl_map
*map
, __isl_keep isl_space
*space
),
2618 __isl_give isl_map
*(*fn
)(__isl_take isl_map
*map
,
2619 __isl_take isl_pw_multi_aff
*pma
))
2623 struct isl_union_map_preimage_data data
;
2625 umap
= isl_union_map_align_params(umap
,
2626 isl_pw_multi_aff_get_space(pma
));
2627 pma
= isl_pw_multi_aff_align_params(pma
, isl_union_map_get_space(umap
));
2632 ctx
= isl_union_map_get_ctx(umap
);
2633 space
= isl_union_map_get_space(umap
);
2634 data
.space
= isl_pw_multi_aff_get_space(pma
);
2636 data
.res
= isl_union_map_alloc(space
, umap
->table
.n
);
2639 if (isl_hash_table_foreach(ctx
, &umap
->table
, &preimage_entry
,
2641 data
.res
= isl_union_map_free(data
.res
);
2643 isl_space_free(data
.space
);
2644 isl_union_map_free(umap
);
2645 isl_pw_multi_aff_free(pma
);
2648 isl_union_map_free(umap
);
2649 isl_pw_multi_aff_free(pma
);
2653 /* Compute the preimage of the domain of "umap" under the function
2654 * represented by "pma".
2655 * In other words, plug in "pma" in the domain of "umap".
2656 * The result contains maps that live in the same spaces as the maps of "umap"
2657 * with domain space equal to the target space of "pma",
2658 * except that the domain has been replaced by the domain space of "pma".
2660 __isl_give isl_union_map
*isl_union_map_preimage_domain_pw_multi_aff(
2661 __isl_take isl_union_map
*umap
, __isl_take isl_pw_multi_aff
*pma
)
2663 return preimage_pw_multi_aff(umap
, pma
, &domain_match
,
2664 &isl_map_preimage_domain_pw_multi_aff
);
2667 /* Compute the preimage of the range of "umap" under the function
2668 * represented by "pma".
2669 * In other words, plug in "pma" in the range of "umap".
2670 * The result contains maps that live in the same spaces as the maps of "umap"
2671 * with range space equal to the target space of "pma",
2672 * except that the range has been replaced by the domain space of "pma".
2674 __isl_give isl_union_map
*isl_union_map_preimage_range_pw_multi_aff(
2675 __isl_take isl_union_map
*umap
, __isl_take isl_pw_multi_aff
*pma
)
2677 return preimage_pw_multi_aff(umap
, pma
, &range_match
,
2678 &isl_map_preimage_range_pw_multi_aff
);
2681 /* Compute the preimage of "uset" under the function represented by "pma".
2682 * In other words, plug in "pma" in "uset".
2683 * The result contains sets that live in the same spaces as the sets of "uset"
2684 * with space equal to the target space of "pma",
2685 * except that the space has been replaced by the domain space of "pma".
2687 __isl_give isl_union_set
*isl_union_set_preimage_pw_multi_aff(
2688 __isl_take isl_union_set
*uset
, __isl_take isl_pw_multi_aff
*pma
)
2690 return preimage_pw_multi_aff(uset
, pma
, &set_match
,
2691 &isl_set_preimage_pw_multi_aff
);
2694 /* Compute the preimage of the domain of "umap" under the function
2695 * represented by "ma".
2696 * In other words, plug in "ma" in the domain of "umap".
2697 * The result contains maps that live in the same spaces as the maps of "umap"
2698 * with domain space equal to the target space of "ma",
2699 * except that the domain has been replaced by the domain space of "ma".
2701 __isl_give isl_union_map
*isl_union_map_preimage_domain_multi_aff(
2702 __isl_take isl_union_map
*umap
, __isl_take isl_multi_aff
*ma
)
2704 return isl_union_map_preimage_domain_pw_multi_aff(umap
,
2705 isl_pw_multi_aff_from_multi_aff(ma
));
2708 /* Compute the preimage of the range of "umap" under the function
2709 * represented by "ma".
2710 * In other words, plug in "ma" in the range of "umap".
2711 * The result contains maps that live in the same spaces as the maps of "umap"
2712 * with range space equal to the target space of "ma",
2713 * except that the range has been replaced by the domain space of "ma".
2715 __isl_give isl_union_map
*isl_union_map_preimage_range_multi_aff(
2716 __isl_take isl_union_map
*umap
, __isl_take isl_multi_aff
*ma
)
2718 return isl_union_map_preimage_range_pw_multi_aff(umap
,
2719 isl_pw_multi_aff_from_multi_aff(ma
));
2722 /* Compute the preimage of "uset" under the function represented by "ma".
2723 * In other words, plug in "ma" in "uset".
2724 * The result contains sets that live in the same spaces as the sets of "uset"
2725 * with space equal to the target space of "ma",
2726 * except that the space has been replaced by the domain space of "ma".
2728 __isl_give isl_union_map
*isl_union_set_preimage_multi_aff(
2729 __isl_take isl_union_set
*uset
, __isl_take isl_multi_aff
*ma
)
2731 return isl_union_set_preimage_pw_multi_aff(uset
,
2732 isl_pw_multi_aff_from_multi_aff(ma
));