Polly 23.0.0git
isl_aff.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 INRIA Saclay
3 * Copyright 2011 Sven Verdoolaege
4 * Copyright 2012-2014 Ecole Normale Superieure
5 * Copyright 2014 INRIA Rocquencourt
6 * Copyright 2016 Sven Verdoolaege
7 * Copyright 2018,2020 Cerebras Systems
8 * Copyright 2021 Sven Verdoolaege
9 * Copyright 2021-2022 Cerebras Systems
10 *
11 * Use of this software is governed by the MIT license
12 *
13 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
14 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
15 * 91893 Orsay, France
16 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
17 * and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt,
18 * B.P. 105 - 78153 Le Chesnay, France
19 * and Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
20 * and Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA
21 */
22
23#include <isl_ctx_private.h>
24#include <isl_map_private.h>
26#include <isl_aff_private.h>
27#include <isl_space_private.h>
29#include <isl_vec_private.h>
30#include <isl_mat_private.h>
31#include <isl_id_private.h>
32#include <isl/constraint.h>
33#include <isl_seq.h>
34#include <isl/set.h>
35#include <isl_val_private.h>
36#include <isl_point_private.h>
37#include <isl_config.h>
38
39#undef EL_BASE
40#define EL_BASE aff
41
42#include <isl_list_templ.c>
43#include <isl_list_read_templ.c>
44
45#undef EL_BASE
46#define EL_BASE pw_aff
47
48#include <isl_list_templ.c>
49#include <isl_list_read_templ.c>
50
51#undef EL_BASE
52#define EL_BASE pw_multi_aff
53
54#include <isl_list_templ.c>
55#include <isl_list_read_templ.c>
56
57#undef EL_BASE
58#define EL_BASE union_pw_aff
59
60#include <isl_list_templ.c>
61#include <isl_list_read_templ.c>
62
63#undef EL_BASE
64#define EL_BASE union_pw_multi_aff
65
66#include <isl_list_templ.c>
67
68/* Construct an isl_aff from the given domain local space "ls" and
69 * coefficients "v", where the local space is known to be valid
70 * for an affine expression.
71 */
74{
75 isl_aff *aff;
76
77 if (!ls || !v)
78 goto error;
79
80 aff = isl_calloc_type(v->ctx, struct isl_aff);
81 if (!aff)
82 goto error;
83
84 aff->ref = 1;
85 aff->ls = ls;
86 aff->v = v;
87
88 return aff;
89error:
91 isl_vec_free(v);
92 return NULL;
93}
94
95/* Construct an isl_aff from the given domain local space "ls" and
96 * coefficients "v".
97 *
98 * First check that "ls" is a valid domain local space
99 * for an affine expression.
100 */
103{
104 isl_ctx *ctx;
105
106 if (!ls)
107 return NULL;
108
109 ctx = isl_local_space_get_ctx(ls);
111 isl_die(ctx, isl_error_invalid, "local space has unknown divs",
112 goto error);
113 if (!isl_local_space_is_set(ls))
115 "domain of affine expression should be a set",
116 goto error);
117 return isl_aff_alloc_vec_validated(ls, v);
118error:
120 isl_vec_free(v);
121 return NULL;
122}
123
125{
126 isl_ctx *ctx;
127 isl_vec *v;
129
130 if (!ls)
131 return NULL;
132
133 ctx = isl_local_space_get_ctx(ls);
134
136 if (total < 0)
137 goto error;
138 v = isl_vec_alloc(ctx, 1 + 1 + total);
139 return isl_aff_alloc_vec(ls, v);
140error:
142 return NULL;
143}
144
146{
147 if (!aff)
148 return NULL;
149
150 aff->ref++;
151 return aff;
152}
153
155{
156 if (!aff)
157 return NULL;
158
160 isl_vec_copy(aff->v));
161}
162
164{
165 if (!aff)
166 return NULL;
167
168 if (aff->ref == 1)
169 return aff;
170 aff->ref--;
171 return isl_aff_dup(aff);
172}
173
174/* Return a copy of the rational affine expression of "aff".
175 */
177{
178 if (!aff)
179 return NULL;
180 return isl_vec_copy(aff->v);
181}
182
183/* Return the rational affine expression of "aff".
184 * This may be either a copy or the expression itself
185 * if there is only one reference to "aff".
186 * This allows the expression to be modified inplace
187 * if both the "aff" and its expression have only a single reference.
188 * The caller is not allowed to modify "aff" between this call and
189 * a subsequent call to isl_aff_restore_rat_aff.
190 * The only exception is that isl_aff_free can be called instead.
191 */
193{
194 isl_vec *v;
195
196 if (!aff)
197 return NULL;
198 if (aff->ref != 1)
199 return isl_aff_get_rat_aff(aff);
200 v = aff->v;
201 aff->v = NULL;
202 return v;
203}
204
205/* Set the rational affine expression of "aff" to "v",
206 * where the rational affine expression of "aff" may be missing
207 * due to a preceding call to isl_aff_take_rat_aff.
208 * However, in this case, "aff" only has a single reference and
209 * then the call to isl_aff_cow has no effect.
210 */
213{
214 if (!aff || !v)
215 goto error;
216
217 if (aff->v == v) {
218 isl_vec_free(v);
219 return aff;
220 }
221
223 if (!aff)
224 goto error;
225 isl_vec_free(aff->v);
226 aff->v = v;
227
228 return aff;
229error:
231 isl_vec_free(v);
232 return NULL;
233}
234
236{
237 isl_aff *aff;
238
239 aff = isl_aff_alloc(ls);
240 if (!aff)
241 return NULL;
242
243 isl_int_set_si(aff->v->el[0], 1);
244 isl_seq_clr(aff->v->el + 1, aff->v->size - 1);
245
246 return aff;
247}
248
249/* Return an affine expression that is equal to zero on domain space "space".
250 */
255
256/* This function performs the same operation as isl_aff_zero_on_domain_space,
257 * but is considered as a function on an isl_space when exported.
258 */
263
264/* Return a piecewise affine expression defined on the specified domain
265 * that is equal to zero.
266 */
271
272/* Change "aff" into a NaN.
273 *
274 * Note that this function gets called from isl_aff_nan_on_domain,
275 * so "aff" may not have been initialized yet.
276 */
278{
279 isl_vec *v;
280
282 v = isl_vec_clr(v);
284
285 return aff;
286}
287
288/* Return an affine expression defined on the specified domain
289 * that represents NaN.
290 */
298
299/* Return an affine expression defined on the specified domain space
300 * that represents NaN.
301 */
306
307/* Return a piecewise affine expression defined on the specified domain space
308 * that represents NaN.
309 */
315
316/* Return a piecewise affine expression defined on the specified domain
317 * that represents NaN.
318 */
323
324/* Return an affine expression that is equal to "val" on
325 * domain local space "ls".
326 *
327 * Note that the encoding for the special value NaN
328 * is the same in isl_val and isl_aff, so this does not need
329 * to be treated in any special way.
330 */
333{
334 isl_aff *aff;
335
336 if (!ls || !val)
337 goto error;
340 "expecting rational value or NaN", goto error);
341
343 if (!aff)
344 goto error;
345
346 isl_seq_clr(aff->v->el + 2, aff->v->size - 2);
347 isl_int_set(aff->v->el[1], val->n);
348 isl_int_set(aff->v->el[0], val->d);
349
352 return aff;
353error:
356 return NULL;
357}
358
359/* Return an affine expression that is equal to "val" on domain space "space".
360 */
366
367/* Return an affine expression that is equal to the specified dimension
368 * in "ls".
369 */
371 enum isl_dim_type type, unsigned pos)
372{
373 isl_space *space;
374 isl_aff *aff;
375
376 if (!ls)
377 return NULL;
378
379 space = isl_local_space_get_space(ls);
380 if (!space)
381 goto error;
382 if (isl_space_is_map(space))
384 "expecting (parameter) set space", goto error);
385 if (isl_local_space_check_range(ls, type, pos, 1) < 0)
386 goto error;
387
388 isl_space_free(space);
389 aff = isl_aff_alloc(ls);
390 if (!aff)
391 return NULL;
392
394
395 isl_int_set_si(aff->v->el[0], 1);
396 isl_seq_clr(aff->v->el + 1, aff->v->size - 1);
397 isl_int_set_si(aff->v->el[1 + pos], 1);
398
399 return aff;
400error:
402 isl_space_free(space);
403 return NULL;
404}
405
406/* Return a piecewise affine expression that is equal to
407 * the specified dimension in "ls".
408 */
414
415/* Return an affine expression that is equal to the parameter
416 * in the domain space "space" with identifier "id".
417 */
420{
421 int pos;
422 isl_local_space *ls;
423
424 if (!space || !id)
425 goto error;
427 if (pos < 0)
429 "parameter not found in space", goto error);
430 isl_id_free(id);
431 ls = isl_local_space_from_space(space);
433error:
434 isl_space_free(space);
435 isl_id_free(id);
436 return NULL;
437}
438
439/* This function performs the same operation as
440 * isl_aff_param_on_domain_space_id,
441 * but is considered as a function on an isl_space when exported.
442 */
448
450{
451 if (!aff)
452 return NULL;
453
454 if (--aff->ref > 0)
455 return NULL;
456
458 isl_vec_free(aff->v);
459
460 free(aff);
461
462 return NULL;
463}
464
469
470/* Return a hash value that digests "aff".
471 */
473{
474 uint32_t hash, ls_hash, v_hash;
475
476 if (!aff)
477 return 0;
478
479 hash = isl_hash_init();
480 ls_hash = isl_local_space_get_hash(aff->ls);
481 isl_hash_hash(hash, ls_hash);
482 v_hash = isl_vec_get_hash(aff->v);
483 isl_hash_hash(hash, v_hash);
484
485 return hash;
486}
487
488/* Return the domain local space of "aff".
489 */
492{
493 return aff ? aff->ls : NULL;
494}
495
496/* Return the number of variables of the given type in the domain of "aff".
497 */
505
506/* Externally, an isl_aff has a map space, but internally, the
507 * ls field corresponds to the domain of that space.
508 */
510{
511 if (!aff)
512 return isl_size_error;
513 if (type == isl_dim_out)
514 return 1;
515 if (type == isl_dim_in)
517 return isl_aff_domain_dim(aff, type);
518}
519
520/* Return the offset of the first variable of type "type" within
521 * the variables of the domain of "aff".
522 */
531
532/* Return the offset of the first coefficient of type "type" in
533 * the domain of "aff".
534 */
544
545/* Return the position of the dimension of the given type and name
546 * in "aff".
547 * Return -1 if no such dimension can be found.
548 */
550 const char *name)
551{
552 if (!aff)
553 return -1;
554 if (type == isl_dim_out)
555 return -1;
556 if (type == isl_dim_in)
559}
560
561/* Return the domain space of "aff".
562 */
567
572
574{
575 isl_space *space;
576 if (!aff)
577 return NULL;
578 space = isl_local_space_get_space(aff->ls);
579 space = isl_space_from_domain(space);
580 space = isl_space_add_dims(space, isl_dim_out, 1);
581 return space;
582}
583
584/* Return a copy of the domain space of "aff".
585 */
591
593{
594 isl_local_space *ls;
595 if (!aff)
596 return NULL;
597 ls = isl_local_space_copy(aff->ls);
600 return ls;
601}
602
603/* Return the local space of the domain of "aff".
604 * This may be either a copy or the local space itself
605 * if there is only one reference to "aff".
606 * This allows the local space to be modified inplace
607 * if both the expression and its local space have only a single reference.
608 * The caller is not allowed to modify "aff" between this call and
609 * a subsequent call to isl_aff_restore_domain_local_space.
610 * The only exception is that isl_aff_free can be called instead.
611 */
614{
615 isl_local_space *ls;
616
617 if (!aff)
618 return NULL;
619 if (aff->ref != 1)
621 ls = aff->ls;
622 aff->ls = NULL;
623 return ls;
624}
625
626/* Set the local space of the domain of "aff" to "ls",
627 * where the local space of "aff" may be missing
628 * due to a preceding call to isl_aff_take_domain_local_space.
629 * However, in this case, "aff" only has a single reference and
630 * then the call to isl_aff_cow has no effect.
631 */
634{
635 if (!aff || !ls)
636 goto error;
637
638 if (aff->ls == ls) {
640 return aff;
641 }
642
644 if (!aff)
645 goto error;
647 aff->ls = ls;
648
649 return aff;
650error:
653 return NULL;
654}
655
656/* Externally, an isl_aff has a map space, but internally, the
657 * ls field corresponds to the domain of that space.
658 */
660 enum isl_dim_type type, unsigned pos)
661{
662 if (!aff)
663 return NULL;
664 if (type == isl_dim_out)
665 return NULL;
666 if (type == isl_dim_in)
669}
670
672 __isl_take isl_space *space)
673{
675 if (!aff || !space)
676 goto error;
677
678 aff->ls = isl_local_space_reset_space(aff->ls, space);
679 if (!aff->ls)
680 return isl_aff_free(aff);
681
682 return aff;
683error:
685 isl_space_free(space);
686 return NULL;
687}
688
689/* Reset the space of "aff". This function is called from isl_pw_templ.c
690 * and doesn't know if the space of an element object is represented
691 * directly or through its domain. It therefore passes along both.
692 */
699
700/* Reorder the dimensions of the domain of "aff" according
701 * to the given reordering.
702 */
705{
707 if (!aff)
708 goto error;
709
710 r = isl_reordering_extend(r, aff->ls->div->n_row);
712 aff->ls = isl_local_space_realign(aff->ls, r);
713
714 if (!aff->v || !aff->ls)
715 return isl_aff_free(aff);
716
717 return aff;
718error:
721 return NULL;
722}
723
725 __isl_take isl_space *model)
726{
727 isl_space *domain_space;
728 isl_bool equal_params;
729
730 domain_space = isl_aff_peek_domain_space(aff);
731 equal_params = isl_space_has_equal_params(domain_space, model);
732 if (equal_params < 0)
733 goto error;
734 if (!equal_params) {
735 isl_reordering *exp;
736
737 exp = isl_parameter_alignment_reordering(domain_space, model);
739 }
740
741 isl_space_free(model);
742 return aff;
743error:
744 isl_space_free(model);
746 return NULL;
747}
748
749#undef TYPE
750#define TYPE isl_aff
752
753/* Is "aff" obviously equal to zero?
754 *
755 * If the denominator is zero, then "aff" is not equal to zero.
756 */
758{
759 int pos;
760
761 if (!aff)
762 return isl_bool_error;
763
764 if (isl_int_is_zero(aff->v->el[0]))
765 return isl_bool_false;
766 pos = isl_seq_first_non_zero(aff->v->el + 1, aff->v->size - 1);
767 return isl_bool_ok(pos < 0);
768}
769
770/* Does "aff" represent NaN?
771 */
773{
774 if (!aff)
775 return isl_bool_error;
776
777 return isl_bool_ok(!isl_seq_any_non_zero(aff->v->el, 2));
778}
779
780/* Are "aff1" and "aff2" obviously equal?
781 *
782 * NaN is not equal to anything, not even to another NaN.
783 */
785 __isl_keep isl_aff *aff2)
786{
788
789 if (!aff1 || !aff2)
790 return isl_bool_error;
791
792 if (isl_aff_is_nan(aff1) || isl_aff_is_nan(aff2))
793 return isl_bool_false;
794
795 equal = isl_local_space_is_equal(aff1->ls, aff2->ls);
796 if (equal < 0 || !equal)
797 return equal;
798
799 return isl_vec_is_equal(aff1->v, aff2->v);
800}
801
802/* Return the common denominator of "aff" in "v".
803 *
804 * We cannot return anything meaningful in case of a NaN.
805 */
807{
808 if (!aff)
809 return isl_stat_error;
810 if (isl_aff_is_nan(aff))
812 "cannot get denominator of NaN", return isl_stat_error);
813 isl_int_set(*v, aff->v->el[0]);
814 return isl_stat_ok;
815}
816
817/* Return the common denominator of "aff".
818 */
820{
821 isl_ctx *ctx;
822
823 if (!aff)
824 return NULL;
825
826 ctx = isl_aff_get_ctx(aff);
827 if (isl_aff_is_nan(aff))
828 return isl_val_nan(ctx);
829 return isl_val_int_from_isl_int(ctx, aff->v->el[0]);
830}
831
832/* Return the constant term of "aff".
833 */
835{
836 isl_ctx *ctx;
837 isl_val *v;
838
839 if (!aff)
840 return NULL;
841
842 ctx = isl_aff_get_ctx(aff);
843 if (isl_aff_is_nan(aff))
844 return isl_val_nan(ctx);
845 v = isl_val_rat_from_isl_int(ctx, aff->v->el[1], aff->v->el[0]);
846 return isl_val_normalize(v);
847}
848
849/* Return the coefficient of the variable of type "type" at position "pos"
850 * of "aff".
851 */
853 enum isl_dim_type type, int pos)
854{
855 isl_ctx *ctx;
856 isl_val *v;
857
858 if (!aff)
859 return NULL;
860
861 ctx = isl_aff_get_ctx(aff);
862 if (type == isl_dim_out)
864 "output/set dimension does not have a coefficient",
865 return NULL);
866 if (type == isl_dim_in)
868
869 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
870 return NULL;
871
872 if (isl_aff_is_nan(aff))
873 return isl_val_nan(ctx);
875 v = isl_val_rat_from_isl_int(ctx, aff->v->el[1 + pos], aff->v->el[0]);
876 return isl_val_normalize(v);
877}
878
879/* Return the sign of the coefficient of the variable of type "type"
880 * at position "pos" of "aff".
881 */
883 int pos)
884{
885 isl_ctx *ctx;
886
887 if (!aff)
888 return 0;
889
890 ctx = isl_aff_get_ctx(aff);
891 if (type == isl_dim_out)
893 "output/set dimension does not have a coefficient",
894 return 0);
895 if (type == isl_dim_in)
897
898 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
899 return 0;
900
902 return isl_int_sgn(aff->v->el[1 + pos]);
903}
904
905/* Replace the numerator of the constant term of "aff" by "v".
906 *
907 * A NaN is unaffected by this operation.
908 */
910{
911 if (!aff)
912 return NULL;
913 if (isl_aff_is_nan(aff))
914 return aff;
916 if (!aff)
917 return NULL;
918
919 aff->v = isl_vec_cow(aff->v);
920 if (!aff->v)
921 return isl_aff_free(aff);
922
923 isl_int_set(aff->v->el[1], v);
924
925 return aff;
926}
927
928/* Replace the constant term of "aff" by "v".
929 *
930 * A NaN is unaffected by this operation.
931 */
934{
935 if (!aff || !v)
936 goto error;
937
938 if (isl_aff_is_nan(aff)) {
939 isl_val_free(v);
940 return aff;
941 }
942
943 if (!isl_val_is_rat(v))
945 "expecting rational value", goto error);
946
947 if (isl_int_eq(aff->v->el[1], v->n) &&
948 isl_int_eq(aff->v->el[0], v->d)) {
949 isl_val_free(v);
950 return aff;
951 }
952
954 if (!aff)
955 goto error;
956 aff->v = isl_vec_cow(aff->v);
957 if (!aff->v)
958 goto error;
959
960 if (isl_int_eq(aff->v->el[0], v->d)) {
961 isl_int_set(aff->v->el[1], v->n);
962 } else if (isl_int_is_one(v->d)) {
963 isl_int_mul(aff->v->el[1], aff->v->el[0], v->n);
964 } else {
965 isl_seq_scale(aff->v->el + 1,
966 aff->v->el + 1, v->d, aff->v->size - 1);
967 isl_int_mul(aff->v->el[1], aff->v->el[0], v->n);
968 isl_int_mul(aff->v->el[0], aff->v->el[0], v->d);
969 aff->v = isl_vec_normalize(aff->v);
970 if (!aff->v)
971 goto error;
972 }
973
974 isl_val_free(v);
975 return aff;
976error:
978 isl_val_free(v);
979 return NULL;
980}
981
982/* Add "v" to the constant term of "aff".
983 *
984 * A NaN is unaffected by this operation.
985 */
987{
988 if (isl_int_is_zero(v))
989 return aff;
990
991 if (!aff)
992 return NULL;
993 if (isl_aff_is_nan(aff))
994 return aff;
996 if (!aff)
997 return NULL;
998
999 aff->v = isl_vec_cow(aff->v);
1000 if (!aff->v)
1001 return isl_aff_free(aff);
1002
1003 isl_int_addmul(aff->v->el[1], aff->v->el[0], v);
1004
1005 return aff;
1006}
1007
1008/* Add "v" to the constant term of "aff",
1009 * in case "aff" is a rational expression.
1010 */
1013{
1014 aff = isl_aff_cow(aff);
1015 if (!aff)
1016 goto error;
1017
1018 aff->v = isl_vec_cow(aff->v);
1019 if (!aff->v)
1020 goto error;
1021
1022 if (isl_int_is_one(v->d)) {
1023 isl_int_addmul(aff->v->el[1], aff->v->el[0], v->n);
1024 } else if (isl_int_eq(aff->v->el[0], v->d)) {
1025 isl_int_add(aff->v->el[1], aff->v->el[1], v->n);
1026 aff->v = isl_vec_normalize(aff->v);
1027 if (!aff->v)
1028 goto error;
1029 } else {
1030 isl_seq_scale(aff->v->el + 1,
1031 aff->v->el + 1, v->d, aff->v->size - 1);
1032 isl_int_addmul(aff->v->el[1], aff->v->el[0], v->n);
1033 isl_int_mul(aff->v->el[0], aff->v->el[0], v->d);
1034 aff->v = isl_vec_normalize(aff->v);
1035 if (!aff->v)
1036 goto error;
1037 }
1038
1039 isl_val_free(v);
1040 return aff;
1041error:
1043 isl_val_free(v);
1044 return NULL;
1045}
1046
1047/* Return the first argument and free the second.
1048 */
1051{
1052 isl_val_free(v);
1053 return aff;
1054}
1055
1056/* Replace the first argument by NaN and free the second argument.
1057 */
1064
1065/* Add "v" to the constant term of "aff".
1066 *
1067 * A NaN is unaffected by this operation.
1068 * Conversely, adding a NaN turns "aff" into a NaN.
1069 */
1072{
1073 isl_bool is_nan, is_zero, is_rat;
1074
1075 is_nan = isl_aff_is_nan(aff);
1076 is_zero = isl_val_is_zero(v);
1077 if (is_nan < 0 || is_zero < 0)
1078 goto error;
1079 if (is_nan || is_zero)
1080 return pick_free(aff, v);
1081
1082 is_nan = isl_val_is_nan(v);
1083 is_rat = isl_val_is_rat(v);
1084 if (is_nan < 0 || is_rat < 0)
1085 goto error;
1086 if (is_nan)
1087 return set_nan_free_val(aff, v);
1088 if (!is_rat)
1090 "expecting rational value or NaN", goto error);
1091
1093error:
1095 isl_val_free(v);
1096 return NULL;
1097}
1098
1100{
1101 isl_int t;
1102
1103 isl_int_init(t);
1104 isl_int_set_si(t, v);
1107
1108 return aff;
1109}
1110
1111/* Add "v" to the numerator of the constant term of "aff".
1112 *
1113 * A NaN is unaffected by this operation.
1114 */
1116{
1117 if (isl_int_is_zero(v))
1118 return aff;
1119
1120 if (!aff)
1121 return NULL;
1122 if (isl_aff_is_nan(aff))
1123 return aff;
1124 aff = isl_aff_cow(aff);
1125 if (!aff)
1126 return NULL;
1127
1128 aff->v = isl_vec_cow(aff->v);
1129 if (!aff->v)
1130 return isl_aff_free(aff);
1131
1132 isl_int_add(aff->v->el[1], aff->v->el[1], v);
1133
1134 return aff;
1135}
1136
1137/* Add "v" to the numerator of the constant term of "aff".
1138 *
1139 * A NaN is unaffected by this operation.
1140 */
1142{
1143 isl_int t;
1144
1145 if (v == 0)
1146 return aff;
1147
1148 isl_int_init(t);
1149 isl_int_set_si(t, v);
1152
1153 return aff;
1154}
1155
1156/* Replace the numerator of the constant term of "aff" by "v".
1157 *
1158 * A NaN is unaffected by this operation.
1159 */
1161{
1162 if (!aff)
1163 return NULL;
1164 if (isl_aff_is_nan(aff))
1165 return aff;
1166 aff = isl_aff_cow(aff);
1167 if (!aff)
1168 return NULL;
1169
1170 aff->v = isl_vec_cow(aff->v);
1171 if (!aff->v)
1172 return isl_aff_free(aff);
1173
1174 isl_int_set_si(aff->v->el[1], v);
1175
1176 return aff;
1177}
1178
1179/* Replace the numerator of the coefficient of the variable of type "type"
1180 * at position "pos" of "aff" by "v".
1181 *
1182 * A NaN is unaffected by this operation.
1183 */
1185 enum isl_dim_type type, int pos, isl_int v)
1186{
1187 if (!aff)
1188 return NULL;
1189
1190 if (type == isl_dim_out)
1191 isl_die(aff->v->ctx, isl_error_invalid,
1192 "output/set dimension does not have a coefficient",
1193 return isl_aff_free(aff));
1194 if (type == isl_dim_in)
1195 type = isl_dim_set;
1196
1197 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
1198 return isl_aff_free(aff);
1199
1200 if (isl_aff_is_nan(aff))
1201 return aff;
1202 aff = isl_aff_cow(aff);
1203 if (!aff)
1204 return NULL;
1205
1206 aff->v = isl_vec_cow(aff->v);
1207 if (!aff->v)
1208 return isl_aff_free(aff);
1209
1211 isl_int_set(aff->v->el[1 + pos], v);
1212
1213 return aff;
1214}
1215
1216/* Replace the numerator of the coefficient of the variable of type "type"
1217 * at position "pos" of "aff" by "v".
1218 *
1219 * A NaN is unaffected by this operation.
1220 */
1222 enum isl_dim_type type, int pos, int v)
1223{
1224 if (!aff)
1225 return NULL;
1226
1227 if (type == isl_dim_out)
1228 isl_die(aff->v->ctx, isl_error_invalid,
1229 "output/set dimension does not have a coefficient",
1230 return isl_aff_free(aff));
1231 if (type == isl_dim_in)
1232 type = isl_dim_set;
1233
1234 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
1235 return isl_aff_free(aff);
1236
1237 if (isl_aff_is_nan(aff))
1238 return aff;
1240 if (isl_int_cmp_si(aff->v->el[1 + pos], v) == 0)
1241 return aff;
1242
1243 aff = isl_aff_cow(aff);
1244 if (!aff)
1245 return NULL;
1246
1247 aff->v = isl_vec_cow(aff->v);
1248 if (!aff->v)
1249 return isl_aff_free(aff);
1250
1251 isl_int_set_si(aff->v->el[1 + pos], v);
1252
1253 return aff;
1254}
1255
1256/* Replace the coefficient of the variable of type "type" at position "pos"
1257 * of "aff" by "v".
1258 *
1259 * A NaN is unaffected by this operation.
1260 */
1262 enum isl_dim_type type, int pos, __isl_take isl_val *v)
1263{
1264 if (!aff || !v)
1265 goto error;
1266
1267 if (type == isl_dim_out)
1268 isl_die(aff->v->ctx, isl_error_invalid,
1269 "output/set dimension does not have a coefficient",
1270 goto error);
1271 if (type == isl_dim_in)
1272 type = isl_dim_set;
1273
1274 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
1275 return isl_aff_free(aff);
1276
1277 if (isl_aff_is_nan(aff)) {
1278 isl_val_free(v);
1279 return aff;
1280 }
1281 if (!isl_val_is_rat(v))
1283 "expecting rational value", goto error);
1284
1286 if (isl_int_eq(aff->v->el[1 + pos], v->n) &&
1287 isl_int_eq(aff->v->el[0], v->d)) {
1288 isl_val_free(v);
1289 return aff;
1290 }
1291
1292 aff = isl_aff_cow(aff);
1293 if (!aff)
1294 goto error;
1295 aff->v = isl_vec_cow(aff->v);
1296 if (!aff->v)
1297 goto error;
1298
1299 if (isl_int_eq(aff->v->el[0], v->d)) {
1300 isl_int_set(aff->v->el[1 + pos], v->n);
1301 } else if (isl_int_is_one(v->d)) {
1302 isl_int_mul(aff->v->el[1 + pos], aff->v->el[0], v->n);
1303 } else {
1304 isl_seq_scale(aff->v->el + 1,
1305 aff->v->el + 1, v->d, aff->v->size - 1);
1306 isl_int_mul(aff->v->el[1 + pos], aff->v->el[0], v->n);
1307 isl_int_mul(aff->v->el[0], aff->v->el[0], v->d);
1308 aff->v = isl_vec_normalize(aff->v);
1309 if (!aff->v)
1310 goto error;
1311 }
1312
1313 isl_val_free(v);
1314 return aff;
1315error:
1317 isl_val_free(v);
1318 return NULL;
1319}
1320
1321/* Add "v" to the coefficient of the variable of type "type"
1322 * at position "pos" of "aff".
1323 *
1324 * A NaN is unaffected by this operation.
1325 */
1327 enum isl_dim_type type, int pos, isl_int v)
1328{
1329 if (!aff)
1330 return NULL;
1331
1332 if (type == isl_dim_out)
1333 isl_die(aff->v->ctx, isl_error_invalid,
1334 "output/set dimension does not have a coefficient",
1335 return isl_aff_free(aff));
1336 if (type == isl_dim_in)
1337 type = isl_dim_set;
1338
1339 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
1340 return isl_aff_free(aff);
1341
1342 if (isl_aff_is_nan(aff))
1343 return aff;
1344 aff = isl_aff_cow(aff);
1345 if (!aff)
1346 return NULL;
1347
1348 aff->v = isl_vec_cow(aff->v);
1349 if (!aff->v)
1350 return isl_aff_free(aff);
1351
1353 isl_int_addmul(aff->v->el[1 + pos], aff->v->el[0], v);
1354
1355 return aff;
1356}
1357
1358/* Add "v" to the coefficient of the variable of type "type"
1359 * at position "pos" of "aff".
1360 *
1361 * A NaN is unaffected by this operation.
1362 */
1364 enum isl_dim_type type, int pos, __isl_take isl_val *v)
1365{
1366 if (!aff || !v)
1367 goto error;
1368
1369 if (isl_val_is_zero(v)) {
1370 isl_val_free(v);
1371 return aff;
1372 }
1373
1374 if (type == isl_dim_out)
1375 isl_die(aff->v->ctx, isl_error_invalid,
1376 "output/set dimension does not have a coefficient",
1377 goto error);
1378 if (type == isl_dim_in)
1379 type = isl_dim_set;
1380
1381 if (isl_local_space_check_range(aff->ls, type, pos, 1) < 0)
1382 goto error;
1383
1384 if (isl_aff_is_nan(aff)) {
1385 isl_val_free(v);
1386 return aff;
1387 }
1388 if (!isl_val_is_rat(v))
1390 "expecting rational value", goto error);
1391
1392 aff = isl_aff_cow(aff);
1393 if (!aff)
1394 goto error;
1395
1396 aff->v = isl_vec_cow(aff->v);
1397 if (!aff->v)
1398 goto error;
1399
1401 if (isl_int_is_one(v->d)) {
1402 isl_int_addmul(aff->v->el[1 + pos], aff->v->el[0], v->n);
1403 } else if (isl_int_eq(aff->v->el[0], v->d)) {
1404 isl_int_add(aff->v->el[1 + pos], aff->v->el[1 + pos], v->n);
1405 aff->v = isl_vec_normalize(aff->v);
1406 if (!aff->v)
1407 goto error;
1408 } else {
1409 isl_seq_scale(aff->v->el + 1,
1410 aff->v->el + 1, v->d, aff->v->size - 1);
1411 isl_int_addmul(aff->v->el[1 + pos], aff->v->el[0], v->n);
1412 isl_int_mul(aff->v->el[0], aff->v->el[0], v->d);
1413 aff->v = isl_vec_normalize(aff->v);
1414 if (!aff->v)
1415 goto error;
1416 }
1417
1418 isl_val_free(v);
1419 return aff;
1420error:
1422 isl_val_free(v);
1423 return NULL;
1424}
1425
1427 enum isl_dim_type type, int pos, int v)
1428{
1429 isl_int t;
1430
1431 isl_int_init(t);
1432 isl_int_set_si(t, v);
1435
1436 return aff;
1437}
1438
1440{
1441 if (!aff)
1442 return NULL;
1443
1444 return isl_local_space_get_div(aff->ls, pos);
1445}
1446
1447/* Return the negation of "aff".
1448 *
1449 * As a special case, -NaN = NaN.
1450 */
1452{
1453 if (!aff)
1454 return NULL;
1455 if (isl_aff_is_nan(aff))
1456 return aff;
1457 aff = isl_aff_cow(aff);
1458 if (!aff)
1459 return NULL;
1460 aff->v = isl_vec_cow(aff->v);
1461 if (!aff->v)
1462 return isl_aff_free(aff);
1463
1464 isl_seq_neg(aff->v->el + 1, aff->v->el + 1, aff->v->size - 1);
1465
1466 return aff;
1467}
1468
1469/* Remove divs from the local space that do not appear in the affine
1470 * expression.
1471 *
1472 * First remove any unused local variables at the end.
1473 * Then look for other unused local variables. These need some extra care
1474 * because a local variable that does not appear in the affine expression
1475 * may still appear in the definition of some later local variable.
1476 */
1478{
1479 int pos;
1480 isl_size v_div;
1481 isl_size n;
1482 int *active;
1483 isl_local_space *ls;
1484
1487 if (n < 0 || v_div < 0)
1488 return isl_aff_free(aff);
1489
1490 pos = isl_seq_last_non_zero(aff->v->el + 1 + 1 + v_div, n) + 1;
1491 if (pos < n)
1493 if (pos <= 1 || !aff)
1494 return aff;
1495
1497 active = isl_local_space_get_active(ls, aff->v->el + 2);
1498 if (!active)
1499 return isl_aff_free(aff);
1500 for (pos = pos - 2; pos >= 0; pos--) {
1501 if (active[v_div + pos])
1502 continue;
1504 }
1505 free(active);
1506
1507 return aff;
1508}
1509
1510/* Look for any divs in the aff->ls with a denominator equal to one
1511 * and plug them into the affine expression and any subsequent divs
1512 * that may reference the div.
1513 */
1515{
1516 int i;
1517 isl_size n;
1518 int len;
1519 isl_int v;
1520 isl_vec *vec;
1521 isl_local_space *ls;
1522 isl_size off;
1523
1526 if (n < 0 || off < 0)
1527 return isl_aff_free(aff);
1528 len = aff->v->size;
1529 for (i = 0; i < n; ++i) {
1530 if (!isl_int_is_one(aff->ls->div->row[i][0]))
1531 continue;
1532 ls = isl_local_space_copy(aff->ls);
1534 aff->ls->div->row[i], len, i + 1, n - (i + 1));
1535 vec = isl_vec_copy(aff->v);
1536 vec = isl_vec_cow(vec);
1537 if (!ls || !vec)
1538 goto error;
1539
1540 isl_int_init(v);
1541
1542 isl_seq_substitute(vec->el, off + i, aff->ls->div->row[i],
1543 len, len, v);
1544
1545 isl_int_clear(v);
1546
1547 isl_vec_free(aff->v);
1548 aff->v = vec;
1550 aff->ls = ls;
1551 }
1552
1553 return aff;
1554error:
1555 isl_vec_free(vec);
1557 return isl_aff_free(aff);
1558}
1559
1560/* Look for any divs j that appear with a unit coefficient inside
1561 * the definitions of other divs i and plug them into the definitions
1562 * of the divs i.
1563 *
1564 * In particular, an expression of the form
1565 *
1566 * floor((f(..) + floor(g(..)/n))/m)
1567 *
1568 * is simplified to
1569 *
1570 * floor((n * f(..) + g(..))/(n * m))
1571 *
1572 * This simplification is correct because we can move the expression
1573 * f(..) into the inner floor in the original expression to obtain
1574 *
1575 * floor(floor((n * f(..) + g(..))/n)/m)
1576 *
1577 * from which we can derive the simplified expression.
1578 */
1580{
1581 int i, j;
1582 isl_size n;
1583 isl_size off;
1584
1587 if (n < 0 || off < 0)
1588 return isl_aff_free(aff);
1589 for (i = 1; i < n; ++i) {
1590 for (j = 0; j < i; ++j) {
1591 if (!isl_int_is_one(aff->ls->div->row[i][1 + off + j]))
1592 continue;
1594 isl_dim_div, j, aff->ls->div->row[j],
1595 aff->v->size, i, 1);
1596 if (!aff->ls)
1597 return isl_aff_free(aff);
1598 }
1599 }
1600
1601 return aff;
1602}
1603
1604/* Swap divs "a" and "b" in "aff", which is assumed to be non-NULL.
1605 *
1606 * Even though this function is only called on isl_affs with a single
1607 * reference, we are careful to only change aff->v and aff->ls together.
1608 */
1610{
1612 isl_local_space *ls;
1613 isl_vec *v;
1614
1615 if (off < 0)
1616 return isl_aff_free(aff);
1617
1618 ls = isl_local_space_copy(aff->ls);
1619 ls = isl_local_space_swap_div(ls, a, b);
1620 v = isl_vec_copy(aff->v);
1621 v = isl_vec_cow(v);
1622 if (!ls || !v)
1623 goto error;
1624
1625 isl_int_swap(v->el[1 + off + a], v->el[1 + off + b]);
1626 isl_vec_free(aff->v);
1627 aff->v = v;
1629 aff->ls = ls;
1630
1631 return aff;
1632error:
1633 isl_vec_free(v);
1635 return isl_aff_free(aff);
1636}
1637
1638/* Merge divs "a" and "b" in "aff", which is assumed to be non-NULL.
1639 *
1640 * We currently do not actually remove div "b", but simply add its
1641 * coefficient to that of "a" and then zero it out.
1642 */
1644{
1646
1647 if (off < 0)
1648 return isl_aff_free(aff);
1649
1650 if (isl_int_is_zero(aff->v->el[1 + off + b]))
1651 return aff;
1652
1653 aff->v = isl_vec_cow(aff->v);
1654 if (!aff->v)
1655 return isl_aff_free(aff);
1656
1657 isl_int_add(aff->v->el[1 + off + a],
1658 aff->v->el[1 + off + a], aff->v->el[1 + off + b]);
1659 isl_int_set_si(aff->v->el[1 + off + b], 0);
1660
1661 return aff;
1662}
1663
1664/* Sort the divs in the local space of "aff" according to
1665 * the comparison function "cmp_row" in isl_local_space.c,
1666 * combining the coefficients of identical divs.
1667 *
1668 * Reordering divs does not change the semantics of "aff",
1669 * so there is no need to call isl_aff_cow.
1670 * Moreover, this function is currently only called on isl_affs
1671 * with a single reference.
1672 */
1674{
1675 isl_size n;
1676 int i, j;
1677
1679 if (n < 0)
1680 return isl_aff_free(aff);
1681 for (i = 1; i < n; ++i) {
1682 for (j = i - 1; j >= 0; --j) {
1683 int cmp = isl_mat_cmp_div(aff->ls->div, j, j + 1);
1684 if (cmp < 0)
1685 break;
1686 if (cmp == 0)
1687 aff = merge_divs(aff, j, j + 1);
1688 else
1689 aff = swap_div(aff, j, j + 1);
1690 if (!aff)
1691 return NULL;
1692 }
1693 }
1694
1695 return aff;
1696}
1697
1698/* Normalize the representation of "aff".
1699 *
1700 * This function should only be called on "new" isl_affs, i.e.,
1701 * with only a single reference. We therefore do not need to
1702 * worry about affecting other instances.
1703 */
1705{
1706 if (!aff)
1707 return NULL;
1708 aff->v = isl_vec_normalize(aff->v);
1709 if (!aff->v)
1710 return isl_aff_free(aff);
1713 aff = sort_divs(aff);
1715 return aff;
1716}
1717
1718/* Given f, return floor(f).
1719 * If f is an integer expression, then just return f.
1720 * If f is a constant, then return the constant floor(f).
1721 * Otherwise, if f = g/m, write g = q m + r,
1722 * create a new div d = [r/m] and return the expression q + d.
1723 * The coefficients in r are taken to lie between -m/2 and m/2.
1724 *
1725 * reduce_div_coefficients performs the same normalization.
1726 *
1727 * As a special case, floor(NaN) = NaN.
1728 */
1730{
1731 int i;
1732 int size;
1733 isl_ctx *ctx;
1734 isl_vec *div;
1735
1736 if (!aff)
1737 return NULL;
1738
1739 if (isl_aff_is_nan(aff))
1740 return aff;
1741 if (isl_int_is_one(aff->v->el[0]))
1742 return aff;
1743
1744 aff = isl_aff_cow(aff);
1745 if (!aff)
1746 return NULL;
1747
1748 aff->v = isl_vec_cow(aff->v);
1749 if (!aff->v)
1750 return isl_aff_free(aff);
1751
1752 if (isl_aff_is_cst(aff)) {
1753 isl_int_fdiv_q(aff->v->el[1], aff->v->el[1], aff->v->el[0]);
1754 isl_int_set_si(aff->v->el[0], 1);
1755 return aff;
1756 }
1757
1758 div = isl_vec_copy(aff->v);
1759 div = isl_vec_cow(div);
1760 if (!div)
1761 return isl_aff_free(aff);
1762
1763 ctx = isl_aff_get_ctx(aff);
1764 isl_int_fdiv_q(aff->v->el[0], aff->v->el[0], ctx->two);
1765 for (i = 1; i < aff->v->size; ++i) {
1766 isl_int_fdiv_r(div->el[i], div->el[i], div->el[0]);
1767 isl_int_fdiv_q(aff->v->el[i], aff->v->el[i], div->el[0]);
1768 if (isl_int_gt(div->el[i], aff->v->el[0])) {
1769 isl_int_sub(div->el[i], div->el[i], div->el[0]);
1770 isl_int_add_ui(aff->v->el[i], aff->v->el[i], 1);
1771 }
1772 }
1773
1774 aff->ls = isl_local_space_add_div(aff->ls, div);
1775 if (!aff->ls)
1776 return isl_aff_free(aff);
1777
1778 size = aff->v->size;
1779 aff->v = isl_vec_extend(aff->v, size + 1);
1780 if (!aff->v)
1781 return isl_aff_free(aff);
1782 isl_int_set_si(aff->v->el[0], 1);
1783 isl_int_set_si(aff->v->el[size], 1);
1784
1786
1787 return aff;
1788}
1789
1790/* Compute
1791 *
1792 * aff mod m = aff - m * floor(aff/m)
1793 *
1794 * with m an integer value.
1795 */
1798{
1799 isl_aff *res;
1800
1801 if (!aff || !m)
1802 goto error;
1803
1804 if (!isl_val_is_int(m))
1806 "expecting integer modulo", goto error);
1807
1808 res = isl_aff_copy(aff);
1812 res = isl_aff_sub(res, aff);
1813
1814 return res;
1815error:
1817 isl_val_free(m);
1818 return NULL;
1819}
1820
1821/* Compute
1822 *
1823 * pwaff mod m = pwaff - m * floor(pwaff/m)
1824 */
1826{
1827 isl_pw_aff *res;
1828
1829 res = isl_pw_aff_copy(pwaff);
1830 pwaff = isl_pw_aff_scale_down(pwaff, m);
1831 pwaff = isl_pw_aff_floor(pwaff);
1832 pwaff = isl_pw_aff_scale(pwaff, m);
1833 res = isl_pw_aff_sub(res, pwaff);
1834
1835 return res;
1836}
1837
1838/* Compute
1839 *
1840 * pa mod m = pa - m * floor(pa/m)
1841 *
1842 * with m an integer value.
1843 */
1846{
1847 if (!pa || !m)
1848 goto error;
1849 if (!isl_val_is_int(m))
1851 "expecting integer modulo", goto error);
1852 pa = isl_pw_aff_mod(pa, m->n);
1853 isl_val_free(m);
1854 return pa;
1855error:
1857 isl_val_free(m);
1858 return NULL;
1859}
1860
1861/* Given f, return ceil(f).
1862 * If f is an integer expression, then just return f.
1863 * Otherwise, let f be the expression
1864 *
1865 * e/m
1866 *
1867 * then return
1868 *
1869 * floor((e + m - 1)/m)
1870 *
1871 * As a special case, ceil(NaN) = NaN.
1872 */
1874{
1875 if (!aff)
1876 return NULL;
1877
1878 if (isl_aff_is_nan(aff))
1879 return aff;
1880 if (isl_int_is_one(aff->v->el[0]))
1881 return aff;
1882
1883 aff = isl_aff_cow(aff);
1884 if (!aff)
1885 return NULL;
1886 aff->v = isl_vec_cow(aff->v);
1887 if (!aff->v)
1888 return isl_aff_free(aff);
1889
1890 isl_int_add(aff->v->el[1], aff->v->el[1], aff->v->el[0]);
1891 isl_int_sub_ui(aff->v->el[1], aff->v->el[1], 1);
1893
1894 return aff;
1895}
1896
1897/* Apply the expansion computed by isl_merge_divs.
1898 * The expansion itself is given by "exp" while the resulting
1899 * list of divs is given by "div".
1900 */
1902 __isl_take isl_mat *div, int *exp)
1903{
1904 isl_size old_n_div;
1905 isl_size new_n_div;
1907
1908 aff = isl_aff_cow(aff);
1909
1911 old_n_div = isl_aff_domain_dim(aff, isl_dim_div);
1912 new_n_div = isl_mat_rows(div);
1913 if (offset < 0 || old_n_div < 0 || new_n_div < 0)
1914 goto error;
1915
1916 aff->v = isl_vec_expand(aff->v, 1 + offset, old_n_div, exp, new_n_div);
1917 aff->ls = isl_local_space_replace_divs(aff->ls, div);
1918 if (!aff->v || !aff->ls)
1919 return isl_aff_free(aff);
1920 return aff;
1921error:
1923 isl_mat_free(div);
1924 return NULL;
1925}
1926
1927/* Add two affine expressions that live in the same local space.
1928 */
1930 __isl_take isl_aff *aff2)
1931{
1932 isl_int gcd, f;
1933
1934 aff1 = isl_aff_cow(aff1);
1935 if (!aff1 || !aff2)
1936 goto error;
1937
1938 aff1->v = isl_vec_cow(aff1->v);
1939 if (!aff1->v)
1940 goto error;
1941
1943 isl_int_init(f);
1944 isl_int_gcd(gcd, aff1->v->el[0], aff2->v->el[0]);
1945 isl_int_divexact(f, aff2->v->el[0], gcd);
1946 isl_seq_scale(aff1->v->el + 1, aff1->v->el + 1, f, aff1->v->size - 1);
1947 isl_int_divexact(f, aff1->v->el[0], gcd);
1948 isl_seq_addmul(aff1->v->el + 1, f, aff2->v->el + 1, aff1->v->size - 1);
1949 isl_int_divexact(f, aff2->v->el[0], gcd);
1950 isl_int_mul(aff1->v->el[0], aff1->v->el[0], f);
1953
1954 isl_aff_free(aff2);
1955 aff1 = isl_aff_normalize(aff1);
1956 return aff1;
1957error:
1958 isl_aff_free(aff1);
1959 isl_aff_free(aff2);
1960 return NULL;
1961}
1962
1963/* Replace one of the arguments by a NaN and free the other one.
1964 */
1966 __isl_take isl_aff *aff2)
1967{
1968 isl_aff_free(aff2);
1969 return isl_aff_set_nan(aff1);
1970}
1971
1972/* Return the sum of "aff1" and "aff2".
1973 *
1974 * If either of the two is NaN, then the result is NaN.
1975 */
1977 __isl_take isl_aff *aff2)
1978{
1979 isl_ctx *ctx;
1980 int *exp1 = NULL;
1981 int *exp2 = NULL;
1982 isl_mat *div;
1983 isl_size n_div1, n_div2;
1984
1985 if (!aff1 || !aff2)
1986 goto error;
1987
1988 ctx = isl_aff_get_ctx(aff1);
1989 if (!isl_space_is_equal(aff1->ls->dim, aff2->ls->dim))
1991 "spaces don't match", goto error);
1992
1993 if (isl_aff_is_nan(aff1)) {
1994 isl_aff_free(aff2);
1995 return aff1;
1996 }
1997 if (isl_aff_is_nan(aff2)) {
1998 isl_aff_free(aff1);
1999 return aff2;
2000 }
2001
2002 n_div1 = isl_aff_dim(aff1, isl_dim_div);
2003 n_div2 = isl_aff_dim(aff2, isl_dim_div);
2004 if (n_div1 < 0 || n_div2 < 0)
2005 goto error;
2006 if (n_div1 == 0 && n_div2 == 0)
2007 return add_expanded(aff1, aff2);
2008
2009 exp1 = isl_alloc_array(ctx, int, n_div1);
2010 exp2 = isl_alloc_array(ctx, int, n_div2);
2011 if ((n_div1 && !exp1) || (n_div2 && !exp2))
2012 goto error;
2013
2014 div = isl_merge_divs(aff1->ls->div, aff2->ls->div, exp1, exp2);
2015 aff1 = isl_aff_expand_divs(aff1, isl_mat_copy(div), exp1);
2016 aff2 = isl_aff_expand_divs(aff2, div, exp2);
2017 free(exp1);
2018 free(exp2);
2019
2020 return add_expanded(aff1, aff2);
2021error:
2022 free(exp1);
2023 free(exp2);
2024 isl_aff_free(aff1);
2025 isl_aff_free(aff2);
2026 return NULL;
2027}
2028
2030 __isl_take isl_aff *aff2)
2031{
2032 return isl_aff_add(aff1, isl_aff_neg(aff2));
2033}
2034
2035/* Return the result of scaling "aff" by a factor of "f".
2036 *
2037 * As a special case, f * NaN = NaN.
2038 */
2040{
2041 isl_int gcd;
2042
2043 if (!aff)
2044 return NULL;
2045 if (isl_aff_is_nan(aff))
2046 return aff;
2047
2048 if (isl_int_is_one(f))
2049 return aff;
2050
2051 aff = isl_aff_cow(aff);
2052 if (!aff)
2053 return NULL;
2054 aff->v = isl_vec_cow(aff->v);
2055 if (!aff->v)
2056 return isl_aff_free(aff);
2057
2058 if (isl_int_is_pos(f) && isl_int_is_divisible_by(aff->v->el[0], f)) {
2059 isl_int_divexact(aff->v->el[0], aff->v->el[0], f);
2060 return aff;
2061 }
2062
2064 isl_int_gcd(gcd, aff->v->el[0], f);
2065 isl_int_divexact(aff->v->el[0], aff->v->el[0], gcd);
2067 isl_seq_scale(aff->v->el + 1, aff->v->el + 1, gcd, aff->v->size - 1);
2069
2070 return aff;
2071}
2072
2073/* Multiple "aff" by "v".
2074 */
2077{
2078 if (!aff || !v)
2079 goto error;
2080
2081 if (isl_val_is_one(v)) {
2082 isl_val_free(v);
2083 return aff;
2084 }
2085
2086 if (!isl_val_is_rat(v))
2088 "expecting rational factor", goto error);
2089
2090 aff = isl_aff_scale(aff, v->n);
2091 aff = isl_aff_scale_down(aff, v->d);
2092
2093 isl_val_free(v);
2094 return aff;
2095error:
2097 isl_val_free(v);
2098 return NULL;
2099}
2100
2101/* Return the result of scaling "aff" down by a factor of "f".
2102 *
2103 * As a special case, NaN/f = NaN.
2104 */
2106{
2107 isl_int gcd;
2108
2109 if (!aff)
2110 return NULL;
2111 if (isl_aff_is_nan(aff))
2112 return aff;
2113
2114 if (isl_int_is_one(f))
2115 return aff;
2116
2117 aff = isl_aff_cow(aff);
2118 if (!aff)
2119 return NULL;
2120
2121 if (isl_int_is_zero(f))
2123 "cannot scale down by zero", return isl_aff_free(aff));
2124
2125 aff->v = isl_vec_cow(aff->v);
2126 if (!aff->v)
2127 return isl_aff_free(aff);
2128
2130 isl_seq_gcd(aff->v->el + 1, aff->v->size - 1, &gcd);
2131 isl_int_gcd(gcd, gcd, f);
2132 isl_seq_scale_down(aff->v->el + 1, aff->v->el + 1, gcd, aff->v->size - 1);
2134 isl_int_mul(aff->v->el[0], aff->v->el[0], gcd);
2136
2137 return aff;
2138}
2139
2140/* Divide "aff" by "v".
2141 */
2144{
2145 if (!aff || !v)
2146 goto error;
2147
2148 if (isl_val_is_one(v)) {
2149 isl_val_free(v);
2150 return aff;
2151 }
2152
2153 if (!isl_val_is_rat(v))
2155 "expecting rational factor", goto error);
2156 if (!isl_val_is_pos(v))
2158 "factor needs to be positive", goto error);
2159
2160 aff = isl_aff_scale(aff, v->d);
2161 aff = isl_aff_scale_down(aff, v->n);
2162
2163 isl_val_free(v);
2164 return aff;
2165error:
2167 isl_val_free(v);
2168 return NULL;
2169}
2170
2172{
2173 isl_int v;
2174
2175 if (f == 1)
2176 return aff;
2177
2178 isl_int_init(v);
2179 isl_int_set_ui(v, f);
2181 isl_int_clear(v);
2182
2183 return aff;
2184}
2185
2187 enum isl_dim_type type, unsigned pos, const char *s)
2188{
2189 aff = isl_aff_cow(aff);
2190 if (!aff)
2191 return NULL;
2192 if (type == isl_dim_out)
2193 isl_die(aff->v->ctx, isl_error_invalid,
2194 "cannot set name of output/set dimension",
2195 return isl_aff_free(aff));
2196 if (type == isl_dim_in)
2197 type = isl_dim_set;
2199 if (!aff->ls)
2200 return isl_aff_free(aff);
2201
2202 return aff;
2203}
2204
2206 enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
2207{
2208 aff = isl_aff_cow(aff);
2209 if (!aff)
2210 goto error;
2211 if (type == isl_dim_out)
2212 isl_die(aff->v->ctx, isl_error_invalid,
2213 "cannot set name of output/set dimension",
2214 goto error);
2215 if (type == isl_dim_in)
2216 type = isl_dim_set;
2217 aff->ls = isl_local_space_set_dim_id(aff->ls, type, pos, id);
2218 if (!aff->ls)
2219 return isl_aff_free(aff);
2220
2221 return aff;
2222error:
2223 isl_id_free(id);
2225 return NULL;
2226}
2227
2228/* Replace the identifier of the input tuple of "aff" by "id".
2229 * type is currently required to be equal to isl_dim_in
2230 */
2233{
2234 aff = isl_aff_cow(aff);
2235 if (!aff)
2236 goto error;
2237 if (type != isl_dim_in)
2238 isl_die(aff->v->ctx, isl_error_invalid,
2239 "cannot only set id of input tuple", goto error);
2241 if (!aff->ls)
2242 return isl_aff_free(aff);
2243
2244 return aff;
2245error:
2246 isl_id_free(id);
2248 return NULL;
2249}
2250
2251/* Exploit the equalities in "eq" to simplify the affine expression
2252 * and the expressions of the integer divisions in the local space.
2253 * The integer divisions in this local space are assumed to appear
2254 * as regular dimensions in "eq".
2255 */
2258{
2259 int i, j;
2260 unsigned o_div;
2261 unsigned n_div;
2262
2263 if (!eq)
2264 goto error;
2265 if (eq->n_eq == 0) {
2267 return aff;
2268 }
2269
2270 aff = isl_aff_cow(aff);
2271 if (!aff)
2272 goto error;
2273
2275 isl_basic_set_copy(eq));
2276 aff->v = isl_vec_cow(aff->v);
2277 if (!aff->ls || !aff->v)
2278 goto error;
2279
2280 o_div = isl_basic_set_offset(eq, isl_dim_div);
2281 n_div = eq->n_div;
2282 for (i = 0; i < eq->n_eq; ++i) {
2283 j = isl_seq_last_non_zero(eq->eq[i], o_div + n_div);
2284 if (j < 0 || j == 0 || j >= o_div)
2285 continue;
2286
2287 isl_seq_elim(aff->v->el + 1, eq->eq[i], j, o_div,
2288 &aff->v->el[0]);
2289 }
2290
2293 return aff;
2294error:
2297 return NULL;
2298}
2299
2300/* Exploit the equalities in "eq" to simplify the affine expression
2301 * and the expressions of the integer divisions in the local space.
2302 */
2305{
2306 isl_size n_div;
2307
2309 if (n_div < 0)
2310 goto error;
2311 if (n_div > 0)
2312 eq = isl_basic_set_add_dims(eq, isl_dim_set, n_div);
2314error:
2317 return NULL;
2318}
2319
2320/* Look for equalities among the variables shared by context and aff
2321 * and the integer divisions of aff, if any.
2322 * The equalities are then used to eliminate coefficients and/or integer
2323 * divisions from aff.
2324 */
2337
2340{
2342 dom_context = isl_set_intersect_params(dom_context, context);
2343 return isl_aff_gist(aff, dom_context);
2344}
2345
2346/* Return a basic set containing those elements in the space
2347 * of aff where it is positive. "rational" should not be set.
2348 *
2349 * If "aff" is NaN, then it is not positive.
2350 */
2352 int rational, void *user)
2353{
2354 isl_constraint *ineq;
2355 isl_basic_set *bset;
2356 isl_val *c;
2357
2358 if (!aff)
2359 return NULL;
2360 if (isl_aff_is_nan(aff)) {
2363 return isl_basic_set_empty(space);
2364 }
2365 if (rational)
2367 "rational sets not supported", goto error);
2368
2371 c = isl_val_sub_ui(c, 1);
2372 ineq = isl_constraint_set_constant_val(ineq, c);
2373
2374 bset = isl_basic_set_from_constraint(ineq);
2375 bset = isl_basic_set_simplify(bset);
2376 return bset;
2377error:
2379 return NULL;
2380}
2381
2382/* Return a basic set containing those elements in the space
2383 * of aff where it is non-negative.
2384 * If "rational" is set, then return a rational basic set.
2385 *
2386 * If "aff" is NaN, then it is not non-negative (it's not negative either).
2387 */
2389 __isl_take isl_aff *aff, int rational, void *user)
2390{
2391 isl_constraint *ineq;
2392 isl_basic_set *bset;
2393
2394 if (!aff)
2395 return NULL;
2396 if (isl_aff_is_nan(aff)) {
2399 return isl_basic_set_empty(space);
2400 }
2401
2403
2404 bset = isl_basic_set_from_constraint(ineq);
2405 if (rational)
2406 bset = isl_basic_set_set_rational(bset);
2407 bset = isl_basic_set_simplify(bset);
2408 return bset;
2409}
2410
2411/* Return a basic set containing those elements in the space
2412 * of aff where it is non-negative.
2413 */
2418
2419/* Return a basic set containing those elements in the domain space
2420 * of "aff" where it is positive.
2421 */
2427
2428/* Return a basic set containing those elements in the domain space
2429 * of aff where it is negative.
2430 */
2436
2437/* Return a basic set containing those elements in the space
2438 * of aff where it is zero.
2439 * If "rational" is set, then return a rational basic set.
2440 *
2441 * If "aff" is NaN, then it is not zero.
2442 */
2444 int rational, void *user)
2445{
2446 isl_constraint *ineq;
2447 isl_basic_set *bset;
2448
2449 if (!aff)
2450 return NULL;
2451 if (isl_aff_is_nan(aff)) {
2454 return isl_basic_set_empty(space);
2455 }
2456
2457 ineq = isl_equality_from_aff(aff);
2458
2459 bset = isl_basic_set_from_constraint(ineq);
2460 if (rational)
2461 bset = isl_basic_set_set_rational(bset);
2462 bset = isl_basic_set_simplify(bset);
2463 return bset;
2464}
2465
2466/* Return a basic set containing those elements in the space
2467 * of aff where it is zero.
2468 */
2473
2474/* Return a basic set containing those elements in the shared space
2475 * of aff1 and aff2 where aff1 is greater than or equal to aff2.
2476 */
2478 __isl_take isl_aff *aff2)
2479{
2480 aff1 = isl_aff_sub(aff1, aff2);
2481
2482 return isl_aff_nonneg_basic_set(aff1);
2483}
2484
2485/* Return a basic set containing those elements in the shared domain space
2486 * of "aff1" and "aff2" where "aff1" is greater than "aff2".
2487 */
2489 __isl_take isl_aff *aff2)
2490{
2491 aff1 = isl_aff_sub(aff1, aff2);
2492
2493 return isl_aff_pos_basic_set(aff1);
2494}
2495
2496/* Return a set containing those elements in the shared space
2497 * of aff1 and aff2 where aff1 is greater than or equal to aff2.
2498 */
2504
2505/* Return a set containing those elements in the shared domain space
2506 * of aff1 and aff2 where aff1 is greater than aff2.
2507 *
2508 * If either of the two inputs is NaN, then the result is empty,
2509 * as comparisons with NaN always return false.
2510 */
2516
2517/* Return a basic set containing those elements in the shared space
2518 * of aff1 and aff2 where aff1 is smaller than or equal to aff2.
2519 */
2525
2526/* Return a basic set containing those elements in the shared domain space
2527 * of "aff1" and "aff2" where "aff1" is smaller than "aff2".
2528 */
2534
2535/* Return a set containing those elements in the shared space
2536 * of aff1 and aff2 where aff1 is smaller than or equal to aff2.
2537 */
2539 __isl_take isl_aff *aff2)
2540{
2541 return isl_aff_ge_set(aff2, aff1);
2542}
2543
2544/* Return a set containing those elements in the shared domain space
2545 * of "aff1" and "aff2" where "aff1" is smaller than "aff2".
2546 */
2552
2553/* Return a basic set containing those elements in the shared space
2554 * of aff1 and aff2 where aff1 and aff2 are equal.
2555 */
2557 __isl_take isl_aff *aff2)
2558{
2559 aff1 = isl_aff_sub(aff1, aff2);
2560
2561 return isl_aff_zero_basic_set(aff1);
2562}
2563
2564/* Return a set containing those elements in the shared space
2565 * of aff1 and aff2 where aff1 and aff2 are equal.
2566 */
2572
2573/* Return a set containing those elements in the shared domain space
2574 * of aff1 and aff2 where aff1 and aff2 are not equal.
2575 *
2576 * If either of the two inputs is NaN, then the result is empty,
2577 * as comparisons with NaN always return false.
2578 */
2580 __isl_take isl_aff *aff2)
2581{
2582 isl_set *set_lt, *set_gt;
2583
2584 set_lt = isl_aff_lt_set(isl_aff_copy(aff1),
2585 isl_aff_copy(aff2));
2586 set_gt = isl_aff_gt_set(aff1, aff2);
2587 return isl_set_union_disjoint(set_lt, set_gt);
2588}
2589
2591 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
2592{
2593 aff1 = isl_aff_add(aff1, aff2);
2594 aff1 = isl_aff_gist(aff1, isl_set_copy(dom));
2595 return aff1;
2596}
2597
2599{
2600 if (!aff)
2601 return isl_bool_error;
2602
2603 return isl_bool_false;
2604}
2605
2606#undef TYPE
2607#define TYPE isl_aff
2608static
2609#include "check_type_range_templ.c"
2610
2611/* Check whether the given affine expression has non-zero coefficient
2612 * for any dimension in the given range or if any of these dimensions
2613 * appear with non-zero coefficients in any of the integer divisions
2614 * involved in the affine expression.
2615 */
2617 enum isl_dim_type type, unsigned first, unsigned n)
2618{
2619 int i;
2620 int *active = NULL;
2621 isl_bool involves = isl_bool_false;
2622
2623 if (!aff)
2624 return isl_bool_error;
2625 if (n == 0)
2626 return isl_bool_false;
2627 if (isl_aff_check_range(aff, type, first, n) < 0)
2628 return isl_bool_error;
2629
2630 active = isl_local_space_get_active(aff->ls, aff->v->el + 2);
2631 if (!active)
2632 goto error;
2633
2634 first += isl_local_space_offset(aff->ls, type) - 1;
2635 for (i = 0; i < n; ++i)
2636 if (active[first + i]) {
2637 involves = isl_bool_true;
2638 break;
2639 }
2640
2641 free(active);
2642
2643 return involves;
2644error:
2645 free(active);
2646 return isl_bool_error;
2647}
2648
2649/* Does "aff" involve any local variables, i.e., integer divisions?
2650 */
2652{
2653 isl_size n;
2654
2656 if (n < 0)
2657 return isl_bool_error;
2658 return isl_bool_ok(n > 0);
2659}
2660
2662 enum isl_dim_type type, unsigned first, unsigned n)
2663{
2664 if (!aff)
2665 return NULL;
2666 if (type == isl_dim_out)
2668 "cannot drop output/set dimension",
2669 return isl_aff_free(aff));
2670 if (type == isl_dim_in)
2671 type = isl_dim_set;
2672 if (n == 0 && !isl_local_space_is_named_or_nested(aff->ls, type))
2673 return aff;
2674
2675 if (isl_local_space_check_range(aff->ls, type, first, n) < 0)
2676 return isl_aff_free(aff);
2677
2678 aff = isl_aff_cow(aff);
2679 if (!aff)
2680 return NULL;
2681
2682 aff->ls = isl_local_space_drop_dims(aff->ls, type, first, n);
2683 if (!aff->ls)
2684 return isl_aff_free(aff);
2685
2686 first += 1 + isl_local_space_offset(aff->ls, type);
2687 aff->v = isl_vec_drop_els(aff->v, first, n);
2688 if (!aff->v)
2689 return isl_aff_free(aff);
2690
2691 return aff;
2692}
2693
2694/* Is the domain of "aff" a product?
2695 */
2700
2701#undef TYPE
2702#define TYPE isl_aff
2704
2705/* Project the domain of the affine expression onto its parameter space.
2706 * The affine expression may not involve any of the domain dimensions.
2707 */
2709{
2710 isl_space *space;
2711 isl_size n;
2712
2714 if (n < 0)
2715 return isl_aff_free(aff);
2716 aff = isl_aff_drop_domain(aff, 0, n);
2718 space = isl_space_params(space);
2720 return aff;
2721}
2722
2723/* Convert an affine expression defined over a parameter domain
2724 * into one that is defined over a zero-dimensional set.
2725 */
2736
2738 enum isl_dim_type type, unsigned first, unsigned n)
2739{
2740 if (!aff)
2741 return NULL;
2742 if (type == isl_dim_out)
2744 "cannot insert output/set dimensions",
2745 return isl_aff_free(aff));
2746 if (type == isl_dim_in)
2747 type = isl_dim_set;
2748 if (n == 0 && !isl_local_space_is_named_or_nested(aff->ls, type))
2749 return aff;
2750
2751 if (isl_local_space_check_range(aff->ls, type, first, 0) < 0)
2752 return isl_aff_free(aff);
2753
2754 aff = isl_aff_cow(aff);
2755 if (!aff)
2756 return NULL;
2757
2758 aff->ls = isl_local_space_insert_dims(aff->ls, type, first, n);
2759 if (!aff->ls)
2760 return isl_aff_free(aff);
2761
2762 first += 1 + isl_local_space_offset(aff->ls, type);
2763 aff->v = isl_vec_insert_zero_els(aff->v, first, n);
2764 if (!aff->v)
2765 return isl_aff_free(aff);
2766
2767 return aff;
2768}
2769
2771 enum isl_dim_type type, unsigned n)
2772{
2773 isl_size pos;
2774
2775 pos = isl_aff_dim(aff, type);
2776 if (pos < 0)
2777 return isl_aff_free(aff);
2778
2779 return isl_aff_insert_dims(aff, type, pos, n);
2780}
2781
2782/* Move the "n" dimensions of "src_type" starting at "src_pos" of "aff"
2783 * to dimensions of "dst_type" at "dst_pos".
2784 *
2785 * We only support moving input dimensions to parameters and vice versa.
2786 */
2788 enum isl_dim_type dst_type, unsigned dst_pos,
2789 enum isl_dim_type src_type, unsigned src_pos, unsigned n)
2790{
2791 unsigned g_dst_pos;
2792 unsigned g_src_pos;
2793 isl_size src_off, dst_off;
2794
2795 if (!aff)
2796 return NULL;
2797 if (n == 0 &&
2798 !isl_local_space_is_named_or_nested(aff->ls, src_type) &&
2800 return aff;
2801
2802 if (dst_type == isl_dim_out || src_type == isl_dim_out)
2804 "cannot move output/set dimension",
2805 return isl_aff_free(aff));
2806 if (dst_type == isl_dim_div || src_type == isl_dim_div)
2808 "cannot move divs", return isl_aff_free(aff));
2809 if (dst_type == isl_dim_in)
2810 dst_type = isl_dim_set;
2811 if (src_type == isl_dim_in)
2812 src_type = isl_dim_set;
2813
2814 if (isl_local_space_check_range(aff->ls, src_type, src_pos, n) < 0)
2815 return isl_aff_free(aff);
2816 if (dst_type == src_type)
2818 "moving dims within the same type not supported",
2819 return isl_aff_free(aff));
2820
2821 aff = isl_aff_cow(aff);
2822 src_off = isl_aff_domain_offset(aff, src_type);
2823 dst_off = isl_aff_domain_offset(aff, dst_type);
2824 if (src_off < 0 || dst_off < 0)
2825 return isl_aff_free(aff);
2826
2827 g_src_pos = 1 + src_off + src_pos;
2828 g_dst_pos = 1 + dst_off + dst_pos;
2829 if (dst_type > src_type)
2830 g_dst_pos -= n;
2831
2832 aff->v = isl_vec_move_els(aff->v, g_dst_pos, g_src_pos, n);
2833 aff->ls = isl_local_space_move_dims(aff->ls, dst_type, dst_pos,
2834 src_type, src_pos, n);
2835 if (!aff->v || !aff->ls)
2836 return isl_aff_free(aff);
2837
2838 aff = sort_divs(aff);
2839
2840 return aff;
2841}
2842
2843/* Given an affine function on a domain (A -> B),
2844 * interchange A and B in the wrapped domain
2845 * to obtain a function on the domain (B -> A).
2846 *
2847 * Since this may change the position of some variables,
2848 * it may also change the normalized order of the local variables.
2849 * Restore this order. Since sort_divs assumes the input
2850 * has a single reference, an explicit isl_aff_cow is required.
2851 */
2853{
2854 isl_space *space;
2855 isl_local_space *ls;
2856 isl_vec *v;
2857 isl_size n_in, n_out;
2858 unsigned offset;
2859
2864 if (offset < 0 || n_in < 0 || n_out < 0)
2865 return isl_aff_free(aff);
2866
2868 v = isl_vec_move_els(v, 1 + 1 + offset, 1 + 1 + offset + n_in, n_out);
2870
2874
2875 aff = isl_aff_cow(aff);
2876 aff = sort_divs(aff);
2877
2878 return aff;
2879}
2880
2881/* Return a zero isl_aff in the given space.
2882 *
2883 * This is a helper function for isl_pw_*_as_* that ensures a uniform
2884 * interface over all piecewise types.
2885 */
2893
2894#define isl_aff_involves_nan isl_aff_is_nan
2895
2896#undef PW
2897#define PW isl_pw_aff
2898#undef BASE
2899#define BASE aff
2900#undef EL_IS_ZERO
2901#define EL_IS_ZERO is_empty
2902#undef ZERO
2903#define ZERO empty
2904#undef IS_ZERO
2905#define IS_ZERO is_empty
2906#undef FIELD
2907#define FIELD aff
2908#undef DEFAULT_IS_ZERO
2909#define DEFAULT_IS_ZERO 0
2910
2911#include <isl_pw_templ.c>
2912#include <isl_pw_un_op_templ.c>
2917#include <isl_pw_eval.c>
2918#include <isl_pw_hash.c>
2919#include <isl_pw_fix_templ.c>
2923#include <isl_pw_move_dims_templ.c>
2924#include <isl_pw_neg_templ.c>
2925#include <isl_pw_pullback_templ.c>
2926#include <isl_pw_scale_templ.c>
2927#include <isl_pw_sub_templ.c>
2928#include <isl_pw_union_opt.c>
2929
2930#undef BASE
2931#define BASE pw_aff
2932
2933#include <isl_union_single.c>
2934#include <isl_union_neg.c>
2935#include <isl_union_sub_templ.c>
2936
2937#undef BASE
2938#define BASE aff
2939
2940#include <isl_union_pw_templ.c>
2941
2942/* Compute a piecewise quasi-affine expression with a domain that
2943 * is the union of those of pwaff1 and pwaff2 and such that on each
2944 * cell, the quasi-affine expression is the maximum of those of pwaff1
2945 * and pwaff2. If only one of pwaff1 or pwaff2 is defined on a given
2946 * cell, then the associated expression is the defined one.
2947 */
2949 __isl_take isl_pw_aff *pwaff2)
2950{
2951 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
2952 return isl_pw_aff_union_opt_cmp(pwaff1, pwaff2, &isl_aff_ge_set);
2953}
2954
2955/* Compute a piecewise quasi-affine expression with a domain that
2956 * is the union of those of pwaff1 and pwaff2 and such that on each
2957 * cell, the quasi-affine expression is the minimum of those of pwaff1
2958 * and pwaff2. If only one of pwaff1 or pwaff2 is defined on a given
2959 * cell, then the associated expression is the defined one.
2960 */
2962 __isl_take isl_pw_aff *pwaff2)
2963{
2964 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
2965 return isl_pw_aff_union_opt_cmp(pwaff1, pwaff2, &isl_aff_le_set);
2966}
2967
2969 __isl_take isl_pw_aff *pwaff2, int max)
2970{
2971 if (max)
2972 return isl_pw_aff_union_max(pwaff1, pwaff2);
2973 else
2974 return isl_pw_aff_union_min(pwaff1, pwaff2);
2975}
2976
2977/* Is the domain of "pa" a product?
2978 */
2980{
2981 return isl_space_domain_is_wrapping(isl_pw_aff_peek_space(pa));
2982}
2983
2984#undef TYPE
2985#define TYPE isl_pw_aff
2987
2988/* Return a set containing those elements in the domain
2989 * of "pwaff" where it satisfies "fn" (if complement is 0) or
2990 * does not satisfy "fn" (if complement is 1).
2991 *
2992 * The pieces with a NaN never belong to the result since
2993 * NaN does not satisfy any property.
2994 */
2996 __isl_give isl_basic_set *(*fn)(__isl_take isl_aff *aff, int rational,
2997 void *user),
2998 int complement, void *user)
2999{
3000 int i;
3001 isl_set *set;
3002
3003 if (!pwaff)
3004 return NULL;
3005
3007
3008 for (i = 0; i < pwaff->n; ++i) {
3009 isl_basic_set *bset;
3010 isl_set *set_i, *locus;
3011 isl_bool rational;
3012
3013 if (isl_aff_is_nan(pwaff->p[i].aff))
3014 continue;
3015
3016 rational = isl_set_has_rational(pwaff->p[i].set);
3017 bset = fn(isl_aff_copy(pwaff->p[i].aff), rational, user);
3018 locus = isl_set_from_basic_set(bset);
3019 set_i = isl_set_copy(pwaff->p[i].set);
3020 if (complement)
3021 set_i = isl_set_subtract(set_i, locus);
3022 else
3023 set_i = isl_set_intersect(set_i, locus);
3024 set = isl_set_union_disjoint(set, set_i);
3025 }
3026
3027 isl_pw_aff_free(pwaff);
3028
3029 return set;
3030}
3031
3032/* Return a set containing those elements in the domain
3033 * of "pa" where it is positive.
3034 */
3039
3040/* Return a set containing those elements in the domain
3041 * of pwaff where it is non-negative.
3042 */
3047
3048/* Return a set containing those elements in the domain
3049 * of pwaff where it is zero.
3050 */
3055
3056/* Return a set containing those elements in the domain
3057 * of pwaff where it is not zero.
3058 */
3063
3064/* Bind the affine function "aff" to the parameter "id",
3065 * returning the elements in the domain where the affine expression
3066 * is equal to the parameter.
3067 */
3069 __isl_take isl_id *id)
3070{
3071 isl_space *space;
3072 isl_aff *aff_id;
3073
3075 space = isl_space_add_param_id(space, isl_id_copy(id));
3076
3078 aff_id = isl_aff_param_on_domain_space_id(space, id);
3079
3080 return isl_aff_eq_basic_set(aff, aff_id);
3081}
3082
3083/* Wrapper around isl_aff_bind_id for use as pw_aff_locus callback.
3084 * "rational" should not be set.
3085 */
3087 int rational, void *user)
3088{
3089 isl_id *id = user;
3090
3091 if (!aff)
3092 return NULL;
3093 if (rational)
3095 "rational binding not supported", goto error);
3096 return isl_aff_bind_id(aff, isl_id_copy(id));
3097error:
3099 return NULL;
3100}
3101
3102/* Bind the piecewise affine function "pa" to the parameter "id",
3103 * returning the elements in the domain where the expression
3104 * is equal to the parameter.
3105 */
3107 __isl_take isl_id *id)
3108{
3109 isl_set *bound;
3110
3111 bound = pw_aff_locus(pa, &aff_bind_id, 0, id);
3112 isl_id_free(id);
3113
3114 return bound;
3115}
3116
3117/* Return a set containing those elements in the shared domain
3118 * of pwaff1 and pwaff2 where pwaff1 is greater than (or equal) to pwaff2.
3119 *
3120 * We compute the difference on the shared domain and then construct
3121 * the set of values where this difference is non-negative.
3122 * If strict is set, we first subtract 1 from the difference.
3123 * If equal is set, we only return the elements where pwaff1 and pwaff2
3124 * are equal.
3125 */
3127 __isl_take isl_pw_aff *pwaff2, int strict, int equal)
3128{
3129 isl_set *set1, *set2;
3130
3136 pwaff1 = isl_pw_aff_add(pwaff1, isl_pw_aff_neg(pwaff2));
3137
3138 if (strict) {
3140 isl_aff *aff;
3143 pwaff1 = isl_pw_aff_add(pwaff1, isl_pw_aff_alloc(set1, aff));
3144 } else
3146
3147 if (equal)
3148 return isl_pw_aff_zero_set(pwaff1);
3149 return isl_pw_aff_nonneg_set(pwaff1);
3150}
3151
3152/* Return a set containing those elements in the shared domain
3153 * of pwaff1 and pwaff2 where pwaff1 is equal to pwaff2.
3154 */
3156 __isl_take isl_pw_aff *pwaff2)
3157{
3158 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3159 return pw_aff_gte_set(pwaff1, pwaff2, 0, 1);
3160}
3161
3162/* Return a set containing those elements in the shared domain
3163 * of pwaff1 and pwaff2 where pwaff1 is greater than or equal to pwaff2.
3164 */
3166 __isl_take isl_pw_aff *pwaff2)
3167{
3168 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3169 return pw_aff_gte_set(pwaff1, pwaff2, 0, 0);
3170}
3171
3172/* Return a set containing those elements in the shared domain
3173 * of pwaff1 and pwaff2 where pwaff1 is strictly greater than pwaff2.
3174 */
3176 __isl_take isl_pw_aff *pwaff2)
3177{
3178 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3179 return pw_aff_gte_set(pwaff1, pwaff2, 1, 0);
3180}
3181
3183 __isl_take isl_pw_aff *pwaff2)
3184{
3185 return isl_pw_aff_ge_set(pwaff2, pwaff1);
3186}
3187
3189 __isl_take isl_pw_aff *pwaff2)
3190{
3191 return isl_pw_aff_gt_set(pwaff2, pwaff1);
3192}
3193
3194/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3195 * where the function values are ordered in the same way as "order",
3196 * which returns a set in the shared domain of its two arguments.
3197 *
3198 * Let "pa1" and "pa2" be defined on domains A and B respectively.
3199 * We first pull back the two functions such that they are defined on
3200 * the domain [A -> B]. Then we apply "order", resulting in a set
3201 * in the space [A -> B]. Finally, we unwrap this set to obtain
3202 * a map in the space A -> B.
3203 */
3206 __isl_give isl_set *(*order)(__isl_take isl_pw_aff *pa1,
3207 __isl_take isl_pw_aff *pa2))
3208{
3209 isl_space *space1, *space2;
3211 isl_set *set;
3212
3213 isl_pw_aff_align_params_bin(&pa1, &pa2);
3216 space1 = isl_space_map_from_domain_and_range(space1, space2);
3219 ma = isl_multi_aff_range_map(space1);
3221 set = order(pa1, pa2);
3222
3223 return isl_set_unwrap(set);
3224}
3225
3226/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3227 * where the function values are equal.
3228 */
3234
3235/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3236 * where the function value of "pa1" is less than or equal to
3237 * the function value of "pa2".
3238 */
3244
3245/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3246 * where the function value of "pa1" is less than the function value of "pa2".
3247 */
3253
3254/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3255 * where the function value of "pa1" is greater than or equal to
3256 * the function value of "pa2".
3257 */
3263
3264/* Return a map containing pairs of elements in the domains of "pa1" and "pa2"
3265 * where the function value of "pa1" is greater than the function value
3266 * of "pa2".
3267 */
3273
3274/* Return a set containing those elements in the shared domain
3275 * of the elements of list1 and list2 where each element in list1
3276 * has the relation specified by "fn" with each element in list2.
3277 */
3278static __isl_give isl_set *pw_aff_list_set(__isl_take isl_pw_aff_list *list1,
3279 __isl_take isl_pw_aff_list *list2,
3281 __isl_take isl_pw_aff *pwaff2))
3282{
3283 int i, j;
3284 isl_ctx *ctx;
3285 isl_set *set;
3286
3287 if (!list1 || !list2)
3288 goto error;
3289
3290 ctx = isl_pw_aff_list_get_ctx(list1);
3291 if (list1->n < 1 || list2->n < 1)
3293 "list should contain at least one element", goto error);
3294
3296 for (i = 0; i < list1->n; ++i)
3297 for (j = 0; j < list2->n; ++j) {
3298 isl_set *set_ij;
3299
3300 set_ij = fn(isl_pw_aff_copy(list1->p[i]),
3301 isl_pw_aff_copy(list2->p[j]));
3302 set = isl_set_intersect(set, set_ij);
3303 }
3304
3305 isl_pw_aff_list_free(list1);
3306 isl_pw_aff_list_free(list2);
3307 return set;
3308error:
3309 isl_pw_aff_list_free(list1);
3310 isl_pw_aff_list_free(list2);
3311 return NULL;
3312}
3313
3314/* Return a set containing those elements in the shared domain
3315 * of the elements of list1 and list2 where each element in list1
3316 * is equal to each element in list2.
3317 */
3319 __isl_take isl_pw_aff_list *list2)
3320{
3321 return pw_aff_list_set(list1, list2, &isl_pw_aff_eq_set);
3322}
3323
3325 __isl_take isl_pw_aff_list *list2)
3326{
3327 return pw_aff_list_set(list1, list2, &isl_pw_aff_ne_set);
3328}
3329
3330/* Return a set containing those elements in the shared domain
3331 * of the elements of list1 and list2 where each element in list1
3332 * is less than or equal to each element in list2.
3333 */
3335 __isl_take isl_pw_aff_list *list2)
3336{
3337 return pw_aff_list_set(list1, list2, &isl_pw_aff_le_set);
3338}
3339
3341 __isl_take isl_pw_aff_list *list2)
3342{
3343 return pw_aff_list_set(list1, list2, &isl_pw_aff_lt_set);
3344}
3345
3347 __isl_take isl_pw_aff_list *list2)
3348{
3349 return pw_aff_list_set(list1, list2, &isl_pw_aff_ge_set);
3350}
3351
3353 __isl_take isl_pw_aff_list *list2)
3354{
3355 return pw_aff_list_set(list1, list2, &isl_pw_aff_gt_set);
3356}
3357
3358
3359/* Return a set containing those elements in the shared domain
3360 * of pwaff1 and pwaff2 where pwaff1 is not equal to pwaff2.
3361 */
3363 __isl_take isl_pw_aff *pwaff2)
3364{
3365 isl_set *set_lt, *set_gt;
3366
3367 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3368 set_lt = isl_pw_aff_lt_set(isl_pw_aff_copy(pwaff1),
3369 isl_pw_aff_copy(pwaff2));
3370 set_gt = isl_pw_aff_gt_set(pwaff1, pwaff2);
3371 return isl_set_union_disjoint(set_lt, set_gt);
3372}
3373
3375 isl_int v)
3376{
3377 int i;
3378
3379 if (isl_int_is_one(v))
3380 return pwaff;
3381 if (!isl_int_is_pos(v))
3383 "factor needs to be positive",
3384 return isl_pw_aff_free(pwaff));
3385 pwaff = isl_pw_aff_cow(pwaff);
3386 if (!pwaff)
3387 return NULL;
3388 if (pwaff->n == 0)
3389 return pwaff;
3390
3391 for (i = 0; i < pwaff->n; ++i) {
3392 pwaff->p[i].aff = isl_aff_scale_down(pwaff->p[i].aff, v);
3393 if (!pwaff->p[i].aff)
3394 return isl_pw_aff_free(pwaff);
3395 }
3396
3397 return pwaff;
3398}
3399
3401{
3402 struct isl_pw_aff_un_op_control control = { .fn_base = &isl_aff_floor };
3403 return isl_pw_aff_un_op(pwaff, &control);
3404}
3405
3407{
3408 struct isl_pw_aff_un_op_control control = { .fn_base = &isl_aff_ceil };
3409 return isl_pw_aff_un_op(pwaff, &control);
3410}
3411
3412/* Assuming that "cond1" and "cond2" are disjoint,
3413 * return an affine expression that is equal to pwaff1 on cond1
3414 * and to pwaff2 on cond2.
3415 */
3417 __isl_take isl_set *cond1, __isl_take isl_pw_aff *pwaff1,
3418 __isl_take isl_set *cond2, __isl_take isl_pw_aff *pwaff2)
3419{
3420 pwaff1 = isl_pw_aff_intersect_domain(pwaff1, cond1);
3421 pwaff2 = isl_pw_aff_intersect_domain(pwaff2, cond2);
3422
3423 return isl_pw_aff_add_disjoint(pwaff1, pwaff2);
3424}
3425
3426/* Return an affine expression that is equal to pwaff_true for elements
3427 * where "cond" is non-zero and to pwaff_false for elements where "cond"
3428 * is zero.
3429 * That is, return cond ? pwaff_true : pwaff_false;
3430 *
3431 * If "cond" involves and NaN, then we conservatively return a NaN
3432 * on its entire domain. In principle, we could consider the pieces
3433 * where it is NaN separately from those where it is not.
3434 *
3435 * If "pwaff_true" and "pwaff_false" are obviously equal to each other,
3436 * then only use the domain of "cond" to restrict the domain.
3437 */
3439 __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false)
3440{
3441 isl_set *cond_true, *cond_false;
3443
3444 if (!cond)
3445 goto error;
3446 if (isl_pw_aff_involves_nan(cond)) {
3449 isl_pw_aff_free(cond);
3450 isl_pw_aff_free(pwaff_true);
3451 isl_pw_aff_free(pwaff_false);
3452 return isl_pw_aff_nan_on_domain(ls);
3453 }
3454
3455 pwaff_true = isl_pw_aff_align_params(pwaff_true,
3456 isl_pw_aff_get_space(pwaff_false));
3457 pwaff_false = isl_pw_aff_align_params(pwaff_false,
3458 isl_pw_aff_get_space(pwaff_true));
3459 equal = isl_pw_aff_plain_is_equal(pwaff_true, pwaff_false);
3460 if (equal < 0)
3461 goto error;
3462 if (equal) {
3463 isl_set *dom;
3464
3466 isl_pw_aff_free(pwaff_false);
3467 return isl_pw_aff_intersect_domain(pwaff_true, dom);
3468 }
3469
3470 cond_true = isl_pw_aff_non_zero_set(isl_pw_aff_copy(cond));
3471 cond_false = isl_pw_aff_zero_set(cond);
3472 return isl_pw_aff_select(cond_true, pwaff_true,
3473 cond_false, pwaff_false);
3474error:
3475 isl_pw_aff_free(cond);
3476 isl_pw_aff_free(pwaff_true);
3477 isl_pw_aff_free(pwaff_false);
3478 return NULL;
3479}
3480
3482{
3483 int pos;
3484
3485 if (!aff)
3486 return isl_bool_error;
3487
3488 pos = isl_seq_first_non_zero(aff->v->el + 2, aff->v->size - 2);
3489 return isl_bool_ok(pos == -1);
3490}
3491
3492/* Check whether pwaff is a piecewise constant.
3493 */
3495{
3496 int i;
3497
3498 if (!pwaff)
3499 return isl_bool_error;
3500
3501 for (i = 0; i < pwaff->n; ++i) {
3502 isl_bool is_cst = isl_aff_is_cst(pwaff->p[i].aff);
3503 if (is_cst < 0 || !is_cst)
3504 return is_cst;
3505 }
3506
3507 return isl_bool_true;
3508}
3509
3510/* Return the product of "aff1" and "aff2".
3511 *
3512 * If either of the two is NaN, then the result is NaN.
3513 *
3514 * Otherwise, at least one of "aff1" or "aff2" needs to be a constant.
3515 */
3517 __isl_take isl_aff *aff2)
3518{
3519 if (!aff1 || !aff2)
3520 goto error;
3521
3522 if (isl_aff_is_nan(aff1)) {
3523 isl_aff_free(aff2);
3524 return aff1;
3525 }
3526 if (isl_aff_is_nan(aff2)) {
3527 isl_aff_free(aff1);
3528 return aff2;
3529 }
3530
3531 if (!isl_aff_is_cst(aff2) && isl_aff_is_cst(aff1))
3532 return isl_aff_mul(aff2, aff1);
3533
3534 if (!isl_aff_is_cst(aff2))
3536 "at least one affine expression should be constant",
3537 goto error);
3538
3539 aff1 = isl_aff_cow(aff1);
3540 if (!aff1 || !aff2)
3541 goto error;
3542
3543 aff1 = isl_aff_scale(aff1, aff2->v->el[1]);
3544 aff1 = isl_aff_scale_down(aff1, aff2->v->el[0]);
3545
3546 isl_aff_free(aff2);
3547 return aff1;
3548error:
3549 isl_aff_free(aff1);
3550 isl_aff_free(aff2);
3551 return NULL;
3552}
3553
3554/* Divide "aff1" by "aff2", assuming "aff2" is a constant.
3555 *
3556 * If either of the two is NaN, then the result is NaN.
3557 * A division by zero also results in NaN.
3558 */
3560 __isl_take isl_aff *aff2)
3561{
3562 isl_bool is_cst, is_zero;
3563 int neg;
3564
3565 if (!aff1 || !aff2)
3566 goto error;
3567
3568 if (isl_aff_is_nan(aff1)) {
3569 isl_aff_free(aff2);
3570 return aff1;
3571 }
3572 if (isl_aff_is_nan(aff2)) {
3573 isl_aff_free(aff1);
3574 return aff2;
3575 }
3576
3577 is_cst = isl_aff_is_cst(aff2);
3578 if (is_cst < 0)
3579 goto error;
3580 if (!is_cst)
3582 "second argument should be a constant", goto error);
3583 is_zero = isl_aff_plain_is_zero(aff2);
3584 if (is_zero < 0)
3585 goto error;
3586 if (is_zero)
3587 return set_nan_free(aff1, aff2);
3588
3589 neg = isl_int_is_neg(aff2->v->el[1]);
3590 if (neg) {
3591 isl_int_neg(aff2->v->el[0], aff2->v->el[0]);
3592 isl_int_neg(aff2->v->el[1], aff2->v->el[1]);
3593 }
3594
3595 aff1 = isl_aff_scale(aff1, aff2->v->el[0]);
3596 aff1 = isl_aff_scale_down(aff1, aff2->v->el[1]);
3597
3598 if (neg) {
3599 isl_int_neg(aff2->v->el[0], aff2->v->el[0]);
3600 isl_int_neg(aff2->v->el[1], aff2->v->el[1]);
3601 }
3602
3603 isl_aff_free(aff2);
3604 return aff1;
3605error:
3606 isl_aff_free(aff1);
3607 isl_aff_free(aff2);
3608 return NULL;
3609}
3610
3612 __isl_take isl_pw_aff *pwaff2)
3613{
3614 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3615 return isl_pw_aff_on_shared_domain(pwaff1, pwaff2, &isl_aff_add);
3616}
3617
3619 __isl_take isl_pw_aff *pwaff2)
3620{
3621 isl_pw_aff_align_params_bin(&pwaff1, &pwaff2);
3622 return isl_pw_aff_on_shared_domain(pwaff1, pwaff2, &isl_aff_mul);
3623}
3624
3625/* Divide "pa1" by "pa2", assuming "pa2" is a piecewise constant.
3626 */
3629{
3630 int is_cst;
3631
3632 is_cst = isl_pw_aff_is_cst(pa2);
3633 if (is_cst < 0)
3634 goto error;
3635 if (!is_cst)
3637 "second argument should be a piecewise constant",
3638 goto error);
3639 isl_pw_aff_align_params_bin(&pa1, &pa2);
3640 return isl_pw_aff_on_shared_domain(pa1, pa2, &isl_aff_div);
3641error:
3642 isl_pw_aff_free(pa1);
3643 isl_pw_aff_free(pa2);
3644 return NULL;
3645}
3646
3647/* Compute the quotient of the integer division of "pa1" by "pa2"
3648 * with rounding towards zero.
3649 * "pa2" is assumed to be a piecewise constant.
3650 *
3651 * In particular, return
3652 *
3653 * pa1 >= 0 ? floor(pa1/pa2) : ceil(pa1/pa2)
3654 *
3655 */
3658{
3659 int is_cst;
3660 isl_set *cond;
3661 isl_pw_aff *f, *c;
3662
3663 is_cst = isl_pw_aff_is_cst(pa2);
3664 if (is_cst < 0)
3665 goto error;
3666 if (!is_cst)
3668 "second argument should be a piecewise constant",
3669 goto error);
3670
3671 pa1 = isl_pw_aff_div(pa1, pa2);
3672
3675 c = isl_pw_aff_ceil(pa1);
3677error:
3678 isl_pw_aff_free(pa1);
3679 isl_pw_aff_free(pa2);
3680 return NULL;
3681}
3682
3683/* Compute the remainder of the integer division of "pa1" by "pa2"
3684 * with rounding towards zero.
3685 * "pa2" is assumed to be a piecewise constant.
3686 *
3687 * In particular, return
3688 *
3689 * pa1 - pa2 * (pa1 >= 0 ? floor(pa1/pa2) : ceil(pa1/pa2))
3690 *
3691 */
3694{
3695 int is_cst;
3696 isl_pw_aff *res;
3697
3698 is_cst = isl_pw_aff_is_cst(pa2);
3699 if (is_cst < 0)
3700 goto error;
3701 if (!is_cst)
3703 "second argument should be a piecewise constant",
3704 goto error);
3706 res = isl_pw_aff_mul(pa2, res);
3707 res = isl_pw_aff_sub(pa1, res);
3708 return res;
3709error:
3710 isl_pw_aff_free(pa1);
3711 isl_pw_aff_free(pa2);
3712 return NULL;
3713}
3714
3715/* Does either of "pa1" or "pa2" involve any NaN?
3716 */
3719{
3720 isl_bool has_nan;
3721
3722 has_nan = isl_pw_aff_involves_nan(pa1);
3723 if (has_nan < 0 || has_nan)
3724 return has_nan;
3725 return isl_pw_aff_involves_nan(pa2);
3726}
3727
3728/* Return a piecewise affine expression defined on the specified domain
3729 * that represents NaN.
3730 */
3742
3743/* Replace "pa1" and "pa2" (at least one of which involves a NaN)
3744 * by a NaN on their shared domain.
3745 *
3746 * In principle, the result could be refined to only being NaN
3747 * on the parts of this domain where at least one of "pa1" or "pa2" is NaN.
3748 */
3751{
3752 isl_set *dom;
3753
3755 return nan_on_domain_set(dom);
3756}
3757
3759 __isl_take isl_pw_aff *pwaff2)
3760{
3761 isl_set *le;
3762 isl_set *dom;
3763
3767 isl_pw_aff_copy(pwaff2));
3768 dom = isl_set_subtract(dom, isl_set_copy(le));
3769 return isl_pw_aff_select(le, pwaff1, dom, pwaff2);
3770}
3771
3773 __isl_take isl_pw_aff *pwaff2)
3774{
3775 isl_set *ge;
3776 isl_set *dom;
3777
3781 isl_pw_aff_copy(pwaff2));
3782 dom = isl_set_subtract(dom, isl_set_copy(ge));
3783 return isl_pw_aff_select(ge, pwaff1, dom, pwaff2);
3784}
3785
3786/* Return an expression for the minimum (if "max" is not set) or
3787 * the maximum (if "max" is set) of "pa1" and "pa2".
3788 * If either expression involves any NaN, then return a NaN
3789 * on the shared domain as result.
3790 */
3792 __isl_take isl_pw_aff *pa2, int max)
3793{
3794 isl_bool has_nan;
3795
3796 has_nan = either_involves_nan(pa1, pa2);
3797 if (has_nan < 0)
3798 pa1 = isl_pw_aff_free(pa1);
3799 else if (has_nan)
3800 return replace_by_nan(pa1, pa2);
3801
3802 isl_pw_aff_align_params_bin(&pa1, &pa2);
3803 if (max)
3804 return pw_aff_max(pa1, pa2);
3805 else
3806 return pw_aff_min(pa1, pa2);
3807}
3808
3809/* Return an expression for the minimum of "pwaff1" and "pwaff2".
3810 */
3812 __isl_take isl_pw_aff *pwaff2)
3813{
3814 return pw_aff_min_max(pwaff1, pwaff2, 0);
3815}
3816
3817/* Return an expression for the maximum of "pwaff1" and "pwaff2".
3818 */
3820 __isl_take isl_pw_aff *pwaff2)
3821{
3822 return pw_aff_min_max(pwaff1, pwaff2, 1);
3823}
3824
3825/* Does "pa" not involve any NaN?
3826 */
3831
3832/* Does any element of "list" involve any NaN?
3833 *
3834 * That is, is it not the case that every element does not involve any NaN?
3835 */
3837{
3838 return isl_bool_not(isl_pw_aff_list_every(list, &pw_aff_no_nan, NULL));
3839}
3840
3841/* Replace "list" (consisting of "n" elements, of which
3842 * at least one element involves a NaN)
3843 * by a NaN on the shared domain of the elements.
3844 *
3845 * In principle, the result could be refined to only being NaN
3846 * on the parts of this domain where at least one of the elements is NaN.
3847 */
3849 __isl_take isl_pw_aff_list *list, int n)
3850{
3851 int i;
3852 isl_set *dom;
3853
3854 dom = isl_pw_aff_domain(isl_pw_aff_list_get_at(list, 0));
3855 for (i = 1; i < n; ++i) {
3856 isl_set *dom_i;
3857
3858 dom_i = isl_pw_aff_domain(isl_pw_aff_list_get_at(list, i));
3859 dom = isl_set_intersect(dom, dom_i);
3860 }
3861
3862 isl_pw_aff_list_free(list);
3863 return nan_on_domain_set(dom);
3864}
3865
3866/* Return the set where the element at "pos1" of "list" is less than or
3867 * equal to the element at "pos2".
3868 * Equality is only allowed if "pos1" is smaller than "pos2".
3869 */
3870static __isl_give isl_set *less(__isl_keep isl_pw_aff_list *list,
3871 int pos1, int pos2)
3872{
3873 isl_pw_aff *pa1, *pa2;
3874
3875 pa1 = isl_pw_aff_list_get_at(list, pos1);
3876 pa2 = isl_pw_aff_list_get_at(list, pos2);
3877
3878 if (pos1 < pos2)
3879 return isl_pw_aff_le_set(pa1, pa2);
3880 else
3881 return isl_pw_aff_lt_set(pa1, pa2);
3882}
3883
3884/* Return an isl_pw_aff that maps each element in the intersection of the
3885 * domains of the piecewise affine expressions in "list"
3886 * to the maximal (if "max" is set) or minimal (if "max" is not set)
3887 * expression in "list" at that element.
3888 * If any expression involves any NaN, then return a NaN
3889 * on the shared domain as result.
3890 *
3891 * If "list" has n elements, then the result consists of n pieces,
3892 * where, in the case of a minimum, each piece has as value expression
3893 * the value expression of one of the elements and as domain
3894 * the set of elements where that value expression
3895 * is less than (or equal) to the other value expressions.
3896 * In the case of a maximum, the condition is
3897 * that all the other value expressions are less than (or equal)
3898 * to the given value expression.
3899 *
3900 * In order to produce disjoint pieces, a pair of elements
3901 * in the original domain is only allowed to be equal to each other
3902 * on exactly one of the two pieces corresponding to the two elements.
3903 * The position in the list is used to break ties.
3904 * In particular, in the case of a minimum,
3905 * in the piece corresponding to a given element,
3906 * this element is allowed to be equal to any later element in the list,
3907 * but not to any earlier element in the list.
3908 */
3910 __isl_take isl_pw_aff_list *list, int max)
3911{
3912 int i, j;
3913 isl_bool has_nan;
3914 isl_size n;
3915 isl_space *space;
3916 isl_pw_aff *pa, *res;
3917
3918 n = isl_pw_aff_list_size(list);
3919 if (n < 0)
3920 goto error;
3921 if (n < 1)
3922 isl_die(isl_pw_aff_list_get_ctx(list), isl_error_invalid,
3923 "list should contain at least one element", goto error);
3924
3925 has_nan = isl_pw_aff_list_involves_nan(list);
3926 if (has_nan < 0)
3927 goto error;
3928 if (has_nan)
3929 return replace_list_by_nan(list, n);
3930
3931 pa = isl_pw_aff_list_get_at(list, 0);
3932 space = isl_pw_aff_get_space(pa);
3934 res = isl_pw_aff_empty(space);
3935
3936 for (i = 0; i < n; ++i) {
3937 pa = isl_pw_aff_list_get_at(list, i);
3938 for (j = 0; j < n; ++j) {
3939 isl_set *dom;
3940
3941 if (j == i)
3942 continue;
3943 if (max)
3944 dom = less(list, j, i);
3945 else
3946 dom = less(list, i, j);
3947
3949 }
3951 }
3952
3953 isl_pw_aff_list_free(list);
3954 return res;
3955error:
3956 isl_pw_aff_list_free(list);
3957 return NULL;
3958}
3959
3960/* Return an isl_pw_aff that maps each element in the intersection of the
3961 * domains of the elements of list to the minimal corresponding affine
3962 * expression.
3963 */
3965{
3966 return isl_pw_aff_list_opt(list, 0);
3967}
3968
3969/* Return an isl_pw_aff that maps each element in the intersection of the
3970 * domains of the elements of list to the maximal corresponding affine
3971 * expression.
3972 */
3974{
3975 return isl_pw_aff_list_opt(list, 1);
3976}
3977
3978/* Mark the domains of "pwaff" as rational.
3979 */
3981{
3982 int i;
3983
3984 pwaff = isl_pw_aff_cow(pwaff);
3985 if (!pwaff)
3986 return NULL;
3987 if (pwaff->n == 0)
3988 return pwaff;
3989
3990 for (i = 0; i < pwaff->n; ++i) {
3991 pwaff->p[i].set = isl_set_set_rational(pwaff->p[i].set);
3992 if (!pwaff->p[i].set)
3993 return isl_pw_aff_free(pwaff);
3994 }
3995
3996 return pwaff;
3997}
3998
3999/* Mark the domains of the elements of "list" as rational.
4000 */
4002 __isl_take isl_pw_aff_list *list)
4003{
4004 int i, n;
4005
4006 if (!list)
4007 return NULL;
4008 if (list->n == 0)
4009 return list;
4010
4011 n = list->n;
4012 for (i = 0; i < n; ++i) {
4013 isl_pw_aff *pa;
4014
4015 pa = isl_pw_aff_list_get_pw_aff(list, i);
4017 list = isl_pw_aff_list_set_pw_aff(list, i, pa);
4018 }
4019
4020 return list;
4021}
4022
4023/* Do the parameters of "aff" match those of "space"?
4024 */
4026 __isl_keep isl_space *space)
4027{
4028 isl_space *aff_space;
4030
4031 if (!aff || !space)
4032 return isl_bool_error;
4033
4034 aff_space = isl_aff_get_domain_space(aff);
4035
4036 match = isl_space_has_equal_params(space, aff_space);
4037
4038 isl_space_free(aff_space);
4039 return match;
4040}
4041
4042/* Check that the domain space of "aff" matches "space".
4043 */
4045 __isl_keep isl_space *space)
4046{
4047 isl_space *aff_space;
4049
4050 if (!aff || !space)
4051 return isl_stat_error;
4052
4053 aff_space = isl_aff_get_domain_space(aff);
4054
4055 match = isl_space_has_equal_params(space, aff_space);
4056 if (match < 0)
4057 goto error;
4058 if (!match)
4060 "parameters don't match", goto error);
4062 aff_space, isl_dim_set);
4063 if (match < 0)
4064 goto error;
4065 if (!match)
4067 "domains don't match", goto error);
4068 isl_space_free(aff_space);
4069 return isl_stat_ok;
4070error:
4071 isl_space_free(aff_space);
4072 return isl_stat_error;
4073}
4074
4075/* Return the shared (universe) domain of the elements of "ma".
4076 *
4077 * Since an isl_multi_aff (and an isl_aff) is always total,
4078 * the domain is always the universe set in its domain space.
4079 * This is a helper function for use in the generic isl_multi_*_bind.
4080 */
4083{
4084 isl_space *space;
4085
4086 space = isl_multi_aff_get_space(ma);
4087 isl_multi_aff_free(ma);
4088
4090}
4091
4092#undef BASE
4093#define BASE aff
4094
4096#include <isl_multi_templ.c>
4097#include <isl_multi_un_op_templ.c>
4100#include <isl_multi_align_set.c>
4101#include <isl_multi_arith_templ.c>
4103#include <isl_multi_cmp.c>
4104#include <isl_multi_dim_id_templ.c>
4105#include <isl_multi_dims.c>
4107#include <isl_multi_floor.c>
4111#include <isl_multi_locals_templ.c>
4113#include <isl_multi_nan_templ.c>
4115#include <isl_multi_splice_templ.c>
4118#include <isl_multi_zero_templ.c>
4119
4120#undef DOMBASE
4121#define DOMBASE set
4124#include <isl_multi_gist.c>
4125
4126#undef DOMBASE
4127#define DOMBASE basic_set
4128#include <isl_multi_bind_templ.c>
4129
4130/* Construct an isl_multi_aff living in "space" that corresponds
4131 * to the affine transformation matrix "mat".
4132 */
4135{
4136 isl_ctx *ctx;
4137 isl_local_space *ls = NULL;
4138 isl_multi_aff *ma = NULL;
4139 isl_size n_row, n_col, n_out, total;
4140 int i;
4141
4142 if (!space || !mat)
4143 goto error;
4144
4145 ctx = isl_mat_get_ctx(mat);
4146
4147 n_row = isl_mat_rows(mat);
4148 n_col = isl_mat_cols(mat);
4149 n_out = isl_space_dim(space, isl_dim_out);
4151 if (n_row < 0 || n_col < 0 || n_out < 0 || total < 0)
4152 goto error;
4153 if (n_row < 1)
4155 "insufficient number of rows", goto error);
4156 if (n_col < 1)
4158 "insufficient number of columns", goto error);
4159 if (1 + n_out != n_row || 2 + total != n_row + n_col)
4161 "dimension mismatch", goto error);
4162
4163 ma = isl_multi_aff_zero(isl_space_copy(space));
4164 space = isl_space_domain(space);
4166
4167 for (i = 0; i < n_row - 1; ++i) {
4168 isl_vec *v;
4169 isl_aff *aff;
4170
4171 v = isl_vec_alloc(ctx, 1 + n_col);
4172 if (!v)
4173 goto error;
4174 isl_int_set(v->el[0], mat->row[0][0]);
4175 isl_seq_cpy(v->el + 1, mat->row[1 + i], n_col);
4176 v = isl_vec_normalize(v);
4178 ma = isl_multi_aff_set_aff(ma, i, aff);
4179 }
4180
4181 isl_space_free(space);
4183 isl_mat_free(mat);
4184 return ma;
4185error:
4186 isl_space_free(space);
4188 isl_mat_free(mat);
4189 isl_multi_aff_free(ma);
4190 return NULL;
4191}
4192
4193/* Return the constant terms of the affine expressions of "ma".
4194 */
4197{
4198 int i;
4199 isl_size n;
4200 isl_space *space;
4201 isl_multi_val *mv;
4202
4203 n = isl_multi_aff_size(ma);
4204 if (n < 0)
4205 return NULL;
4206 space = isl_space_range(isl_multi_aff_get_space(ma));
4207 space = isl_space_drop_all_params(space);
4208 mv = isl_multi_val_zero(space);
4209
4210 for (i = 0; i < n; ++i) {
4211 isl_aff *aff;
4212 isl_val *val;
4213
4214 aff = isl_multi_aff_get_at(ma, i);
4217 mv = isl_multi_val_set_at(mv, i, val);
4218 }
4219
4220 return mv;
4221}
4222
4223/* Remove any internal structure of the domain of "ma".
4224 * If there is any such internal structure in the input,
4225 * then the name of the corresponding space is also removed.
4226 */
4229{
4230 isl_space *space;
4231
4232 if (!ma)
4233 return NULL;
4234
4235 if (!ma->space->nested[0])
4236 return ma;
4237
4238 space = isl_multi_aff_get_space(ma);
4239 space = isl_space_flatten_domain(space);
4240 ma = isl_multi_aff_reset_space(ma, space);
4241
4242 return ma;
4243}
4244
4245/* Given a map space, return an isl_multi_aff that maps a wrapped copy
4246 * of the space to its domain.
4247 */
4249{
4250 int i;
4251 isl_size n_in;
4252 isl_local_space *ls;
4254
4255 if (!space)
4256 return NULL;
4257 if (!isl_space_is_map(space))
4259 "not a map space", goto error);
4260
4261 n_in = isl_space_dim(space, isl_dim_in);
4262 if (n_in < 0)
4263 goto error;
4264 space = isl_space_domain_map(space);
4265
4266 ma = isl_multi_aff_alloc(isl_space_copy(space));
4267 if (n_in == 0) {
4268 isl_space_free(space);
4269 return ma;
4270 }
4271
4272 space = isl_space_domain(space);
4273 ls = isl_local_space_from_space(space);
4274 for (i = 0; i < n_in; ++i) {
4275 isl_aff *aff;
4276
4278 isl_dim_set, i);
4279 ma = isl_multi_aff_set_aff(ma, i, aff);
4280 }
4282 return ma;
4283error:
4284 isl_space_free(space);
4285 return NULL;
4286}
4287
4288/* This function performs the same operation as isl_multi_aff_domain_map,
4289 * but is considered as a function on an isl_space when exported.
4290 */
4296
4297/* Given a map space, return an isl_multi_aff that maps a wrapped copy
4298 * of the space to its range.
4299 */
4301{
4302 int i;
4303 isl_size n_in, n_out;
4304 isl_local_space *ls;
4306
4307 if (!space)
4308 return NULL;
4309 if (!isl_space_is_map(space))
4311 "not a map space", goto error);
4312
4313 n_in = isl_space_dim(space, isl_dim_in);
4314 n_out = isl_space_dim(space, isl_dim_out);
4315 if (n_in < 0 || n_out < 0)
4316 goto error;
4317 space = isl_space_range_map(space);
4318
4319 ma = isl_multi_aff_alloc(isl_space_copy(space));
4320 if (n_out == 0) {
4321 isl_space_free(space);
4322 return ma;
4323 }
4324
4325 space = isl_space_domain(space);
4326 ls = isl_local_space_from_space(space);
4327 for (i = 0; i < n_out; ++i) {
4328 isl_aff *aff;
4329
4331 isl_dim_set, n_in + i);
4332 ma = isl_multi_aff_set_aff(ma, i, aff);
4333 }
4335 return ma;
4336error:
4337 isl_space_free(space);
4338 return NULL;
4339}
4340
4341/* This function performs the same operation as isl_multi_aff_range_map,
4342 * but is considered as a function on an isl_space when exported.
4343 */
4349
4350/* Given a map space, return an isl_pw_multi_aff that maps a wrapped copy
4351 * of the space to its domain.
4352 */
4358
4359/* This function performs the same operation as isl_pw_multi_aff_domain_map,
4360 * but is considered as a function on an isl_space when exported.
4361 */
4367
4368/* Given a map space, return an isl_pw_multi_aff that maps a wrapped copy
4369 * of the space to its range.
4370 */
4376
4377/* This function performs the same operation as isl_pw_multi_aff_range_map,
4378 * but is considered as a function on an isl_space when exported.
4379 */
4385
4386/* Given the space of a set and a range of set dimensions,
4387 * construct an isl_multi_aff that projects out those dimensions.
4388 */
4391 unsigned first, unsigned n)
4392{
4393 int i;
4394 isl_size dim;
4395 isl_local_space *ls;
4397
4398 if (!space)
4399 return NULL;
4400 if (!isl_space_is_set(space))
4402 "expecting set space", goto error);
4403 if (type != isl_dim_set)
4405 "only set dimensions can be projected out", goto error);
4406 if (isl_space_check_range(space, type, first, n) < 0)
4407 goto error;
4408
4409 dim = isl_space_dim(space, isl_dim_set);
4410 if (dim < 0)
4411 goto error;
4412
4413 space = isl_space_from_domain(space);
4414 space = isl_space_add_dims(space, isl_dim_out, dim - n);
4415
4416 if (dim == n)
4417 return isl_multi_aff_alloc(space);
4418
4419 ma = isl_multi_aff_alloc(isl_space_copy(space));
4420 space = isl_space_domain(space);
4421 ls = isl_local_space_from_space(space);
4422
4423 for (i = 0; i < first; ++i) {
4424 isl_aff *aff;
4425
4427 isl_dim_set, i);
4428 ma = isl_multi_aff_set_aff(ma, i, aff);
4429 }
4430
4431 for (i = 0; i < dim - (first + n); ++i) {
4432 isl_aff *aff;
4433
4435 isl_dim_set, first + n + i);
4436 ma = isl_multi_aff_set_aff(ma, first + i, aff);
4437 }
4438
4440 return ma;
4441error:
4442 isl_space_free(space);
4443 return NULL;
4444}
4445
4446/* Given the space of a set and a range of set dimensions,
4447 * construct an isl_pw_multi_aff that projects out those dimensions.
4448 */
4451 unsigned first, unsigned n)
4452{
4454
4455 ma = isl_multi_aff_project_out_map(space, type, first, n);
4457}
4458
4459/* This function performs the same operation as isl_pw_multi_aff_from_multi_aff,
4460 * but is considered as a function on an isl_multi_aff when exported.
4461 */
4467
4468/* Create a piecewise multi-affine expression in the given space that maps each
4469 * input dimension to the corresponding output dimension.
4470 */
4472 __isl_take isl_space *space)
4473{
4474 return isl_pw_multi_aff_from_multi_aff(isl_multi_aff_identity(space));
4475}
4476
4477/* Create a piecewise multi expression that maps elements in the given space
4478 * to themselves.
4479 */
4481 __isl_take isl_space *space)
4482{
4484
4485 ma = isl_multi_aff_identity_on_domain_space(space);
4487}
4488
4489/* This function performs the same operation as
4490 * isl_pw_multi_aff_identity_on_domain_space,
4491 * but is considered as a function on an isl_space when exported.
4492 */
4498
4499/* Exploit the equalities in "eq" to simplify the affine expressions.
4500 */
4503{
4504 isl_size n;
4505 int i;
4506
4507 n = isl_multi_aff_size(maff);
4508 if (n < 0 || !eq)
4509 goto error;
4510
4511 for (i = 0; i < n; ++i) {
4512 isl_aff *aff;
4513
4514 aff = isl_multi_aff_take_at(maff, i);
4516 isl_basic_set_copy(eq));
4517 maff = isl_multi_aff_restore_at(maff, i, aff);
4518 }
4519
4521 return maff;
4522error:
4524 isl_multi_aff_free(maff);
4525 return NULL;
4526}
4527
4529 isl_int f)
4530{
4531 isl_size n;
4532 int i;
4533
4534 n = isl_multi_aff_size(maff);
4535 if (n < 0)
4536 return isl_multi_aff_free(maff);
4537
4538 for (i = 0; i < n; ++i) {
4539 isl_aff *aff;
4540
4541 aff = isl_multi_aff_take_at(maff, i);
4542 aff = isl_aff_scale(aff, f);
4543 maff = isl_multi_aff_restore_at(maff, i, aff);
4544 }
4545
4546 return maff;
4547}
4548
4551{
4552 maff1 = isl_multi_aff_add(maff1, maff2);
4553 maff1 = isl_multi_aff_gist(maff1, isl_set_copy(dom));
4554 return maff1;
4555}
4556
4558{
4559 if (!maff)
4560 return isl_bool_error;
4561
4562 return isl_bool_false;
4563}
4564
4565/* Return the set of domain elements where "ma1" is lexicographically
4566 * smaller than or equal to "ma2".
4567 */
4573
4574/* Return the set of domain elements where "ma1" is lexicographically
4575 * smaller than "ma2".
4576 */
4582
4583/* Return the set of domain elements where "ma1" is lexicographically
4584 * greater than to "ma2". If "equal" is set, then include the domain
4585 * elements where they are equal.
4586 * Do this for the case where there are no entries.
4587 * In this case, "ma1" cannot be greater than "ma2",
4588 * but it is (greater than or) equal to "ma2".
4589 */
4592{
4593 isl_space *space;
4594
4595 space = isl_multi_aff_get_domain_space(ma1);
4596
4597 isl_multi_aff_free(ma1);
4598 isl_multi_aff_free(ma2);
4599
4600 if (equal)
4601 return isl_set_universe(space);
4602 else
4603 return isl_set_empty(space);
4604}
4605
4606/* Return the set where entry "i" of "ma1" and "ma2"
4607 * satisfy the relation prescribed by "cmp".
4608 */
4610 __isl_keep isl_multi_aff *ma2, int i,
4612 __isl_take isl_aff *aff2))
4613{
4614 isl_aff *aff1, *aff2;
4615
4616 aff1 = isl_multi_aff_get_at(ma1, i);
4617 aff2 = isl_multi_aff_get_at(ma2, i);
4618 return cmp(aff1, aff2);
4619}
4620
4621/* Return the set of domain elements where "ma1" is lexicographically
4622 * greater than to "ma2". If "equal" is set, then include the domain
4623 * elements where they are equal.
4624 *
4625 * In particular, for all but the final entry,
4626 * include the set of elements where this entry is strictly greater in "ma1"
4627 * and all previous entries are equal.
4628 * The final entry is also allowed to be equal in the two functions
4629 * if "equal" is set.
4630 *
4631 * The case where there are no entries is handled separately.
4632 */
4635{
4636 int i;
4637 isl_size n;
4638 isl_space *space;
4639 isl_set *res;
4640 isl_set *equal_set;
4641 isl_set *gte;
4642
4643 if (isl_multi_aff_check_equal_space(ma1, ma2) < 0)
4644 goto error;
4645 n = isl_multi_aff_size(ma1);
4646 if (n < 0)
4647 goto error;
4648 if (n == 0)
4650
4651 space = isl_multi_aff_get_domain_space(ma1);
4653 equal_set = isl_set_universe(space);
4654
4655 for (i = 0; i + 1 < n; ++i) {
4656 isl_bool empty;
4657 isl_set *gt, *eq;
4658
4660 gt = isl_set_intersect(gt, isl_set_copy(equal_set));
4661 res = isl_set_union(res, gt);
4663 equal_set = isl_set_intersect(equal_set, eq);
4664
4665 empty = isl_set_is_empty(equal_set);
4666 if (empty >= 0 && empty)
4667 break;
4668 }
4669
4670 if (equal)
4671 gte = isl_multi_aff_order_at(ma1, ma2, n - 1, &isl_aff_ge_set);
4672 else
4673 gte = isl_multi_aff_order_at(ma1, ma2, n - 1, &isl_aff_gt_set);
4674 isl_multi_aff_free(ma1);
4675 isl_multi_aff_free(ma2);
4676
4677 gte = isl_set_intersect(gte, equal_set);
4678 return isl_set_union(res, gte);
4679error:
4680 isl_multi_aff_free(ma1);
4681 isl_multi_aff_free(ma2);
4682 return NULL;
4683}
4684
4685/* Return the set of domain elements where "ma1" is lexicographically
4686 * greater than or equal to "ma2".
4687 */
4693
4694/* Return the set of domain elements where "ma1" is lexicographically
4695 * greater than "ma2".
4696 */
4702
4703#define isl_multi_aff_zero_in_space isl_multi_aff_zero
4704
4705#undef PW
4706#define PW isl_pw_multi_aff
4707#undef BASE
4708#define BASE multi_aff
4709#undef EL_IS_ZERO
4710#define EL_IS_ZERO is_empty
4711#undef ZERO
4712#define ZERO empty
4713#undef IS_ZERO
4714#define IS_ZERO is_empty
4715#undef FIELD
4716#define FIELD maff
4717#undef DEFAULT_IS_ZERO
4718#define DEFAULT_IS_ZERO 0
4719
4720#include <isl_pw_templ.c>
4721#include <isl_pw_un_op_templ.c>
4727#include <isl_pw_fix_templ.c>
4731#include <isl_pw_locals_templ.c>
4732#include <isl_pw_move_dims_templ.c>
4733#include <isl_pw_neg_templ.c>
4734#include <isl_pw_pullback_templ.c>
4736#include <isl_pw_union_opt.c>
4737
4738#undef BASE
4739#define BASE pw_multi_aff
4740
4741#include <isl_union_multi.c>
4742#include "isl_union_locals_templ.c"
4743#include <isl_union_neg.c>
4744#include <isl_union_sub_templ.c>
4745
4746#undef BASE
4747#define BASE multi_aff
4748
4749#include <isl_union_pw_templ.c>
4750
4751/* Generic function for extracting a factor from a product "pma".
4752 * "check_space" checks that the space is that of the right kind of product.
4753 * "space_factor" extracts the factor from the space.
4754 * "multi_aff_factor" extracts the factor from the constituent functions.
4755 */
4758 isl_stat (*check_space)(__isl_keep isl_pw_multi_aff *pma),
4759 __isl_give isl_space *(*space_factor)(__isl_take isl_space *space),
4760 __isl_give isl_multi_aff *(*multi_aff_factor)(
4762{
4763 int i;
4764 isl_space *space;
4765
4766 if (check_space(pma) < 0)
4767 return isl_pw_multi_aff_free(pma);
4768
4769 space = isl_pw_multi_aff_take_space(pma);
4770 space = space_factor(space);
4771
4772 for (i = 0; pma && i < pma->n; ++i) {
4774
4775 ma = isl_pw_multi_aff_take_base_at(pma, i);
4776 ma = multi_aff_factor(ma);
4777 pma = isl_pw_multi_aff_restore_base_at(pma, i, ma);
4778 }
4779
4780 pma = isl_pw_multi_aff_restore_space(pma, space);
4781
4782 return pma;
4783}
4784
4785/* Is the range of "pma" a wrapped relation?
4786 */
4789{
4790 return isl_space_range_is_wrapping(isl_pw_multi_aff_peek_space(pma));
4791}
4792
4793/* Check that the range of "pma" is a product.
4794 */
4797{
4798 isl_bool wraps;
4799
4801 if (wraps < 0)
4802 return isl_stat_error;
4803 if (!wraps)
4805 "range is not a product", return isl_stat_error);
4806 return isl_stat_ok;
4807}
4808
4809/* Given a function A -> [B -> C], extract the function A -> B.
4810 */
4818
4819/* Given a function A -> [B -> C], extract the function A -> C.
4820 */
4828
4829/* Given two piecewise multi affine expressions, return a piecewise
4830 * multi-affine expression defined on the union of the definition domains
4831 * of the inputs that is equal to the lexicographic maximum of the two
4832 * inputs on each cell. If only one of the two inputs is defined on
4833 * a given cell, then it is considered to be the maximum.
4834 */
4838{
4839 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
4840 return isl_pw_multi_aff_union_opt_cmp(pma1, pma2,
4842}
4843
4844/* Given two piecewise multi affine expressions, return a piecewise
4845 * multi-affine expression defined on the union of the definition domains
4846 * of the inputs that is equal to the lexicographic minimum of the two
4847 * inputs on each cell. If only one of the two inputs is defined on
4848 * a given cell, then it is considered to be the minimum.
4849 */
4853{
4854 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
4855 return isl_pw_multi_aff_union_opt_cmp(pma1, pma2,
4857}
4858
4861{
4862 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
4863 return isl_pw_multi_aff_on_shared_domain(pma1, pma2,
4864 &isl_multi_aff_add);
4865}
4866
4867/* Subtract "pma2" from "pma1" and return the result.
4868 */
4871{
4872 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
4873 return isl_pw_multi_aff_on_shared_domain(pma1, pma2,
4874 &isl_multi_aff_sub);
4875}
4876
4877/* Given two piecewise multi-affine expressions A -> B and C -> D,
4878 * construct a piecewise multi-affine expression [A -> C] -> [B -> D].
4879 */
4882{
4883 int i, j, n;
4884 isl_space *space;
4886
4887 if (isl_pw_multi_aff_align_params_bin(&pma1, &pma2) < 0)
4888 goto error;
4889
4890 n = pma1->n * pma2->n;
4891 space = isl_space_product(isl_space_copy(pma1->dim),
4892 isl_space_copy(pma2->dim));
4893 res = isl_pw_multi_aff_alloc_size(space, n);
4894
4895 for (i = 0; i < pma1->n; ++i) {
4896 for (j = 0; j < pma2->n; ++j) {
4897 isl_set *domain;
4899
4900 domain = isl_set_product(isl_set_copy(pma1->p[i].set),
4901 isl_set_copy(pma2->p[j].set));
4902 ma = isl_multi_aff_product(
4903 isl_multi_aff_copy(pma1->p[i].maff),
4904 isl_multi_aff_copy(pma2->p[j].maff));
4905 res = isl_pw_multi_aff_add_piece(res, domain, ma);
4906 }
4907 }
4908
4911 return res;
4912error:
4915 return NULL;
4916}
4917
4918/* Subtract the initial "n" elements in "ma" with coefficients in "c" and
4919 * denominator "denom".
4920 * "denom" is allowed to be negative, in which case the actual denominator
4921 * is -denom and the expressions are added instead.
4922 */
4924 __isl_keep isl_multi_aff *ma, int n, isl_int *c, isl_int denom)
4925{
4926 int i, first;
4927 int sign;
4928 isl_int d;
4929
4930 first = isl_seq_first_non_zero(c, n);
4931 if (first == -1)
4932 return aff;
4933
4934 sign = isl_int_sgn(denom);
4935 isl_int_init(d);
4936 isl_int_abs(d, denom);
4937 for (i = first; i < n; ++i) {
4938 isl_aff *aff_i;
4939
4940 if (isl_int_is_zero(c[i]))
4941 continue;
4942 aff_i = isl_multi_aff_get_aff(ma, i);
4943 aff_i = isl_aff_scale(aff_i, c[i]);
4944 aff_i = isl_aff_scale_down(aff_i, d);
4945 if (sign >= 0)
4946 aff = isl_aff_sub(aff, aff_i);
4947 else
4948 aff = isl_aff_add(aff, aff_i);
4949 }
4950 isl_int_clear(d);
4951
4952 return aff;
4953}
4954
4955/* Extract an affine expression that expresses the output dimension "pos"
4956 * of "bmap" in terms of the parameters and input dimensions from
4957 * equality "eq".
4958 * Note that this expression may involve integer divisions defined
4959 * in terms of parameters and input dimensions.
4960 * The equality may also involve references to earlier (but not later)
4961 * output dimensions. These are replaced by the corresponding elements
4962 * in "ma".
4963 *
4964 * If the equality is of the form
4965 *
4966 * f(i) + h(j) + a x + g(i) = 0,
4967 *
4968 * with f(i) a linear combinations of the parameters and input dimensions,
4969 * g(i) a linear combination of integer divisions defined in terms of the same
4970 * and h(j) a linear combinations of earlier output dimensions,
4971 * then the affine expression is
4972 *
4973 * (-f(i) - g(i))/a - h(j)/a
4974 *
4975 * If the equality is of the form
4976 *
4977 * f(i) + h(j) - a x + g(i) = 0,
4978 *
4979 * then the affine expression is
4980 *
4981 * (f(i) + g(i))/a - h(j)/(-a)
4982 *
4983 *
4984 * If "div" refers to an integer division (i.e., it is smaller than
4985 * the number of integer divisions), then the equality constraint
4986 * does involve an integer division (the one at position "div") that
4987 * is defined in terms of output dimensions. However, this integer
4988 * division can be eliminated by exploiting a pair of constraints
4989 * x >= l and x <= l + n, with n smaller than the coefficient of "div"
4990 * in the equality constraint. "ineq" refers to inequality x >= l, i.e.,
4991 * -l + x >= 0.
4992 * In particular, let
4993 *
4994 * x = e(i) + m floor(...)
4995 *
4996 * with e(i) the expression derived above and floor(...) the integer
4997 * division involving output dimensions.
4998 * From
4999 *
5000 * l <= x <= l + n,
5001 *
5002 * we have
5003 *
5004 * 0 <= x - l <= n
5005 *
5006 * This means
5007 *
5008 * e(i) + m floor(...) - l = (e(i) + m floor(...) - l) mod m
5009 * = (e(i) - l) mod m
5010 *
5011 * Therefore,
5012 *
5013 * x - l = (e(i) - l) mod m
5014 *
5015 * or
5016 *
5017 * x = ((e(i) - l) mod m) + l
5018 *
5019 * The variable "shift" below contains the expression -l, which may
5020 * also involve a linear combination of earlier output dimensions.
5021 */
5023 __isl_keep isl_basic_map *bmap, int pos, int eq, int div, int ineq,
5025{
5026 unsigned o_out;
5027 isl_size n_div, n_out;
5028 isl_ctx *ctx;
5029 isl_local_space *ls;
5030 isl_aff *aff, *shift;
5031 isl_val *mod;
5032
5033 ctx = isl_basic_map_get_ctx(bmap);
5035 ls = isl_local_space_domain(ls);
5037 if (!aff)
5038 goto error;
5039 o_out = isl_basic_map_offset(bmap, isl_dim_out);
5040 n_out = isl_basic_map_dim(bmap, isl_dim_out);
5041 n_div = isl_basic_map_dim(bmap, isl_dim_div);
5042 if (n_out < 0 || n_div < 0)
5043 goto error;
5044 if (isl_int_is_neg(bmap->eq[eq][o_out + pos])) {
5045 isl_seq_cpy(aff->v->el + 1, bmap->eq[eq], o_out);
5046 isl_seq_cpy(aff->v->el + 1 + o_out,
5047 bmap->eq[eq] + o_out + n_out, n_div);
5048 } else {
5049 isl_seq_neg(aff->v->el + 1, bmap->eq[eq], o_out);
5050 isl_seq_neg(aff->v->el + 1 + o_out,
5051 bmap->eq[eq] + o_out + n_out, n_div);
5052 }
5053 if (div < n_div)
5054 isl_int_set_si(aff->v->el[1 + o_out + div], 0);
5055 isl_int_abs(aff->v->el[0], bmap->eq[eq][o_out + pos]);
5056 aff = subtract_initial(aff, ma, pos, bmap->eq[eq] + o_out,
5057 bmap->eq[eq][o_out + pos]);
5058 if (div < n_div) {
5060 if (!shift)
5061 goto error;
5062 isl_seq_cpy(shift->v->el + 1, bmap->ineq[ineq], o_out);
5063 isl_seq_cpy(shift->v->el + 1 + o_out,
5064 bmap->ineq[ineq] + o_out + n_out, n_div);
5065 isl_int_set_si(shift->v->el[0], 1);
5066 shift = subtract_initial(shift, ma, pos,
5067 bmap->ineq[ineq] + o_out, ctx->negone);
5068 aff = isl_aff_add(aff, isl_aff_copy(shift));
5069 mod = isl_val_int_from_isl_int(ctx,
5070 bmap->eq[eq][o_out + n_out + div]);
5071 mod = isl_val_abs(mod);
5072 aff = isl_aff_mod_val(aff, mod);
5073 aff = isl_aff_sub(aff, shift);
5074 }
5075
5077 return aff;
5078error:
5081 return NULL;
5082}
5083
5084/* Given a basic map with output dimensions defined
5085 * in terms of the parameters input dimensions and earlier
5086 * output dimensions using an equality (and possibly a pair on inequalities),
5087 * extract an isl_aff that expresses output dimension "pos" in terms
5088 * of the parameters and input dimensions.
5089 * Note that this expression may involve integer divisions defined
5090 * in terms of parameters and input dimensions.
5091 * "ma" contains the expressions corresponding to earlier output dimensions.
5092 *
5093 * This function shares some similarities with
5094 * isl_basic_map_has_defining_equality and isl_constraint_get_bound.
5095 */
5098{
5099 int eq, div, ineq;
5100 isl_aff *aff;
5101
5102 if (!bmap)
5103 return NULL;
5104 eq = isl_basic_map_output_defining_equality(bmap, pos, &div, &ineq);
5105 if (eq >= bmap->n_eq)
5107 "unable to find suitable equality", return NULL);
5108 aff = extract_aff_from_equality(bmap, pos, eq, div, ineq, ma);
5109
5111 return aff;
5112}
5113
5114/* Given a basic map where each output dimension is defined
5115 * in terms of the parameters and input dimensions using an equality,
5116 * extract an isl_multi_aff that expresses the output dimensions in terms
5117 * of the parameters and input dimensions.
5118 */
5121{
5122 int i;
5123 isl_size n_out;
5125
5126 if (!bmap)
5127 return NULL;
5128
5129 ma = isl_multi_aff_alloc(isl_basic_map_get_space(bmap));
5130 n_out = isl_basic_map_dim(bmap, isl_dim_out);
5131 if (n_out < 0)
5132 ma = isl_multi_aff_free(ma);
5133
5134 for (i = 0; i < n_out; ++i) {
5135 isl_aff *aff;
5136
5138 ma = isl_multi_aff_set_aff(ma, i, aff);
5139 }
5140
5141 isl_basic_map_free(bmap);
5142
5143 return ma;
5144}
5145
5146/* Given a basic set where each set dimension is defined
5147 * in terms of the parameters using an equality,
5148 * extract an isl_multi_aff that expresses the set dimensions in terms
5149 * of the parameters.
5150 */
5156
5157/* Create an isl_pw_multi_aff that is equivalent to
5158 * isl_map_intersect_domain(isl_map_from_basic_map(bmap), domain).
5159 * The given basic map is such that each output dimension is defined
5160 * in terms of the parameters and input dimensions using an equality.
5161 *
5162 * Since some applications expect the result of isl_pw_multi_aff_from_map
5163 * to only contain integer affine expressions, we compute the floor
5164 * of the expression before returning.
5165 *
5166 * Remove all constraints involving local variables without
5167 * an explicit representation (resulting in the removal of those
5168 * local variables) prior to the actual extraction to ensure
5169 * that the local spaces in which the resulting affine expressions
5170 * are created do not contain any unknown local variables.
5171 * Removing such constraints is safe because constraints involving
5172 * unknown local variables are not used to determine whether
5173 * a basic map is obviously single-valued.
5174 */
5185
5186/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map.
5187 * This obviously only works if the input "map" is single-valued.
5188 * If so, we compute the lexicographic minimum of the image in the form
5189 * of an isl_pw_multi_aff. Since the image is unique, it is equal
5190 * to its lexicographic minimum.
5191 * If the input is not single-valued, we produce an error.
5192 */
5195{
5196 int i;
5197 int sv;
5199
5201 if (sv < 0)
5202 goto error;
5203 if (!sv)
5205 "map is not single-valued", goto error);
5207 if (!map)
5208 return NULL;
5209
5211
5212 for (i = 0; i < map->n; ++i) {
5213 isl_pw_multi_aff *pma_i;
5214 isl_basic_map *bmap;
5215 bmap = isl_basic_map_copy(map->p[i]);
5218 }
5219
5221 return pma;
5222error:
5224 return NULL;
5225}
5226
5227/* Given an affine expression "aff", return an extended multi-affine expression
5228 * that also includes an identity on the domain.
5229 * In other words, the returned expression can be used to extend the domain
5230 * with an extra dimension corresponding to "aff".
5231 *
5232 * That is, if "aff" is of the form
5233 *
5234 * A -> f
5235 *
5236 * then return
5237 *
5238 * A -> [A -> f]
5239 *
5240 * However, if "aff" is of the form
5241 *
5242 * f
5243 *
5244 * i.e., "aff" lives in a set space rather than a map space,
5245 * then simply return
5246 *
5247 * f
5248 */
5250{
5251 isl_bool is_set;
5253
5255 if (is_set < 0)
5257
5258 if (is_set) {
5260 } else {
5261 isl_space *space;
5263
5265 id = isl_multi_aff_identity(isl_space_map_from_set(space));
5267 ma = isl_multi_aff_range_product(id, ma);
5268 }
5269
5270 return ma;
5271}
5272
5273/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map,
5274 * taking into account that the output dimension at position "d"
5275 * is equal to some expression f in the parameters and input dimensions
5276 * represented by "aff".
5277 *
5278 * Let "map" be of the form
5279 *
5280 * A -> B
5281 *
5282 * Construct a mapping
5283 *
5284 * A -> [A -> x = f]
5285 *
5286 * apply that to the map, obtaining
5287 *
5288 * [A -> x = f] -> B
5289 *
5290 * and equate dimension "d" to x.
5291 * An isl_pw_multi_aff representation of this map is then computed and
5292 * the above expression is plugged in in the result.
5293 */
5296{
5298 isl_map *insert;
5299 isl_size n_in;
5301
5302 n_in = isl_aff_dim(aff, isl_dim_in);
5303 if (n_in < 0)
5304 goto error;
5305
5307 insert = isl_map_from_multi_aff_internal(isl_multi_aff_copy(ma));
5308 map = isl_map_apply_domain(map, insert);
5312
5313 return pma;
5314error:
5317 return NULL;
5318}
5319
5320/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map.
5321 *
5322 * As a special case, we first check if there is any pair of constraints,
5323 * shared by all the basic maps in "map" that force a given dimension
5324 * to be equal to the floor or modulo of some affine combination
5325 * of the input dimensions.
5326 *
5327 * Sort the constraints first to make it easier to find such pairs
5328 * of constraints.
5329 */
5332{
5333 int d;
5335 isl_maybe_isl_aff sub;
5336
5339
5341
5343
5344 if (sub.valid < 0)
5345 goto error;
5346 if (sub.valid)
5347 return pw_multi_aff_from_map_plug_in(map, d, sub.value);
5349error:
5351 return NULL;
5352}
5353
5354/* Given an affine expression
5355 *
5356 * [A -> B] -> f(A,B)
5357 *
5358 * construct an isl_multi_aff
5359 *
5360 * [A -> B] -> B'
5361 *
5362 * such that dimension "d" in B' is set to "aff" and the remaining
5363 * dimensions are set equal to the corresponding dimensions in B.
5364 * "n_in" is the dimension of the space A.
5365 * "n_out" is the dimension of the space B.
5366 *
5367 * If "is_set" is set, then the affine expression is of the form
5368 *
5369 * [B] -> f(B)
5370 *
5371 * and we construct an isl_multi_aff
5372 *
5373 * B -> B'
5374 */
5376 unsigned n_in, unsigned n_out, int is_set)
5377{
5378 int i;
5380 isl_space *space, *space2;
5381 isl_local_space *ls;
5382
5385 space2 = isl_space_copy(space);
5386 if (!is_set)
5387 space2 = isl_space_range(isl_space_unwrap(space2));
5388 space = isl_space_map_from_domain_and_range(space, space2);
5389 ma = isl_multi_aff_alloc(space);
5390 ma = isl_multi_aff_set_aff(ma, d, aff);
5391
5392 for (i = 0; i < n_out; ++i) {
5393 if (i == d)
5394 continue;
5396 isl_dim_set, n_in + i);
5397 ma = isl_multi_aff_set_aff(ma, i, aff);
5398 }
5399
5401
5402 return ma;
5403}
5404
5405/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map,
5406 * taking into account that the dimension at position "d" can be written as
5407 *
5408 * x = m a + f(..) (1)
5409 *
5410 * where m is equal to "gcd".
5411 * "i" is the index of the equality in "hull" that defines f(..).
5412 * In particular, the equality is of the form
5413 *
5414 * f(..) - x + m g(existentials) = 0
5415 *
5416 * or
5417 *
5418 * -f(..) + x + m g(existentials) = 0
5419 *
5420 * We basically plug (1) into "map", resulting in a map with "a"
5421 * in the range instead of "x". The corresponding isl_pw_multi_aff
5422 * defining "a" is then plugged back into (1) to obtain a definition for "x".
5423 *
5424 * Specifically, given the input map
5425 *
5426 * A -> B
5427 *
5428 * We first wrap it into a set
5429 *
5430 * [A -> B]
5431 *
5432 * and define (1) on top of the corresponding space, resulting in "aff".
5433 * We use this to create an isl_multi_aff that maps the output position "d"
5434 * from "a" to "x", leaving all other (intput and output) dimensions unchanged.
5435 * We plug this into the wrapped map, unwrap the result and compute the
5436 * corresponding isl_pw_multi_aff.
5437 * The result is an expression
5438 *
5439 * A -> T(A)
5440 *
5441 * We adjust that to
5442 *
5443 * A -> [A -> T(A)]
5444 *
5445 * so that we can plug that into "aff", after extending the latter to
5446 * a mapping
5447 *
5448 * [A -> B] -> B'
5449 *
5450 *
5451 * If "map" is actually a set, then there is no "A" space, meaning
5452 * that we do not need to perform any wrapping, and that the result
5453 * of the recursive call is of the form
5454 *
5455 * [T]
5456 *
5457 * which is plugged into a mapping of the form
5458 *
5459 * B -> B'
5460 */
5463 isl_int gcd)
5464{
5465 isl_set *set;
5466 isl_space *space;
5467 isl_local_space *ls;
5468 isl_aff *aff;
5471 isl_size n_in;
5472 unsigned o_out;
5473 isl_size n_out;
5474 isl_bool is_set;
5475
5476 is_set = isl_map_is_set(map);
5477 if (is_set < 0)
5478 goto error;
5479
5482 if (n_in < 0 || n_out < 0)
5483 goto error;
5485
5486 if (is_set)
5487 set = map;
5488 else
5489 set = isl_map_wrap(map);
5491 ma = isl_multi_aff_identity(space);
5493 aff = isl_aff_alloc(ls);
5494 if (aff) {
5495 isl_int_set_si(aff->v->el[0], 1);
5496 if (isl_int_is_one(hull->eq[i][o_out + d]))
5497 isl_seq_neg(aff->v->el + 1, hull->eq[i],
5498 aff->v->size - 1);
5499 else
5500 isl_seq_cpy(aff->v->el + 1, hull->eq[i],
5501 aff->v->size - 1);
5502 isl_int_set(aff->v->el[1 + o_out + d], gcd);
5503 }
5504 ma = isl_multi_aff_set_aff(ma, n_in + d, isl_aff_copy(aff));
5506
5507 ma = range_map(aff, d, n_in, n_out, is_set);
5508
5509 if (is_set)
5510 map = set;
5511 else
5514
5515 if (!is_set) {
5517 space = isl_space_map_from_set(space);
5518 id = isl_pw_multi_aff_identity(space);
5520 }
5523
5525 return pma;
5526error:
5529 return NULL;
5530}
5531
5532/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map.
5533 * "hull" contains the equalities valid for "map".
5534 *
5535 * Check if any of the output dimensions is "strided".
5536 * That is, we check if it can be written as
5537 *
5538 * x = m a + f(..)
5539 *
5540 * with m greater than 1, a some combination of existentially quantified
5541 * variables and f an expression in the parameters and input dimensions.
5542 * If so, we remove the stride in pw_multi_aff_from_map_stride.
5543 *
5544 * Otherwise, we continue with pw_multi_aff_from_map_check_div_mod for a further
5545 * special case.
5546 */
5549{
5550 int i, j;
5551 isl_size n_out;
5552 unsigned o_out;
5553 isl_size n_div;
5554 unsigned o_div;
5555 isl_int gcd;
5556
5559 if (n_div < 0 || n_out < 0)
5560 goto error;
5561
5562 if (n_div == 0) {
5565 }
5566
5568
5571
5572 for (i = 0; i < n_out; ++i) {
5573 for (j = 0; j < hull->n_eq; ++j) {
5574 isl_int *eq = hull->eq[j];
5576
5577 if (!isl_int_is_one(eq[o_out + i]) &&
5578 !isl_int_is_negone(eq[o_out + i]))
5579 continue;
5580 if (isl_seq_any_non_zero(eq + o_out, i))
5581 continue;
5582 if (isl_seq_any_non_zero(eq + o_out + i + 1,
5583 n_out - (i + 1)))
5584 continue;
5585 isl_seq_gcd(eq + o_div, n_div, &gcd);
5586 if (isl_int_is_zero(gcd))
5587 continue;
5588 if (isl_int_is_one(gcd))
5589 continue;
5590
5592 i, j, gcd);
5594 return res;
5595 }
5596 }
5597
5601error:
5604 return NULL;
5605}
5606
5607/* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map.
5608 *
5609 * As a special case, we first check if all output dimensions are uniquely
5610 * defined in terms of the parameters and input dimensions over the entire
5611 * domain. If so, we extract the desired isl_pw_multi_aff directly
5612 * from the affine hull of "map" and its domain.
5613 *
5614 * Otherwise, continue with pw_multi_aff_from_map_check_strides for more
5615 * special cases.
5616 */
5648
5649/* This function performs the same operation as isl_pw_multi_aff_from_map,
5650 * but is considered as a function on an isl_map when exported.
5651 */
5656
5661
5662/* This function performs the same operation as isl_pw_multi_aff_from_set,
5663 * but is considered as a function on an isl_set when exported.
5664 */
5669
5670/* Convert "map" into an isl_pw_multi_aff (if possible) and
5671 * add it to *user.
5672 */
5683
5684/* Create an isl_union_pw_multi_aff with the given isl_aff on a universe
5685 * domain.
5686 */
5697
5698/* Try and create an isl_union_pw_multi_aff that is equivalent
5699 * to the given isl_union_map.
5700 * The isl_union_map is required to be single-valued in each space.
5701 * Otherwise, an error is produced.
5702 */
5705{
5706 isl_space *space;
5708
5709 space = isl_union_map_get_space(umap);
5710 upma = isl_union_pw_multi_aff_empty(space);
5711 if (isl_union_map_foreach_map(umap, &pw_multi_aff_from_map, &upma) < 0)
5712 upma = isl_union_pw_multi_aff_free(upma);
5713 isl_union_map_free(umap);
5714
5715 return upma;
5716}
5717
5718/* This function performs the same operation as
5719 * isl_union_pw_multi_aff_from_union_map,
5720 * but is considered as a function on an isl_union_map when exported.
5721 */
5727
5728/* Try and create an isl_union_pw_multi_aff that is equivalent
5729 * to the given isl_union_set.
5730 * The isl_union_set is required to be a singleton in each space.
5731 * Otherwise, an error is produced.
5732 */
5738
5739/* Return the piecewise affine expression "set ? 1 : 0".
5740 */
5756
5757/* Plug in "subs" for dimension "type", "pos" of "aff".
5758 *
5759 * Let i be the dimension to replace and let "subs" be of the form
5760 *
5761 * f/d
5762 *
5763 * and "aff" of the form
5764 *
5765 * (a i + g)/m
5766 *
5767 * The result is
5768 *
5769 * (a f + d g')/(m d)
5770 *
5771 * where g' is the result of plugging in "subs" in each of the integer
5772 * divisions in g.
5773 */
5775 enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
5776{
5777 isl_ctx *ctx;
5778 isl_int v;
5779 isl_size n_div;
5780
5781 aff = isl_aff_cow(aff);
5782 if (!aff || !subs)
5783 return isl_aff_free(aff);
5784
5785 ctx = isl_aff_get_ctx(aff);
5786 if (!isl_space_is_equal(aff->ls->dim, subs->ls->dim))
5788 "spaces don't match", return isl_aff_free(aff));
5789 n_div = isl_aff_domain_dim(subs, isl_dim_div);
5790 if (n_div < 0)
5791 return isl_aff_free(aff);
5792 if (n_div != 0)
5794 "cannot handle divs yet", return isl_aff_free(aff));
5795
5796 aff->ls = isl_local_space_substitute(aff->ls, type, pos, subs);
5797 if (!aff->ls)
5798 return isl_aff_free(aff);
5799
5800 aff->v = isl_vec_cow(aff->v);
5801 if (!aff->v)
5802 return isl_aff_free(aff);
5803
5805
5806 isl_int_init(v);
5807 isl_seq_substitute(aff->v->el, pos, subs->v->el,
5808 aff->v->size, subs->v->size, v);
5809 isl_int_clear(v);
5810
5811 return aff;
5812}
5813
5814/* Plug in "subs" for dimension "type", "pos" in each of the affine
5815 * expressions in "maff".
5816 */
5818 __isl_take isl_multi_aff *maff, enum isl_dim_type type, unsigned pos,
5819 __isl_keep isl_aff *subs)
5820{
5821 isl_size n;
5822 int i;
5823
5824 n = isl_multi_aff_size(maff);
5825 if (n < 0 || !subs)
5826 return isl_multi_aff_free(maff);
5827
5828 if (type == isl_dim_in)
5829 type = isl_dim_set;
5830
5831 for (i = 0; i < n; ++i) {
5832 isl_aff *aff;
5833
5834 aff = isl_multi_aff_take_at(maff, i);
5835 aff = isl_aff_substitute(aff, type, pos, subs);
5836 maff = isl_multi_aff_restore_at(maff, i, aff);
5837 }
5838
5839 return maff;
5840}
5841
5842/* Plug in "subs" for input dimension "pos" of "pma".
5843 *
5844 * pma is of the form
5845 *
5846 * A_i(v) -> M_i(v)
5847 *
5848 * while subs is of the form
5849 *
5850 * v' = B_j(v) -> S_j
5851 *
5852 * Each pair i,j such that C_ij = A_i \cap B_i is non-empty
5853 * has a contribution in the result, in particular
5854 *
5855 * C_ij(S_j) -> M_i(S_j)
5856 *
5857 * Note that plugging in S_j in C_ij may also result in an empty set
5858 * and this contribution should simply be discarded.
5859 */
5862 __isl_keep isl_pw_aff *subs)
5863{
5864 int i, j, n;
5866
5867 if (!pma || !subs)
5868 return isl_pw_multi_aff_free(pma);
5869
5870 n = pma->n * subs->n;
5871 res = isl_pw_multi_aff_alloc_size(isl_space_copy(pma->dim), n);
5872
5873 for (i = 0; i < pma->n; ++i) {
5874 for (j = 0; j < subs->n; ++j) {
5875 isl_set *common;
5876 isl_multi_aff *res_ij;
5877 int empty;
5878
5879 common = isl_set_intersect(
5880 isl_set_copy(pma->p[i].set),
5881 isl_set_copy(subs->p[j].set));
5882 common = isl_set_substitute(common,
5883 pos, subs->p[j].aff);
5884 empty = isl_set_plain_is_empty(common);
5885 if (empty < 0 || empty) {
5886 isl_set_free(common);
5887 if (empty < 0)
5888 goto error;
5889 continue;
5890 }
5891
5892 res_ij = isl_multi_aff_substitute(
5893 isl_multi_aff_copy(pma->p[i].maff),
5894 isl_dim_in, pos, subs->p[j].aff);
5895
5896 res = isl_pw_multi_aff_add_piece(res, common, res_ij);
5897 }
5898 }
5899
5901 return res;
5902error:
5905 return NULL;
5906}
5907
5908/* Compute the preimage of a range of dimensions in the affine expression "src"
5909 * under "ma" and put the result in "dst". The number of dimensions in "src"
5910 * that precede the range is given by "n_before". The number of dimensions
5911 * in the range is given by the number of output dimensions of "ma".
5912 * The number of dimensions that follow the range is given by "n_after".
5913 * If "has_denom" is set (to one),
5914 * then "src" and "dst" have an extra initial denominator.
5915 * "n_div_ma" is the number of existentials in "ma"
5916 * "n_div_bset" is the number of existentials in "src"
5917 * The resulting "dst" (which is assumed to have been allocated by
5918 * the caller) contains coefficients for both sets of existentials,
5919 * first those in "ma" and then those in "src".
5920 * f, c1, c2 and g are temporary objects that have been initialized
5921 * by the caller.
5922 *
5923 * Let src represent the expression
5924 *
5925 * (a(p) + f_u u + b v + f_w w + c(divs))/d
5926 *
5927 * and let ma represent the expressions
5928 *
5929 * v_i = (r_i(p) + s_i(y) + t_i(divs'))/m_i
5930 *
5931 * We start out with the following expression for dst:
5932 *
5933 * (a(p) + f_u u + 0 y + f_w w + 0 divs' + c(divs) + f \sum_i b_i v_i)/d
5934 *
5935 * with the multiplication factor f initially equal to 1
5936 * and f \sum_i b_i v_i kept separately.
5937 * For each x_i that we substitute, we multiply the numerator
5938 * (and denominator) of dst by c_1 = m_i and add the numerator
5939 * of the x_i expression multiplied by c_2 = f b_i,
5940 * after removing the common factors of c_1 and c_2.
5941 * The multiplication factor f also needs to be multiplied by c_1
5942 * for the next x_j, j > i.
5943 */
5945 __isl_keep isl_multi_aff *ma, int n_before, int n_after,
5946 int n_div_ma, int n_div_bmap,
5947 isl_int f, isl_int c1, isl_int c2, isl_int g, int has_denom)
5948{
5949 int i;
5950 isl_size n_param, n_in, n_out;
5951 int o_dst, o_src;
5952
5953 n_param = isl_multi_aff_dim(ma, isl_dim_param);
5954 n_in = isl_multi_aff_dim(ma, isl_dim_in);
5955 n_out = isl_multi_aff_dim(ma, isl_dim_out);
5956 if (n_param < 0 || n_in < 0 || n_out < 0)
5957 return isl_stat_error;
5958
5959 isl_seq_cpy(dst, src, has_denom + 1 + n_param + n_before);
5960 o_dst = o_src = has_denom + 1 + n_param + n_before;
5961 isl_seq_clr(dst + o_dst, n_in);
5962 o_dst += n_in;
5963 o_src += n_out;
5964 isl_seq_cpy(dst + o_dst, src + o_src, n_after);
5965 o_dst += n_after;
5966 o_src += n_after;
5967 isl_seq_clr(dst + o_dst, n_div_ma);
5968 o_dst += n_div_ma;
5969 isl_seq_cpy(dst + o_dst, src + o_src, n_div_bmap);
5970
5971 isl_int_set_si(f, 1);
5972
5973 for (i = 0; i < n_out; ++i) {
5974 int offset = has_denom + 1 + n_param + n_before + i;
5975
5976 if (isl_int_is_zero(src[offset]))
5977 continue;
5978 isl_int_set(c1, ma->u.p[i]->v->el[0]);
5979 isl_int_mul(c2, f, src[offset]);
5980 isl_int_gcd(g, c1, c2);
5981 isl_int_divexact(c1, c1, g);
5982 isl_int_divexact(c2, c2, g);
5983
5984 isl_int_mul(f, f, c1);
5985 o_dst = has_denom;
5986 o_src = 1;
5987 isl_seq_combine(dst + o_dst, c1, dst + o_dst,
5988 c2, ma->u.p[i]->v->el + o_src, 1 + n_param);
5989 o_dst += 1 + n_param;
5990 o_src += 1 + n_param;
5991 isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_before);
5992 o_dst += n_before;
5993 isl_seq_combine(dst + o_dst, c1, dst + o_dst,
5994 c2, ma->u.p[i]->v->el + o_src, n_in);
5995 o_dst += n_in;
5996 o_src += n_in;
5997 isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_after);
5998 o_dst += n_after;
5999 isl_seq_combine(dst + o_dst, c1, dst + o_dst,
6000 c2, ma->u.p[i]->v->el + o_src, n_div_ma);
6001 o_dst += n_div_ma;
6002 o_src += n_div_ma;
6003 isl_seq_scale(dst + o_dst, dst + o_dst, c1, n_div_bmap);
6004 if (has_denom)
6005 isl_int_mul(dst[0], dst[0], c1);
6006 }
6007
6008 return isl_stat_ok;
6009}
6010
6011/* Compute the pullback of "aff" by the function represented by "ma".
6012 * In other words, plug in "ma" in "aff". The result is an affine expression
6013 * defined over the domain space of "ma".
6014 *
6015 * If "aff" is represented by
6016 *
6017 * (a(p) + b x + c(divs))/d
6018 *
6019 * and ma is represented by
6020 *
6021 * x = D(p) + F(y) + G(divs')
6022 *
6023 * then the result is
6024 *
6025 * (a(p) + b D(p) + b F(y) + b G(divs') + c(divs))/d
6026 *
6027 * The divs in the local space of the input are similarly adjusted
6028 * through a call to isl_local_space_preimage_multi_aff.
6029 */
6032{
6033 isl_aff *res = NULL;
6034 isl_local_space *ls;
6035 isl_size n_div_aff, n_div_ma;
6036 isl_int f, c1, c2, g;
6037
6039 if (!aff || !ma)
6040 goto error;
6041
6042 n_div_aff = isl_aff_dim(aff, isl_dim_div);
6043 n_div_ma = ma->n ? isl_aff_dim(ma->u.p[0], isl_dim_div) : 0;
6044 if (n_div_aff < 0 || n_div_ma < 0)
6045 goto error;
6046
6048 ls = isl_local_space_preimage_multi_aff(ls, isl_multi_aff_copy(ma));
6049 res = isl_aff_alloc(ls);
6050 if (!res)
6051 goto error;
6052
6053 isl_int_init(f);
6056 isl_int_init(g);
6057
6058 if (isl_seq_preimage(res->v->el, aff->v->el, ma, 0, 0,
6059 n_div_ma, n_div_aff, f, c1, c2, g, 1) < 0)
6060 res = isl_aff_free(res);
6061
6065 isl_int_clear(g);
6066
6068 isl_multi_aff_free(ma);
6070 return res;
6071error:
6073 isl_multi_aff_free(ma);
6075 return NULL;
6076}
6077
6078/* Compute the pullback of "aff1" by the function represented by "aff2".
6079 * In other words, plug in "aff2" in "aff1". The result is an affine expression
6080 * defined over the domain space of "aff1".
6081 *
6082 * The domain of "aff1" should match the range of "aff2", which means
6083 * that it should be single-dimensional.
6084 */
6093
6094/* Compute the pullback of "ma1" by the function represented by "ma2".
6095 * In other words, plug in "ma2" in "ma1".
6096 */
6099{
6100 int i;
6101 isl_size n;
6102 isl_space *space = NULL;
6103
6104 isl_multi_aff_align_params_bin(&ma1, &ma2);
6105 ma2 = isl_multi_aff_align_divs(ma2);
6106 n = isl_multi_aff_size(ma1);
6107 if (n < 0 || !ma2)
6108 goto error;
6109
6110 space = isl_space_join(isl_multi_aff_get_space(ma2),
6111 isl_multi_aff_get_space(ma1));
6112
6113 for (i = 0; i < n; ++i) {
6114 isl_aff *aff;
6115
6116 aff = isl_multi_aff_take_at(ma1, i);
6117 aff = isl_aff_pullback_multi_aff(aff, isl_multi_aff_copy(ma2));
6118 ma1 = isl_multi_aff_restore_at(ma1, i, aff);
6119 }
6120
6121 ma1 = isl_multi_aff_reset_space(ma1, space);
6122 isl_multi_aff_free(ma2);
6123 return ma1;
6124error:
6125 isl_space_free(space);
6126 isl_multi_aff_free(ma2);
6127 isl_multi_aff_free(ma1);
6128 return NULL;
6129}
6130
6131/* Extend the local space of "dst" to include the divs
6132 * in the local space of "src".
6133 *
6134 * If "src" does not have any divs or if the local spaces of "dst" and
6135 * "src" are the same, then no extension is required.
6136 */
6138 __isl_keep isl_aff *src)
6139{
6140 isl_ctx *ctx;
6141 isl_size src_n_div, dst_n_div;
6142 int *exp1 = NULL;
6143 int *exp2 = NULL;
6145 isl_mat *div;
6146
6147 if (!src || !dst)
6148 return isl_aff_free(dst);
6149
6150 ctx = isl_aff_get_ctx(src);
6151 equal = isl_local_space_has_equal_space(src->ls, dst->ls);
6152 if (equal < 0)
6153 return isl_aff_free(dst);
6154 if (!equal)
6156 "spaces don't match", goto error);
6157
6158 src_n_div = isl_aff_domain_dim(src, isl_dim_div);
6159 dst_n_div = isl_aff_domain_dim(dst, isl_dim_div);
6160 if (src_n_div == 0)
6161 return dst;
6162 equal = isl_local_space_is_equal(src->ls, dst->ls);
6163 if (equal < 0 || src_n_div < 0 || dst_n_div < 0)
6164 return isl_aff_free(dst);
6165 if (equal)
6166 return dst;
6167
6168 exp1 = isl_alloc_array(ctx, int, src_n_div);
6169 exp2 = isl_alloc_array(ctx, int, dst_n_div);
6170 if (!exp1 || (dst_n_div && !exp2))
6171 goto error;
6172
6173 div = isl_merge_divs(src->ls->div, dst->ls->div, exp1, exp2);
6174 dst = isl_aff_expand_divs(dst, div, exp2);
6175 free(exp1);
6176 free(exp2);
6177
6178 return dst;
6179error:
6180 free(exp1);
6181 free(exp2);
6182 return isl_aff_free(dst);
6183}
6184
6185/* Adjust the local spaces of the affine expressions in "maff"
6186 * such that they all have the save divs.
6187 */
6190{
6191 isl_aff *aff_0;
6192 isl_size n;
6193 int i;
6194
6195 n = isl_multi_aff_size(maff);
6196 if (n < 0)
6197 return isl_multi_aff_free(maff);
6198 if (n <= 1)
6199 return maff;
6200
6201 aff_0 = isl_multi_aff_take_at(maff, 0);
6202 for (i = 1; i < n; ++i) {
6203 isl_aff *aff_i;
6204
6205 aff_i = isl_multi_aff_peek_at(maff, i);
6206 aff_0 = isl_aff_align_divs(aff_0, aff_i);
6207 }
6208 maff = isl_multi_aff_restore_at(maff, 0, aff_0);
6209
6210 aff_0 = isl_multi_aff_peek_at(maff, 0);
6211 for (i = 1; i < n; ++i) {
6212 isl_aff *aff_i;
6213
6214 aff_i = isl_multi_aff_take_at(maff, i);
6215 aff_i = isl_aff_align_divs(aff_i, aff_0);
6216 maff = isl_multi_aff_restore_at(maff, i, aff_i);
6217 }
6218
6219 return maff;
6220}
6221
6223{
6224 aff = isl_aff_cow(aff);
6225 if (!aff)
6226 return NULL;
6227
6228 aff->ls = isl_local_space_lift(aff->ls);
6229 if (!aff->ls)
6230 return isl_aff_free(aff);
6231
6232 return aff;
6233}
6234
6235/* Lift "maff" to a space with extra dimensions such that the result
6236 * has no more existentially quantified variables.
6237 * If "ls" is not NULL, then *ls is assigned the local space that lies
6238 * at the basis of the lifting applied to "maff".
6239 */
6242{
6243 int i;
6244 isl_space *space;
6245 isl_aff *aff;
6246 isl_size n, n_div;
6247
6248 if (ls)
6249 *ls = NULL;
6250
6251 n = isl_multi_aff_size(maff);
6252 if (n < 0)
6253 return isl_multi_aff_free(maff);
6254
6255 if (n == 0) {
6256 if (ls) {
6257 isl_space *space = isl_multi_aff_get_domain_space(maff);
6258 *ls = isl_local_space_from_space(space);
6259 if (!*ls)
6260 return isl_multi_aff_free(maff);
6261 }
6262 return maff;
6263 }
6264
6265 maff = isl_multi_aff_align_divs(maff);
6266
6267 aff = isl_multi_aff_peek_at(maff, 0);
6268 n_div = isl_aff_dim(aff, isl_dim_div);
6269 if (n_div < 0)
6270 return isl_multi_aff_free(maff);
6271 space = isl_multi_aff_get_space(maff);
6272 space = isl_space_lift(isl_space_domain(space), n_div);
6274 isl_multi_aff_get_space(maff));
6275 maff = isl_multi_aff_restore_space(maff, space);
6276
6277 if (ls) {
6278 aff = isl_multi_aff_peek_at(maff, 0);
6280 if (!*ls)
6281 return isl_multi_aff_free(maff);
6282 }
6283
6284 for (i = 0; i < n; ++i) {
6285 aff = isl_multi_aff_take_at(maff, i);
6286 aff = isl_aff_lift(aff);
6287 maff = isl_multi_aff_restore_at(maff, i, aff);
6288 }
6289
6290 return maff;
6291}
6292
6293#undef TYPE
6294#define TYPE isl_pw_multi_aff
6295static
6296#include "check_type_range_templ.c"
6297
6298/* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma".
6299 */
6302{
6303 int i;
6304 isl_size n_out;
6305 isl_space *space;
6306 isl_pw_aff *pa;
6307
6308 if (isl_pw_multi_aff_check_range(pma, isl_dim_out, pos, 1) < 0)
6309 return NULL;
6310
6312 if (n_out < 0)
6313 return NULL;
6314
6316 space = isl_space_drop_dims(space, isl_dim_out,
6317 pos + 1, n_out - pos - 1);
6318 space = isl_space_drop_dims(space, isl_dim_out, 0, pos);
6319
6320 pa = isl_pw_aff_alloc_size(space, pma->n);
6321 for (i = 0; i < pma->n; ++i) {
6322 isl_aff *aff;
6323 aff = isl_multi_aff_get_aff(pma->p[i].maff, pos);
6324 pa = isl_pw_aff_add_piece(pa, isl_set_copy(pma->p[i].set), aff);
6325 }
6326
6327 return pa;
6328}
6329
6330/* This is an alternative name for the function above.
6331 */
6337
6338/* Return an isl_pw_multi_aff with the given "set" as domain and
6339 * an unnamed zero-dimensional range.
6340 */
6343{
6345 isl_space *space;
6346
6347 space = isl_set_get_space(set);
6348 space = isl_space_from_domain(space);
6349 ma = isl_multi_aff_zero(space);
6350 return isl_pw_multi_aff_alloc(set, ma);
6351}
6352
6353/* Add an isl_pw_multi_aff with the given "set" as domain and
6354 * an unnamed zero-dimensional range to *user.
6355 */
6367
6368/* Return an isl_union_pw_multi_aff with the given "uset" as domain and
6369 * an unnamed zero-dimensional range.
6370 */
6373{
6374 isl_space *space;
6376
6377 if (!uset)
6378 return NULL;
6379
6380 space = isl_union_set_get_space(uset);
6381 upma = isl_union_pw_multi_aff_empty(space);
6382
6384 &add_pw_multi_aff_from_domain, &upma) < 0)
6385 goto error;
6386
6387 isl_union_set_free(uset);
6388 return upma;
6389error:
6390 isl_union_set_free(uset);
6392 return NULL;
6393}
6394
6395/* Local data for bin_entry and the callback "fn".
6396 */
6403
6404/* Given an isl_pw_multi_aff from upma1, store it in data->pma
6405 * and call data->fn for each isl_pw_multi_aff in data->upma2.
6406 */
6408{
6410 isl_stat r;
6411
6412 data->pma = pma;
6414 data->fn, data);
6416
6417 return r;
6418}
6419
6420/* Call "fn" on each pair of isl_pw_multi_affs in "upma1" and "upma2".
6421 * The isl_pw_multi_aff from upma1 is stored in data->pma (where data is
6422 * passed as user field) and the isl_pw_multi_aff from upma2 is available
6423 * as *entry. The callback should adjust data->res if desired.
6424 */
6429{
6430 isl_space *space;
6431 struct isl_union_pw_multi_aff_bin_data data = { NULL, NULL, NULL, fn };
6432
6434 upma1 = isl_union_pw_multi_aff_align_params(upma1, space);
6435 space = isl_union_pw_multi_aff_get_space(upma1);
6437
6438 if (!upma1 || !upma2)
6439 goto error;
6440
6441 data.upma2 = upma2;
6442 data.res = isl_union_pw_multi_aff_alloc_same_size(upma1);
6444 &bin_entry, &data) < 0)
6445 goto error;
6446
6449 return data.res;
6450error:
6454 return NULL;
6455}
6456
6457/* Given two isl_pw_multi_affs A -> B and C -> D,
6458 * construct an isl_pw_multi_aff (A * C) -> [B -> D].
6459 */
6462{
6463 isl_space *space;
6464
6465 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
6468 return isl_pw_multi_aff_on_shared_domain_in(pma1, pma2, space,
6469 &isl_multi_aff_range_product);
6470}
6471
6472/* Given two isl_pw_multi_affs A -> B and C -> D,
6473 * construct an isl_pw_multi_aff (A * C) -> (B, D).
6474 */
6477{
6478 isl_space *space;
6479
6480 isl_pw_multi_aff_align_params_bin(&pma1, &pma2);
6483 space = isl_space_flatten_range(space);
6484 return isl_pw_multi_aff_on_shared_domain_in(pma1, pma2, space,
6485 &isl_multi_aff_flat_range_product);
6486}
6487
6488/* If data->pma and "pma2" have the same domain space, then use "range_product"
6489 * to compute some form of range product and add the result to data->res.
6490 */
6495 void *user)
6496{
6499 isl_space *space1, *space2;
6500
6501 space1 = isl_pw_multi_aff_peek_space(data->pma);
6502 space2 = isl_pw_multi_aff_peek_space(pma2);
6504 space2, isl_dim_in);
6505 if (match < 0 || !match) {
6507 return match < 0 ? isl_stat_error : isl_stat_ok;
6508 }
6509
6510 pma2 = range_product(isl_pw_multi_aff_copy(data->pma), pma2);
6511
6512 data->res = isl_union_pw_multi_aff_add_pw_multi_aff(data->res, pma2);
6513
6514 return isl_stat_ok;
6515}
6516
6517/* If data->pma and "pma2" have the same domain space, then compute
6518 * their flat range product and add the result to data->res.
6519 */
6526
6527/* Given two isl_union_pw_multi_affs A -> B and C -> D,
6528 * construct an isl_union_pw_multi_aff (A * C) -> (B, D).
6529 */
6536
6537/* If data->pma and "pma2" have the same domain space, then compute
6538 * their range product and add the result to data->res.
6539 */
6546
6547/* Given two isl_union_pw_multi_affs A -> B and C -> D,
6548 * construct an isl_union_pw_multi_aff (A * C) -> [B -> D].
6549 */
6556
6557/* Replace the affine expressions at position "pos" in "pma" by "pa".
6558 * The parameters are assumed to have been aligned.
6559 *
6560 * The implementation essentially performs an isl_pw_*_on_shared_domain,
6561 * except that it works on two different isl_pw_* types.
6562 */
6566{
6567 int i, j, n;
6568 isl_pw_multi_aff *res = NULL;
6569
6570 if (!pma || !pa)
6571 goto error;
6572
6574 pa->dim, isl_dim_in))
6576 "domains don't match", goto error);
6577 if (isl_pw_multi_aff_check_range(pma, isl_dim_out, pos, 1) < 0)
6578 goto error;
6579
6580 n = pma->n * pa->n;
6581 res = isl_pw_multi_aff_alloc_size(isl_pw_multi_aff_get_space(pma), n);
6582
6583 for (i = 0; i < pma->n; ++i) {
6584 for (j = 0; j < pa->n; ++j) {
6585 isl_set *common;
6586 isl_multi_aff *res_ij;
6587 int empty;
6588
6589 common = isl_set_intersect(isl_set_copy(pma->p[i].set),
6590 isl_set_copy(pa->p[j].set));
6591 empty = isl_set_plain_is_empty(common);
6592 if (empty < 0 || empty) {
6593 isl_set_free(common);
6594 if (empty < 0)
6595 goto error;
6596 continue;
6597 }
6598
6599 res_ij = isl_multi_aff_set_aff(
6600 isl_multi_aff_copy(pma->p[i].maff), pos,
6601 isl_aff_copy(pa->p[j].aff));
6602 res_ij = isl_multi_aff_gist(res_ij,
6603 isl_set_copy(common));
6604
6605 res = isl_pw_multi_aff_add_piece(res, common, res_ij);
6606 }
6607 }
6608
6611 return res;
6612error:
6615 return isl_pw_multi_aff_free(res);
6616}
6617
6618/* Replace the affine expressions at position "pos" in "pma" by "pa".
6619 */
6623{
6624 isl_bool equal_params;
6625
6626 if (!pma || !pa)
6627 goto error;
6628 equal_params = isl_space_has_equal_params(pma->dim, pa->dim);
6629 if (equal_params < 0)
6630 goto error;
6631 if (equal_params)
6635 goto error;
6639error:
6642 return NULL;
6643}
6644
6645/* Do the parameters of "pa" match those of "space"?
6646 */
6648 __isl_keep isl_space *space)
6649{
6650 isl_space *pa_space;
6652
6653 if (!pa || !space)
6654 return isl_bool_error;
6655
6656 pa_space = isl_pw_aff_get_space(pa);
6657
6658 match = isl_space_has_equal_params(space, pa_space);
6659
6660 isl_space_free(pa_space);
6661 return match;
6662}
6663
6664/* Check that the domain space of "pa" matches "space".
6665 */
6667 __isl_keep isl_space *space)
6668{
6669 isl_space *pa_space;
6671
6672 if (!pa || !space)
6673 return isl_stat_error;
6674
6675 pa_space = isl_pw_aff_get_space(pa);
6676
6677 match = isl_space_has_equal_params(space, pa_space);
6678 if (match < 0)
6679 goto error;
6680 if (!match)
6682 "parameters don't match", goto error);
6684 pa_space, isl_dim_in);
6685 if (match < 0)
6686 goto error;
6687 if (!match)
6689 "domains don't match", goto error);
6690 isl_space_free(pa_space);
6691 return isl_stat_ok;
6692error:
6693 isl_space_free(pa_space);
6694 return isl_stat_error;
6695}
6696
6697#undef BASE
6698#define BASE pw_aff
6699#undef DOMBASE
6700#define DOMBASE set
6701
6704#include <isl_multi_templ.c>
6705#include <isl_multi_un_op_templ.c>
6708#include <isl_multi_align_set.c>
6710#include <isl_multi_arith_templ.c>
6711#include <isl_multi_bind_templ.c>
6713#include <isl_multi_coalesce.c>
6714#include <isl_multi_domain_templ.c>
6716#include <isl_multi_dim_id_templ.c>
6717#include <isl_multi_dims.c>
6720#include <isl_multi_gist.c>
6721#include <isl_multi_hash.c>
6724#include <isl_multi_intersect.c>
6727#include <isl_multi_nan_templ.c>
6728#include <isl_multi_param_templ.c>
6730#include <isl_multi_splice_templ.c>
6733#include <isl_multi_zero_templ.c>
6735
6736/* Is every element of "mpa" defined over a single universe domain?
6737 */
6739{
6740 return isl_multi_pw_aff_every(mpa, &isl_pw_aff_isa_aff);
6741}
6742
6743/* Given that every element of "mpa" is defined over a single universe domain,
6744 * return the corresponding base expressions.
6745 */
6748{
6749 int i;
6750 isl_size n;
6752
6753 n = isl_multi_pw_aff_size(mpa);
6754 if (n < 0)
6755 mpa = isl_multi_pw_aff_free(mpa);
6756 ma = isl_multi_aff_alloc(isl_multi_pw_aff_get_space(mpa));
6757 for (i = 0; i < n; ++i) {
6758 isl_aff *aff;
6759
6760 aff = isl_pw_aff_as_aff(isl_multi_pw_aff_get_at(mpa, i));
6761 ma = isl_multi_aff_set_aff(ma, i, aff);
6762 }
6763 isl_multi_pw_aff_free(mpa);
6764 return ma;
6765}
6766
6767/* If "mpa" has an explicit domain, then intersect the domain of "map"
6768 * with this explicit domain.
6769 */
6772{
6773 isl_set *dom;
6774
6775 if (!isl_multi_pw_aff_has_explicit_domain(mpa))
6776 return map;
6777
6778 dom = isl_multi_pw_aff_domain(isl_multi_pw_aff_copy(mpa));
6780
6781 return map;
6782}
6783
6784/* Are all elements of "mpa" piecewise constants?
6785 */
6787{
6788 return isl_multi_pw_aff_every(mpa, &isl_pw_aff_is_cst);
6789}
6790
6791/* Does "mpa" have a non-trivial explicit domain?
6792 *
6793 * The explicit domain, if present, is trivial if it represents
6794 * an (obviously) universe set.
6795 */
6798{
6799 if (!mpa)
6800 return isl_bool_error;
6801 if (!isl_multi_pw_aff_has_explicit_domain(mpa))
6802 return isl_bool_false;
6803 return isl_bool_not(isl_set_plain_is_universe(mpa->u.dom));
6804}
6805
6806#undef BASE
6807#define BASE set
6808
6809#include "isl_opt_mpa_templ.c"
6810
6811/* Compute the minima of the set dimensions as a function of the
6812 * parameters, but independently of the other set dimensions.
6813 */
6818
6819/* Compute the maxima of the set dimensions as a function of the
6820 * parameters, but independently of the other set dimensions.
6821 */
6826
6827#undef BASE
6828#define BASE map
6829
6830#include "isl_opt_mpa_templ.c"
6831
6832/* Compute the minima of the output dimensions as a function of the
6833 * parameters and input dimensions, but independently of
6834 * the other output dimensions.
6835 */
6840
6841/* Compute the maxima of the output dimensions as a function of the
6842 * parameters and input dimensions, but independently of
6843 * the other output dimensions.
6844 */
6849
6850#undef TYPE
6851#define TYPE isl_pw_multi_aff
6853
6854/* Apply "fn" to the base expressions of "pma" and "mv".
6855 */
6860{
6861 int i;
6862 isl_size n;
6863
6864 if (isl_pw_multi_aff_check_match_range_multi_val(pma, mv) < 0)
6865 goto error;
6866
6868 if (n < 0)
6869 goto error;
6870
6871 for (i = 0; i < n; ++i) {
6873
6874 ma = isl_pw_multi_aff_take_base_at(pma, i);
6875 ma = fn(ma, isl_multi_val_copy(mv));
6876 pma = isl_pw_multi_aff_restore_base_at(pma, i, ma);
6877 }
6878
6879 isl_multi_val_free(mv);
6880 return pma;
6881error:
6882 isl_multi_val_free(mv);
6884 return NULL;
6885}
6886
6887/* Scale the elements of "pma" by the corresponding elements of "mv".
6888 */
6895
6896/* Scale the elements of "pma" down by the corresponding elements of "mv".
6897 */
6904
6905/* This function is called for each entry of an isl_union_pw_multi_aff.
6906 * If the space of the entry matches that of data->mv,
6907 * then apply isl_pw_multi_aff_scale_multi_val and return the result.
6908 * Otherwise, return an empty isl_pw_multi_aff.
6909 */
6912{
6914 isl_multi_val *mv = user;
6915
6916 equal = isl_pw_multi_aff_match_range_multi_val(pma, mv);
6917 if (equal < 0)
6918 return isl_pw_multi_aff_free(pma);
6919 if (!equal) {
6922 return isl_pw_multi_aff_empty(space);
6923 }
6924
6925 return isl_pw_multi_aff_scale_multi_val(pma, isl_multi_val_copy(mv));
6926}
6927
6928/* Scale the elements of "upma" by the corresponding elements of "mv",
6929 * for those entries that match the space of "mv".
6930 */
6933{
6934 struct isl_union_pw_multi_aff_transform_control control = {
6936 .fn_user = mv,
6937 };
6938
6940 isl_multi_val_get_space(mv));
6941 mv = isl_multi_val_align_params(mv,
6943 if (!upma || !mv)
6944 goto error;
6945
6946 return isl_union_pw_multi_aff_transform(upma, &control);
6947
6948 isl_multi_val_free(mv);
6949 return upma;
6950error:
6951 isl_multi_val_free(mv);
6953 return NULL;
6954}
6955
6956/* Construct and return a piecewise multi affine expression
6957 * in the given space with value zero in each of the output dimensions and
6958 * a universe domain.
6959 */
6964
6965/* Construct and return a piecewise multi affine expression
6966 * that is equal to the given piecewise affine expression.
6967 */
6970{
6971 int i;
6972 isl_space *space;
6974
6975 if (!pa)
6976 return NULL;
6977
6978 space = isl_pw_aff_get_space(pa);
6979 pma = isl_pw_multi_aff_alloc_size(space, pa->n);
6980
6981 for (i = 0; i < pa->n; ++i) {
6982 isl_set *set;
6984
6985 set = isl_set_copy(pa->p[i].set);
6987 pma = isl_pw_multi_aff_add_piece(pma, set, ma);
6988 }
6989
6991 return pma;
6992}
6993
6994/* Construct and return a piecewise multi affine expression
6995 * that is equal to the given multi piecewise affine expression
6996 * on the shared domain of the piecewise affine expressions,
6997 * in the special case of a 0D multi piecewise affine expression.
6998 *
6999 * Create a piecewise multi affine expression with the explicit domain of
7000 * the 0D multi piecewise affine expression as domain.
7001 */
7004{
7005 isl_space *space;
7006 isl_set *dom;
7008
7009 space = isl_multi_pw_aff_get_space(mpa);
7010 dom = isl_multi_pw_aff_get_explicit_domain(mpa);
7011 isl_multi_pw_aff_free(mpa);
7012
7013 ma = isl_multi_aff_zero(space);
7014 return isl_pw_multi_aff_alloc(dom, ma);
7015}
7016
7017/* Construct and return a piecewise multi affine expression
7018 * that is equal to the given multi piecewise affine expression
7019 * on the shared domain of the piecewise affine expressions.
7020 */
7023{
7024 int i;
7025 isl_space *space;
7026 isl_pw_aff *pa;
7028
7029 if (!mpa)
7030 return NULL;
7031
7032 if (mpa->n == 0)
7034
7035 space = isl_multi_pw_aff_get_space(mpa);
7036 pa = isl_multi_pw_aff_get_pw_aff(mpa, 0);
7038
7039 for (i = 1; i < mpa->n; ++i) {
7040 isl_pw_multi_aff *pma_i;
7041
7042 pa = isl_multi_pw_aff_get_pw_aff(mpa, i);
7045 }
7046
7048
7049 isl_multi_pw_aff_free(mpa);
7050 return pma;
7051}
7052
7053/* Convenience function that constructs an isl_multi_pw_aff
7054 * directly from an isl_aff.
7055 */
7060
7061/* Construct and return a multi piecewise affine expression
7062 * that is equal to the given multi affine expression.
7063 */
7066{
7067 int i;
7068 isl_size n;
7069 isl_multi_pw_aff *mpa;
7070
7071 n = isl_multi_aff_dim(ma, isl_dim_out);
7072 if (n < 0)
7073 ma = isl_multi_aff_free(ma);
7074 if (!ma)
7075 return NULL;
7076
7077 mpa = isl_multi_pw_aff_alloc(isl_multi_aff_get_space(ma));
7078
7079 for (i = 0; i < n; ++i) {
7080 isl_pw_aff *pa;
7081
7082 pa = isl_pw_aff_from_aff(isl_multi_aff_get_aff(ma, i));
7083 mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
7084 }
7085
7086 isl_multi_aff_free(ma);
7087 return mpa;
7088}
7089
7090/* This function performs the same operation as isl_multi_pw_aff_from_multi_aff,
7091 * but is considered as a function on an isl_multi_aff when exported.
7092 */
7098
7099/* Construct and return a multi piecewise affine expression
7100 * that is equal to the given piecewise multi affine expression.
7101 *
7102 * If the resulting multi piecewise affine expression has
7103 * an explicit domain, then assign it the domain of the input.
7104 * In other cases, the domain is stored in the individual elements.
7105 */
7108{
7109 int i;
7110 isl_size n;
7111 isl_space *space;
7112 isl_multi_pw_aff *mpa;
7113
7115 if (n < 0)
7118 mpa = isl_multi_pw_aff_alloc(space);
7119
7120 for (i = 0; i < n; ++i) {
7121 isl_pw_aff *pa;
7122
7124 mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
7125 }
7126 if (isl_multi_pw_aff_has_explicit_domain(mpa)) {
7127 isl_set *dom;
7128
7130 mpa = isl_multi_pw_aff_intersect_domain(mpa, dom);
7131 }
7132
7134 return mpa;
7135}
7136
7137/* This function performs the same operation as
7138 * isl_multi_pw_aff_from_pw_multi_aff,
7139 * but is considered as a function on an isl_pw_multi_aff when exported.
7140 */
7146
7147/* Do "pa1" and "pa2" represent the same function?
7148 *
7149 * We first check if they are obviously equal.
7150 * If not, we convert them to maps and check if those are equal.
7151 *
7152 * If "pa1" or "pa2" contain any NaNs, then they are considered
7153 * not to be the same. A NaN is not equal to anything, not even
7154 * to another NaN.
7155 */
7158{
7160 isl_bool has_nan;
7161 isl_map *map1, *map2;
7162
7163 if (!pa1 || !pa2)
7164 return isl_bool_error;
7165
7166 equal = isl_pw_aff_plain_is_equal(pa1, pa2);
7167 if (equal < 0 || equal)
7168 return equal;
7169 has_nan = either_involves_nan(pa1, pa2);
7170 if (has_nan < 0)
7171 return isl_bool_error;
7172 if (has_nan)
7173 return isl_bool_false;
7174
7180
7181 return equal;
7182}
7183
7184/* Do "mpa1" and "mpa2" represent the same function?
7185 *
7186 * Note that we cannot convert the entire isl_multi_pw_aff
7187 * to a map because the domains of the piecewise affine expressions
7188 * may not be the same.
7189 */
7192{
7193 int i;
7194 isl_bool equal, equal_params;
7195
7196 if (!mpa1 || !mpa2)
7197 return isl_bool_error;
7198
7199 equal_params = isl_space_has_equal_params(mpa1->space, mpa2->space);
7200 if (equal_params < 0)
7201 return isl_bool_error;
7202 if (!equal_params) {
7203 if (!isl_space_has_named_params(mpa1->space))
7204 return isl_bool_false;
7205 if (!isl_space_has_named_params(mpa2->space))
7206 return isl_bool_false;
7207 mpa1 = isl_multi_pw_aff_copy(mpa1);
7208 mpa2 = isl_multi_pw_aff_copy(mpa2);
7209 mpa1 = isl_multi_pw_aff_align_params(mpa1,
7210 isl_multi_pw_aff_get_space(mpa2));
7211 mpa2 = isl_multi_pw_aff_align_params(mpa2,
7212 isl_multi_pw_aff_get_space(mpa1));
7213 equal = isl_multi_pw_aff_is_equal(mpa1, mpa2);
7214 isl_multi_pw_aff_free(mpa1);
7215 isl_multi_pw_aff_free(mpa2);
7216 return equal;
7217 }
7218
7219 equal = isl_space_is_equal(mpa1->space, mpa2->space);
7220 if (equal < 0 || !equal)
7221 return equal;
7222
7223 for (i = 0; i < mpa1->n; ++i) {
7224 equal = isl_pw_aff_is_equal(mpa1->u.p[i], mpa2->u.p[i]);
7225 if (equal < 0 || !equal)
7226 return equal;
7227 }
7228
7229 return isl_bool_true;
7230}
7231
7232/* Do "pma1" and "pma2" represent the same function?
7233 *
7234 * First check if they are obviously equal.
7235 * If not, then convert them to maps and check if those are equal.
7236 *
7237 * If "pa1" or "pa2" contain any NaNs, then they are considered
7238 * not to be the same. A NaN is not equal to anything, not even
7239 * to another NaN.
7240 */
7243{
7245 isl_bool has_nan;
7246 isl_map *map1, *map2;
7247
7248 if (!pma1 || !pma2)
7249 return isl_bool_error;
7250
7252 if (equal < 0 || equal)
7253 return equal;
7254 has_nan = isl_pw_multi_aff_involves_nan(pma1);
7255 if (has_nan >= 0 && !has_nan)
7256 has_nan = isl_pw_multi_aff_involves_nan(pma2);
7257 if (has_nan < 0 || has_nan)
7258 return isl_bool_not(has_nan);
7259
7265
7266 return equal;
7267}
7268
7269#undef BASE
7270#define BASE multi_aff
7271
7273
7274#undef BASE
7275#define BASE pw_multi_aff
7276
7278
7279/* Apply "aff" to "mpa". The range of "mpa" needs to be compatible
7280 * with the domain of "aff". The domain of the result is the same
7281 * as that of "mpa".
7282 * "mpa" and "aff" are assumed to have been aligned.
7283 *
7284 * We first extract the parametric constant from "aff", defined
7285 * over the correct domain.
7286 * Then we add the appropriate combinations of the members of "mpa".
7287 * Finally, we add the integer divisions through recursive calls.
7288 */
7291{
7292 int i;
7293 isl_size n_in, n_div, n_mpa_in;
7294 isl_space *space;
7295 isl_val *v;
7296 isl_pw_aff *pa;
7297 isl_aff *tmp;
7298
7299 n_in = isl_aff_dim(aff, isl_dim_in);
7300 n_div = isl_aff_dim(aff, isl_dim_div);
7301 n_mpa_in = isl_multi_pw_aff_dim(mpa, isl_dim_in);
7302 if (n_in < 0 || n_div < 0 || n_mpa_in < 0)
7303 goto error;
7304
7305 space = isl_space_domain(isl_multi_pw_aff_get_space(mpa));
7306 tmp = isl_aff_copy(aff);
7307 tmp = isl_aff_drop_dims(tmp, isl_dim_div, 0, n_div);
7308 tmp = isl_aff_drop_dims(tmp, isl_dim_in, 0, n_in);
7309 tmp = isl_aff_add_dims(tmp, isl_dim_in, n_mpa_in);
7310 tmp = isl_aff_reset_domain_space(tmp, space);
7311 pa = isl_pw_aff_from_aff(tmp);
7312
7313 for (i = 0; i < n_in; ++i) {
7314 isl_pw_aff *pa_i;
7315
7317 continue;
7319 pa_i = isl_multi_pw_aff_get_pw_aff(mpa, i);
7320 pa_i = isl_pw_aff_scale_val(pa_i, v);
7321 pa = isl_pw_aff_add(pa, pa_i);
7322 }
7323
7324 for (i = 0; i < n_div; ++i) {
7325 isl_aff *div;
7326 isl_pw_aff *pa_i;
7327
7329 continue;
7330 div = isl_aff_get_div(aff, i);
7332 isl_multi_pw_aff_copy(mpa), div);
7333 pa_i = isl_pw_aff_floor(pa_i);
7335 pa_i = isl_pw_aff_scale_val(pa_i, v);
7336 pa = isl_pw_aff_add(pa, pa_i);
7337 }
7338
7339 isl_multi_pw_aff_free(mpa);
7341
7342 return pa;
7343error:
7344 isl_multi_pw_aff_free(mpa);
7346 return NULL;
7347}
7348
7349/* Apply "aff" to "mpa". The range of "mpa" needs to be compatible
7350 * with the domain of "aff". The domain of the result is the same
7351 * as that of "mpa".
7352 */
7355{
7356 isl_bool equal_params;
7357
7358 if (!aff || !mpa)
7359 goto error;
7360 equal_params = isl_space_has_equal_params(aff->ls->dim, mpa->space);
7361 if (equal_params < 0)
7362 goto error;
7363 if (equal_params)
7365
7366 aff = isl_aff_align_params(aff, isl_multi_pw_aff_get_space(mpa));
7367 mpa = isl_multi_pw_aff_align_params(mpa, isl_aff_get_space(aff));
7368
7370error:
7372 isl_multi_pw_aff_free(mpa);
7373 return NULL;
7374}
7375
7376/* Apply "pa" to "mpa". The range of "mpa" needs to be compatible
7377 * with the domain of "pa". The domain of the result is the same
7378 * as that of "mpa".
7379 * "mpa" and "pa" are assumed to have been aligned.
7380 *
7381 * We consider each piece in turn. Note that the domains of the
7382 * pieces are assumed to be disjoint and they remain disjoint
7383 * after taking the preimage (over the same function).
7384 */
7387{
7388 isl_space *space;
7389 isl_pw_aff *res;
7390 int i;
7391
7392 if (!mpa || !pa)
7393 goto error;
7394
7395 space = isl_space_join(isl_multi_pw_aff_get_space(mpa),
7397 res = isl_pw_aff_empty(space);
7398
7399 for (i = 0; i < pa->n; ++i) {
7400 isl_pw_aff *pa_i;
7401 isl_set *domain;
7402
7404 isl_multi_pw_aff_copy(mpa),
7405 isl_aff_copy(pa->p[i].aff));
7406 domain = isl_set_copy(pa->p[i].set);
7408 isl_multi_pw_aff_copy(mpa));
7409 pa_i = isl_pw_aff_intersect_domain(pa_i, domain);
7411 }
7412
7414 isl_multi_pw_aff_free(mpa);
7415 return res;
7416error:
7418 isl_multi_pw_aff_free(mpa);
7419 return NULL;
7420}
7421
7422/* Apply "pa" to "mpa". The range of "mpa" needs to be compatible
7423 * with the domain of "pa". The domain of the result is the same
7424 * as that of "mpa".
7425 */
7428{
7429 isl_bool equal_params;
7430
7431 if (!pa || !mpa)
7432 goto error;
7433 equal_params = isl_space_has_equal_params(pa->dim, mpa->space);
7434 if (equal_params < 0)
7435 goto error;
7436 if (equal_params)
7438
7439 pa = isl_pw_aff_align_params(pa, isl_multi_pw_aff_get_space(mpa));
7440 mpa = isl_multi_pw_aff_align_params(mpa, isl_pw_aff_get_space(pa));
7441
7443error:
7445 isl_multi_pw_aff_free(mpa);
7446 return NULL;
7447}
7448
7449/* Compute the pullback of "pa" by the function represented by "mpa".
7450 * In other words, plug in "mpa" in "pa".
7451 *
7452 * The pullback is computed by applying "pa" to "mpa".
7453 */
7459
7460#undef BASE
7461#define BASE multi_pw_aff
7462
7464
7465/* Align the parameters of "mpa1" and "mpa2", check that the ranges
7466 * of "mpa1" and "mpa2" live in the same space, construct map space
7467 * between the domain spaces of "mpa1" and "mpa2" and call "order"
7468 * with this map space as extract argument.
7469 */
7474{
7475 int match;
7476 isl_space *space1, *space2;
7477 isl_map *res;
7478
7479 mpa1 = isl_multi_pw_aff_align_params(mpa1,
7480 isl_multi_pw_aff_get_space(mpa2));
7481 mpa2 = isl_multi_pw_aff_align_params(mpa2,
7482 isl_multi_pw_aff_get_space(mpa1));
7483 if (!mpa1 || !mpa2)
7484 goto error;
7486 mpa2->space, isl_dim_out);
7487 if (match < 0)
7488 goto error;
7489 if (!match)
7490 isl_die(isl_multi_pw_aff_get_ctx(mpa1), isl_error_invalid,
7491 "range spaces don't match", goto error);
7492 space1 = isl_space_domain(isl_multi_pw_aff_get_space(mpa1));
7493 space2 = isl_space_domain(isl_multi_pw_aff_get_space(mpa2));
7494 space1 = isl_space_map_from_domain_and_range(space1, space2);
7495
7496 res = order(mpa1, mpa2, space1);
7497 isl_multi_pw_aff_free(mpa1);
7498 isl_multi_pw_aff_free(mpa2);
7499 return res;
7500error:
7501 isl_multi_pw_aff_free(mpa1);
7502 isl_multi_pw_aff_free(mpa2);
7503 return NULL;
7504}
7505
7506/* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2"
7507 * where the function values are equal. "space" is the space of the result.
7508 * The parameters of "mpa1" and "mpa2" are assumed to have been aligned.
7509 *
7510 * "mpa1" and "mpa2" are equal when each of the pairs of elements
7511 * in the sequences are equal.
7512 */
7515 __isl_take isl_space *space)
7516{
7517 int i;
7518 isl_size n;
7519 isl_map *res;
7520
7521 n = isl_multi_pw_aff_dim(mpa1, isl_dim_out);
7522 if (n < 0)
7523 space = isl_space_free(space);
7524 res = isl_map_universe(space);
7525
7526 for (i = 0; i < n; ++i) {
7527 isl_pw_aff *pa1, *pa2;
7528 isl_map *map;
7529
7530 pa1 = isl_multi_pw_aff_get_pw_aff(mpa1, i);
7531 pa2 = isl_multi_pw_aff_get_pw_aff(mpa2, i);
7532 map = isl_pw_aff_eq_map(pa1, pa2);
7534 }
7535
7536 return res;
7537}
7538
7539/* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2"
7540 * where the function values are equal.
7541 */
7548
7549/* Intersect "map" with the result of applying "order"
7550 * on two copies of "mpa".
7551 */
7556{
7557 return isl_map_intersect(map, order(mpa, isl_multi_pw_aff_copy(mpa)));
7558}
7559
7560/* Return the subset of "map" where the domain and the range
7561 * have equal "mpa" values.
7562 */
7569
7570/* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2"
7571 * where the function values of "mpa1" lexicographically satisfies
7572 * "strict_base"/"base" compared to that of "mpa2".
7573 * "space" is the space of the result.
7574 * The parameters of "mpa1" and "mpa2" are assumed to have been aligned.
7575 *
7576 * "mpa1" lexicographically satisfies "strict_base"/"base" compared to "mpa2"
7577 * if, for some i, the i-th element of "mpa1" satisfies "strict_base"/"base"
7578 * when compared to the i-th element of "mpa2" while all previous elements are
7579 * pairwise equal.
7580 * In particular, if i corresponds to the final elements
7581 * then they need to satisfy "base", while "strict_base" needs to be satisfied
7582 * for other values of i.
7583 * If "base" is a strict order, then "base" and "strict_base" are the same.
7584 */
7587 __isl_give isl_map *(*strict_base)(__isl_take isl_pw_aff *pa1,
7588 __isl_take isl_pw_aff *pa2),
7590 __isl_take isl_pw_aff *pa2),
7591 __isl_take isl_space *space)
7592{
7593 int i;
7594 isl_size n;
7595 isl_map *res, *rest;
7596
7597 n = isl_multi_pw_aff_dim(mpa1, isl_dim_out);
7598 if (n < 0)
7599 space = isl_space_free(space);
7601 rest = isl_map_universe(space);
7602
7603 for (i = 0; i < n; ++i) {
7604 int last;
7605 isl_pw_aff *pa1, *pa2;
7606 isl_map *map;
7607
7608 last = i == n - 1;
7609
7610 pa1 = isl_multi_pw_aff_get_pw_aff(mpa1, i);
7611 pa2 = isl_multi_pw_aff_get_pw_aff(mpa2, i);
7612 map = last ? base(pa1, pa2) : strict_base(pa1, pa2);
7615
7616 if (last)
7617 continue;
7618
7619 pa1 = isl_multi_pw_aff_get_pw_aff(mpa1, i);
7620 pa2 = isl_multi_pw_aff_get_pw_aff(mpa2, i);
7621 map = isl_pw_aff_eq_map(pa1, pa2);
7622 rest = isl_map_intersect(rest, map);
7623 }
7624
7625 isl_map_free(rest);
7626 return res;
7627}
7628
7629#undef ORDER
7630#define ORDER le
7631#undef STRICT_ORDER
7632#define STRICT_ORDER lt
7633#include "isl_aff_lex_templ.c"
7634
7635#undef ORDER
7636#define ORDER lt
7637#undef STRICT_ORDER
7638#define STRICT_ORDER lt
7639#include "isl_aff_lex_templ.c"
7640
7641#undef ORDER
7642#define ORDER ge
7643#undef STRICT_ORDER
7644#define STRICT_ORDER gt
7645#include "isl_aff_lex_templ.c"
7646
7647#undef ORDER
7648#define ORDER gt
7649#undef STRICT_ORDER
7650#define STRICT_ORDER gt
7651#include "isl_aff_lex_templ.c"
7652
7653/* Compare two isl_affs.
7654 *
7655 * Return -1 if "aff1" is "smaller" than "aff2", 1 if "aff1" is "greater"
7656 * than "aff2" and 0 if they are equal.
7657 *
7658 * The order is fairly arbitrary. We do consider expressions that only involve
7659 * earlier dimensions as "smaller".
7660 */
7662{
7663 int cmp;
7664 int last1, last2;
7665
7666 if (aff1 == aff2)
7667 return 0;
7668
7669 if (!aff1)
7670 return -1;
7671 if (!aff2)
7672 return 1;
7673
7674 cmp = isl_local_space_cmp(aff1->ls, aff2->ls);
7675 if (cmp != 0)
7676 return cmp;
7677
7678 last1 = isl_seq_last_non_zero(aff1->v->el + 1, aff1->v->size - 1);
7679 last2 = isl_seq_last_non_zero(aff2->v->el + 1, aff1->v->size - 1);
7680 if (last1 != last2)
7681 return last1 - last2;
7682
7683 return isl_seq_cmp(aff1->v->el, aff2->v->el, aff1->v->size);
7684}
7685
7686/* Compare two isl_pw_affs.
7687 *
7688 * Return -1 if "pa1" is "smaller" than "pa2", 1 if "pa1" is "greater"
7689 * than "pa2" and 0 if they are equal.
7690 *
7691 * The order is fairly arbitrary. We do consider expressions that only involve
7692 * earlier dimensions as "smaller".
7693 */
7696{
7697 int i;
7698 int cmp;
7699
7700 if (pa1 == pa2)
7701 return 0;
7702
7703 if (!pa1)
7704 return -1;
7705 if (!pa2)
7706 return 1;
7707
7708 cmp = isl_space_cmp(pa1->dim, pa2->dim);
7709 if (cmp != 0)
7710 return cmp;
7711
7712 if (pa1->n != pa2->n)
7713 return pa1->n - pa2->n;
7714
7715 for (i = 0; i < pa1->n; ++i) {
7716 cmp = isl_set_plain_cmp(pa1->p[i].set, pa2->p[i].set);
7717 if (cmp != 0)
7718 return cmp;
7719 cmp = isl_aff_plain_cmp(pa1->p[i].aff, pa2->p[i].aff);
7720 if (cmp != 0)
7721 return cmp;
7722 }
7723
7724 return 0;
7725}
7726
7727/* Return a piecewise affine expression that is equal to "v" on "domain".
7728 */
7742
7743/* This function performs the same operation as isl_pw_aff_val_on_domain,
7744 * but is considered as a function on an isl_set when exported.
7745 */
7751
7752/* Return a piecewise affine expression that is equal to the parameter
7753 * with identifier "id" on "domain".
7754 */
7768
7769/* This function performs the same operation as
7770 * isl_pw_aff_param_on_domain_id,
7771 * but is considered as a function on an isl_set when exported.
7772 */
7778
7779/* Return a multi affine expression that is equal to "mv" on domain
7780 * space "space".
7781 */
7784{
7785 int i;
7786 isl_size n;
7787 isl_space *space2;
7788 isl_local_space *ls;
7790
7791 n = isl_multi_val_dim(mv, isl_dim_set);
7792 if (!space || n < 0)
7793 goto error;
7794
7795 space2 = isl_multi_val_get_space(mv);
7796 space2 = isl_space_align_params(space2, isl_space_copy(space));
7797 space = isl_space_align_params(space, isl_space_copy(space2));
7798 space = isl_space_map_from_domain_and_range(space, space2);
7799 ma = isl_multi_aff_alloc(isl_space_copy(space));
7801 for (i = 0; i < n; ++i) {
7802 isl_val *v;
7803 isl_aff *aff;
7804
7805 v = isl_multi_val_get_val(mv, i);
7807 ma = isl_multi_aff_set_aff(ma, i, aff);
7808 }
7810
7811 isl_multi_val_free(mv);
7812 return ma;
7813error:
7814 isl_space_free(space);
7815 isl_multi_val_free(mv);
7816 return NULL;
7817}
7818
7819/* This is an alternative name for the function above.
7820 */
7826
7827/* This function performs the same operation as
7828 * isl_multi_aff_multi_val_on_domain_space,
7829 * but is considered as a function on an isl_space when exported.
7830 */
7836
7837/* Return a piecewise multi-affine expression
7838 * that is equal to "mv" on "domain".
7839 */
7851
7852/* This function performs the same operation as
7853 * isl_pw_multi_aff_multi_val_on_domain,
7854 * but is considered as a function on an isl_set when exported.
7855 */
7861
7862/* Internal data structure for isl_union_pw_multi_aff_multi_val_on_domain.
7863 * mv is the value that should be attained on each domain set
7864 * res collects the results
7865 */
7870
7871/* Create an isl_pw_multi_aff equal to data->mv on "domain"
7872 * and add it to data->res.
7873 */
7875 void *user)
7876{
7880
7881 mv = isl_multi_val_copy(data->mv);
7884
7885 return data->res ? isl_stat_ok : isl_stat_error;
7886}
7887
7888/* Return a union piecewise multi-affine expression
7889 * that is equal to "mv" on "domain".
7890 */
7907
7908/* Compute the pullback of data->pma by the function represented by "pma2",
7909 * provided the spaces match, and add the results to data->res.
7910 */
7912{
7914
7916 pma2->dim, isl_dim_out)) {
7918 return isl_stat_ok;
7919 }
7920
7922 isl_pw_multi_aff_copy(data->pma), pma2);
7923
7924 data->res = isl_union_pw_multi_aff_add_pw_multi_aff(data->res, pma2);
7925 if (!data->res)
7926 return isl_stat_error;
7927
7928 return isl_stat_ok;
7929}
7930
7931/* Compute the pullback of "upma1" by the function represented by "upma2".
7932 */
7940
7941/* Apply "upma2" to "upma1".
7942 *
7943 * That is, compute the pullback of "upma2" by "upma1".
7944 */
7952
7953#undef BASE
7954#define BASE pw_multi_aff
7955static
7957
7958/* Given a function "pma1" of the form A[B -> C] -> D and
7959 * a function "pma2" of the form E -> B,
7960 * replace the domain of the wrapped relation inside the domain of "pma1"
7961 * by the preimage with respect to "pma2".
7962 * In other words, plug in "pma2" in this nested domain.
7963 * The result is of the form A[E -> C] -> D.
7964 *
7965 * In particular, extend E -> B to A[E -> C] -> A[B -> C] and
7966 * plug that into "pma1".
7967 */
7971{
7972 isl_space *pma1_space, *pma2_space;
7973 isl_space *space;
7975
7976 pma1_space = isl_pw_multi_aff_peek_space(pma1);
7977 pma2_space = isl_pw_multi_aff_peek_space(pma2);
7978
7979 if (isl_space_check_domain_is_wrapping(pma1_space) < 0)
7980 goto error;
7982 isl_dim_in, isl_dim_in, pma2_space, isl_dim_out) < 0)
7983 goto error;
7984
7985 space = isl_space_domain(isl_space_copy(pma1_space));
7986 space = isl_space_range(isl_space_unwrap(space));
7988 pma2 = isl_pw_multi_aff_product(pma2, id);
7989
7990 pma2 = isl_pw_multi_aff_copy_tuple_id(pma2, isl_dim_in,
7991 pma1_space, isl_dim_in);
7992 pma2 = isl_pw_multi_aff_copy_tuple_id(pma2, isl_dim_out,
7993 pma1_space, isl_dim_in);
7994
7995 return isl_pw_multi_aff_pullback_pw_multi_aff(pma1, pma2);
7996error:
7999 return NULL;
8000}
8001
8002/* If data->pma and "pma2" are such that
8003 * data->pma is of the form A[B -> C] -> D and
8004 * "pma2" is of the form E -> B,
8005 * then replace the domain of the wrapped relation
8006 * inside the domain of data->pma by the preimage with respect to "pma2" and
8007 * add the result to data->res.
8008 */
8010 __isl_take isl_pw_multi_aff *pma2, void *user)
8011{
8013 isl_space *pma1_space, *pma2_space;
8015
8016 pma1_space = isl_pw_multi_aff_peek_space(data->pma);
8017 pma2_space = isl_pw_multi_aff_peek_space(pma2);
8018
8019 match = isl_space_domain_is_wrapping(pma1_space);
8020 if (match >= 0 && match)
8022 isl_dim_in, pma2_space, isl_dim_out);
8023 if (match < 0 || !match) {
8025 return match < 0 ? isl_stat_error : isl_stat_ok;
8026 }
8027
8029 isl_pw_multi_aff_copy(data->pma), pma2);
8030
8031 data->res = isl_union_pw_multi_aff_add_pw_multi_aff(data->res, pma2);
8032
8033 return isl_stat_non_null(data->res);
8034}
8035
8036/* For each pair of functions A[B -> C] -> D in "upma1" and
8037 * E -> B in "upma2",
8038 * replace the domain of the wrapped relation inside the domain of the first
8039 * by the preimage with respect to the second and collect the results.
8040 * In other words, plug in the second function in this nested domain.
8041 * The results are of the form A[E -> C] -> D.
8042 */
8050
8051/* Check that the domain space of "upa" matches "space".
8052 *
8053 * This function is called from isl_multi_union_pw_aff_set_union_pw_aff and
8054 * can in principle never fail since the space "space" is that
8055 * of the isl_multi_union_pw_aff and is a set space such that
8056 * there is no domain space to match.
8057 *
8058 * We check the parameters and double-check that "space" is
8059 * indeed that of a set.
8060 */
8063{
8064 isl_space *upa_space;
8066
8067 if (!upa || !space)
8068 return isl_stat_error;
8069
8070 match = isl_space_is_set(space);
8071 if (match < 0)
8072 return isl_stat_error;
8073 if (!match)
8075 "expecting set space", return isl_stat_error);
8076
8077 upa_space = isl_union_pw_aff_get_space(upa);
8078 match = isl_space_has_equal_params(space, upa_space);
8079 if (match < 0)
8080 goto error;
8081 if (!match)
8083 "parameters don't match", goto error);
8084
8085 isl_space_free(upa_space);
8086 return isl_stat_ok;
8087error:
8088 isl_space_free(upa_space);
8089 return isl_stat_error;
8090}
8091
8092/* Do the parameters of "upa" match those of "space"?
8093 */
8096{
8097 isl_space *upa_space;
8099
8100 if (!upa || !space)
8101 return isl_bool_error;
8102
8103 upa_space = isl_union_pw_aff_get_space(upa);
8104
8105 match = isl_space_has_equal_params(space, upa_space);
8106
8107 isl_space_free(upa_space);
8108 return match;
8109}
8110
8111/* Internal data structure for isl_union_pw_aff_reset_domain_space.
8112 * space represents the new parameters.
8113 * res collects the results.
8114 */
8119
8120/* Replace the parameters of "pa" by data->space and
8121 * add the result to data->res.
8122 */
8135
8136/* Replace the domain space of "upa" by "space".
8137 * Since a union expression does not have a (single) domain space,
8138 * "space" is necessarily a parameter space.
8139 *
8140 * Since the order and the names of the parameters determine
8141 * the hash value, we need to create a new hash table.
8142 */
8145{
8146 struct isl_union_pw_aff_reset_params_data data = { space };
8148
8150 if (match < 0)
8151 upa = isl_union_pw_aff_free(upa);
8152 else if (match) {
8154 return upa;
8155 }
8156
8158 if (isl_union_pw_aff_foreach_pw_aff(upa, &reset_params, &data) < 0)
8159 data.res = isl_union_pw_aff_free(data.res);
8160
8163 return data.res;
8164}
8165
8166/* Return the floor of "pa".
8167 */
8172
8173/* Given f, return floor(f).
8174 */
8177{
8178 return isl_union_pw_aff_transform_inplace(upa, &floor_entry, NULL);
8179}
8180
8181/* Compute
8182 *
8183 * upa mod m = upa - m * floor(upa/m)
8184 *
8185 * with m an integer value.
8186 */
8189{
8191
8192 if (!upa || !m)
8193 goto error;
8194
8195 if (!isl_val_is_int(m))
8197 "expecting integer modulo", goto error);
8198 if (!isl_val_is_pos(m))
8200 "expecting positive modulo", goto error);
8201
8204 upa = isl_union_pw_aff_floor(upa);
8205 upa = isl_union_pw_aff_scale_val(upa, m);
8207
8208 return res;
8209error:
8210 isl_val_free(m);
8212 return NULL;
8213}
8214
8215/* Internal data structure for isl_union_pw_multi_aff_get_union_pw_aff.
8216 * pos is the output position that needs to be extracted.
8217 * res collects the results.
8218 */
8223
8224/* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma"
8225 * (assuming it has such a dimension) and add it to data->res.
8226 */
8228{
8230 isl_size n_out;
8231 isl_pw_aff *pa;
8232
8234 if (n_out < 0)
8235 return isl_stat_error;
8236 if (data->pos >= n_out) {
8238 return isl_stat_ok;
8239 }
8240
8243
8244 data->res = isl_union_pw_aff_add_pw_aff(data->res, pa);
8245
8246 return data->res ? isl_stat_ok : isl_stat_error;
8247}
8248
8249/* Extract an isl_union_pw_aff corresponding to
8250 * output dimension "pos" of "upma".
8251 */
8254{
8256 isl_space *space;
8257
8258 if (!upma)
8259 return NULL;
8260
8261 if (pos < 0)
8263 "cannot extract at negative position", return NULL);
8264
8266 data.res = isl_union_pw_aff_empty(space);
8267 data.pos = pos;
8269 &get_union_pw_aff, &data) < 0)
8270 data.res = isl_union_pw_aff_free(data.res);
8271
8272 return data.res;
8273}
8274
8275/* Return a union piecewise affine expression
8276 * that is equal to "aff" on "domain".
8277 */
8286
8287/* Return a union piecewise affine expression
8288 * that is equal to the parameter identified by "id" on "domain".
8289 *
8290 * Make sure the parameter appears in the space passed to
8291 * isl_aff_param_on_domain_space_id.
8292 */
8304
8305/* Internal data structure for isl_union_pw_aff_pw_aff_on_domain.
8306 * "pa" is the piecewise symbolic value that the resulting isl_union_pw_aff
8307 * needs to attain.
8308 * "res" collects the results.
8309 */
8314
8315/* Construct a piecewise affine expression that is equal to data->pa
8316 * on "domain" and add the result to data->res.
8317 */
8336
8337/* Return a union piecewise affine expression
8338 * that is equal to "pa" on "domain", assuming "domain" and "pa"
8339 * have been aligned.
8340 *
8341 * Construct an isl_pw_aff on each of the sets in "domain" and
8342 * collect the results.
8343 */
8359
8360/* Return a union piecewise affine expression
8361 * that is equal to "pa" on "domain".
8362 *
8363 * Check that "pa" is a parametric expression,
8364 * align the parameters if needed and call
8365 * isl_union_pw_aff_pw_aff_on_domain_aligned.
8366 */
8369{
8370 isl_bool is_set;
8371 isl_bool equal_params;
8372 isl_space *domain_space, *pa_space;
8373
8374 pa_space = isl_pw_aff_peek_space(pa);
8375 is_set = isl_space_is_set(pa_space);
8376 if (is_set < 0)
8377 goto error;
8378 if (!is_set)
8380 "expecting parametric expression", goto error);
8381
8382 domain_space = isl_union_set_get_space(domain);
8383 pa_space = isl_pw_aff_get_space(pa);
8384 equal_params = isl_space_has_equal_params(domain_space, pa_space);
8385 if (equal_params >= 0 && !equal_params) {
8386 isl_space *space;
8387
8388 space = isl_space_align_params(domain_space, pa_space);
8391 } else {
8392 isl_space_free(domain_space);
8393 isl_space_free(pa_space);
8394 }
8395
8396 if (equal_params < 0)
8397 goto error;
8399error:
8402 return NULL;
8403}
8404
8405/* Internal data structure for isl_union_pw_aff_val_on_domain.
8406 * "v" is the value that the resulting isl_union_pw_aff needs to attain.
8407 * "res" collects the results.
8408 */
8413
8414/* Construct a piecewise affine expression that is equal to data->v
8415 * on "domain" and add the result to data->res.
8416 */
8418{
8420 isl_pw_aff *pa;
8421 isl_val *v;
8422
8423 v = isl_val_copy(data->v);
8425 data->res = isl_union_pw_aff_add_pw_aff(data->res, pa);
8426
8427 return data->res ? isl_stat_ok : isl_stat_error;
8428}
8429
8430/* Return a union piecewise affine expression
8431 * that is equal to "v" on "domain".
8432 *
8433 * Construct an isl_pw_aff on each of the sets in "domain" and
8434 * collect the results.
8435 */
8451
8452/* Construct a piecewise multi affine expression
8453 * that is equal to "pa" and add it to upma.
8454 */
8466
8467/* Construct and return a union piecewise multi affine expression
8468 * that is equal to the given union piecewise affine expression.
8469 */
8472{
8473 isl_space *space;
8475
8476 if (!upa)
8477 return NULL;
8478
8479 space = isl_union_pw_aff_get_space(upa);
8480 upma = isl_union_pw_multi_aff_empty(space);
8481
8483 &pw_multi_aff_from_pw_aff_entry, &upma) < 0)
8484 upma = isl_union_pw_multi_aff_free(upma);
8485
8487 return upma;
8488}
8489
8490/* Compute the set of elements in the domain of "pa" where it is zero and
8491 * add this set to "uset".
8492 */
8494{
8495 isl_union_set **uset = (isl_union_set **)user;
8496
8498
8499 return *uset ? isl_stat_ok : isl_stat_error;
8500}
8501
8502/* Return a union set containing those elements in the domain
8503 * of "upa" where it is zero.
8504 */
8507{
8508 isl_union_set *zero;
8509
8511 if (isl_union_pw_aff_foreach_pw_aff(upa, &zero_union_set, &zero) < 0)
8512 zero = isl_union_set_free(zero);
8513
8515 return zero;
8516}
8517
8518/* Internal data structure for isl_union_pw_aff_bind_id,
8519 * storing the parameter that needs to be bound and
8520 * the accumulated results.
8521 */
8526
8527/* Bind the piecewise affine function "pa" to the parameter data->id,
8528 * adding the resulting elements in the domain where the expression
8529 * is equal to the parameter to data->bound.
8530 */
8532{
8533 struct isl_bind_id_data *data = user;
8534 isl_set *bound;
8535
8537 data->bound = isl_union_set_add_set(data->bound, bound);
8538
8539 return data->bound ? isl_stat_ok : isl_stat_error;
8540}
8541
8542/* Bind the union piecewise affine function "upa" to the parameter "id",
8543 * returning the elements in the domain where the expression
8544 * is equal to the parameter.
8545 */
8548{
8549 struct isl_bind_id_data data = { id };
8550
8552 if (isl_union_pw_aff_foreach_pw_aff(upa, &bind_id, &data) < 0)
8553 data.bound = isl_union_set_free(data.bound);
8554
8556 isl_id_free(id);
8557 return data.bound;
8558}
8559
8560/* Internal data structure for isl_union_pw_aff_pullback_union_pw_multi_aff.
8561 * upma is the function that is plugged in.
8562 * pa is the current part of the function in which upma is plugged in.
8563 * res collects the results.
8564 */
8570
8571/* Check if "pma" can be plugged into data->pa.
8572 * If so, perform the pullback and add the result to data->res.
8573 */
8575{
8577 isl_pw_aff *pa;
8578
8580 pma->dim, isl_dim_out)) {
8582 return isl_stat_ok;
8583 }
8584
8585 pa = isl_pw_aff_copy(data->pa);
8587
8588 data->res = isl_union_pw_aff_add_pw_aff(data->res, pa);
8589
8590 return data->res ? isl_stat_ok : isl_stat_error;
8591}
8592
8593/* Check if any of the elements of data->upma can be plugged into pa,
8594 * add if so add the result to data->res.
8595 */
8597{
8599 isl_stat r;
8600
8601 data->pa = pa;
8603 &pa_pb_pma, data);
8605
8606 return r;
8607}
8608
8609/* Compute the pullback of "upa" by the function represented by "upma".
8610 * In other words, plug in "upma" in "upa". The result contains
8611 * expressions defined over the domain space of "upma".
8612 *
8613 * Run over all pairs of elements in "upa" and "upma", perform
8614 * the pullback when appropriate and collect the results.
8615 * If the hash value were based on the domain space rather than
8616 * the function space, then we could run through all elements
8617 * of "upma" and directly pick out the corresponding element of "upa".
8618 */
8622{
8623 struct isl_union_pw_aff_pullback_upma_data data = { NULL, NULL };
8624 isl_space *space;
8625
8627 upa = isl_union_pw_aff_align_params(upa, space);
8628 space = isl_union_pw_aff_get_space(upa);
8630
8631 if (!upa || !upma)
8632 goto error;
8633
8634 data.upma = upma;
8635 data.res = isl_union_pw_aff_alloc_same_size(upa);
8636 if (isl_union_pw_aff_foreach_pw_aff(upa, &upa_pb_upma, &data) < 0)
8637 data.res = isl_union_pw_aff_free(data.res);
8638
8641 return data.res;
8642error:
8645 return NULL;
8646}
8647
8648#undef BASE
8649#define BASE union_pw_aff
8650#undef DOMBASE
8651#define DOMBASE union_set
8652
8655#include <isl_multi_templ.c>
8656#include <isl_multi_un_op_templ.c>
8658#include <isl_multi_align_set.c>
8662#include <isl_multi_arith_templ.c>
8663#include <isl_multi_bind_templ.c>
8664#include <isl_multi_coalesce.c>
8665#include <isl_multi_dim_id_templ.c>
8666#include <isl_multi_floor.c>
8669#include <isl_multi_gist.c>
8670#include <isl_multi_intersect.c>
8671#include <isl_multi_nan_templ.c>
8675
8676/* Does "mupa" have a non-trivial explicit domain?
8677 *
8678 * The explicit domain, if present, is trivial if it represents
8679 * an (obviously) universe parameter set.
8680 */
8683{
8684 isl_bool is_params, trivial;
8685 isl_set *set;
8686
8687 if (!mupa)
8688 return isl_bool_error;
8689 if (!isl_multi_union_pw_aff_has_explicit_domain(mupa))
8690 return isl_bool_false;
8691 is_params = isl_union_set_is_params(mupa->u.dom);
8692 if (is_params < 0 || !is_params)
8693 return isl_bool_not(is_params);
8695 trivial = isl_set_plain_is_universe(set);
8697 return isl_bool_not(trivial);
8698}
8699
8700/* Construct a multiple union piecewise affine expression
8701 * in the given space with value zero in each of the output dimensions.
8702 *
8703 * Since there is no canonical zero value for
8704 * a union piecewise affine expression, we can only construct
8705 * a zero-dimensional "zero" value.
8706 */
8708 __isl_take isl_space *space)
8709{
8710 isl_size dim;
8711
8712 if (isl_space_check_is_proper_set(space) < 0)
8713 goto error;
8714 dim = isl_space_dim(space, isl_dim_set);
8715 if (dim < 0)
8716 goto error;
8717 if (dim != 0)
8719 "expecting 0D space", goto error);
8720
8721 return isl_multi_union_pw_aff_alloc(space);
8722error:
8723 isl_space_free(space);
8724 return NULL;
8725}
8726
8727/* Construct and return a multi union piecewise affine expression
8728 * that is equal to the given multi affine expression.
8729 */
8738
8739/* This function performs the same operation as
8740 * isl_multi_union_pw_aff_from_multi_aff, but is considered as a function on an
8741 * isl_multi_aff when exported.
8742 */
8748
8749/* Construct and return a multi union piecewise affine expression
8750 * that is equal to the given multi piecewise affine expression.
8751 *
8752 * If the resulting multi union piecewise affine expression has
8753 * an explicit domain, then assign it the domain of the input.
8754 * In other cases, the domain is stored in the individual elements.
8755 */
8758{
8759 int i;
8760 isl_size n;
8761 isl_space *space;
8763
8764 n = isl_multi_pw_aff_dim(mpa, isl_dim_out);
8765 if (n < 0)
8766 mpa = isl_multi_pw_aff_free(mpa);
8767 if (!mpa)
8768 return NULL;
8769
8770 space = isl_multi_pw_aff_get_space(mpa);
8771 space = isl_space_range(space);
8772 mupa = isl_multi_union_pw_aff_alloc(space);
8773
8774 for (i = 0; i < n; ++i) {
8775 isl_pw_aff *pa;
8776 isl_union_pw_aff *upa;
8777
8778 pa = isl_multi_pw_aff_get_pw_aff(mpa, i);
8780 mupa = isl_multi_union_pw_aff_restore_check_space(mupa, i, upa);
8781 }
8782 if (isl_multi_union_pw_aff_has_explicit_domain(mupa)) {
8783 isl_union_set *dom;
8784 isl_multi_pw_aff *copy;
8785
8786 copy = isl_multi_pw_aff_copy(mpa);
8789 }
8790
8791 isl_multi_pw_aff_free(mpa);
8792
8793 return mupa;
8794}
8795
8796/* Extract the range space of "pma" and assign it to *space.
8797 * If *space has already been set (through a previous call to this function),
8798 * then check that the range space is the same.
8799 */
8801{
8802 isl_space **space = user;
8803 isl_space *pma_space;
8805
8808
8809 if (!pma_space)
8810 return isl_stat_error;
8811 if (!*space) {
8812 *space = pma_space;
8813 return isl_stat_ok;
8814 }
8815
8816 equal = isl_space_is_equal(pma_space, *space);
8817 isl_space_free(pma_space);
8818
8819 if (equal < 0)
8820 return isl_stat_error;
8821 if (!equal)
8823 "range spaces not the same", return isl_stat_error);
8824 return isl_stat_ok;
8825}
8826
8827/* Construct and return a multi union piecewise affine expression
8828 * that is equal to the given union piecewise multi affine expression.
8829 *
8830 * In order to be able to perform the conversion, the input
8831 * needs to be non-empty and may only involve a single range space.
8832 *
8833 * If the resulting multi union piecewise affine expression has
8834 * an explicit domain, then assign it the domain of the input.
8835 * In other cases, the domain is stored in the individual elements.
8836 */
8840{
8841 isl_space *space = NULL;
8843 int i;
8844 isl_size n;
8845
8847 if (n < 0)
8848 goto error;
8849 if (n == 0)
8851 "cannot extract range space from empty input",
8852 goto error);
8854 &space) < 0)
8855 goto error;
8856
8857 if (!space)
8858 goto error;
8859
8860 n = isl_space_dim(space, isl_dim_set);
8861 if (n < 0)
8862 space = isl_space_free(space);
8863 mupa = isl_multi_union_pw_aff_alloc(space);
8864
8865 for (i = 0; i < n; ++i) {
8866 isl_union_pw_aff *upa;
8867
8869 mupa = isl_multi_union_pw_aff_set_union_pw_aff(mupa, i, upa);
8870 }
8871 if (isl_multi_union_pw_aff_has_explicit_domain(mupa)) {
8872 isl_union_set *dom;
8874
8878 }
8879
8881 return mupa;
8882error:
8883 isl_space_free(space);
8885 return NULL;
8886}
8887
8888/* This function performs the same operation as
8889 * isl_multi_union_pw_aff_from_union_pw_multi_aff,
8890 * but is considered as a function on an isl_union_pw_multi_aff when exported.
8891 */
8898
8899/* Try and create an isl_multi_union_pw_aff that is equivalent
8900 * to the given isl_union_map.
8901 * The isl_union_map is required to be single-valued in each space.
8902 * Moreover, it cannot be empty and all range spaces need to be the same.
8903 * Otherwise, an error is produced.
8904 */
8913
8914/* This function performs the same operation as
8915 * isl_multi_union_pw_aff_from_union_map,
8916 * but is considered as a function on an isl_union_map when exported.
8917 */
8923
8924/* Return a multiple union piecewise affine expression
8925 * that is equal to "mv" on "domain", assuming "domain" and "mv"
8926 * have been aligned.
8927 *
8928 * If the resulting multi union piecewise affine expression has
8929 * an explicit domain, then assign it the input domain.
8930 * In other cases, the domain is stored in the individual elements.
8931 */
8935{
8936 int i;
8937 isl_size n;
8938 isl_space *space;
8940
8941 n = isl_multi_val_dim(mv, isl_dim_set);
8942 if (!domain || n < 0)
8943 goto error;
8944
8945 space = isl_multi_val_get_space(mv);
8946 mupa = isl_multi_union_pw_aff_alloc(space);
8947 for (i = 0; i < n; ++i) {
8948 isl_val *v;
8949 isl_union_pw_aff *upa;
8950
8951 v = isl_multi_val_get_val(mv, i);
8953 v);
8954 mupa = isl_multi_union_pw_aff_set_union_pw_aff(mupa, i, upa);
8955 }
8956 if (isl_multi_union_pw_aff_has_explicit_domain(mupa))
8959
8961 isl_multi_val_free(mv);
8962 return mupa;
8963error:
8965 isl_multi_val_free(mv);
8966 return NULL;
8967}
8968
8969/* Return a multiple union piecewise affine expression
8970 * that is equal to "mv" on "domain".
8971 */
8974{
8975 isl_bool equal_params;
8976
8977 if (!domain || !mv)
8978 goto error;
8979 equal_params = isl_space_has_equal_params(domain->dim, mv->space);
8980 if (equal_params < 0)
8981 goto error;
8982 if (equal_params)
8984 domain, mv);
8986 isl_multi_val_get_space(mv));
8987 mv = isl_multi_val_align_params(mv, isl_union_set_get_space(domain));
8989error:
8991 isl_multi_val_free(mv);
8992 return NULL;
8993}
8994
8995/* Return a multiple union piecewise affine expression
8996 * that is equal to "ma" on "domain".
8997 */
9006
9007/* Return a multiple union piecewise affine expression
9008 * that is equal to "pma" on "domain", assuming "domain" and "pma"
9009 * have been aligned.
9010 *
9011 * If the resulting multi union piecewise affine expression has
9012 * an explicit domain, then assign it the input domain.
9013 * In other cases, the domain is stored in the individual elements.
9014 */
9018{
9019 int i;
9020 isl_size n;
9021 isl_space *space;
9023
9025 if (!domain || n < 0)
9026 goto error;
9028 mupa = isl_multi_union_pw_aff_alloc(space);
9029 for (i = 0; i < n; ++i) {
9030 isl_pw_aff *pa;
9031 isl_union_pw_aff *upa;
9032
9036 mupa = isl_multi_union_pw_aff_set_union_pw_aff(mupa, i, upa);
9037 }
9038 if (isl_multi_union_pw_aff_has_explicit_domain(mupa))
9041
9044 return mupa;
9045error:
9048 return NULL;
9049}
9050
9051/* Return a multiple union piecewise affine expression
9052 * that is equal to "pma" on "domain".
9053 */
9057{
9058 isl_bool equal_params;
9059 isl_space *space;
9060
9061 space = isl_pw_multi_aff_peek_space(pma);
9062 equal_params = isl_union_set_space_has_equal_params(domain, space);
9063 if (equal_params < 0)
9064 goto error;
9065 if (equal_params)
9067 domain, pma);
9073 pma);
9074error:
9077 return NULL;
9078}
9079
9080/* Return a union set containing those elements in the domains
9081 * of the elements of "mupa" where they are all zero.
9082 *
9083 * If there are no elements, then simply return the entire domain.
9084 */
9087{
9088 int i;
9089 isl_size n;
9090 isl_union_pw_aff *upa;
9091 isl_union_set *zero;
9092
9093 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9094 if (n < 0)
9095 mupa = isl_multi_union_pw_aff_free(mupa);
9096 if (!mupa)
9097 return NULL;
9098
9099 if (n == 0)
9101
9102 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, 0);
9104
9105 for (i = 1; i < n; ++i) {
9106 isl_union_set *zero_i;
9107
9108 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9109 zero_i = isl_union_pw_aff_zero_union_set(upa);
9110
9111 zero = isl_union_set_intersect(zero, zero_i);
9112 }
9113
9114 isl_multi_union_pw_aff_free(mupa);
9115 return zero;
9116}
9117
9118/* Construct a union map mapping the shared domain
9119 * of the union piecewise affine expressions to the range of "mupa"
9120 * in the special case of a 0D multi union piecewise affine expression.
9121 *
9122 * Construct a map between the explicit domain of "mupa" and
9123 * the range space.
9124 * Note that this assumes that the domain consists of explicit elements.
9125 */
9128{
9129 isl_bool is_params;
9130 isl_space *space;
9131 isl_union_set *dom, *ran;
9132
9133 space = isl_multi_union_pw_aff_get_space(mupa);
9136
9137 is_params = isl_union_set_is_params(dom);
9138 if (is_params < 0)
9139 dom = isl_union_set_free(dom);
9140 else if (is_params)
9142 "cannot create union map from expression without "
9143 "explicit domain elements",
9144 dom = isl_union_set_free(dom));
9145
9146 return isl_union_map_from_domain_and_range(dom, ran);
9147}
9148
9149/* Construct a union map mapping the shared domain
9150 * of the union piecewise affine expressions to the range of "mupa"
9151 * with each dimension in the range equated to the
9152 * corresponding union piecewise affine expression.
9153 *
9154 * If the input is zero-dimensional, then construct a mapping
9155 * from its explicit domain.
9156 */
9159{
9160 int i;
9161 isl_size n;
9162 isl_space *space;
9163 isl_union_map *umap;
9164 isl_union_pw_aff *upa;
9165
9166 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9167 if (n < 0)
9168 mupa = isl_multi_union_pw_aff_free(mupa);
9169 if (!mupa)
9170 return NULL;
9171
9172 if (n == 0)
9174
9175 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, 0);
9177
9178 for (i = 1; i < n; ++i) {
9179 isl_union_map *umap_i;
9180
9181 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9182 umap_i = isl_union_map_from_union_pw_aff(upa);
9183 umap = isl_union_map_flat_range_product(umap, umap_i);
9184 }
9185
9186 space = isl_multi_union_pw_aff_get_space(mupa);
9187 umap = isl_union_map_reset_range_space(umap, space);
9188
9189 isl_multi_union_pw_aff_free(mupa);
9190 return umap;
9191}
9192
9193/* Internal data structure for isl_union_pw_multi_aff_reset_range_space.
9194 * "range" is the space from which to set the range space.
9195 * "res" collects the results.
9196 */
9201
9202/* Replace the range space of "pma" by the range space of data->range and
9203 * add the result to data->res.
9204 */
9206{
9208 isl_space *space;
9209
9211 space = isl_space_domain(space);
9213 isl_space_copy(data->range));
9216
9217 return data->res ? isl_stat_ok : isl_stat_error;
9218}
9219
9220/* Replace the range space of all the piecewise affine expressions in "upma" by
9221 * the range space of "space".
9222 *
9223 * This assumes that all these expressions have the same output dimension.
9224 *
9225 * Since the spaces of the expressions change, so do their hash values.
9226 * We therefore need to create a new isl_union_pw_multi_aff.
9227 * Note that the hash value is currently computed based on the entire
9228 * space even though there can only be a single expression with a given
9229 * domain space.
9230 */
9234{
9235 struct isl_union_pw_multi_aff_reset_range_space_data data = { space };
9236 isl_space *space_upma;
9237
9238 space_upma = isl_union_pw_multi_aff_get_space(upma);
9239 data.res = isl_union_pw_multi_aff_empty(space_upma);
9241 &reset_range_space, &data) < 0)
9242 data.res = isl_union_pw_multi_aff_free(data.res);
9243
9244 isl_space_free(space);
9246 return data.res;
9247}
9248
9249/* Construct and return a union piecewise multi affine expression
9250 * that is equal to the given multi union piecewise affine expression,
9251 * in the special case of a 0D multi union piecewise affine expression.
9252 *
9253 * Construct a union piecewise multi affine expression
9254 * on top of the explicit domain of the input.
9255 */
9259{
9260 isl_space *space;
9261 isl_multi_val *mv;
9263
9264 space = isl_multi_union_pw_aff_get_space(mupa);
9265 mv = isl_multi_val_zero(space);
9268}
9269
9270/* Construct and return a union piecewise multi affine expression
9271 * that is equal to the given multi union piecewise affine expression.
9272 *
9273 * If the input is zero-dimensional, then
9274 * construct a union piecewise multi affine expression
9275 * on top of the explicit domain of the input.
9276 */
9280{
9281 int i;
9282 isl_size n;
9283 isl_space *space;
9285 isl_union_pw_aff *upa;
9286
9287 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9288 if (n < 0)
9289 mupa = isl_multi_union_pw_aff_free(mupa);
9290 if (!mupa)
9291 return NULL;
9292
9293 if (n == 0)
9295
9296 space = isl_multi_union_pw_aff_get_space(mupa);
9297 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, 0);
9299
9300 for (i = 1; i < n; ++i) {
9301 isl_union_pw_multi_aff *upma_i;
9302
9303 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9305 upma = isl_union_pw_multi_aff_flat_range_product(upma, upma_i);
9306 }
9307
9308 upma = isl_union_pw_multi_aff_reset_range_space(upma, space);
9309
9310 isl_multi_union_pw_aff_free(mupa);
9311 return upma;
9312}
9313
9314/* Intersect the range of "mupa" with "range",
9315 * in the special case where "mupa" is 0D.
9316 *
9317 * Intersect the domain of "mupa" with the constraints on the parameters
9318 * of "range".
9319 */
9327
9328/* Intersect the range of "mupa" with "range".
9329 * That is, keep only those domain elements that have a function value
9330 * in "range".
9331 */
9334{
9337 isl_space *space;
9338 isl_size n;
9339 int match;
9340
9341 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9342 if (n < 0 || !range)
9343 goto error;
9344
9345 space = isl_set_get_space(range);
9347 space, isl_dim_set);
9348 isl_space_free(space);
9349 if (match < 0)
9350 goto error;
9351 if (!match)
9352 isl_die(isl_multi_union_pw_aff_get_ctx(mupa), isl_error_invalid,
9353 "space don't match", goto error);
9354 if (n == 0)
9356
9358 isl_multi_union_pw_aff_copy(mupa));
9362
9363 return mupa;
9364error:
9365 isl_multi_union_pw_aff_free(mupa);
9367 return NULL;
9368}
9369
9370/* Return the shared domain of the elements of "mupa",
9371 * in the special case where "mupa" is zero-dimensional.
9372 *
9373 * Return the explicit domain of "mupa".
9374 * Note that this domain may be a parameter set, either
9375 * because "mupa" is meant to live in a set space or
9376 * because no explicit domain has been set.
9377 */
9380{
9381 isl_union_set *dom;
9382
9383 dom = isl_multi_union_pw_aff_get_explicit_domain(mupa);
9384 isl_multi_union_pw_aff_free(mupa);
9385
9386 return dom;
9387}
9388
9389/* Return the shared domain of the elements of "mupa".
9390 *
9391 * If "mupa" is zero-dimensional, then return its explicit domain.
9392 */
9395{
9396 int i;
9397 isl_size n;
9398 isl_union_pw_aff *upa;
9399 isl_union_set *dom;
9400
9401 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9402 if (n < 0)
9403 mupa = isl_multi_union_pw_aff_free(mupa);
9404 if (!mupa)
9405 return NULL;
9406
9407 if (n == 0)
9409
9410 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, 0);
9411 dom = isl_union_pw_aff_domain(upa);
9412 for (i = 1; i < n; ++i) {
9413 isl_union_set *dom_i;
9414
9415 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9416 dom_i = isl_union_pw_aff_domain(upa);
9417 dom = isl_union_set_intersect(dom, dom_i);
9418 }
9419
9420 isl_multi_union_pw_aff_free(mupa);
9421 return dom;
9422}
9423
9424/* Apply "aff" to "mupa". The space of "mupa" is equal to the domain of "aff".
9425 * In particular, the spaces have been aligned.
9426 * The result is defined over the shared domain of the elements of "mupa"
9427 *
9428 * We first extract the parametric constant part of "aff" and
9429 * define that over the shared domain.
9430 * Then we iterate over all input dimensions of "aff" and add the corresponding
9431 * multiples of the elements of "mupa".
9432 * Finally, we consider the integer divisions, calling the function
9433 * recursively to obtain an isl_union_pw_aff corresponding to the
9434 * integer division argument.
9435 */
9438{
9439 int i;
9440 isl_size n_in, n_div;
9441 isl_union_pw_aff *upa;
9442 isl_union_set *uset;
9443 isl_val *v;
9444 isl_aff *cst;
9445
9446 n_in = isl_aff_dim(aff, isl_dim_in);
9447 n_div = isl_aff_dim(aff, isl_dim_div);
9448 if (n_in < 0 || n_div < 0)
9449 goto error;
9450
9451 uset = isl_multi_union_pw_aff_domain(isl_multi_union_pw_aff_copy(mupa));
9452 cst = isl_aff_copy(aff);
9453 cst = isl_aff_drop_dims(cst, isl_dim_div, 0, n_div);
9454 cst = isl_aff_drop_dims(cst, isl_dim_in, 0, n_in);
9456 upa = isl_union_pw_aff_aff_on_domain(uset, cst);
9457
9458 for (i = 0; i < n_in; ++i) {
9459 isl_union_pw_aff *upa_i;
9460
9462 continue;
9464 upa_i = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9465 upa_i = isl_union_pw_aff_scale_val(upa_i, v);
9466 upa = isl_union_pw_aff_add(upa, upa_i);
9467 }
9468
9469 for (i = 0; i < n_div; ++i) {
9470 isl_aff *div;
9471 isl_union_pw_aff *upa_i;
9472
9474 continue;
9475 div = isl_aff_get_div(aff, i);
9477 isl_multi_union_pw_aff_copy(mupa), div);
9478 upa_i = isl_union_pw_aff_floor(upa_i);
9480 upa_i = isl_union_pw_aff_scale_val(upa_i, v);
9481 upa = isl_union_pw_aff_add(upa, upa_i);
9482 }
9483
9484 isl_multi_union_pw_aff_free(mupa);
9486
9487 return upa;
9488error:
9489 isl_multi_union_pw_aff_free(mupa);
9491 return NULL;
9492}
9493
9494/* Apply "aff" to "mupa". The space of "mupa" needs to be compatible
9495 * with the domain of "aff".
9496 * Furthermore, the dimension of this space needs to be greater than zero.
9497 * The result is defined over the shared domain of the elements of "mupa"
9498 *
9499 * We perform these checks and then hand over control to
9500 * multi_union_pw_aff_apply_aff.
9501 */
9504{
9505 isl_size dim;
9506 isl_space *space1, *space2;
9508
9509 mupa = isl_multi_union_pw_aff_align_params(mupa,
9511 aff = isl_aff_align_params(aff, isl_multi_union_pw_aff_get_space(mupa));
9512 if (!mupa || !aff)
9513 goto error;
9514
9515 space1 = isl_multi_union_pw_aff_get_space(mupa);
9516 space2 = isl_aff_get_domain_space(aff);
9517 equal = isl_space_is_equal(space1, space2);
9518 isl_space_free(space1);
9519 isl_space_free(space2);
9520 if (equal < 0)
9521 goto error;
9522 if (!equal)
9524 "spaces don't match", goto error);
9525 dim = isl_aff_dim(aff, isl_dim_in);
9526 if (dim < 0)
9527 goto error;
9528 if (dim == 0)
9530 "cannot determine domains", goto error);
9531
9533error:
9534 isl_multi_union_pw_aff_free(mupa);
9536 return NULL;
9537}
9538
9539/* Apply "ma" to "mupa", in the special case where "mupa" is 0D.
9540 * The space of "mupa" is known to be compatible with the domain of "ma".
9541 *
9542 * Construct an isl_multi_union_pw_aff that is equal to "ma"
9543 * on the domain of "mupa".
9544 */
9547{
9548 isl_union_set *dom;
9549
9551 ma = isl_multi_aff_project_domain_on_params(ma);
9552
9554}
9555
9556/* Apply "ma" to "mupa". The space of "mupa" needs to be compatible
9557 * with the domain of "ma".
9558 * The result is defined over the shared domain of the elements of "mupa"
9559 */
9562{
9563 isl_space *space1, *space2;
9566 int i;
9567 isl_size n_in, n_out;
9568
9569 mupa = isl_multi_union_pw_aff_align_params(mupa,
9570 isl_multi_aff_get_space(ma));
9571 ma = isl_multi_aff_align_params(ma,
9572 isl_multi_union_pw_aff_get_space(mupa));
9573 n_in = isl_multi_aff_dim(ma, isl_dim_in);
9574 n_out = isl_multi_aff_dim(ma, isl_dim_out);
9575 if (!mupa || n_in < 0 || n_out < 0)
9576 goto error;
9577
9578 space1 = isl_multi_union_pw_aff_get_space(mupa);
9579 space2 = isl_multi_aff_get_domain_space(ma);
9580 equal = isl_space_is_equal(space1, space2);
9581 isl_space_free(space1);
9582 isl_space_free(space2);
9583 if (equal < 0)
9584 goto error;
9585 if (!equal)
9586 isl_die(isl_multi_aff_get_ctx(ma), isl_error_invalid,
9587 "spaces don't match", goto error);
9588 if (n_in == 0)
9590
9591 space1 = isl_space_range(isl_multi_aff_get_space(ma));
9592 res = isl_multi_union_pw_aff_alloc(space1);
9593
9594 for (i = 0; i < n_out; ++i) {
9595 isl_aff *aff;
9596 isl_union_pw_aff *upa;
9597
9598 aff = isl_multi_aff_get_aff(ma, i);
9600 isl_multi_union_pw_aff_copy(mupa), aff);
9601 res = isl_multi_union_pw_aff_set_union_pw_aff(res, i, upa);
9602 }
9603
9604 isl_multi_aff_free(ma);
9605 isl_multi_union_pw_aff_free(mupa);
9606 return res;
9607error:
9608 isl_multi_union_pw_aff_free(mupa);
9609 isl_multi_aff_free(ma);
9610 return NULL;
9611}
9612
9613/* Apply "pa" to "mupa", in the special case where "mupa" is 0D.
9614 * The space of "mupa" is known to be compatible with the domain of "pa".
9615 *
9616 * Construct an isl_multi_union_pw_aff that is equal to "pa"
9617 * on the domain of "mupa".
9618 */
9629
9630/* Apply "pa" to "mupa". The space of "mupa" needs to be compatible
9631 * with the domain of "pa".
9632 * Furthermore, the dimension of this space needs to be greater than zero.
9633 * The result is defined over the shared domain of the elements of "mupa"
9634 */
9637{
9638 int i;
9640 isl_size n_in;
9641 isl_space *space, *space2;
9642 isl_union_pw_aff *upa;
9643
9644 mupa = isl_multi_union_pw_aff_align_params(mupa,
9647 isl_multi_union_pw_aff_get_space(mupa));
9648 if (!mupa || !pa)
9649 goto error;
9650
9651 space = isl_multi_union_pw_aff_get_space(mupa);
9653 equal = isl_space_is_equal(space, space2);
9654 isl_space_free(space);
9655 isl_space_free(space2);
9656 if (equal < 0)
9657 goto error;
9658 if (!equal)
9660 "spaces don't match", goto error);
9661 n_in = isl_pw_aff_dim(pa, isl_dim_in);
9662 if (n_in < 0)
9663 goto error;
9664 if (n_in == 0)
9666
9667 space = isl_space_params(isl_multi_union_pw_aff_get_space(mupa));
9668 upa = isl_union_pw_aff_empty(space);
9669
9670 for (i = 0; i < pa->n; ++i) {
9671 isl_aff *aff;
9672 isl_set *domain;
9673 isl_multi_union_pw_aff *mupa_i;
9674 isl_union_pw_aff *upa_i;
9675
9676 mupa_i = isl_multi_union_pw_aff_copy(mupa);
9677 domain = isl_set_copy(pa->p[i].set);
9679 aff = isl_aff_copy(pa->p[i].aff);
9680 upa_i = multi_union_pw_aff_apply_aff(mupa_i, aff);
9681 upa = isl_union_pw_aff_union_add(upa, upa_i);
9682 }
9683
9684 isl_multi_union_pw_aff_free(mupa);
9686 return upa;
9687error:
9688 isl_multi_union_pw_aff_free(mupa);
9690 return NULL;
9691}
9692
9693/* Apply "pma" to "mupa", in the special case where "mupa" is 0D.
9694 * The space of "mupa" is known to be compatible with the domain of "pma".
9695 *
9696 * Construct an isl_multi_union_pw_aff that is equal to "pma"
9697 * on the domain of "mupa".
9698 */
9710
9711/* Apply "pma" to "mupa". The space of "mupa" needs to be compatible
9712 * with the domain of "pma".
9713 * The result is defined over the shared domain of the elements of "mupa"
9714 */
9718{
9719 isl_space *space1, *space2;
9722 int i;
9723 isl_size n_in, n_out;
9724
9725 mupa = isl_multi_union_pw_aff_align_params(mupa,
9728 isl_multi_union_pw_aff_get_space(mupa));
9729 if (!mupa || !pma)
9730 goto error;
9731
9732 space1 = isl_multi_union_pw_aff_get_space(mupa);
9734 equal = isl_space_is_equal(space1, space2);
9735 isl_space_free(space1);
9736 isl_space_free(space2);
9737 if (equal < 0)
9738 goto error;
9739 if (!equal)
9741 "spaces don't match", goto error);
9744 if (n_in < 0 || n_out < 0)
9745 goto error;
9746 if (n_in == 0)
9748
9750 res = isl_multi_union_pw_aff_alloc(space1);
9751
9752 for (i = 0; i < n_out; ++i) {
9753 isl_pw_aff *pa;
9754 isl_union_pw_aff *upa;
9755
9758 isl_multi_union_pw_aff_copy(mupa), pa);
9759 res = isl_multi_union_pw_aff_set_union_pw_aff(res, i, upa);
9760 }
9761
9763 isl_multi_union_pw_aff_free(mupa);
9764 return res;
9765error:
9766 isl_multi_union_pw_aff_free(mupa);
9768 return NULL;
9769}
9770
9771/* Replace the explicit domain of "mupa" by its preimage under "upma".
9772 * If the explicit domain only keeps track of constraints on the parameters,
9773 * then only update those constraints.
9774 */
9778{
9779 isl_bool is_params;
9780
9781 if (isl_multi_union_pw_aff_check_has_explicit_domain(mupa) < 0)
9782 return isl_multi_union_pw_aff_free(mupa);
9783
9784 mupa = isl_multi_union_pw_aff_cow(mupa);
9785 if (!mupa)
9786 return NULL;
9787
9788 is_params = isl_union_set_is_params(mupa->u.dom);
9789 if (is_params < 0)
9790 return isl_multi_union_pw_aff_free(mupa);
9791
9792 upma = isl_union_pw_multi_aff_copy(upma);
9793 if (is_params)
9796 else
9798 mupa->u.dom, upma);
9799 if (!mupa->u.dom)
9800 return isl_multi_union_pw_aff_free(mupa);
9801 return mupa;
9802}
9803
9804/* Compute the pullback of "mupa" by the function represented by "upma".
9805 * In other words, plug in "upma" in "mupa". The result contains
9806 * expressions defined over the domain space of "upma".
9807 *
9808 * Run over all elements of "mupa" and plug in "upma" in each of them.
9809 *
9810 * If "mupa" has an explicit domain, then it is this domain
9811 * that needs to undergo a pullback instead, i.e., a preimage.
9812 */
9817{
9818 int i;
9819 isl_size n;
9820
9821 mupa = isl_multi_union_pw_aff_align_params(mupa,
9824 isl_multi_union_pw_aff_get_space(mupa));
9825 mupa = isl_multi_union_pw_aff_cow(mupa);
9826 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9827 if (n < 0 || !upma)
9828 goto error;
9829
9830 for (i = 0; i < n; ++i) {
9831 isl_union_pw_aff *upa;
9832
9833 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9836 mupa = isl_multi_union_pw_aff_set_union_pw_aff(mupa, i, upa);
9837 }
9838
9839 if (isl_multi_union_pw_aff_has_explicit_domain(mupa))
9841
9843 return mupa;
9844error:
9845 isl_multi_union_pw_aff_free(mupa);
9847 return NULL;
9848}
9849
9850/* Extract the sequence of elements in "mupa" with domain space "space"
9851 * (ignoring parameters).
9852 *
9853 * For the elements of "mupa" that are not defined on the specified space,
9854 * the corresponding element in the result is empty.
9855 */
9858{
9859 int i;
9860 isl_size n;
9861 isl_space *space_mpa;
9862 isl_multi_pw_aff *mpa;
9863
9864 n = isl_multi_union_pw_aff_dim(mupa, isl_dim_set);
9865 if (n < 0 || !space)
9866 goto error;
9867
9868 space_mpa = isl_multi_union_pw_aff_get_space(mupa);
9869 space = isl_space_replace_params(space, space_mpa);
9871 space_mpa);
9872 mpa = isl_multi_pw_aff_alloc(space_mpa);
9873
9874 space = isl_space_from_domain(space);
9875 space = isl_space_add_dims(space, isl_dim_out, 1);
9876 for (i = 0; i < n; ++i) {
9877 isl_union_pw_aff *upa;
9878 isl_pw_aff *pa;
9879
9880 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, i);
9882 isl_space_copy(space));
9883 mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
9885 }
9886
9887 isl_space_free(space);
9888 return mpa;
9889error:
9890 isl_space_free(space);
9891 return NULL;
9892}
9893
9894/* Data structure that specifies how isl_union_pw_multi_aff_un_op
9895 * should modify the base expressions in the input.
9896 *
9897 * If "filter" is not NULL, then only the base expressions that satisfy "filter"
9898 * are taken into account.
9899 * "fn" is applied to each entry in the input.
9900 */
9905
9906/* Wrapper for isl_union_pw_multi_aff_un_op filter functions (which do not take
9907 * a second argument) for use as an isl_union_pw_multi_aff_transform
9908 * filter function (which does take a second argument).
9909 * Simply call control->filter without the second argument.
9910 */
9913{
9915
9916 return control->filter(pma);
9917}
9918
9919/* Wrapper for isl_union_pw_multi_aff_un_op base functions (which do not take
9920 * a second argument) for use as an isl_union_pw_multi_aff_transform
9921 * base function (which does take a second argument).
9922 * Simply call control->fn without the second argument.
9923 */
9926{
9928
9929 return control->fn(pma);
9930}
9931
9932/* Construct an isl_union_pw_multi_aff that is obtained by
9933 * modifying "upma" according to "control".
9934 *
9935 * isl_union_pw_multi_aff_transform performs essentially
9936 * the same operation, but takes a filter and a callback function
9937 * of a different form (with an extra argument).
9938 * Call isl_union_pw_multi_aff_transform with wrappers
9939 * that remove this extra argument.
9940 */
9944{
9945 struct isl_union_pw_multi_aff_transform_control t_control = {
9947 .filter_user = control,
9949 .fn_user = control,
9950 };
9951
9952 return isl_union_pw_multi_aff_transform(upma, &t_control);
9953}
9954
9955/* For each function in "upma" of the form A -> [B -> C],
9956 * extract the function A -> B and collect the results.
9957 */
9967
9968/* For each function in "upma" of the form A -> [B -> C],
9969 * extract the function A -> C and collect the results.
9970 */
9980
9981/* Evaluate the affine function "aff" in the void point "pnt".
9982 * In particular, return the value NaN.
9983 */
9985 __isl_take isl_point *pnt)
9986{
9987 isl_ctx *ctx;
9988
9989 ctx = isl_point_get_ctx(pnt);
9991 isl_point_free(pnt);
9992 return isl_val_nan(ctx);
9993}
9994
9995/* Evaluate the affine expression "aff"
9996 * in the coordinates (with denominator) "pnt".
9997 */
9999 __isl_keep isl_vec *pnt)
10000{
10001 isl_int n, d;
10002 isl_ctx *ctx;
10003 isl_val *v;
10004
10005 if (!aff || !pnt)
10006 return NULL;
10007
10008 ctx = isl_vec_get_ctx(aff);
10009 isl_int_init(n);
10010 isl_int_init(d);
10011 isl_seq_inner_product(aff->el + 1, pnt->el, pnt->size, &n);
10012 isl_int_mul(d, aff->el[0], pnt->el[0]);
10013 v = isl_val_rat_from_isl_int(ctx, n, d);
10014 v = isl_val_normalize(v);
10016 isl_int_clear(d);
10017
10018 return v;
10019}
10020
10021/* Check that the domain space of "aff" is equal to "space".
10022 */
10024 __isl_keep isl_space *space)
10025{
10026 isl_bool ok;
10027
10029 if (ok < 0)
10030 return isl_stat_error;
10031 if (!ok)
10033 "incompatible spaces", return isl_stat_error);
10034 return isl_stat_ok;
10035}
10036
10037/* Evaluate the affine function "aff" in "pnt".
10038 */
10040 __isl_take isl_point *pnt)
10041{
10042 isl_bool is_void;
10043 isl_val *v;
10044 isl_local_space *ls;
10045
10047 goto error;
10048 is_void = isl_point_is_void(pnt);
10049 if (is_void < 0)
10050 goto error;
10051 if (is_void)
10052 return eval_void(aff, pnt);
10053
10055 pnt = isl_local_space_lift_point(ls, pnt);
10056
10057 v = eval(aff->v, isl_point_peek_vec(pnt));
10058
10060 isl_point_free(pnt);
10061
10062 return v;
10063error:
10065 isl_point_free(pnt);
10066 return NULL;
10067}
__isl_give isl_pw_aff * isl_pw_aff_align_params(__isl_take isl_pw_aff *pwaff, __isl_take isl_space *model)
__isl_constructor __isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_aff(__isl_take isl_multi_aff *ma)
__isl_overload __isl_give isl_pw_multi_aff * isl_pw_multi_aff_pullback_pw_multi_aff(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
__isl_give isl_union_pw_aff * isl_union_pw_aff_align_params(__isl_take isl_union_pw_aff *upa, __isl_take isl_space *model)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_empty(__isl_take isl_space *space)
__isl_give isl_set * isl_multi_aff_lex_le_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4568
__isl_export isl_bool isl_pw_aff_isa_aff(__isl_keep isl_pw_aff *pa)
__isl_export __isl_give isl_space * isl_pw_multi_aff_get_space(__isl_keep isl_pw_multi_aff *pma)
__isl_export __isl_give isl_set * isl_pw_aff_ne_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3362
__isl_null isl_aff * isl_aff_free(__isl_take isl_aff *aff)
Definition isl_aff.c:449
__isl_null isl_union_pw_multi_aff * isl_union_pw_multi_aff_free(__isl_take isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_space * isl_union_pw_multi_aff_get_space(__isl_keep isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_multi_pw_aff * isl_multi_pw_aff_intersect_domain(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_set *domain)
__isl_null isl_union_pw_aff * isl_union_pw_aff_free(__isl_take isl_union_pw_aff *upa)
__isl_overload __isl_give isl_pw_aff * isl_pw_aff_scale_val(__isl_take isl_pw_aff *pa, __isl_take isl_val *v)
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_factor_domain(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:4811
isl_ctx * isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff)
__isl_export __isl_give isl_union_pw_aff * isl_union_pw_aff_union_add(__isl_take isl_union_pw_aff *upa1, __isl_take isl_union_pw_aff *upa2)
__isl_export __isl_give isl_set * isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3155
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_align_params(__isl_take isl_pw_multi_aff *pma, __isl_take isl_space *model)
isl_ctx * isl_pw_multi_aff_get_ctx(__isl_keep isl_pw_multi_aff *pma)
__isl_give isl_union_pw_aff * isl_union_pw_aff_scale_down_val(__isl_take isl_union_pw_aff *upa, __isl_take isl_val *v)
isl_stat isl_union_pw_aff_foreach_pw_aff(__isl_keep isl_union_pw_aff *upa, isl_stat(*fn)(__isl_take isl_pw_aff *pa, void *user), void *user)
__isl_constructor __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
__isl_give isl_pw_aff * isl_union_pw_aff_extract_pw_aff(__isl_keep isl_union_pw_aff *upa, __isl_take isl_space *space)
__isl_export isl_bool isl_pw_aff_plain_is_equal(__isl_keep isl_pw_aff *pwaff1, __isl_keep isl_pw_aff *pwaff2)
__isl_give isl_set * isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4688
__isl_overload __isl_give isl_pw_aff * isl_pw_aff_pullback_pw_multi_aff(__isl_take isl_pw_aff *pa, __isl_take isl_pw_multi_aff *pma)
isl_size isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff, enum isl_dim_type type)
__isl_export __isl_give isl_set * isl_aff_le_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2538
isl_bool isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff)
Definition isl_aff.c:3494
__isl_overload __isl_give isl_pw_aff * isl_pw_aff_pullback_multi_aff(__isl_take isl_pw_aff *pa, __isl_take isl_multi_aff *ma)
__isl_export __isl_give isl_space * isl_union_pw_aff_get_space(__isl_keep isl_union_pw_aff *upa)
__isl_give isl_pw_aff * isl_pw_aff_alloc(__isl_take isl_set *set, __isl_take isl_aff *aff)
__isl_export isl_size isl_pw_multi_aff_n_piece(__isl_keep isl_pw_multi_aff *pma)
__isl_export __isl_give isl_aff * isl_pw_aff_as_aff(__isl_take isl_pw_aff *pa)
__isl_export __isl_give isl_union_pw_aff * isl_union_pw_aff_sub(__isl_take isl_union_pw_aff *upa1, __isl_take isl_union_pw_aff *upa2)
__isl_export __isl_give isl_pw_aff * isl_pw_aff_intersect_domain(__isl_take isl_pw_aff *pa, __isl_take isl_set *set)
__isl_give isl_union_map * isl_union_map_from_union_pw_aff(__isl_take isl_union_pw_aff *upa)
__isl_give isl_pw_aff * isl_pw_aff_empty(__isl_take isl_space *space)
__isl_give isl_map * isl_multi_pw_aff_eq_map(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2)
Definition isl_aff.c:7542
__isl_null isl_pw_aff * isl_pw_aff_free(__isl_take isl_pw_aff *pwaff)
__isl_export __isl_give isl_multi_aff * isl_multi_aff_gist(__isl_take isl_multi_aff *maff, __isl_take isl_set *context)
__isl_export __isl_give isl_space * isl_pw_aff_get_space(__isl_keep isl_pw_aff *pwaff)
__isl_export __isl_give isl_pw_aff * isl_pw_aff_neg(__isl_take isl_pw_aff *pwaff)
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_align_params(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_space *model)
isl_stat isl_union_pw_multi_aff_foreach_pw_multi_aff(__isl_keep isl_union_pw_multi_aff *upma, isl_stat(*fn)(__isl_take isl_pw_multi_aff *pma, void *user), void *user)
__isl_give isl_pw_aff * isl_pw_aff_add_dims(__isl_take isl_pw_aff *pwaff, enum isl_dim_type type, unsigned n)
isl_bool isl_pw_multi_aff_involves_nan(__isl_keep isl_pw_multi_aff *pma)
__isl_give isl_aff * isl_aff_copy(__isl_keep isl_aff *aff)
Definition isl_aff.c:145
__isl_export __isl_give isl_set * isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3175
isl_size isl_pw_multi_aff_dim(__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type)
__isl_constructor __isl_give isl_multi_pw_aff * isl_multi_pw_aff_from_pw_aff(__isl_take isl_pw_aff *pa)
__isl_export __isl_give isl_union_set * isl_union_pw_multi_aff_domain(__isl_take isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_aff * isl_aff_div(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3559
__isl_export __isl_give isl_aff * isl_aff_floor(__isl_take isl_aff *aff)
Definition isl_aff.c:1729
__isl_export __isl_give isl_pw_aff * isl_pw_aff_sub(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
__isl_give isl_space * isl_pw_multi_aff_get_domain_space(__isl_keep isl_pw_multi_aff *pma)
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_copy(__isl_keep isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_set * isl_aff_ge_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2499
isl_ctx * isl_union_pw_multi_aff_get_ctx(__isl_keep isl_union_pw_multi_aff *upma)
__isl_give isl_pw_aff * isl_pw_aff_project_domain_on_params(__isl_take isl_pw_aff *pa)
__isl_constructor __isl_give isl_pw_aff * isl_pw_aff_from_aff(__isl_take isl_aff *aff)
isl_bool isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa)
isl_size isl_union_pw_multi_aff_n_pw_multi_aff(__isl_keep isl_union_pw_multi_aff *upma)
__isl_give isl_union_pw_aff * isl_union_pw_aff_copy(__isl_keep isl_union_pw_aff *upa)
__isl_export __isl_give isl_union_pw_aff * isl_union_pw_aff_add(__isl_take isl_union_pw_aff *upa1, __isl_take isl_union_pw_aff *upa2)
__isl_constructor __isl_give isl_multi_aff * isl_multi_aff_from_aff(__isl_take isl_aff *aff)
__isl_export __isl_give isl_set * isl_aff_gt_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2511
__isl_export isl_bool isl_pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2)
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_empty(__isl_take isl_space *space)
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_flat_range_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:6475
__isl_give isl_space * isl_pw_aff_get_domain_space(__isl_keep isl_pw_aff *pwaff)
__isl_give isl_pw_aff * isl_pw_aff_from_range(__isl_take isl_pw_aff *pwa)
__isl_constructor __isl_give isl_union_pw_aff * isl_union_pw_aff_from_pw_aff(__isl_take isl_pw_aff *pa)
__isl_export __isl_give isl_union_set * isl_union_pw_aff_domain(__isl_take isl_union_pw_aff *upa)
__isl_export __isl_give isl_aff * isl_aff_add(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1976
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_add_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_pw_multi_aff *pma)
__isl_give isl_union_pw_aff * isl_union_pw_aff_scale_val(__isl_take isl_union_pw_aff *upa, __isl_take isl_val *v)
__isl_export __isl_give isl_set * isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3188
__isl_export __isl_give isl_set * isl_aff_eq_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2567
__isl_null isl_pw_multi_aff * isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma)
__isl_overload __isl_give isl_pw_multi_aff * isl_pw_multi_aff_pullback_multi_aff(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_aff *ma)
__isl_export __isl_give isl_aff * isl_aff_ceil(__isl_take isl_aff *aff)
Definition isl_aff.c:1873
__isl_export __isl_give isl_set * isl_pw_multi_aff_domain(__isl_take isl_pw_multi_aff *pma)
__isl_export __isl_give isl_set * isl_pw_aff_le_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3182
__isl_export __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_params(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *params)
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_factor_range(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:4821
__isl_export __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_domain(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_union_set *uset)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_copy(__isl_keep isl_pw_multi_aff *pma)
__isl_export __isl_give isl_set * isl_multi_pw_aff_domain(__isl_take isl_multi_pw_aff *mpa)
__isl_export __isl_give isl_set * isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff)
__isl_export __isl_give isl_multi_aff * isl_multi_aff_floor(__isl_take isl_multi_aff *ma)
__isl_give isl_union_pw_aff * isl_union_pw_aff_empty(__isl_take isl_space *space)
__isl_export __isl_give isl_aff * isl_aff_mul(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3516
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:6460
__isl_give isl_pw_aff * isl_pw_aff_copy(__isl_keep isl_pw_aff *pwaff)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_project_domain_on_params(__isl_take isl_pw_multi_aff *pma)
__isl_export __isl_give isl_set * isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3165
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_alloc(__isl_take isl_set *set, __isl_take isl_multi_aff *maff)
__isl_give isl_union_pw_aff * isl_union_pw_aff_add_pw_aff(__isl_take isl_union_pw_aff *upa, __isl_take isl_pw_aff *pa)
struct isl_union_pw_multi_aff isl_union_pw_multi_aff
Definition aff_type.h:38
struct isl_union_pw_aff isl_union_pw_aff
Definition aff_type.h:23
struct isl_multi_aff isl_multi_aff
Definition aff_type.h:29
struct isl_multi_pw_aff isl_multi_pw_aff
Definition aff_type.h:43
struct isl_multi_union_pw_aff isl_multi_union_pw_aff
Definition aff_type.h:46
__isl_give isl_constraint * isl_inequality_from_aff(__isl_take isl_aff *aff)
__isl_give isl_constraint * isl_constraint_set_constant_val(__isl_take isl_constraint *constraint, __isl_take isl_val *v)
__isl_give isl_constraint * isl_equality_from_aff(__isl_take isl_aff *aff)
__isl_give isl_val * isl_constraint_get_constant_val(__isl_keep isl_constraint *constraint)
__isl_give isl_basic_set * isl_basic_set_from_constraint(__isl_take isl_constraint *constraint)
isl_stat isl_stat_non_null(void *obj)
Definition isl_ctx.c:34
#define __isl_take
Definition ctx.h:22
#define isl_calloc_type(ctx, type)
Definition ctx.h:130
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_size_error
Definition ctx.h:98
#define __isl_null
Definition ctx.h:28
#define isl_die(ctx, errno, msg, code)
Definition ctx.h:138
isl_bool isl_bool_ok(int b)
Definition isl_ctx.c:58
@ isl_error_unsupported
Definition ctx.h:82
@ isl_error_invalid
Definition ctx.h:80
#define isl_alloc_array(ctx, type, n)
Definition ctx.h:132
#define __isl_keep
Definition ctx.h:25
int isl_size
Definition ctx.h:97
isl_bool isl_bool_not(isl_bool b)
Definition isl_ctx.c:44
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
c1
Definition dot.c:2
m
Definition guard1-0.c:2
#define isl_hash_hash(h, h2)
Definition hash.h:26
#define isl_hash_init()
Definition hash.h:21
__isl_export __isl_give ISL_HMAP __isl_take ISL_KEY __isl_take ISL_VAL * val
Definition hmap.h:32
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
Definition hmap.h:37
isl_stat isl_stat void * user
Definition hmap.h:39
__isl_null isl_id * isl_id_free(__isl_take isl_id *id)
Definition isl_id.c:207
__isl_give isl_id * isl_id_copy(isl_id *id)
Definition isl_id.c:129
int GMPQAPI cmp(mp_rat op1, mp_rat op2)
void GMPZAPI neg(mp_int rop, mp_int op)
void GMPZAPI gcd(mp_int rop, mp_int op1, mp_int op2)
void GMPZAPI sub(mp_int rop, mp_int op1, mp_int op2)
__isl_give isl_pw_aff * isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff, isl_int v)
Definition isl_aff.c:3374
static __isl_give isl_map * isl_multi_pw_aff_eq_map_on_space(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_take isl_space *space)
Definition isl_aff.c:7513
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_identity_on_domain_space(__isl_take isl_space *space)
Definition isl_aff.c:4480
__isl_give isl_aff * isl_aff_add_constant_si(__isl_take isl_aff *aff, int v)
Definition isl_aff.c:1099
__isl_give isl_set * isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3352
__isl_give isl_pw_aff * isl_pw_aff_union_opt(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2, int max)
Definition isl_aff.c:2968
__isl_give isl_aff * isl_aff_substitute_equalities(__isl_take isl_aff *aff, __isl_take isl_basic_set *eq)
Definition isl_aff.c:2303
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_set_pw_aff(__isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:6620
__isl_give isl_aff * isl_aff_scale(__isl_take isl_aff *aff, isl_int f)
Definition isl_aff.c:2039
static isl_stat get_union_pw_aff(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:8227
static __isl_give isl_aff * isl_aff_zero_in_space(__isl_take isl_space *space)
Definition isl_aff.c:2886
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_add(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4859
static __isl_give isl_basic_set * aff_nonneg_basic_set(__isl_take isl_aff *aff, int rational, void *user)
Definition isl_aff.c:2388
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4880
__isl_give isl_set * isl_pw_aff_list_eq_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3318
__isl_give isl_pw_aff * isl_pw_aff_pullback_multi_pw_aff(__isl_take isl_pw_aff *pa, __isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:7454
__isl_give isl_union_set * isl_multi_union_pw_aff_zero_union_set(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9085
isl_ctx * isl_aff_get_ctx(__isl_keep isl_aff *aff)
Definition isl_aff.c:465
__isl_give isl_multi_aff * isl_multi_aff_range_map(__isl_take isl_space *space)
Definition isl_aff.c:4300
__isl_give isl_pw_aff * isl_pw_aff_var_on_domain(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos)
Definition isl_aff.c:409
__isl_give isl_aff * isl_aff_align_params(__isl_take isl_aff *aff, __isl_take isl_space *model)
Definition isl_aff.c:724
isl_bool isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2)
Definition isl_aff.c:7156
static isl_bool isl_aff_domain_is_product(__isl_keep isl_aff *aff)
Definition isl_aff.c:2696
static __isl_give isl_basic_set * isl_multi_aff_domain(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:4081
__isl_give isl_set * isl_multi_aff_lex_le_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4568
__isl_give isl_pw_aff * isl_pw_aff_set_rational(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3980
__isl_give isl_aff * isl_aff_pullback_aff(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:6085
__isl_give isl_pw_aff * isl_multi_pw_aff_apply_aff(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_aff *aff)
Definition isl_aff.c:7353
static __isl_give isl_aff * swap_div(__isl_take isl_aff *aff, int a, int b)
Definition isl_aff.c:1609
static __isl_give isl_pw_aff * nan_on_domain_set(__isl_take isl_set *dom)
Definition isl_aff.c:3731
static __isl_give isl_aff * subtract_initial(__isl_take isl_aff *aff, __isl_keep isl_multi_aff *ma, int n, isl_int *c, isl_int denom)
Definition isl_aff.c:4923
__isl_give isl_aff * isl_aff_project_domain_on_params(__isl_take isl_aff *aff)
Definition isl_aff.c:2708
__isl_null isl_aff * isl_aff_free(__isl_take isl_aff *aff)
Definition isl_aff.c:449
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_flat_range_product(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:6530
__isl_give isl_pw_multi_aff * isl_space_range_map_pw_multi_aff(__isl_take isl_space *space)
Definition isl_aff.c:4380
__isl_give isl_aff * isl_aff_from_range(__isl_take isl_aff *aff)
Definition isl_aff.c:2726
__isl_give isl_map * isl_pw_aff_le_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3239
__isl_give isl_set * isl_pw_aff_ne_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3362
__isl_give isl_aff * isl_aff_move_dims(__isl_take isl_aff *aff, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n)
Definition isl_aff.c:2787
__isl_give isl_aff * isl_aff_gist_params(__isl_take isl_aff *aff, __isl_take isl_set *context)
Definition isl_aff.c:2338
static __isl_give isl_pw_aff * isl_pw_aff_list_opt(__isl_take isl_pw_aff_list *list, int max)
Definition isl_aff.c:3909
static __isl_give isl_union_pw_aff * isl_union_pw_aff_pw_aff_on_domain_aligned(__isl_take isl_union_set *domain, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:8344
__isl_give isl_pw_aff * isl_pw_aff_val_on_domain(__isl_take isl_set *domain, __isl_take isl_val *v)
Definition isl_aff.c:7729
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_range_product(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:6550
static __isl_give isl_pw_multi_aff * isl_union_pw_multi_aff_un_op_drop_user(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:9924
isl_size isl_aff_domain_dim(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:498
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_zero(__isl_take isl_space *space)
Definition isl_aff.c:6960
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_scale_multi_val(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv)
Definition isl_aff.c:6889
static __isl_give isl_pw_multi_aff * pw_multi_aff_from_map_base(__isl_take isl_map *map)
Definition isl_aff.c:5193
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_substitute(__isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_keep isl_pw_aff *subs)
Definition isl_aff.c:5860
static __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_reset_range_space(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_space *space)
Definition isl_aff.c:9232
static __isl_give isl_pw_aff * replace_list_by_nan(__isl_take isl_pw_aff_list *list, int n)
Definition isl_aff.c:3848
__isl_give isl_aff * isl_aff_scale_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:2075
__isl_give isl_map * isl_pw_aff_gt_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3268
__isl_give isl_pw_multi_aff * isl_multi_aff_to_pw_multi_aff(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:4462
static isl_stat pw_multi_aff_from_pw_aff_entry(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8455
static __isl_give isl_basic_set * aff_pos_basic_set(__isl_take isl_aff *aff, int rational, void *user)
Definition isl_aff.c:2351
int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2)
Definition isl_aff.c:7694
__isl_give isl_aff * isl_aff_drop_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_aff.c:2661
isl_bool isl_aff_involves_locals(__isl_keep isl_aff *aff)
Definition isl_aff.c:2651
__isl_give isl_basic_set * isl_aff_bind_id(__isl_take isl_aff *aff, __isl_take isl_id *id)
Definition isl_aff.c:3068
__isl_give isl_aff * isl_aff_add(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1976
isl_stat isl_seq_preimage(isl_int *dst, isl_int *src, __isl_keep isl_multi_aff *ma, int n_before, int n_after, int n_div_ma, int n_div_bmap, isl_int f, isl_int c1, isl_int c2, isl_int g, int has_denom)
Definition isl_aff.c:5944
__isl_give isl_aff * isl_aff_insert_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_aff.c:2737
__isl_give isl_local_space * isl_aff_get_domain_local_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:586
__isl_give isl_aff * isl_aff_val_on_domain_space(__isl_take isl_space *space, __isl_take isl_val *val)
Definition isl_aff.c:361
static __isl_give isl_union_pw_aff * isl_union_pw_aff_reset_domain_space(__isl_take isl_union_pw_aff *upa, __isl_take isl_space *space)
Definition isl_aff.c:8143
__isl_give isl_aff * isl_aff_cow(__isl_take isl_aff *aff)
Definition isl_aff.c:163
__isl_give isl_pw_multi_aff * isl_set_pw_multi_aff_on_domain_multi_val(__isl_take isl_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7856
static __isl_give isl_aff * add_expanded(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1929
static __isl_give isl_multi_union_pw_aff * mupa_intersect_range_0D(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *range)
Definition isl_aff.c:9320
__isl_give isl_aff * isl_aff_nan_on_domain_space(__isl_take isl_space *space)
Definition isl_aff.c:302
__isl_give isl_multi_union_pw_aff * isl_union_pw_multi_aff_as_multi_union_pw_aff(__isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:8893
__isl_give isl_pw_aff * isl_pw_aff_list_min(__isl_take isl_pw_aff_list *list)
Definition isl_aff.c:3964
static __isl_give isl_multi_union_pw_aff * mupa_apply_pw_multi_aff_0D(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9699
__isl_give isl_union_set * isl_union_pw_aff_zero_union_set(__isl_take isl_union_pw_aff *upa)
Definition isl_aff.c:8505
__isl_give isl_pw_aff * isl_pw_aff_mul(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3618
static __isl_give isl_pw_aff * pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3758
__isl_give isl_pw_aff * isl_pw_aff_union_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:2961
isl_bool isl_pw_multi_aff_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2)
Definition isl_aff.c:7241
__isl_give isl_pw_aff * isl_pw_aff_floor(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3400
__isl_give isl_map * isl_pw_aff_ge_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3258
__isl_give isl_aff * isl_aff_nan_on_domain(__isl_take isl_local_space *ls)
Definition isl_aff.c:291
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:6460
__isl_give isl_set * isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3175
__isl_give isl_pw_aff * isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3811
__isl_give isl_union_pw_aff * isl_union_pw_multi_aff_get_union_pw_aff(__isl_keep isl_union_pw_multi_aff *upma, int pos)
Definition isl_aff.c:8252
__isl_give isl_aff * isl_aff_val_on_domain(__isl_take isl_local_space *ls, __isl_take isl_val *val)
Definition isl_aff.c:331
int isl_aff_plain_cmp(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2)
Definition isl_aff.c:7661
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_domain(__isl_take isl_set *set)
Definition isl_aff.c:6341
__isl_give isl_union_pw_aff * isl_union_pw_aff_mod_val(__isl_take isl_union_pw_aff *upa, __isl_take isl_val *m)
Definition isl_aff.c:8187
__isl_give isl_union_pw_aff * isl_union_pw_aff_pw_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:8367
__isl_give isl_union_pw_aff * isl_union_pw_aff_floor(__isl_take isl_union_pw_aff *upa)
Definition isl_aff.c:8175
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_factor_domain(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:4811
isl_bool isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2)
Definition isl_aff.c:784
static __isl_give isl_pw_aff * floor_entry(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8168
__isl_give isl_aff * isl_aff_lift(__isl_take isl_aff *aff)
Definition isl_aff.c:6222
__isl_give isl_multi_pw_aff * isl_map_max_multi_pw_aff(__isl_take isl_map *map)
Definition isl_aff.c:6845
int isl_aff_find_dim_by_name(__isl_keep isl_aff *aff, enum isl_dim_type type, const char *name)
Definition isl_aff.c:549
__isl_give isl_aff * isl_aff_mod_val(__isl_take isl_aff *aff, __isl_take isl_val *m)
Definition isl_aff.c:1796
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pullback_union_pw_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:9814
static __isl_give isl_val * eval_void(__isl_take isl_aff *aff, __isl_take isl_point *pnt)
Definition isl_aff.c:9984
__isl_give isl_aff * isl_aff_align_divs(__isl_take isl_aff *dst, __isl_keep isl_aff *src)
Definition isl_aff.c:6137
__isl_give isl_set * isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4688
static __isl_give isl_union_map * isl_union_map_from_multi_union_pw_aff_0D(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9126
__isl_give isl_pw_aff * isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3406
__isl_give isl_aff * isl_space_param_aff_on_domain_id(__isl_take isl_space *space, __isl_take isl_id *id)
Definition isl_aff.c:443
__isl_give isl_pw_aff * isl_pw_aff_list_max(__isl_take isl_pw_aff_list *list)
Definition isl_aff.c:3973
__isl_give isl_set * isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3346
__isl_give isl_aff * isl_aff_set_constant_si(__isl_take isl_aff *aff, int v)
Definition isl_aff.c:1160
static isl_stat flat_range_product_entry(__isl_take isl_pw_multi_aff *pma2, void *user)
Definition isl_aff.c:6520
__isl_give isl_pw_aff * isl_pw_aff_param_on_domain_id(__isl_take isl_set *domain, __isl_take isl_id *id)
Definition isl_aff.c:7755
__isl_give isl_union_set * isl_union_pw_aff_bind_id(__isl_take isl_union_pw_aff *upa, __isl_take isl_id *id)
Definition isl_aff.c:8546
__isl_give isl_aff * isl_aff_ceil(__isl_take isl_aff *aff)
Definition isl_aff.c:1873
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_range_factor_domain(__isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:9958
static isl_bool isl_aff_involves_dims(__isl_keep isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_aff.c:2616
__isl_give isl_val * isl_aff_get_coefficient_val(__isl_keep isl_aff *aff, enum isl_dim_type type, int pos)
Definition isl_aff.c:852
__isl_give isl_aff * isl_aff_add_constant_num(__isl_take isl_aff *aff, isl_int v)
Definition isl_aff.c:1115
__isl_give isl_val * isl_aff_get_constant_val(__isl_keep isl_aff *aff)
Definition isl_aff.c:834
__isl_give isl_pw_aff * isl_multi_pw_aff_apply_pw_aff(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:7426
static __isl_give isl_pw_multi_aff * pw_multi_aff_from_map_check_div_mod(__isl_take isl_map *map)
Definition isl_aff.c:5330
__isl_give isl_set * isl_aff_ne_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2579
__isl_give isl_basic_set * isl_aff_zero_basic_set(__isl_take isl_aff *aff)
Definition isl_aff.c:2469
isl_bool isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff)
Definition isl_aff.c:3494
__isl_give isl_aff * isl_aff_var_on_domain(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos)
Definition isl_aff.c:370
static __isl_give isl_union_pw_aff * isl_multi_union_pw_aff_apply_pw_aff_0D(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:9619
static __isl_give isl_map * isl_multi_pw_aff_lex_map_on_space(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_give isl_map *(*strict_base)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2), __isl_give isl_map *(*base)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2), __isl_take isl_space *space)
Definition isl_aff.c:7585
__isl_give isl_pw_aff * isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3819
static __isl_give isl_pw_aff * isl_multi_pw_aff_apply_pw_aff_aligned(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:7385
static isl_bool isl_pw_aff_domain_is_product(__isl_keep isl_pw_aff *pa)
Definition isl_aff.c:2979
__isl_give isl_set * isl_aff_le_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2538
__isl_give isl_multi_union_pw_aff * isl_multi_aff_to_multi_union_pw_aff(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:8743
__isl_give isl_aff * isl_aff_normalize(__isl_take isl_aff *aff)
Definition isl_aff.c:1704
static __isl_keep isl_space * isl_aff_peek_domain_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:563
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_multi_val_on_domain(__isl_take isl_union_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7891
static __isl_give isl_map * isl_map_order_at_multi_pw_aff(__isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa, __isl_give isl_map *(*order)(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2))
Definition isl_aff.c:7552
__isl_give isl_set * isl_aff_ge_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2499
static __isl_give isl_union_pw_aff * multi_union_pw_aff_apply_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_aff *aff)
Definition isl_aff.c:9436
static __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_multi_val_on_domain_aligned(__isl_take isl_union_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:8933
static __isl_give isl_set * pw_aff_gte_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2, int strict, int equal)
Definition isl_aff.c:3126
__isl_give isl_union_pw_aff * isl_multi_union_pw_aff_apply_pw_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:9635
static isl_stat upa_pb_upma(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8596
__isl_give isl_set * isl_multi_aff_lex_gt_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4697
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_preimage_domain_wrapped_domain_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:8044
__isl_give isl_set * isl_aff_eq_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2567
static __isl_give isl_basic_set * aff_zero_basic_set(__isl_take isl_aff *aff, int rational, void *user)
Definition isl_aff.c:2443
static __isl_keep isl_local_space * isl_aff_peek_domain_local_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:490
__isl_give isl_pw_aff * isl_pw_aff_add(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3611
__isl_give isl_aff * isl_aff_neg(__isl_take isl_aff *aff)
Definition isl_aff.c:1451
static __isl_give isl_set * isl_multi_aff_order_at(__isl_keep isl_multi_aff *ma1, __isl_keep isl_multi_aff *ma2, int i, __isl_give isl_set *(*cmp)(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2))
Definition isl_aff.c:4609
static __isl_give isl_multi_union_pw_aff * mupa_apply_multi_aff_0D(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_aff *ma)
Definition isl_aff.c:9545
__isl_give isl_pw_aff_list * isl_pw_aff_list_set_rational(__isl_take isl_pw_aff_list *list)
Definition isl_aff.c:4001
__isl_give isl_val * isl_aff_get_denominator_val(__isl_keep isl_aff *aff)
Definition isl_aff.c:819
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_scale_multi_val(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_multi_val *mv)
Definition isl_aff.c:6931
__isl_give isl_pw_aff * isl_pw_aff_union_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:2948
__isl_give isl_aff * isl_aff_add_on_domain(__isl_keep isl_set *dom, __isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2590
static isl_stat gen_range_product_entry(__isl_take isl_pw_multi_aff *pma2, __isl_give isl_pw_multi_aff *(*range_product)(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2), void *user)
Definition isl_aff.c:6491
isl_bool isl_aff_plain_is_zero(__isl_keep isl_aff *aff)
Definition isl_aff.c:757
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_range_factor_range(__isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:9971
__isl_give isl_pw_aff * isl_set_param_pw_aff_on_domain_id(__isl_take isl_set *domain, __isl_take isl_id *id)
Definition isl_aff.c:7773
__isl_give isl_set * isl_pw_aff_list_ne_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3324
static __isl_give isl_pw_aff * isl_pw_multi_aff_get_at(__isl_keep isl_pw_multi_aff *pma, int pos)
Definition isl_aff.c:6300
static __isl_give isl_pw_multi_aff * pw_multi_aff_set_pw_aff(__isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:6563
__isl_give isl_aff * isl_aff_set_dim_id(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
Definition isl_aff.c:2205
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_pw_aff(__isl_take isl_pw_aff *pa)
Definition isl_aff.c:6968
__isl_give isl_aff * isl_aff_sub(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2029
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_factor_range(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:4821
static isl_bool isl_pw_multi_aff_range_is_wrapping(__isl_keep isl_pw_multi_aff *pma)
Definition isl_aff.c:4787
__isl_give isl_pw_multi_aff * isl_set_as_pw_multi_aff(__isl_take isl_set *set)
Definition isl_aff.c:5665
__isl_give isl_aff * isl_aff_restore_domain_local_space(__isl_keep isl_aff *aff, __isl_take isl_local_space *ls)
Definition isl_aff.c:632
__isl_give isl_aff * isl_aff_param_on_domain_space_id(__isl_take isl_space *space, __isl_take isl_id *id)
Definition isl_aff.c:418
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_union_lexmax(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4835
__isl_give isl_multi_val * isl_multi_aff_get_constant_multi_val(__isl_keep isl_multi_aff *ma)
Definition isl_aff.c:4195
__isl_give isl_set * isl_aff_lt_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2547
__isl_give isl_pw_aff * isl_pw_aff_tdiv_q(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3656
isl_bool isl_multi_pw_aff_has_non_trivial_domain(__isl_keep isl_multi_pw_aff *mpa)
Definition isl_aff.c:6796
__isl_give isl_multi_pw_aff * isl_multi_union_pw_aff_extract_multi_pw_aff(__isl_keep isl_multi_union_pw_aff *mupa, __isl_take isl_space *space)
Definition isl_aff.c:9856
__isl_give isl_aff * isl_aff_expand_divs(__isl_take isl_aff *aff, __isl_take isl_mat *div, int *exp)
Definition isl_aff.c:1901
__isl_give isl_multi_aff * isl_aff_as_domain_extension(__isl_take isl_aff *aff)
Definition isl_aff.c:5249
static isl_size isl_aff_domain_var_offset(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:523
__isl_give isl_aff * isl_aff_set_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v)
Definition isl_aff.c:1221
__isl_give isl_aff * isl_space_zero_aff_on_domain(__isl_take isl_space *space)
Definition isl_aff.c:259
__isl_give isl_multi_aff * isl_multi_aff_pullback_multi_aff(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:6097
static __isl_give isl_aff * extract_isl_aff_from_basic_map(__isl_keep isl_basic_map *bmap, int pos, __isl_keep isl_multi_aff *ma)
Definition isl_aff.c:5096
__isl_give isl_aff * isl_aff_reset_space_and_domain(__isl_take isl_aff *aff, __isl_take isl_space *space, __isl_take isl_space *domain)
Definition isl_aff.c:693
isl_bool isl_multi_pw_aff_isa_multi_aff(__isl_keep isl_multi_pw_aff *mpa)
Definition isl_aff.c:6738
__isl_give isl_aff * isl_aff_add_coefficient(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, isl_int v)
Definition isl_aff.c:1326
__isl_give isl_aff * isl_aff_scale_down(__isl_take isl_aff *aff, isl_int f)
Definition isl_aff.c:2105
static __isl_give isl_aff * set_nan_free(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1965
__isl_give isl_aff * isl_aff_set_constant(__isl_take isl_aff *aff, isl_int v)
Definition isl_aff.c:909
__isl_give isl_union_pw_aff * isl_union_pw_aff_param_on_domain_id(__isl_take isl_union_set *domain, __isl_take isl_id *id)
Definition isl_aff.c:8293
static __isl_give isl_vec * isl_aff_get_rat_aff(__isl_keep isl_aff *aff)
Definition isl_aff.c:176
static __isl_give isl_aff * isl_aff_restore_rat_aff(__isl_keep isl_aff *aff, __isl_take isl_vec *v)
Definition isl_aff.c:211
static __isl_give isl_pw_multi_aff * isl_pw_multi_aff_op_multi_val(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv, __isl_give isl_multi_aff *(*fn)(__isl_take isl_multi_aff *ma, __isl_take isl_multi_val *mv))
Definition isl_aff.c:6856
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_union_map(__isl_take isl_union_map *umap)
Definition isl_aff.c:8905
__isl_give isl_set * isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3188
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_scale_down_multi_val(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv)
Definition isl_aff.c:6898
static __isl_give isl_vec * isl_aff_take_rat_aff(__isl_keep isl_aff *aff)
Definition isl_aff.c:192
__isl_give isl_basic_set * isl_aff_eq_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2556
isl_bool isl_multi_union_pw_aff_has_non_trivial_domain(__isl_keep isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:8681
static isl_stat bin_entry(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:6407
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_union_set(__isl_take isl_union_set *uset)
Definition isl_aff.c:5733
__isl_give isl_pw_aff * isl_pw_aff_nan_on_domain_space(__isl_take isl_space *space)
Definition isl_aff.c:310
__isl_give isl_map * isl_multi_pw_aff_eq_map(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2)
Definition isl_aff.c:7542
__isl_give isl_multi_aff * isl_multi_aff_align_divs(__isl_take isl_multi_aff *maff)
Definition isl_aff.c:6188
__isl_give isl_union_pw_aff * isl_union_pw_aff_pullback_union_pw_multi_aff(__isl_take isl_union_pw_aff *upa, __isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:8619
static __isl_give isl_set * pw_aff_locus(__isl_take isl_pw_aff *pwaff, __isl_give isl_basic_set *(*fn)(__isl_take isl_aff *aff, int rational, void *user), int complement, void *user)
Definition isl_aff.c:2995
static __isl_give isl_pw_aff * pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3772
__isl_give isl_aff * isl_aff_set_dim_name(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, const char *s)
Definition isl_aff.c:2186
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_multi_val_on_domain(__isl_take isl_union_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:8972
__isl_give isl_space * isl_aff_get_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:573
static isl_bool isl_pw_aff_list_involves_nan(__isl_keep isl_pw_aff_list *list)
Definition isl_aff.c:3836
static isl_stat pw_aff_val_on_domain(__isl_take isl_set *domain, void *user)
Definition isl_aff.c:8417
static __isl_give isl_pw_aff * isl_multi_pw_aff_apply_aff_aligned(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_aff *aff)
Definition isl_aff.c:7289
static __isl_give isl_aff * plug_in_integral_divs(__isl_take isl_aff *aff)
Definition isl_aff.c:1514
__isl_give isl_pw_multi_aff * isl_space_identity_pw_multi_aff_on_domain(__isl_take isl_space *space)
Definition isl_aff.c:4493
__isl_give isl_aff * isl_aff_set_tuple_id(__isl_take isl_aff *aff, enum isl_dim_type type, __isl_take isl_id *id)
Definition isl_aff.c:2231
__isl_give isl_aff * isl_aff_div(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3559
__isl_give isl_basic_set * isl_aff_ge_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2477
isl_bool isl_multi_aff_is_empty(__isl_keep isl_multi_aff *maff)
Definition isl_aff.c:4557
__isl_give isl_set * isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3165
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_union_lexmin(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4850
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_zero(__isl_take isl_space *space)
Definition isl_aff.c:8707
__isl_give isl_map * isl_map_intersect_multi_pw_aff_explicit_domain(__isl_take isl_map *map, __isl_keep isl_multi_pw_aff *mpa)
Definition isl_aff.c:6770
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_multi_union_pw_aff_0D(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9257
__isl_give isl_aff * isl_aff_copy(__isl_keep isl_aff *aff)
Definition isl_aff.c:145
__isl_give isl_aff * isl_aff_add_constant(__isl_take isl_aff *aff, isl_int v)
Definition isl_aff.c:986
__isl_give isl_space * isl_aff_get_domain_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:568
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_project_out_map(__isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_aff.c:4449
__isl_give isl_multi_aff * isl_multi_aff_from_basic_set_equalities(__isl_take isl_basic_set *bset)
Definition isl_aff.c:5151
__isl_give isl_set * isl_pw_aff_pos_set(__isl_take isl_pw_aff *pa)
Definition isl_aff.c:3035
static isl_stat pw_multi_aff_check_range_product(__isl_keep isl_pw_multi_aff *pma)
Definition isl_aff.c:4795
__isl_give isl_aff * isl_aff_add_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned n)
Definition isl_aff.c:2770
__isl_give isl_pw_aff * isl_pw_aff_mod(__isl_take isl_pw_aff *pwaff, isl_int m)
Definition isl_aff.c:1825
isl_bool isl_aff_is_empty(__isl_keep isl_aff *aff)
Definition isl_aff.c:2598
isl_bool isl_aff_matching_params(__isl_keep isl_aff *aff, __isl_keep isl_space *space)
Definition isl_aff.c:4025
__isl_give isl_aff * isl_aff_scale_down_ui(__isl_take isl_aff *aff, unsigned f)
Definition isl_aff.c:2171
__isl_give isl_aff * isl_aff_substitute(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
Definition isl_aff.c:5774
__isl_give isl_multi_aff * isl_multi_aff_scale(__isl_take isl_multi_aff *maff, isl_int f)
Definition isl_aff.c:4528
isl_bool isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa, __isl_keep isl_space *space)
Definition isl_aff.c:6647
static __isl_give isl_val * eval(__isl_keep isl_vec *aff, __isl_keep isl_vec *pnt)
Definition isl_aff.c:9998
static __isl_give isl_aff * extract_aff_from_equality(__isl_keep isl_basic_map *bmap, int pos, int eq, int div, int ineq, __isl_keep isl_multi_aff *ma)
Definition isl_aff.c:5022
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_domain_map(__isl_take isl_space *space)
Definition isl_aff.c:4353
static isl_stat preimage_domain_wrapped_domain_entry(__isl_take isl_pw_multi_aff *pma2, void *user)
Definition isl_aff.c:8009
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:7021
__isl_give isl_multi_pw_aff * isl_map_min_multi_pw_aff(__isl_take isl_map *map)
Definition isl_aff.c:6836
__isl_give isl_aff * isl_aff_add_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v)
Definition isl_aff.c:1426
__isl_give isl_aff * isl_aff_set_coefficient_val(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, __isl_take isl_val *v)
Definition isl_aff.c:1261
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_sub(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4869
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_apply_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:7946
__isl_give isl_multi_aff * isl_multi_aff_substitute(__isl_take isl_multi_aff *maff, enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
Definition isl_aff.c:5817
isl_bool isl_multi_pw_aff_is_equal(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2)
Definition isl_aff.c:7190
__isl_give isl_union_set * isl_multi_union_pw_aff_domain_0D(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9378
static __isl_give isl_pw_multi_aff * isl_pw_multi_aff_preimage_domain_wrapped_domain_pw_multi_aff(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:7969
__isl_give isl_basic_set * isl_aff_nonneg_basic_set(__isl_take isl_aff *aff)
Definition isl_aff.c:2414
uint32_t isl_aff_get_hash(__isl_keep isl_aff *aff)
Definition isl_aff.c:472
static __isl_give isl_map * isl_pw_aff_order_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2, __isl_give isl_set *(*order)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2))
Definition isl_aff.c:3204
__isl_give isl_basic_set * isl_aff_neg_basic_set(__isl_take isl_aff *aff)
Definition isl_aff.c:2431
__isl_give isl_basic_set * isl_aff_gt_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2488
static __isl_give isl_multi_aff * extract_isl_multi_aff_from_basic_map(__isl_take isl_basic_map *bmap)
Definition isl_aff.c:5119
static isl_stat add_pw_multi_aff_from_domain(__isl_take isl_set *set, void *user)
Definition isl_aff.c:6356
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:8838
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_multi_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_multi_aff *ma)
Definition isl_aff.c:8998
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_apply_pw_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9715
isl_bool isl_aff_is_cst(__isl_keep isl_aff *aff)
Definition isl_aff.c:3481
isl_stat isl_aff_check_match_domain_space(__isl_keep isl_aff *aff, __isl_keep isl_space *space)
Definition isl_aff.c:4044
__isl_give isl_aff * isl_aff_zero_on_domain_space(__isl_take isl_space *space)
Definition isl_aff.c:251
__isl_give isl_pw_aff * isl_pw_aff_zero_on_domain(__isl_take isl_local_space *ls)
Definition isl_aff.c:267
__isl_give isl_aff * isl_aff_remove_unused_divs(__isl_take isl_aff *aff)
Definition isl_aff.c:1477
static __isl_give isl_aff * isl_aff_set_nan(__isl_take isl_aff *aff)
Definition isl_aff.c:277
__isl_give isl_set * isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3155
__isl_give isl_union_pw_aff * isl_union_pw_aff_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_aff *aff)
Definition isl_aff.c:8278
__isl_give isl_aff * isl_aff_zero_on_domain(__isl_take isl_local_space *ls)
Definition isl_aff.c:235
static __isl_give isl_pw_multi_aff * pw_multi_aff_from_map_stride(__isl_take isl_map *map, __isl_take isl_basic_map *hull, int d, int i, isl_int gcd)
Definition isl_aff.c:5461
static isl_stat bind_id(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8531
__isl_give isl_aff * isl_aff_realign_domain(__isl_take isl_aff *aff, __isl_take isl_reordering *r)
Definition isl_aff.c:703
static __isl_give isl_pw_aff * replace_by_nan(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3749
isl_size isl_aff_dim(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:509
const char * isl_aff_get_dim_name(__isl_keep isl_aff *aff, enum isl_dim_type type, unsigned pos)
Definition isl_aff.c:659
__isl_give isl_multi_aff * isl_multi_aff_lift(__isl_take isl_multi_aff *maff, __isl_give isl_local_space **ls)
Definition isl_aff.c:6240
__isl_give isl_set * isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3043
static isl_stat reset_range_space(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:9205
__isl_give isl_local_space * isl_aff_get_local_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:592
static __isl_give isl_pw_aff * pw_aff_min_max(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2, int max)
Definition isl_aff.c:3791
__isl_give isl_aff * isl_aff_mul(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3516
static __isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_pw_aff_0D(__isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:7002
__isl_give isl_pw_multi_aff * isl_map_as_pw_multi_aff(__isl_take isl_map *map)
Definition isl_aff.c:5652
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_range_map(__isl_take isl_space *space)
Definition isl_aff.c:4371
static isl_stat pw_multi_aff_from_map(__isl_take isl_map *map, void *user)
Definition isl_aff.c:5673
static __isl_give isl_aff * plug_in_unit_divs(__isl_take isl_aff *aff)
Definition isl_aff.c:1579
__isl_give isl_aff * isl_aff_floor(__isl_take isl_aff *aff)
Definition isl_aff.c:1729
static isl_bool either_involves_nan(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2)
Definition isl_aff.c:3717
__isl_give isl_aff * isl_aff_alloc_vec(__isl_take isl_local_space *ls, __isl_take isl_vec *v)
Definition isl_aff.c:101
static isl_stat pw_aff_on_domain(__isl_take isl_set *domain, void *user)
Definition isl_aff.c:8318
__isl_give isl_aff * isl_aff_alloc(__isl_take isl_local_space *ls)
Definition isl_aff.c:124
static __isl_give isl_pw_multi_aff * union_pw_multi_aff_scale_multi_val_entry(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:6910
static isl_bool isl_union_pw_multi_aff_un_op_filter_drop_user(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:9911
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9278
__isl_give isl_set * isl_pw_aff_le_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3182
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_map(__isl_take isl_map *map)
Definition isl_aff.c:5617
__isl_give isl_multi_aff * isl_multi_aff_multi_val_on_domain_space(__isl_take isl_space *space, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7782
static isl_bool pw_aff_no_nan(__isl_keep isl_pw_aff *pa, void *user)
Definition isl_aff.c:3827
__isl_give isl_basic_set * isl_aff_lt_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2529
static isl_stat pullback_entry(__isl_take isl_pw_multi_aff *pma2, void *user)
Definition isl_aff.c:7911
__isl_give isl_set * isl_aff_gt_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2511
__isl_give isl_aff * isl_aff_add_coefficient_val(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, __isl_take isl_val *v)
Definition isl_aff.c:1363
__isl_give isl_val * isl_aff_eval(__isl_take isl_aff *aff, __isl_take isl_point *pnt)
Definition isl_aff.c:10039
__isl_give isl_pw_multi_aff * isl_space_domain_map_pw_multi_aff(__isl_take isl_space *space)
Definition isl_aff.c:4362
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_aff(__isl_take isl_aff *aff)
Definition isl_aff.c:5687
static __isl_give isl_set * isl_multi_aff_lex_gte_set_0d(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2, int equal)
Definition isl_aff.c:4590
__isl_give isl_multi_aff * isl_multi_aff_multi_val_on_space(__isl_take isl_space *space, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7821
static __isl_give isl_aff * isl_aff_substitute_equalities_lifted(__isl_take isl_aff *aff, __isl_take isl_basic_set *eq)
Definition isl_aff.c:2256
__isl_give isl_multi_aff * isl_multi_aff_domain_map(__isl_take isl_space *space)
Definition isl_aff.c:4248
static isl_stat zero_union_set(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8493
static isl_stat extract_space(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:8800
__isl_give isl_aff * isl_aff_set_coefficient(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, isl_int v)
Definition isl_aff.c:1184
__isl_give isl_map * isl_map_eq_at_multi_pw_aff(__isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:7563
__isl_give isl_multi_pw_aff * isl_set_max_multi_pw_aff(__isl_take isl_set *set)
Definition isl_aff.c:6822
__isl_give isl_multi_aff * isl_multi_aff_project_out_map(__isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_aff.c:4389
__isl_give isl_union_map * isl_union_map_from_multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9157
static __isl_give isl_pw_aff * isl_pw_aff_select(__isl_take isl_set *cond1, __isl_take isl_pw_aff *pwaff1, __isl_take isl_set *cond2, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3416
__isl_give isl_set * isl_multi_aff_lex_lt_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4577
isl_bool isl_multi_pw_aff_is_cst(__isl_keep isl_multi_pw_aff *mpa)
Definition isl_aff.c:6786
__isl_give isl_multi_aff * isl_space_domain_map_multi_aff(__isl_take isl_space *space)
Definition isl_aff.c:4291
__isl_give isl_multi_aff * isl_space_range_map_multi_aff(__isl_take isl_space *space)
Definition isl_aff.c:4344
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_multi_aff(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:8730
int isl_aff_coefficient_sgn(__isl_keep isl_aff *aff, enum isl_dim_type type, int pos)
Definition isl_aff.c:882
isl_stat isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa, __isl_keep isl_space *space)
Definition isl_aff.c:6666
__isl_give isl_union_pw_aff * isl_multi_union_pw_aff_apply_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_aff *aff)
Definition isl_aff.c:9502
static __isl_give isl_set * isl_multi_aff_lex_gte_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2, int equal)
Definition isl_aff.c:4633
__isl_give isl_union_pw_aff * isl_union_pw_aff_val_on_domain(__isl_take isl_union_set *domain, __isl_take isl_val *v)
Definition isl_aff.c:8436
static isl_stat isl_union_pw_aff_check_match_domain_space(__isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space)
Definition isl_aff.c:8061
static __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pw_multi_aff_on_domain_aligned(__isl_take isl_union_set *domain, __isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9016
__isl_give isl_pw_aff * isl_set_pw_aff_on_domain_val(__isl_take isl_set *domain, __isl_take isl_val *v)
Definition isl_aff.c:7746
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_range(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *range)
Definition isl_aff.c:9332
__isl_give isl_aff * isl_aff_gist(__isl_take isl_aff *aff, __isl_take isl_set *context)
Definition isl_aff.c:2325
__isl_give isl_aff * isl_aff_reset_domain_space(__isl_take isl_aff *aff, __isl_take isl_space *space)
Definition isl_aff.c:671
__isl_give isl_aff * isl_aff_add_constant_num_si(__isl_take isl_aff *aff, int v)
Definition isl_aff.c:1141
isl_size isl_aff_domain_offset(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:535
static __isl_give isl_aff * merge_divs(__isl_take isl_aff *aff, int a, int b)
Definition isl_aff.c:1643
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pw_multi_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9055
__isl_give isl_pw_aff * isl_pw_aff_nan_on_domain(__isl_take isl_local_space *ls)
Definition isl_aff.c:319
__isl_give isl_map * isl_pw_aff_lt_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3248
static __isl_give isl_map * isl_multi_pw_aff_order_map(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2, __isl_give isl_map *(*order)(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_take isl_space *space))
Definition isl_aff.c:7470
__isl_give isl_multi_pw_aff * isl_multi_pw_aff_from_aff(__isl_take isl_aff *aff)
Definition isl_aff.c:7056
__isl_give isl_multi_aff * isl_multi_aff_flatten_domain(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:4227
__isl_give isl_union_pw_multi_aff * isl_union_map_as_union_pw_multi_aff(__isl_take isl_union_map *umap)
Definition isl_aff.c:5722
__isl_give isl_basic_set * isl_aff_le_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2520
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_domain(__isl_take isl_union_set *uset)
Definition isl_aff.c:6371
static isl_stat reset_params(__isl_take isl_pw_aff *pa, void *user)
Definition isl_aff.c:8123
__isl_give isl_union_set * isl_multi_union_pw_aff_domain(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9393
__isl_give isl_set * isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3051
__isl_give isl_multi_aff * isl_multi_aff_add_on_domain(__isl_keep isl_set *dom, __isl_take isl_multi_aff *maff1, __isl_take isl_multi_aff *maff2)
Definition isl_aff.c:4549
__isl_give isl_set * isl_pw_aff_list_lt_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3340
static __isl_give isl_set * less(__isl_keep isl_pw_aff_list *list, int pos1, int pos2)
Definition isl_aff.c:3870
__isl_give isl_set * isl_pw_aff_bind_id(__isl_take isl_pw_aff *pa, __isl_take isl_id *id)
Definition isl_aff.c:3106
static __isl_give isl_aff * isl_aff_add_rat_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:1011
__isl_give isl_aff * isl_aff_get_div(__isl_keep isl_aff *aff, int pos)
Definition isl_aff.c:1439
static __isl_give isl_aff * set_nan_free_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:1058
__isl_give isl_multi_pw_aff * isl_multi_aff_to_multi_pw_aff(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:7093
static __isl_give isl_pw_multi_aff * pw_multi_aff_from_map_plug_in(__isl_take isl_map *map, int d, __isl_take isl_aff *aff)
Definition isl_aff.c:5294
__isl_give isl_multi_pw_aff * isl_multi_pw_aff_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:7106
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:8756
__isl_give isl_multi_aff * isl_multi_pw_aff_as_multi_aff(__isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:6746
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_pullback_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:7934
__isl_give isl_multi_aff * isl_multi_aff_from_aff_mat(__isl_take isl_space *space, __isl_take isl_mat *mat)
Definition isl_aff.c:4133
static isl_stat range_product_entry(__isl_take isl_pw_multi_aff *pma2, void *user)
Definition isl_aff.c:6540
static __isl_give isl_aff * sort_divs(__isl_take isl_aff *aff)
Definition isl_aff.c:1673
__isl_give isl_pw_aff * isl_pw_aff_cond(__isl_take isl_pw_aff *cond, __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false)
Definition isl_aff.c:3438
static isl_stat isl_aff_check_has_domain_space(__isl_keep isl_aff *aff, __isl_keep isl_space *space)
Definition isl_aff.c:10023
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_multi_val_on_domain(__isl_take isl_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7840
__isl_give isl_pw_aff * isl_pw_multi_aff_get_pw_aff(__isl_keep isl_pw_multi_aff *pma, int pos)
Definition isl_aff.c:6332
isl_stat isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v)
Definition isl_aff.c:806
static __isl_give isl_aff * isl_aff_alloc_vec_validated(__isl_take isl_local_space *ls, __isl_take isl_vec *v)
Definition isl_aff.c:72
__isl_give isl_map * isl_pw_aff_eq_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3229
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_flat_range_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:6475
__isl_give isl_pw_aff * isl_pw_aff_div(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3627
static __isl_give isl_multi_aff * isl_multi_aff_substitute_equalities(__isl_take isl_multi_aff *maff, __isl_take isl_basic_set *eq)
Definition isl_aff.c:4501
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_union_map(__isl_take isl_union_map *umap)
Definition isl_aff.c:5703
static isl_stat pa_pb_pma(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:8574
__isl_give isl_multi_pw_aff * isl_multi_pw_aff_from_multi_aff(__isl_take isl_multi_aff *ma)
Definition isl_aff.c:7064
__isl_give isl_basic_set * isl_aff_pos_basic_set(__isl_take isl_aff *aff)
Definition isl_aff.c:2422
__isl_give isl_aff * isl_aff_pullback_multi_aff(__isl_take isl_aff *aff, __isl_take isl_multi_aff *ma)
Definition isl_aff.c:6030
__isl_give isl_set * isl_pw_aff_list_le_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2)
Definition isl_aff.c:3334
__isl_give isl_aff * isl_aff_scale_down_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:2142
static isl_stat pw_multi_aff_multi_val_on_domain(__isl_take isl_set *domain, void *user)
Definition isl_aff.c:7874
__isl_give isl_multi_pw_aff * isl_pw_multi_aff_to_multi_pw_aff(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:7141
static __isl_give isl_multi_union_pw_aff * preimage_explicit_domain(__isl_take isl_multi_union_pw_aff *mupa, __isl_keep isl_union_pw_multi_aff *upma)
Definition isl_aff.c:9775
__isl_give isl_pw_aff * isl_set_indicator_function(__isl_take isl_set *set)
Definition isl_aff.c:5741
__isl_give isl_aff * isl_aff_dup(__isl_keep isl_aff *aff)
Definition isl_aff.c:154
static __isl_give isl_pw_multi_aff * pw_multi_aff_factor(__isl_take isl_pw_multi_aff *pma, isl_stat(*check_space)(__isl_keep isl_pw_multi_aff *pma), __isl_give isl_space *(*space_factor)(__isl_take isl_space *space), __isl_give isl_multi_aff *(*multi_aff_factor)(__isl_take isl_multi_aff *ma))
Definition isl_aff.c:4756
static __isl_give isl_basic_set * aff_bind_id(__isl_take isl_aff *aff, int rational, void *user)
Definition isl_aff.c:3086
__isl_give isl_multi_pw_aff * isl_set_min_multi_pw_aff(__isl_take isl_set *set)
Definition isl_aff.c:6814
static __isl_give isl_set * pw_aff_list_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2, __isl_give isl_set *(*fn)(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2))
Definition isl_aff.c:3278
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_union_pw_aff(__isl_take isl_union_pw_aff *upa)
Definition isl_aff.c:8470
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_set(__isl_take isl_set *set)
Definition isl_aff.c:5657
static __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_un_op(__isl_take isl_union_pw_multi_aff *upma, struct isl_union_pw_multi_aff_un_op_control *control)
Definition isl_aff.c:9941
__isl_give isl_multi_union_pw_aff * isl_union_map_as_multi_union_pw_aff(__isl_take isl_union_map *umap)
Definition isl_aff.c:8918
static __isl_give isl_aff * pick_free(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:1049
static __isl_give isl_pw_multi_aff * pw_multi_aff_from_map_check_strides(__isl_take isl_map *map, __isl_take isl_basic_map *hull)
Definition isl_aff.c:5547
__isl_give isl_aff * isl_aff_set_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:932
__isl_give isl_pw_aff * isl_pw_aff_mod_val(__isl_take isl_pw_aff *pa, __isl_take isl_val *m)
Definition isl_aff.c:1844
static isl_bool isl_union_pw_aff_matching_params(__isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space)
Definition isl_aff.c:8094
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_identity(__isl_take isl_space *space)
Definition isl_aff.c:4471
__isl_give isl_aff * isl_aff_add_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:1070
__isl_give isl_pw_aff * isl_pw_aff_tdiv_r(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)
Definition isl_aff.c:3692
__isl_give isl_local_space * isl_aff_take_domain_local_space(__isl_keep isl_aff *aff)
Definition isl_aff.c:612
__isl_give isl_multi_aff * isl_space_multi_aff_on_domain_multi_val(__isl_take isl_space *space, __isl_take isl_multi_val *mv)
Definition isl_aff.c:7831
__isl_give isl_set * isl_pw_aff_non_zero_set(__isl_take isl_pw_aff *pwaff)
Definition isl_aff.c:3059
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_apply_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_aff *ma)
Definition isl_aff.c:9560
static __isl_give isl_pw_multi_aff * plain_pw_multi_aff_from_map(__isl_take isl_set *domain, __isl_take isl_basic_map *bmap)
Definition isl_aff.c:5175
isl_bool isl_aff_is_nan(__isl_keep isl_aff *aff)
Definition isl_aff.c:772
__isl_give isl_aff * isl_aff_domain_reverse(__isl_take isl_aff *aff)
Definition isl_aff.c:2852
__isl_give isl_map * isl_map_from_multi_aff_internal(__isl_take isl_multi_aff *maff)
__isl_give isl_map * isl_map_from_pw_multi_aff_internal(__isl_take isl_pw_multi_aff *pma)
__isl_give isl_map * isl_map_from_pw_aff_internal(__isl_take isl_pw_aff *pwaff)
isl_stat isl_pw_multi_aff_check_named_params(__isl_keep isl_pw_multi_aff *pma)
__isl_give isl_pw_aff * isl_pw_aff_alloc_size(__isl_take isl_space *space, int n)
isl_stat isl_pw_aff_check_named_params(__isl_keep isl_pw_aff *pa)
__isl_give isl_pw_aff * isl_pw_aff_scale(__isl_take isl_pw_aff *pwaff, isl_int f)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_add_disjoint(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
__isl_give isl_pw_aff * isl_pw_aff_reset_space(__isl_take isl_pw_aff *pwaff, __isl_take isl_space *space)
__isl_give isl_pw_aff * isl_pw_aff_reset_domain_space(__isl_take isl_pw_aff *pwaff, __isl_take isl_space *space)
__isl_give isl_pw_aff * isl_pw_aff_add_disjoint(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_reset_space(__isl_take isl_pw_multi_aff *pwmaff, __isl_take isl_space *space)
__isl_give isl_basic_map * isl_basic_map_plain_affine_hull(__isl_take isl_basic_map *bmap)
#define isl_int_is_zero(i)
Definition isl_int.h:31
#define isl_int_is_one(i)
Definition isl_int.h:32
#define isl_int_is_pos(i)
Definition isl_int.h:34
#define isl_int_is_negone(i)
Definition isl_int.h:33
#define isl_int_is_neg(i)
Definition isl_int.h:35
#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_gt(i, j)
Definition isl_int_gmp.h:61
#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_addmul(r, i, j)
Definition isl_int_gmp.h:37
#define isl_int_is_divisible_by(i, j)
Definition isl_int_gmp.h:69
#define isl_int_eq(i, j)
Definition isl_int_gmp.h:57
#define isl_int_fdiv_r(r, i, j)
Definition isl_int_gmp.h:50
#define isl_int_set(r, i)
Definition isl_int_gmp.h:14
#define isl_int_divexact(r, i, j)
Definition isl_int_gmp.h:44
#define isl_int_sgn(i)
Definition isl_int_gmp.h:54
#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
mpz_t isl_int
Definition isl_int_gmp.h:9
#define isl_int_sub_ui(r, i, j)
Definition isl_int_gmp.h:28
#define isl_int_fdiv_q(r, i, j)
Definition isl_int_gmp.h:49
#define isl_int_set_ui(r, i)
Definition isl_int_gmp.h:16
#define isl_int_swap(i, j)
Definition isl_int_gmp.h:25
#define isl_int_sub(r, i, j)
Definition isl_int_gmp.h:31
#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
#define isl_int_cmp_si(i, si)
Definition isl_int_gmp.h:56
__isl_give isl_local_space * isl_local_space_move_dims(__isl_take isl_local_space *ls, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n)
isl_bool isl_local_space_divs_known(__isl_keep isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_replace_divs(__isl_take isl_local_space *ls, __isl_take isl_mat *div)
__isl_give isl_point * isl_local_space_lift_point(__isl_take isl_local_space *ls, __isl_take isl_point *pnt)
int * isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l)
__isl_keep isl_space * isl_local_space_peek_space(__isl_keep isl_local_space *ls)
unsigned isl_local_space_offset(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_give isl_mat * isl_merge_divs(__isl_keep isl_mat *div1, __isl_keep isl_mat *div2, int *exp1, int *exp2)
__isl_give isl_set * isl_local_space_lift_set(__isl_take isl_local_space *ls, __isl_take isl_set *set)
int isl_mat_cmp_div(__isl_keep isl_mat *div, int i, int j)
__isl_give isl_local_space * isl_local_space_swap_div(__isl_take isl_local_space *ls, int a, int b)
__isl_give isl_local_space * isl_local_space_wrapped_reverse(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_substitute_seq(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos, isl_int *subs, int subs_len, int first, int n)
__isl_give isl_local_space * isl_local_space_reset_space(__isl_take isl_local_space *ls, __isl_take isl_space *space)
int isl_local_space_cmp(__isl_keep isl_local_space *ls1, __isl_keep isl_local_space *ls2)
__isl_give isl_local_space * isl_local_space_preimage_multi_aff(__isl_take isl_local_space *ls, __isl_take isl_multi_aff *ma)
isl_bool isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_give isl_local_space * isl_local_space_add_div(__isl_take isl_local_space *ls, __isl_take isl_vec *div)
__isl_give isl_local_space * isl_local_space_substitute(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
uint32_t isl_local_space_get_hash(__isl_keep isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_substitute_equalities(__isl_take isl_local_space *ls, __isl_take isl_basic_set *eq)
isl_size isl_local_space_var_offset(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_give isl_local_space * isl_local_space_lift(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_realign(__isl_take isl_local_space *ls, __isl_take isl_reordering *r)
isl_stat isl_local_space_check_range(__isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned first, unsigned n)
isl_bool isl_local_space_has_equal_space(__isl_keep isl_local_space *ls1, __isl_keep isl_local_space *ls2)
unsigned isl_basic_map_offset(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:178
isl_bool isl_set_has_rational(__isl_keep isl_set *set)
Definition isl_map.c:1254
unsigned isl_basic_set_offset(__isl_keep isl_basic_set *bset, enum isl_dim_type type)
Definition isl_map.c:191
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_map.c:73
__isl_give isl_maybe_isl_aff isl_basic_map_try_find_any_output_div_mod(__isl_keep isl_basic_map *bmap, int *pos)
Definition isl_map.c:15778
int isl_basic_map_output_defining_equality(__isl_keep isl_basic_map *bmap, int pos, int *div, int *ineq)
Definition isl_map.c:12499
__isl_give isl_basic_set * isl_basic_set_set_rational(__isl_take isl_basic_set *bset)
Definition isl_map.c:2243
__isl_give isl_basic_map * isl_basic_map_sort_constraints(__isl_take isl_basic_map *bmap)
Definition isl_map.c:10959
__isl_give isl_set * isl_set_set_rational(__isl_take isl_set *set)
Definition isl_map.c:2285
__isl_give isl_set * isl_set_substitute(__isl_take isl_set *set, unsigned pos, __isl_keep isl_aff *subs)
Definition isl_map.c:14181
isl_bool isl_map_is_set(__isl_keep isl_map *map)
Definition isl_map.c:6721
isl_bool isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:12555
__isl_give isl_basic_set * isl_basic_set_simplify(__isl_take isl_basic_set *bset)
__isl_give isl_basic_map * isl_basic_map_drop_constraints_involving_unknown_divs(__isl_take isl_basic_map *bmap)
#define isl_set
#define isl_basic_set
static struct isl_arg_choice bound[]
Definition isl_options.c:39
__isl_keep isl_space * isl_point_peek_space(__isl_keep isl_point *pnt)
Definition isl_point.c:39
__isl_keep isl_vec * isl_point_peek_vec(__isl_keep isl_point *pnt)
Definition isl_point.c:233
__isl_null isl_reordering * isl_reordering_free(__isl_take isl_reordering *exp)
__isl_give isl_reordering * isl_reordering_extend(__isl_take isl_reordering *exp, unsigned extra)
__isl_give isl_reordering * isl_parameter_alignment_reordering(__isl_keep isl_space *alignee, __isl_keep isl_space *aligner)
__isl_give isl_reordering * isl_reordering_copy(__isl_keep isl_reordering *exp)
void isl_seq_combine(isl_int *dst, isl_int m1, isl_int *src1, isl_int m2, isl_int *src2, unsigned len)
Definition isl_seq.c:116
int isl_seq_last_non_zero(isl_int *p, unsigned len)
Definition isl_seq.c:217
void isl_seq_inner_product(isl_int *p1, isl_int *p2, unsigned len, isl_int *prod)
Definition isl_seq.c:301
int isl_seq_first_non_zero(isl_int *p, unsigned len)
Definition isl_seq.c:207
void isl_seq_scale_down(isl_int *dst, isl_int *src, isl_int m, unsigned len)
Definition isl_seq.c:88
void isl_seq_gcd(isl_int *p, unsigned len, isl_int *gcd)
Definition isl_seq.c:260
void isl_seq_substitute(isl_int *p, int pos, isl_int *subs, int p_len, int subs_len, isl_int v)
Definition isl_seq.c:347
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:81
void isl_seq_elim(isl_int *dst, isl_int *src, unsigned pos, unsigned len, isl_int *m)
Definition isl_seq.c:146
int isl_seq_cmp(isl_int *p1, isl_int *p2, unsigned len)
Definition isl_seq.c:182
void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len)
Definition isl_seq.c:42
int isl_seq_any_non_zero(isl_int *p, unsigned len)
Definition isl_seq.c:230
void isl_seq_addmul(isl_int *dst, isl_int f, isl_int *src, unsigned len)
Definition isl_seq.c:67
void isl_seq_neg(isl_int *dst, isl_int *src, unsigned len)
Definition isl_seq.c:35
isl_size isl_space_wrapped_dim(__isl_keep isl_space *space, enum isl_dim_type outer, enum isl_dim_type inner)
Definition isl_space.c:382
__isl_give isl_space * isl_space_extend_domain_with_range(__isl_take isl_space *space, __isl_take isl_space *model)
Definition isl_space.c:3382
isl_size isl_space_offset(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_space.c:397
isl_stat isl_space_check_wrapped_tuple_is_equal(__isl_keep isl_space *space1, enum isl_dim_type outer, enum isl_dim_type inner, __isl_keep isl_space *space2, enum isl_dim_type type2)
Definition isl_space.c:1134
isl_bool isl_space_has_named_params(__isl_keep isl_space *space)
Definition isl_space.c:3319
static isl_bool match(__isl_keep isl_space *space1, enum isl_dim_type type1, __isl_keep isl_space *space2, enum isl_dim_type type2)
Definition isl_space.c:1145
__isl_give isl_space * isl_space_lift(__isl_take isl_space *space, unsigned n_local)
Definition isl_space.c:3149
__isl_give isl_space * isl_space_replace_params(__isl_take isl_space *dst, __isl_keep isl_space *src)
Definition isl_space.c:3060
isl_bool isl_space_wrapped_tuple_is_equal(__isl_keep isl_space *space1, enum isl_dim_type outer, enum isl_dim_type inner, __isl_keep isl_space *space2, enum isl_dim_type type2)
Definition isl_space.c:1113
isl_stat isl_space_check_domain_is_wrapping(__isl_keep isl_space *space)
Definition isl_space.c:159
isl_stat isl_space_check_is_proper_set(__isl_keep isl_space *space)
Definition isl_space.c:99
int isl_space_cmp(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
Definition isl_space.c:3460
isl_stat isl_space_check_range(__isl_keep isl_space *space, enum isl_dim_type type, unsigned first, unsigned n)
int sv
Definition isl_test.c:3554
enum isl_fold type
Definition isl_test.c:3867
const char * pa
Definition isl_test.c:7173
const char * set
Definition isl_test.c:1364
const char * hull
Definition isl_test.c:1493
const char * ma
Definition isl_test.c:7387
const char * map
Definition isl_test.c:1791
int equal
Definition isl_test.c:7720
const char * pma
Definition isl_test.c:3019
const char * offset
Definition isl_test.c:1577
const char * name
Definition isl_test.c:10749
const char * context
Definition isl_test.c:1792
const char * map1
Definition isl_test.c:365
const char * aff
Definition isl_test.c:7130
const char * map2
Definition isl_test.c:366
const char * set1
Definition isl_test.c:4055
const char * res
Definition isl_test.c:783
const char * set2
Definition isl_test.c:4056
const char * ma1
Definition isl_test.c:9265
const char * size
Definition isl_test.c:1578
const char * mupa
Definition isl_test.c:7217
const char * f
Definition isl_test.c:8453
const char * id
Definition isl_test.c:7131
static __isl_give isl_union_map * total(__isl_take isl_union_map *umap, __isl_give isl_map *(*fn)(__isl_take isl_map *))
__isl_give isl_union_map * isl_union_map_reset_range_space(__isl_take isl_union_map *umap, __isl_take isl_space *space)
isl_bool isl_union_set_space_has_equal_params(__isl_keep isl_union_set *uset, __isl_keep isl_space *space)
#define isl_union_set
__isl_give isl_val * isl_val_int_from_isl_int(isl_ctx *ctx, isl_int n)
Definition isl_val.c:185
__isl_give isl_val * isl_val_normalize(__isl_take isl_val *v)
Definition isl_val.c:385
__isl_give isl_val * isl_val_rat_from_isl_int(isl_ctx *ctx, isl_int n, isl_int d)
Definition isl_val.c:202
__isl_give isl_vec * isl_vec_expand(__isl_take isl_vec *vec, int pos, int n, int *exp, int expanded)
Definition isl_vec.c:87
uint32_t isl_vec_get_hash(__isl_keep isl_vec *vec)
Definition isl_vec.c:25
__isl_give isl_vec * isl_vec_cow(__isl_take isl_vec *vec)
Definition isl_vec.c:220
__isl_give isl_vec * isl_vec_reorder(__isl_take isl_vec *vec, unsigned offset, __isl_take isl_reordering *r)
Definition isl_vec.c:661
t0 *a *b *t *a *b * t
__isl_give isl_aff * isl_local_space_get_div(__isl_keep isl_local_space *ls, int pos)
__isl_give isl_local_space * isl_local_space_set_dim_id(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
isl_bool isl_local_space_is_set(__isl_keep isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_from_space(__isl_take isl_space *space)
const char * isl_local_space_get_dim_name(__isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned pos)
__isl_give isl_local_space * isl_local_space_drop_dims(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned first, unsigned n)
__isl_give isl_local_space * isl_local_space_set_from_params(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_insert_dims(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned first, unsigned n)
__isl_give isl_local_space * isl_local_space_add_dims(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned n)
__isl_give isl_local_space * isl_local_space_domain(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_set_tuple_id(__isl_take isl_local_space *ls, enum isl_dim_type type, __isl_take isl_id *id)
isl_ctx * isl_local_space_get_ctx(__isl_keep isl_local_space *ls)
isl_bool isl_local_space_is_equal(__isl_keep isl_local_space *ls1, __isl_keep isl_local_space *ls2)
int isl_local_space_find_dim_by_name(__isl_keep isl_local_space *ls, enum isl_dim_type type, const char *name)
isl_size isl_local_space_dim(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_give isl_local_space * isl_local_space_from_domain(__isl_take isl_local_space *ls)
__isl_null isl_local_space * isl_local_space_free(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_copy(__isl_keep isl_local_space *ls)
__isl_give isl_space * isl_local_space_get_space(__isl_keep isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_set_dim_name(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos, const char *s)
__isl_export __isl_give isl_map * isl_map_detect_equalities(__isl_take isl_map *map)
__isl_export __isl_give isl_set * isl_map_domain(__isl_take isl_map *bmap)
Definition isl_map.c:8777
__isl_export __isl_give isl_map * isl_map_union(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:8894
__isl_give isl_space * isl_basic_map_get_space(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:417
__isl_export isl_size isl_map_n_basic_map(__isl_keep isl_map *map)
Definition isl_map.c:11923
__isl_give isl_pw_aff * isl_map_dim_min(__isl_take isl_map *map, int pos)
Definition isl_map.c:8122
__isl_give isl_pw_multi_aff * isl_basic_map_lexmin_pw_multi_aff(__isl_take isl_basic_map *bmap)
__isl_export isl_bool isl_map_is_single_valued(__isl_keep isl_map *map)
Definition isl_map.c:12632
__isl_export __isl_give isl_map * isl_map_apply_domain(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:9263
__isl_export __isl_give isl_map * isl_map_intersect(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:4514
__isl_give isl_map * isl_map_make_disjoint(__isl_take isl_map *map)
__isl_export __isl_give isl_map * isl_map_universe(__isl_take isl_space *space)
Definition isl_map.c:6967
__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_ctx * isl_basic_map_get_ctx(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:382
__isl_export __isl_give isl_space * isl_map_get_space(__isl_keep isl_map *map)
Definition isl_map.c:599
isl_size isl_basic_map_dim(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:83
isl_ctx * isl_map_get_ctx(__isl_keep isl_map *map)
Definition isl_map.c:392
__isl_export __isl_give isl_map * isl_map_intersect_domain(__isl_take isl_map *map, __isl_take isl_set *set)
Definition isl_map.c:9001
__isl_give isl_local_space * isl_basic_map_get_local_space(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:512
__isl_export isl_bool isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
Definition isl_map.c:9902
__isl_export __isl_give isl_map * isl_map_empty(__isl_take isl_space *space)
Definition isl_map.c:6957
__isl_export __isl_give isl_map * isl_set_unwrap(__isl_take isl_set *set)
Definition isl_map.c:12909
__isl_give isl_pw_aff * isl_map_dim_max(__isl_take isl_map *map, int pos)
Definition isl_map.c:8131
__isl_export __isl_give isl_set * isl_map_wrap(__isl_take isl_map *map)
Definition isl_map.c:12883
__isl_export __isl_give isl_basic_map * isl_map_unshifted_simple_hull(__isl_take isl_map *map)
__isl_give isl_map * isl_map_equate(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
Definition isl_map.c:13957
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
Definition isl_map.c:7040
__isl_give isl_basic_map * isl_basic_map_copy(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:1479
__isl_give isl_mat * isl_mat_copy(__isl_keep isl_mat *mat)
Definition isl_mat.c:202
isl_size isl_mat_cols(__isl_keep isl_mat *mat)
Definition isl_mat.c:262
isl_size isl_mat_rows(__isl_keep isl_mat *mat)
Definition isl_mat.c:257
__isl_null isl_mat * isl_mat_free(__isl_take isl_mat *mat)
Definition isl_mat.c:240
isl_ctx * isl_mat_get_ctx(__isl_keep isl_mat *mat)
Definition isl_mat.c:25
isl_bool isl_point_is_void(__isl_keep isl_point *pnt)
Definition isl_point.c:172
__isl_null isl_point * isl_point_free(__isl_take isl_point *pnt)
Definition isl_point.c:150
isl_ctx * isl_point_get_ctx(__isl_keep isl_point *pnt)
Definition isl_point.c:32
a(0)
b(9)
__isl_export __isl_give isl_set * isl_set_universe(__isl_take isl_space *space)
Definition isl_map.c:6985
__isl_export __isl_give isl_set * isl_set_coalesce(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_product(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:11635
__isl_export __isl_give isl_set * isl_set_subtract(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export __isl_give isl_space * isl_set_get_space(__isl_keep isl_set *set)
Definition isl_map.c:604
isl_bool isl_set_plain_is_empty(__isl_keep isl_set *set)
Definition isl_map.c:9823
__isl_export __isl_give isl_set * isl_set_union(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:8929
__isl_overload __isl_give isl_set * isl_set_preimage_multi_aff(__isl_take isl_set *set, __isl_take isl_multi_aff *ma)
Definition isl_map.c:14675
__isl_export __isl_give isl_set * isl_set_intersect_params(__isl_take isl_set *set, __isl_take isl_set *params)
Definition isl_map.c:4538
__isl_null isl_basic_set * isl_basic_set_free(__isl_take isl_basic_set *bset)
Definition isl_map.c:1523
__isl_give isl_pw_aff * isl_set_dim_min(__isl_take isl_set *set, int pos)
Definition isl_map.c:8157
__isl_export __isl_give isl_set * isl_set_complement(__isl_take isl_set *set)
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
Definition isl_map.c:4055
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
Definition isl_map.c:1470
__isl_give isl_basic_set * isl_basic_set_add_dims(__isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned n)
Definition isl_map.c:4734
__isl_give isl_basic_set * isl_basic_set_empty(__isl_take isl_space *space)
Definition isl_map.c:6894
isl_size isl_set_dim(__isl_keep isl_set *set, enum isl_dim_type type)
Definition isl_map.c:132
int isl_set_plain_cmp(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
Definition isl_map.c:11068
__isl_overload __isl_give isl_set * isl_set_preimage_multi_pw_aff(__isl_take isl_set *set, __isl_take isl_multi_pw_aff *mpa)
Definition isl_map.c:14895
__isl_give isl_set * isl_set_align_params(__isl_take isl_set *set, __isl_take isl_space *model)
Definition isl_map.c:13178
isl_bool isl_set_plain_is_universe(__isl_keep isl_set *set)
Definition isl_map.c:10039
__isl_export __isl_give isl_set * isl_set_intersect(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:4521
__isl_export __isl_give isl_set * isl_set_empty(__isl_take isl_space *space)
Definition isl_map.c:6962
__isl_give isl_set * isl_set_union_disjoint(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:8922
__isl_constructor __isl_give isl_set * isl_set_from_basic_set(__isl_take isl_basic_set *bset)
Definition isl_map.c:4024
__isl_give isl_basic_set * isl_basic_set_copy(__isl_keep isl_basic_set *bset)
Definition isl_map.c:1465
__isl_give isl_basic_set * isl_basic_set_universe(__isl_take isl_space *space)
Definition isl_map.c:6910
__isl_export __isl_give isl_basic_set * isl_set_affine_hull(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_params(__isl_take isl_set *set)
Definition isl_map.c:6567
__isl_export isl_bool isl_set_is_empty(__isl_keep isl_set *set)
Definition isl_map.c:9828
__isl_give isl_pw_aff * isl_set_dim_max(__isl_take isl_set *set, int pos)
Definition isl_map.c:8149
isl_bool isl_space_has_equal_params(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
Definition isl_space.c:1173
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition isl_space.c:478
__isl_give isl_space * isl_space_from_domain(__isl_take isl_space *space)
Definition isl_space.c:2242
__isl_export __isl_give isl_space * isl_space_flatten_range(__isl_take isl_space *space)
Definition isl_space.c:3048
__isl_give isl_space * isl_space_range_factor_range(__isl_take isl_space *space)
Definition isl_space.c:1859
__isl_give isl_space * isl_space_range_map(__isl_take isl_space *space)
Definition isl_space.c:2294
__isl_export __isl_give isl_space * isl_space_params(__isl_take isl_space *space)
Definition isl_space.c:2305
__isl_export __isl_give isl_space * isl_space_product(__isl_take isl_space *left, __isl_take isl_space *right)
Definition isl_space.c:1585
__isl_overload __isl_give isl_space * isl_space_add_param_id(__isl_take isl_space *space, __isl_take isl_id *id)
Definition isl_space.c:1299
isl_ctx * isl_space_get_ctx(__isl_keep isl_space *space)
Definition isl_space.c:23
isl_bool isl_space_range_is_wrapping(__isl_keep isl_space *space)
Definition isl_space.c:2895
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
Definition isl_space.c:469
isl_bool isl_space_is_map(__isl_keep isl_space *space)
Definition isl_space.c:115
__isl_give isl_space * isl_space_align_params(__isl_take isl_space *space1, __isl_take isl_space *space2)
Definition isl_space.c:3358
__isl_give isl_space * isl_space_map_from_domain_and_range(__isl_take isl_space *domain, __isl_take isl_space *range)
Definition isl_space.c:1967
__isl_give isl_space * isl_space_join(__isl_take isl_space *left, __isl_take isl_space *right)
Definition isl_space.c:1537
__isl_export __isl_give isl_space * isl_space_range(__isl_take isl_space *space)
Definition isl_space.c:2257
isl_bool isl_space_is_params(__isl_keep isl_space *space)
Definition isl_space.c:211
__isl_export __isl_give isl_space * isl_space_unwrap(__isl_take isl_space *space)
Definition isl_space.c:2951
__isl_export __isl_give isl_space * isl_space_flatten_domain(__isl_take isl_space *space)
Definition isl_space.c:3038
__isl_export __isl_give isl_space * isl_space_map_from_set(__isl_take isl_space *space)
Definition isl_space.c:1927
int isl_space_find_dim_by_id(__isl_keep isl_space *space, enum isl_dim_type type, __isl_keep isl_id *id)
Definition isl_space.c:903
__isl_export isl_bool isl_space_is_equal(__isl_keep isl_space *space1, __isl_keep isl_space *space2)
Definition isl_space.c:2605
__isl_give isl_space * isl_space_range_factor_domain(__isl_take isl_space *space)
Definition isl_space.c:1784
__isl_give isl_space * isl_space_drop_dims(__isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned num)
Definition isl_space.c:2141
__isl_give isl_space * isl_space_range_product(__isl_take isl_space *left, __isl_take isl_space *right)
Definition isl_space.c:1648
__isl_give isl_space * isl_space_domain_map(__isl_take isl_space *space)
Definition isl_space.c:2281
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_space.c:372
isl_bool isl_space_is_set(__isl_keep isl_space *space)
Definition isl_space.c:70
__isl_export __isl_give isl_space * isl_space_drop_all_params(__isl_take isl_space *space)
Definition isl_space.c:2222
isl_bool isl_space_tuple_is_equal(__isl_keep isl_space *space1, enum isl_dim_type type1, __isl_keep isl_space *space2, enum isl_dim_type type2)
Definition isl_space.c:1080
isl_bool isl_space_domain_is_wrapping(__isl_keep isl_space *space)
Definition isl_space.c:2882
__isl_give isl_space * isl_space_add_dims(__isl_take isl_space *space, enum isl_dim_type type, unsigned n)
Definition isl_space.c:1262
isl_bool isl_space_is_product(__isl_keep isl_space *space)
Definition isl_space.c:2910
__isl_export __isl_give isl_space * isl_space_domain(__isl_take isl_space *space)
Definition isl_space.c:2232
isl_dim_type
Definition space_type.h:13
@ isl_dim_param
Definition space_type.h:15
@ isl_dim_in
Definition space_type.h:16
@ isl_dim_set
Definition space_type.h:18
@ isl_dim_all
Definition space_type.h:20
@ isl_dim_div
Definition space_type.h:19
@ isl_dim_out
Definition space_type.h:17
isl_vec * v
isl_union_set * bound
Definition isl_aff.c:8524
isl_int two
isl_int negone
isl_space * dim
isl_union_pw_multi_aff * upma
Definition isl_aff.c:8566
isl_union_pw_multi_aff * upma2
Definition isl_aff.c:6398
isl_union_pw_multi_aff * res
Definition isl_aff.c:6399
isl_stat(* fn)(__isl_take isl_pw_multi_aff *pma, void *user)
Definition isl_aff.c:6401
__isl_give isl_pw_multi_aff *(* fn)(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9903
isl_bool(* filter)(__isl_keep isl_pw_multi_aff *part)
Definition isl_aff.c:9902
isl_int * el
static std::vector< Signature > bin_op
static Signature range
static Signature range_product
static Signature domain
static Signature range_map
__isl_null isl_union_map * isl_union_map_free(__isl_take isl_union_map *umap)
__isl_export __isl_give isl_space * isl_union_map_get_space(__isl_keep isl_union_map *umap)
__isl_export isl_stat isl_union_map_foreach_map(__isl_keep isl_union_map *umap, isl_stat(*fn)(__isl_take isl_map *map, void *user), void *user)
__isl_give isl_union_map * isl_union_map_flat_range_product(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
__isl_give isl_union_set * isl_union_set_align_params(__isl_take isl_union_set *uset, __isl_take isl_space *model)
__isl_export __isl_give isl_union_map * isl_union_map_from_domain_and_range(__isl_take isl_union_set *domain, __isl_take isl_union_set *range)
__isl_give isl_set * isl_set_from_union_set(__isl_take isl_union_set *uset)
__isl_overload __isl_give isl_union_set * isl_union_set_preimage_union_pw_multi_aff(__isl_take isl_union_set *uset, __isl_take isl_union_pw_multi_aff *upma)
isl_bool isl_union_set_is_params(__isl_keep isl_union_set *uset)
__isl_export isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset, isl_stat(*fn)(__isl_take isl_set *set, void *user), void *user)
__isl_give isl_union_set * isl_union_set_add_set(__isl_take isl_union_set *uset, __isl_take isl_set *set)
__isl_export __isl_give isl_union_set * isl_union_set_intersect(__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2)
__isl_give isl_union_set * isl_union_set_empty(__isl_take isl_space *space)
__isl_export __isl_give isl_space * isl_union_set_get_space(__isl_keep isl_union_set *uset)
__isl_constructor __isl_give isl_union_set * isl_union_set_from_set(__isl_take isl_set *set)
isl_ctx * isl_union_set_get_ctx(__isl_keep isl_union_set *uset)
__isl_give isl_union_set * isl_union_set_copy(__isl_keep isl_union_set *uset)
__isl_export __isl_give isl_union_set * isl_union_set_intersect_params(__isl_take isl_union_set *uset, __isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_union_set_params(__isl_take isl_union_set *uset)
__isl_null isl_union_set * isl_union_set_free(__isl_take isl_union_set *uset)
__isl_export __isl_give isl_val * isl_val_abs(__isl_take isl_val *v)
Definition isl_val.c:456
__isl_export isl_bool isl_val_is_nan(__isl_keep isl_val *v)
Definition isl_val.c:1161
__isl_give isl_val * isl_val_copy(__isl_keep isl_val *v)
Definition isl_val.c:219
__isl_give isl_val * isl_val_sub_ui(__isl_take isl_val *v1, unsigned long v2)
Definition isl_val.c:763
__isl_export isl_bool isl_val_is_pos(__isl_keep isl_val *v)
Definition isl_val.c:1224
isl_ctx * isl_val_get_ctx(__isl_keep isl_val *val)
Definition isl_val.c:355
__isl_export __isl_give isl_val * isl_val_nan(isl_ctx *ctx)
Definition isl_val.c:62
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition isl_val.c:263
__isl_export isl_bool isl_val_is_zero(__isl_keep isl_val *v)
Definition isl_val.c:1191
__isl_export isl_bool isl_val_is_one(__isl_keep isl_val *v)
Definition isl_val.c:1201
__isl_export isl_bool isl_val_is_int(__isl_keep isl_val *v)
Definition isl_val.c:1141
__isl_export isl_bool isl_val_is_rat(__isl_keep isl_val *v)
Definition isl_val.c:1151
struct isl_multi_val isl_multi_val
Definition val_type.h:16
isl_ctx * isl_vec_get_ctx(__isl_keep isl_vec *vec)
Definition isl_vec.c:18
__isl_null isl_vec * isl_vec_free(__isl_take isl_vec *vec)
Definition isl_vec.c:234
__isl_give isl_vec * isl_vec_copy(__isl_keep isl_vec *vec)
Definition isl_vec.c:198
isl_bool isl_vec_is_equal(__isl_keep isl_vec *vec1, __isl_keep isl_vec *vec2)
Definition isl_vec.c:341
__isl_give isl_vec * isl_vec_drop_els(__isl_take isl_vec *vec, unsigned pos, unsigned n)
Definition isl_vec.c:535
__isl_give isl_vec * isl_vec_normalize(__isl_take isl_vec *vec)
Definition isl_vec.c:456
__isl_give isl_vec * isl_vec_extend(__isl_take isl_vec *vec, unsigned size)
Definition isl_vec.c:58
__isl_give isl_vec * isl_vec_clr(__isl_take isl_vec *vec)
Definition isl_vec.c:426
__isl_give isl_vec * isl_vec_alloc(isl_ctx *ctx, unsigned size)
Definition isl_vec.c:33
__isl_give isl_vec * isl_vec_insert_zero_els(__isl_take isl_vec *vec, unsigned pos, unsigned n)
Definition isl_vec.c:598
__isl_give isl_vec * isl_vec_move_els(__isl_take isl_vec *vec, unsigned dst_col, unsigned src_col, unsigned n)
Definition isl_vec.c:615
n
Definition youcefn.c:8