2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
12 #include <isl_space_private.h>
13 #include <isl_val_private.h>
15 #include <isl_reordering.h>
17 #include <isl_multi_macro.h>
19 #define MULTI_NAME(BASE) "isl_multi_" #BASE
20 #define xLIST(EL) EL ## _list
21 #define LIST(EL) xLIST(EL)
23 isl_ctx
*FN(MULTI(BASE
),get_ctx
)(__isl_keep
MULTI(BASE
) *multi
)
25 return multi
? isl_space_get_ctx(multi
->space
) : NULL
;
28 __isl_give isl_space
*FN(MULTI(BASE
),get_space
)(__isl_keep
MULTI(BASE
) *multi
)
30 return multi
? isl_space_copy(multi
->space
) : NULL
;
33 /* Return the position of the dimension of the given type and name
35 * Return -1 if no such dimension can be found.
37 int FN(MULTI(BASE
),find_dim_by_name
)(__isl_keep
MULTI(BASE
) *multi
,
38 enum isl_dim_type type
, const char *name
)
42 return isl_space_find_dim_by_name(multi
->space
, type
, name
);
45 __isl_give isl_space
*FN(MULTI(BASE
),get_domain_space
)(
46 __isl_keep
MULTI(BASE
) *multi
)
48 return multi
? isl_space_domain(isl_space_copy(multi
->space
)) : NULL
;
51 /* Allocate a multi expression living in "space".
53 * If the number of base expressions is zero, then make sure
54 * there is enough room in the structure for the explicit domain,
55 * in case the type supports such an explicit domain.
57 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),alloc
)(__isl_take isl_space
*space
)
66 ctx
= isl_space_get_ctx(space
);
67 n
= isl_space_dim(space
, isl_dim_out
);
69 multi
= isl_calloc(ctx
, MULTI(BASE
),
70 sizeof(MULTI(BASE
)) + (n
- 1) * sizeof(struct EL
*));
72 multi
= isl_calloc(ctx
, MULTI(BASE
), sizeof(MULTI(BASE
)));
79 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
80 multi
= FN(MULTI(BASE
),init_explicit_domain
)(multi
);
83 isl_space_free(space
);
87 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),dup
)(__isl_keep
MULTI(BASE
) *multi
)
95 dup
= FN(MULTI(BASE
),alloc
)(isl_space_copy(multi
->space
));
99 for (i
= 0; i
< multi
->n
; ++i
)
100 dup
= FN(FN(MULTI(BASE
),set
),BASE
)(dup
, i
,
101 FN(EL
,copy
)(multi
->u
.p
[i
]));
102 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
103 dup
= FN(MULTI(BASE
),copy_explicit_domain
)(dup
, multi
);
108 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),cow
)(__isl_take
MULTI(BASE
) *multi
)
117 return FN(MULTI(BASE
),dup
)(multi
);
120 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),copy
)(__isl_keep
MULTI(BASE
) *multi
)
129 __isl_null
MULTI(BASE
) *FN(MULTI(BASE
),free
)(__isl_take
MULTI(BASE
) *multi
)
136 if (--multi
->ref
> 0)
139 isl_space_free(multi
->space
);
140 for (i
= 0; i
< multi
->n
; ++i
)
141 FN(EL
,free
)(multi
->u
.p
[i
]);
142 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
143 FN(MULTI(BASE
),free_explicit_domain
)(multi
);
149 unsigned FN(MULTI(BASE
),dim
)(__isl_keep
MULTI(BASE
) *multi
,
150 enum isl_dim_type type
)
152 return multi
? isl_space_dim(multi
->space
, type
) : 0;
155 /* Return the position of the first dimension of "type" with id "id".
156 * Return -1 if there is no such dimension.
158 int FN(MULTI(BASE
),find_dim_by_id
)(__isl_keep
MULTI(BASE
) *multi
,
159 enum isl_dim_type type
, __isl_keep isl_id
*id
)
163 return isl_space_find_dim_by_id(multi
->space
, type
, id
);
166 /* Return the id of the given dimension.
168 __isl_give isl_id
*FN(MULTI(BASE
),get_dim_id
)(__isl_keep
MULTI(BASE
) *multi
,
169 enum isl_dim_type type
, unsigned pos
)
171 return multi
? isl_space_get_dim_id(multi
->space
, type
, pos
) : NULL
;
174 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_dim_name
)(
175 __isl_take
MULTI(BASE
) *multi
,
176 enum isl_dim_type type
, unsigned pos
, const char *s
)
180 multi
= FN(MULTI(BASE
),cow
)(multi
);
184 multi
->space
= isl_space_set_dim_name(multi
->space
, type
, pos
, s
);
186 return FN(MULTI(BASE
),free
)(multi
);
188 if (type
== isl_dim_out
)
190 for (i
= 0; i
< multi
->n
; ++i
) {
191 multi
->u
.p
[i
] = FN(EL
,set_dim_name
)(multi
->u
.p
[i
],
194 return FN(MULTI(BASE
),free
)(multi
);
200 const char *FN(MULTI(BASE
),get_tuple_name
)(__isl_keep
MULTI(BASE
) *multi
,
201 enum isl_dim_type type
)
203 return multi
? isl_space_get_tuple_name(multi
->space
, type
) : NULL
;
206 /* Does the specified tuple have an id?
208 isl_bool
FN(MULTI(BASE
),has_tuple_id
)(__isl_keep
MULTI(BASE
) *multi
,
209 enum isl_dim_type type
)
212 return isl_bool_error
;
213 return isl_space_has_tuple_id(multi
->space
, type
);
216 /* Return the id of the specified tuple.
218 __isl_give isl_id
*FN(MULTI(BASE
),get_tuple_id
)(__isl_keep
MULTI(BASE
) *multi
,
219 enum isl_dim_type type
)
221 return multi
? isl_space_get_tuple_id(multi
->space
, type
) : NULL
;
224 __isl_give EL
*FN(FN(MULTI(BASE
),get
),BASE
)(__isl_keep
MULTI(BASE
) *multi
,
231 ctx
= FN(MULTI(BASE
),get_ctx
)(multi
);
232 if (pos
< 0 || pos
>= multi
->n
)
233 isl_die(ctx
, isl_error_invalid
,
234 "index out of bounds", return NULL
);
235 return FN(EL
,copy
)(multi
->u
.p
[pos
]);
238 /* Set the element at position "pos" of "multi" to "el",
239 * where the position may be empty if "multi" has only a single reference.
241 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),restore
)(
242 __isl_take
MULTI(BASE
) *multi
, int pos
, __isl_take EL
*el
)
244 multi
= FN(MULTI(BASE
),cow
)(multi
);
248 if (pos
< 0 || pos
>= multi
->n
)
249 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
250 "index out of bounds", goto error
);
252 FN(EL
,free
)(multi
->u
.p
[pos
]);
253 multi
->u
.p
[pos
] = el
;
257 FN(MULTI(BASE
),free
)(multi
);
262 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),set
),BASE
)(
263 __isl_take
MULTI(BASE
) *multi
, int pos
, __isl_take EL
*el
)
265 isl_space
*multi_space
= NULL
;
266 isl_space
*el_space
= NULL
;
269 multi_space
= FN(MULTI(BASE
),get_space
)(multi
);
270 match
= FN(EL
,matching_params
)(el
, multi_space
);
274 multi
= FN(MULTI(BASE
),align_params
)(multi
,
275 FN(EL
,get_space
)(el
));
276 isl_space_free(multi_space
);
277 multi_space
= FN(MULTI(BASE
),get_space
)(multi
);
278 el
= FN(EL
,align_params
)(el
, isl_space_copy(multi_space
));
280 if (FN(EL
,check_match_domain_space
)(el
, multi_space
) < 0)
283 multi
= FN(MULTI(BASE
),restore
)(multi
, pos
, el
);
285 isl_space_free(multi_space
);
286 isl_space_free(el_space
);
290 FN(MULTI(BASE
),free
)(multi
);
292 isl_space_free(multi_space
);
293 isl_space_free(el_space
);
297 /* Reset the space of "multi". This function is called from isl_pw_templ.c
298 * and doesn't know if the space of an element object is represented
299 * directly or through its domain. It therefore passes along both,
300 * which we pass along to the element function since we don't know how
301 * that is represented either.
303 * If "multi" has an explicit domain, then the caller is expected
304 * to make sure that any modification that would change the dimensions
305 * of the explicit domain has bee applied before this function is called.
307 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_space_and_domain
)(
308 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*space
,
309 __isl_take isl_space
*domain
)
313 multi
= FN(MULTI(BASE
),cow
)(multi
);
314 if (!multi
|| !space
|| !domain
)
317 for (i
= 0; i
< multi
->n
; ++i
) {
318 multi
->u
.p
[i
] = FN(EL
,reset_domain_space
)(multi
->u
.p
[i
],
319 isl_space_copy(domain
));
323 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
324 multi
= FN(MULTI(BASE
),reset_explicit_domain_space
)(multi
,
325 isl_space_copy(domain
));
329 isl_space_free(domain
);
330 isl_space_free(multi
->space
);
331 multi
->space
= space
;
335 isl_space_free(domain
);
336 isl_space_free(space
);
337 FN(MULTI(BASE
),free
)(multi
);
341 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_domain_space
)(
342 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*domain
)
346 space
= isl_space_extend_domain_with_range(isl_space_copy(domain
),
347 isl_space_copy(multi
->space
));
348 return FN(MULTI(BASE
),reset_space_and_domain
)(multi
, space
, domain
);
351 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_space
)(
352 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*space
)
356 domain
= isl_space_domain(isl_space_copy(space
));
357 return FN(MULTI(BASE
),reset_space_and_domain
)(multi
, space
, domain
);
360 /* Set the id of the given dimension of "multi" to "id".
362 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_dim_id
)(
363 __isl_take
MULTI(BASE
) *multi
,
364 enum isl_dim_type type
, unsigned pos
, __isl_take isl_id
*id
)
368 multi
= FN(MULTI(BASE
),cow
)(multi
);
372 space
= FN(MULTI(BASE
),get_space
)(multi
);
373 space
= isl_space_set_dim_id(space
, type
, pos
, id
);
375 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
378 FN(MULTI(BASE
),free
)(multi
);
382 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_tuple_name
)(
383 __isl_keep
MULTI(BASE
) *multi
, enum isl_dim_type type
,
388 multi
= FN(MULTI(BASE
),cow
)(multi
);
392 space
= FN(MULTI(BASE
),get_space
)(multi
);
393 space
= isl_space_set_tuple_name(space
, type
, s
);
395 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
398 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_tuple_id
)(
399 __isl_take
MULTI(BASE
) *multi
, enum isl_dim_type type
,
400 __isl_take isl_id
*id
)
404 multi
= FN(MULTI(BASE
),cow
)(multi
);
408 space
= FN(MULTI(BASE
),get_space
)(multi
);
409 space
= isl_space_set_tuple_id(space
, type
, id
);
411 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
417 /* Drop the id on the specified tuple.
419 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_tuple_id
)(
420 __isl_take
MULTI(BASE
) *multi
, enum isl_dim_type type
)
426 if (!FN(MULTI(BASE
),has_tuple_id
)(multi
, type
))
429 multi
= FN(MULTI(BASE
),cow
)(multi
);
433 space
= FN(MULTI(BASE
),get_space
)(multi
);
434 space
= isl_space_reset_tuple_id(space
, type
);
436 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
439 /* Reset the user pointer on all identifiers of parameters and tuples
440 * of the space of "multi".
442 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_user
)(
443 __isl_take
MULTI(BASE
) *multi
)
447 space
= FN(MULTI(BASE
),get_space
)(multi
);
448 space
= isl_space_reset_user(space
);
450 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
453 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),realign_domain
)(
454 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_reordering
*exp
)
459 multi
= FN(MULTI(BASE
),cow
)(multi
);
463 for (i
= 0; i
< multi
->n
; ++i
) {
464 multi
->u
.p
[i
] = FN(EL
,realign_domain
)(multi
->u
.p
[i
],
465 isl_reordering_copy(exp
));
470 space
= isl_reordering_get_space(exp
);
471 multi
= FN(MULTI(BASE
),reset_domain_space
)(multi
, space
);
473 isl_reordering_free(exp
);
476 isl_reordering_free(exp
);
477 FN(MULTI(BASE
),free
)(multi
);
481 /* Align the parameters of "multi" to those of "model".
483 * If "multi" has an explicit domain, then align the parameters
484 * of the domain first.
486 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),align_params
)(
487 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*model
)
490 isl_bool equal_params
;
493 if (!multi
|| !model
)
496 equal_params
= isl_space_has_equal_params(multi
->space
, model
);
497 if (equal_params
< 0)
500 isl_space_free(model
);
504 ctx
= isl_space_get_ctx(model
);
505 if (!isl_space_has_named_params(model
))
506 isl_die(ctx
, isl_error_invalid
,
507 "model has unnamed parameters", goto error
);
508 if (!isl_space_has_named_params(multi
->space
))
509 isl_die(ctx
, isl_error_invalid
,
510 "input has unnamed parameters", goto error
);
512 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
513 multi
= FN(MULTI(BASE
),align_explicit_domain_params
)(multi
,
514 isl_space_copy(model
));
518 model
= isl_space_params(model
);
519 exp
= isl_parameter_alignment_reordering(multi
->space
, model
);
520 exp
= isl_reordering_extend_space(exp
,
521 FN(MULTI(BASE
),get_domain_space
)(multi
));
522 multi
= FN(MULTI(BASE
),realign_domain
)(multi
, exp
);
524 isl_space_free(model
);
527 isl_space_free(model
);
528 FN(MULTI(BASE
),free
)(multi
);
532 /* Create a multi expression in the given space with the elements of "list"
533 * as base expressions.
535 * Since isl_multi_*_restore_* assumes that the element and
536 * the multi expression have matching spaces, the alignment
537 * (if any) needs to be performed beforehand.
539 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),from
),LIST(BASE
))(
540 __isl_take isl_space
*space
, __isl_take
LIST(EL
) *list
)
550 ctx
= isl_space_get_ctx(space
);
551 n
= FN(FN(LIST(EL
),n
),BASE
)(list
);
552 if (n
!= isl_space_dim(space
, isl_dim_out
))
553 isl_die(ctx
, isl_error_invalid
,
554 "invalid number of elements in list", goto error
);
556 for (i
= 0; i
< n
; ++i
) {
557 EL
*el
= FN(LIST(EL
),peek
)(list
, i
);
558 space
= isl_space_align_params(space
, FN(EL
,get_space
)(el
));
560 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
561 for (i
= 0; i
< n
; ++i
) {
562 EL
*el
= FN(FN(LIST(EL
),get
),BASE
)(list
, i
);
563 el
= FN(EL
,align_params
)(el
, isl_space_copy(space
));
564 multi
= FN(MULTI(BASE
),restore
)(multi
, i
, el
);
567 isl_space_free(space
);
568 FN(LIST(EL
),free
)(list
);
571 isl_space_free(space
);
572 FN(LIST(EL
),free
)(list
);
577 /* Create a multi expression in the given space that maps each
578 * input dimension to the corresponding output dimension.
580 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),identity
)(__isl_take isl_space
*space
)
589 if (isl_space_is_set(space
))
590 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
591 "expecting map space", goto error
);
593 n
= isl_space_dim(space
, isl_dim_out
);
594 if (n
!= isl_space_dim(space
, isl_dim_in
))
595 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
596 "number of input and output dimensions needs to be "
597 "the same", goto error
);
599 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
602 isl_space_free(space
);
606 space
= isl_space_domain(space
);
607 ls
= isl_local_space_from_space(space
);
609 for (i
= 0; i
< n
; ++i
) {
611 el
= FN(EL
,var_on_domain
)(isl_local_space_copy(ls
),
613 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
, el
);
616 isl_local_space_free(ls
);
620 isl_space_free(space
);
626 /* Construct a multi expression in the given space with value zero in
627 * each of the output dimensions.
629 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),zero
)(__isl_take isl_space
*space
)
637 n
= isl_space_dim(space
, isl_dim_out
);
638 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
641 isl_space_free(space
);
647 space
= isl_space_domain(space
);
648 ls
= isl_local_space_from_space(space
);
649 el
= FN(EL
,zero_on_domain
)(ls
);
651 for (i
= 0; i
< n
; ++i
)
652 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
,
663 /* Create a multiple expression with a single output/set dimension
665 * For most multiple expression types, the base type has a single
666 * output/set dimension and the space of the result is therefore
667 * the same as the space of the input.
668 * In the case of isl_multi_union_pw_aff, however, the base type
669 * lives in a parameter space and we therefore need to add
670 * a single set dimension.
672 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),from
),BASE
)(__isl_take EL
*el
)
677 space
= FN(EL
,get_space(el
));
678 if (isl_space_is_params(space
)) {
679 space
= isl_space_set_from_params(space
);
680 space
= isl_space_add_dims(space
, isl_dim_set
, 1);
682 multi
= FN(MULTI(BASE
),alloc
)(space
);
683 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, 0, el
);
689 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),drop_dims
)(
690 __isl_take
MULTI(BASE
) *multi
,
691 enum isl_dim_type type
, unsigned first
, unsigned n
)
696 multi
= FN(MULTI(BASE
),cow
)(multi
);
700 dim
= FN(MULTI(BASE
),dim
)(multi
, type
);
701 if (first
+ n
> dim
|| first
+ n
< first
)
702 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
703 "index out of bounds",
704 return FN(MULTI(BASE
),free
)(multi
));
706 multi
->space
= isl_space_drop_dims(multi
->space
, type
, first
, n
);
708 return FN(MULTI(BASE
),free
)(multi
);
710 if (type
== isl_dim_out
) {
711 for (i
= 0; i
< n
; ++i
)
712 FN(EL
,free
)(multi
->u
.p
[first
+ i
]);
713 for (i
= first
; i
+ n
< multi
->n
; ++i
)
714 multi
->u
.p
[i
] = multi
->u
.p
[i
+ n
];
716 if (n
> 0 && FN(MULTI(BASE
),has_explicit_domain
)(multi
))
717 multi
= FN(MULTI(BASE
),init_explicit_domain
)(multi
);
722 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
723 multi
= FN(MULTI(BASE
),drop_explicit_domain_dims
)(multi
,
728 for (i
= 0; i
< multi
->n
; ++i
) {
729 multi
->u
.p
[i
] = FN(EL
,drop_dims
)(multi
->u
.p
[i
], type
, first
, n
);
731 return FN(MULTI(BASE
),free
)(multi
);
737 /* Align the parameters of "multi1" and "multi2" (if needed) and call "fn".
739 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),align_params_multi_multi_and
)(
740 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
741 __isl_give
MULTI(BASE
) *(*fn
)(__isl_take
MULTI(BASE
) *multi1
,
742 __isl_take
MULTI(BASE
) *multi2
))
745 isl_bool equal_params
;
747 if (!multi1
|| !multi2
)
749 equal_params
= isl_space_has_equal_params(multi1
->space
, multi2
->space
);
750 if (equal_params
< 0)
753 return fn(multi1
, multi2
);
754 ctx
= FN(MULTI(BASE
),get_ctx
)(multi1
);
755 if (!isl_space_has_named_params(multi1
->space
) ||
756 !isl_space_has_named_params(multi2
->space
))
757 isl_die(ctx
, isl_error_invalid
,
758 "unaligned unnamed parameters", goto error
);
759 multi1
= FN(MULTI(BASE
),align_params
)(multi1
,
760 FN(MULTI(BASE
),get_space
)(multi2
));
761 multi2
= FN(MULTI(BASE
),align_params
)(multi2
,
762 FN(MULTI(BASE
),get_space
)(multi1
));
763 return fn(multi1
, multi2
);
765 FN(MULTI(BASE
),free
)(multi1
);
766 FN(MULTI(BASE
),free
)(multi2
);
770 /* Given two MULTI(BASE)s A -> B and C -> D,
771 * construct a MULTI(BASE) (A * C) -> [B -> D].
773 * The parameters are assumed to have been aligned.
775 * If "multi1" and/or "multi2" has an explicit domain, then
776 * intersect the domain of the result with these explicit domains.
778 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_product_aligned
)(
779 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
786 if (!multi1
|| !multi2
)
789 space
= isl_space_range_product(FN(MULTI(BASE
),get_space
)(multi1
),
790 FN(MULTI(BASE
),get_space
)(multi2
));
791 res
= FN(MULTI(BASE
),alloc
)(space
);
793 n1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
794 n2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_out
);
796 for (i
= 0; i
< n1
; ++i
) {
797 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi1
, i
);
798 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, i
, el
);
801 for (i
= 0; i
< n2
; ++i
) {
802 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi2
, i
);
803 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, n1
+ i
, el
);
806 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
))
807 res
= FN(MULTI(BASE
),intersect_explicit_domain
)(res
, multi1
);
808 if (FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
809 res
= FN(MULTI(BASE
),intersect_explicit_domain
)(res
, multi2
);
811 FN(MULTI(BASE
),free
)(multi1
);
812 FN(MULTI(BASE
),free
)(multi2
);
815 FN(MULTI(BASE
),free
)(multi1
);
816 FN(MULTI(BASE
),free
)(multi2
);
820 /* Given two MULTI(BASE)s A -> B and C -> D,
821 * construct a MULTI(BASE) (A * C) -> [B -> D].
823 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_product
)(
824 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
826 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
827 &FN(MULTI(BASE
),range_product_aligned
));
830 /* Is the range of "multi" a wrapped relation?
832 isl_bool
FN(MULTI(BASE
),range_is_wrapping
)(__isl_keep
MULTI(BASE
) *multi
)
835 return isl_bool_error
;
836 return isl_space_range_is_wrapping(multi
->space
);
839 /* Given a function A -> [B -> C], extract the function A -> B.
841 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_factor_domain
)(
842 __isl_take
MULTI(BASE
) *multi
)
849 if (!isl_space_range_is_wrapping(multi
->space
))
850 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
851 "range is not a product",
852 return FN(MULTI(BASE
),free
)(multi
));
854 space
= FN(MULTI(BASE
),get_space
)(multi
);
855 total
= isl_space_dim(space
, isl_dim_out
);
856 space
= isl_space_range_factor_domain(space
);
857 keep
= isl_space_dim(space
, isl_dim_out
);
858 multi
= FN(MULTI(BASE
),drop_dims
)(multi
,
859 isl_dim_out
, keep
, total
- keep
);
860 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
865 /* Given a function A -> [B -> C], extract the function A -> C.
867 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_factor_range
)(
868 __isl_take
MULTI(BASE
) *multi
)
875 if (!isl_space_range_is_wrapping(multi
->space
))
876 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
877 "range is not a product",
878 return FN(MULTI(BASE
),free
)(multi
));
880 space
= FN(MULTI(BASE
),get_space
)(multi
);
881 total
= isl_space_dim(space
, isl_dim_out
);
882 space
= isl_space_range_factor_range(space
);
883 keep
= isl_space_dim(space
, isl_dim_out
);
884 multi
= FN(MULTI(BASE
),drop_dims
)(multi
, isl_dim_out
, 0, total
- keep
);
885 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
890 /* Given a function [B -> C], extract the function C.
892 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),factor_range
)(
893 __isl_take
MULTI(BASE
) *multi
)
900 if (!isl_space_is_wrapping(multi
->space
))
901 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
902 "not a product", return FN(MULTI(BASE
),free
)(multi
));
904 space
= FN(MULTI(BASE
),get_space
)(multi
);
905 total
= isl_space_dim(space
, isl_dim_out
);
906 space
= isl_space_factor_range(space
);
907 keep
= isl_space_dim(space
, isl_dim_out
);
908 multi
= FN(MULTI(BASE
),drop_dims
)(multi
, isl_dim_out
, 0, total
- keep
);
909 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
915 /* Given two MULTI(BASE)s A -> B and C -> D,
916 * construct a MULTI(BASE) [A -> C] -> [B -> D].
918 * The parameters are assumed to have been aligned.
920 * If "multi1" and/or "multi2" has an explicit domain, then
921 * intersect the domain of the result with these explicit domains.
923 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),product_aligned
)(
924 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
930 int in1
, in2
, out1
, out2
;
932 in1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_in
);
933 in2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_in
);
934 out1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
935 out2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_out
);
936 space
= isl_space_product(FN(MULTI(BASE
),get_space
)(multi1
),
937 FN(MULTI(BASE
),get_space
)(multi2
));
938 res
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
939 space
= isl_space_domain(space
);
941 for (i
= 0; i
< out1
; ++i
) {
942 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi1
, i
);
943 el
= FN(EL
,insert_dims
)(el
, isl_dim_in
, in1
, in2
);
944 el
= FN(EL
,reset_domain_space
)(el
, isl_space_copy(space
));
945 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, i
, el
);
948 for (i
= 0; i
< out2
; ++i
) {
949 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi2
, i
);
950 el
= FN(EL
,insert_dims
)(el
, isl_dim_in
, 0, in1
);
951 el
= FN(EL
,reset_domain_space
)(el
, isl_space_copy(space
));
952 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, out1
+ i
, el
);
955 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
) ||
956 FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
957 res
= FN(MULTI(BASE
),intersect_explicit_domain_product
)(res
,
960 isl_space_free(space
);
961 FN(MULTI(BASE
),free
)(multi1
);
962 FN(MULTI(BASE
),free
)(multi2
);
966 /* Given two MULTI(BASE)s A -> B and C -> D,
967 * construct a MULTI(BASE) [A -> C] -> [B -> D].
969 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),product
)(
970 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
972 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
973 &FN(MULTI(BASE
),product_aligned
));
977 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),flatten_range
)(
978 __isl_take
MULTI(BASE
) *multi
)
983 if (!multi
->space
->nested
[1])
986 multi
= FN(MULTI(BASE
),cow
)(multi
);
990 multi
->space
= isl_space_flatten_range(multi
->space
);
992 return FN(MULTI(BASE
),free
)(multi
);
997 /* Given two MULTI(BASE)s A -> B and C -> D,
998 * construct a MULTI(BASE) (A * C) -> (B, D).
1000 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),flat_range_product
)(
1001 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
1005 multi
= FN(MULTI(BASE
),range_product
)(multi1
, multi2
);
1006 multi
= FN(MULTI(BASE
),flatten_range
)(multi
);
1010 /* Given two multi expressions, "multi1"
1014 * where B2 starts at position "pos", and "multi2"
1018 * return the multi expression
1022 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_splice
)(
1023 __isl_take
MULTI(BASE
) *multi1
, unsigned pos
,
1024 __isl_take
MULTI(BASE
) *multi2
)
1029 if (!multi1
|| !multi2
)
1032 dim
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
1034 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1035 "index out of bounds", goto error
);
1037 res
= FN(MULTI(BASE
),copy
)(multi1
);
1038 res
= FN(MULTI(BASE
),drop_dims
)(res
, isl_dim_out
, pos
, dim
- pos
);
1039 multi1
= FN(MULTI(BASE
),drop_dims
)(multi1
, isl_dim_out
, 0, pos
);
1041 res
= FN(MULTI(BASE
),flat_range_product
)(res
, multi2
);
1042 res
= FN(MULTI(BASE
),flat_range_product
)(res
, multi1
);
1046 FN(MULTI(BASE
),free
)(multi1
);
1047 FN(MULTI(BASE
),free
)(multi2
);
1052 /* Given two multi expressions, "multi1"
1054 * [A1 A2] -> [B1 B2]
1056 * where A2 starts at position "in_pos" and B2 starts at position "out_pos",
1061 * return the multi expression
1063 * [A1 C A2] -> [B1 D B2]
1065 * We first insert input dimensions to obtain
1067 * [A1 C A2] -> [B1 B2]
1073 * and then apply range_splice.
1075 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),splice
)(
1076 __isl_take
MULTI(BASE
) *multi1
, unsigned in_pos
, unsigned out_pos
,
1077 __isl_take
MULTI(BASE
) *multi2
)
1082 if (!multi1
|| !multi2
)
1085 n_in1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_in
);
1087 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1088 "index out of bounds", goto error
);
1090 n_in2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_in
);
1092 multi1
= FN(MULTI(BASE
),insert_dims
)(multi1
, isl_dim_in
, in_pos
, n_in2
);
1093 multi2
= FN(MULTI(BASE
),insert_dims
)(multi2
, isl_dim_in
, n_in2
,
1095 multi2
= FN(MULTI(BASE
),insert_dims
)(multi2
, isl_dim_in
, 0, in_pos
);
1097 return FN(MULTI(BASE
),range_splice
)(multi1
, out_pos
, multi2
);
1099 FN(MULTI(BASE
),free
)(multi1
);
1100 FN(MULTI(BASE
),free
)(multi2
);
1105 /* Check that "multi1" and "multi2" live in the same space,
1106 * reporting an error if they do not.
1108 static isl_stat
FN(MULTI(BASE
),check_equal_space
)(
1109 __isl_keep
MULTI(BASE
) *multi1
, __isl_keep
MULTI(BASE
) *multi2
)
1113 if (!multi1
|| !multi2
)
1114 return isl_stat_error
;
1116 equal
= isl_space_is_equal(multi1
->space
, multi2
->space
);
1118 return isl_stat_error
;
1120 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1121 "spaces don't match", return isl_stat_error
);
1126 /* This function is currently only used from isl_aff.c
1128 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),bin_op
)(
1129 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
1130 __isl_give EL
*(*fn
)(__isl_take EL
*, __isl_take EL
*))
1131 __attribute__ ((unused
));
1133 /* Pairwise perform "fn" to the elements of "multi1" and "multi2" and
1134 * return the result.
1136 * If "multi2" has an explicit domain, then
1137 * intersect the domain of the result with this explicit domain.
1139 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),bin_op
)(
1140 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
1141 __isl_give EL
*(*fn
)(__isl_take EL
*, __isl_take EL
*))
1145 multi1
= FN(MULTI(BASE
),cow
)(multi1
);
1146 if (FN(MULTI(BASE
),check_equal_space
)(multi1
, multi2
) < 0)
1149 for (i
= 0; i
< multi1
->n
; ++i
) {
1150 multi1
->u
.p
[i
] = fn(multi1
->u
.p
[i
],
1151 FN(EL
,copy
)(multi2
->u
.p
[i
]));
1152 if (!multi1
->u
.p
[i
])
1156 if (FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
1157 multi1
= FN(MULTI(BASE
),intersect_explicit_domain
)(multi1
,
1160 FN(MULTI(BASE
),free
)(multi2
);
1163 FN(MULTI(BASE
),free
)(multi1
);
1164 FN(MULTI(BASE
),free
)(multi2
);
1168 /* Add "multi2" from "multi1" and return the result.
1170 * The parameters of "multi1" and "multi2" are assumed to have been aligned.
1172 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),add_aligned
)(
1173 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
1175 return FN(MULTI(BASE
),bin_op
)(multi1
, multi2
, &FN(EL
,add
));
1178 /* Add "multi2" from "multi1" and return the result.
1180 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),add
)(__isl_take
MULTI(BASE
) *multi1
,
1181 __isl_take
MULTI(BASE
) *multi2
)
1183 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
1184 &FN(MULTI(BASE
),add_aligned
));
1187 /* Subtract "multi2" from "multi1" and return the result.
1189 * The parameters of "multi1" and "multi2" are assumed to have been aligned.
1191 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),sub_aligned
)(
1192 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
1194 return FN(MULTI(BASE
),bin_op
)(multi1
, multi2
, &FN(EL
,sub
));
1197 /* Subtract "multi2" from "multi1" and return the result.
1199 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),sub
)(__isl_take
MULTI(BASE
) *multi1
,
1200 __isl_take
MULTI(BASE
) *multi2
)
1202 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
1203 &FN(MULTI(BASE
),sub_aligned
));
1206 /* Multiply the elements of "multi" by "v" and return the result.
1208 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_val
)(__isl_take
MULTI(BASE
) *multi
,
1209 __isl_take isl_val
*v
)
1216 if (isl_val_is_one(v
)) {
1221 if (!isl_val_is_rat(v
))
1222 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1223 "expecting rational factor", goto error
);
1225 multi
= FN(MULTI(BASE
),cow
)(multi
);
1229 for (i
= 0; i
< multi
->n
; ++i
) {
1230 multi
->u
.p
[i
] = FN(EL
,scale_val
)(multi
->u
.p
[i
],
1240 return FN(MULTI(BASE
),free
)(multi
);
1243 /* Divide the elements of "multi" by "v" and return the result.
1245 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_down_val
)(
1246 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_val
*v
)
1253 if (isl_val_is_one(v
)) {
1258 if (!isl_val_is_rat(v
))
1259 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1260 "expecting rational factor", goto error
);
1261 if (isl_val_is_zero(v
))
1262 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1263 "cannot scale down by zero", goto error
);
1265 multi
= FN(MULTI(BASE
),cow
)(multi
);
1269 for (i
= 0; i
< multi
->n
; ++i
) {
1270 multi
->u
.p
[i
] = FN(EL
,scale_down_val
)(multi
->u
.p
[i
],
1280 return FN(MULTI(BASE
),free
)(multi
);
1283 /* Multiply the elements of "multi" by the corresponding element of "mv"
1284 * and return the result.
1286 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_multi_val
)(
1287 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1294 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1295 mv
->space
, isl_dim_set
))
1296 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1297 "spaces don't match", goto error
);
1299 multi
= FN(MULTI(BASE
),cow
)(multi
);
1303 for (i
= 0; i
< multi
->n
; ++i
) {
1306 v
= isl_multi_val_get_val(mv
, i
);
1307 multi
->u
.p
[i
] = FN(EL
,scale_val
)(multi
->u
.p
[i
], v
);
1312 isl_multi_val_free(mv
);
1315 isl_multi_val_free(mv
);
1316 return FN(MULTI(BASE
),free
)(multi
);
1319 /* Divide the elements of "multi" by the corresponding element of "mv"
1320 * and return the result.
1322 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_down_multi_val
)(
1323 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1330 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1331 mv
->space
, isl_dim_set
))
1332 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1333 "spaces don't match", goto error
);
1335 multi
= FN(MULTI(BASE
),cow
)(multi
);
1339 for (i
= 0; i
< multi
->n
; ++i
) {
1342 v
= isl_multi_val_get_val(mv
, i
);
1343 multi
->u
.p
[i
] = FN(EL
,scale_down_val
)(multi
->u
.p
[i
], v
);
1348 isl_multi_val_free(mv
);
1351 isl_multi_val_free(mv
);
1352 return FN(MULTI(BASE
),free
)(multi
);
1355 /* Compute the residues of the elements of "multi" modulo
1356 * the corresponding element of "mv" and return the result.
1358 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),mod_multi_val
)(
1359 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1366 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1367 mv
->space
, isl_dim_set
))
1368 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1369 "spaces don't match", goto error
);
1371 multi
= FN(MULTI(BASE
),cow
)(multi
);
1375 for (i
= 0; i
< multi
->n
; ++i
) {
1378 v
= isl_multi_val_get_val(mv
, i
);
1379 multi
->u
.p
[i
] = FN(EL
,mod_val
)(multi
->u
.p
[i
], v
);
1384 isl_multi_val_free(mv
);
1387 isl_multi_val_free(mv
);
1388 return FN(MULTI(BASE
),free
)(multi
);
1391 #ifndef NO_MOVE_DIMS
1392 /* Move the "n" dimensions of "src_type" starting at "src_pos" of "multi"
1393 * to dimensions of "dst_type" at "dst_pos".
1395 * We only support moving input dimensions to parameters and vice versa.
1397 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),move_dims
)(__isl_take
MULTI(BASE
) *multi
,
1398 enum isl_dim_type dst_type
, unsigned dst_pos
,
1399 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
)
1407 !isl_space_is_named_or_nested(multi
->space
, src_type
) &&
1408 !isl_space_is_named_or_nested(multi
->space
, dst_type
))
1411 if (dst_type
== isl_dim_out
|| src_type
== isl_dim_out
)
1412 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1413 "cannot move output/set dimension",
1414 return FN(MULTI(BASE
),free
)(multi
));
1415 if (dst_type
== isl_dim_div
|| src_type
== isl_dim_div
)
1416 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1418 return FN(MULTI(BASE
),free
)(multi
));
1419 if (src_pos
+ n
> isl_space_dim(multi
->space
, src_type
))
1420 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1421 "range out of bounds",
1422 return FN(MULTI(BASE
),free
)(multi
));
1423 if (dst_type
== src_type
)
1424 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_unsupported
,
1425 "moving dims within the same type not supported",
1426 return FN(MULTI(BASE
),free
)(multi
));
1428 multi
= FN(MULTI(BASE
),cow
)(multi
);
1432 multi
->space
= isl_space_move_dims(multi
->space
, dst_type
, dst_pos
,
1433 src_type
, src_pos
, n
);
1435 return FN(MULTI(BASE
),free
)(multi
);
1436 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
1437 multi
= FN(MULTI(BASE
),move_explicit_domain_dims
)(multi
,
1438 dst_type
, dst_pos
, src_type
, src_pos
, n
);
1442 for (i
= 0; i
< multi
->n
; ++i
) {
1443 multi
->u
.p
[i
] = FN(EL
,move_dims
)(multi
->u
.p
[i
],
1445 src_type
, src_pos
, n
);
1447 return FN(MULTI(BASE
),free
)(multi
);
1454 /* Convert a multiple expression defined over a parameter domain
1455 * into one that is defined over a zero-dimensional set.
1457 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),from_range
)(
1458 __isl_take
MULTI(BASE
) *multi
)
1464 if (!isl_space_is_set(multi
->space
))
1465 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1466 "not living in a set space",
1467 return FN(MULTI(BASE
),free
)(multi
));
1469 space
= FN(MULTI(BASE
),get_space
)(multi
);
1470 space
= isl_space_from_range(space
);
1471 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
1476 /* Are "multi1" and "multi2" obviously equal?
1478 isl_bool
FN(MULTI(BASE
),plain_is_equal
)(__isl_keep
MULTI(BASE
) *multi1
,
1479 __isl_keep
MULTI(BASE
) *multi2
)
1484 if (!multi1
|| !multi2
)
1485 return isl_bool_error
;
1486 if (multi1
->n
!= multi2
->n
)
1487 return isl_bool_false
;
1488 equal
= isl_space_is_equal(multi1
->space
, multi2
->space
);
1489 if (equal
< 0 || !equal
)
1492 for (i
= 0; i
< multi1
->n
; ++i
) {
1493 equal
= FN(EL
,plain_is_equal
)(multi1
->u
.p
[i
], multi2
->u
.p
[i
]);
1494 if (equal
< 0 || !equal
)
1498 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
) ||
1499 FN(MULTI(BASE
),has_explicit_domain
)(multi2
)) {
1500 equal
= FN(MULTI(BASE
),equal_explicit_domain
)(multi1
, multi2
);
1501 if (equal
< 0 || !equal
)
1505 return isl_bool_true
;
1508 /* Does "multi" involve any NaNs?
1510 isl_bool
FN(MULTI(BASE
),involves_nan
)(__isl_keep
MULTI(BASE
) *multi
)
1515 return isl_bool_error
;
1517 return isl_bool_false
;
1519 for (i
= 0; i
< multi
->n
; ++i
) {
1520 isl_bool has_nan
= FN(EL
,involves_nan
)(multi
->u
.p
[i
]);
1521 if (has_nan
< 0 || has_nan
)
1525 return isl_bool_false
;
1529 /* Return the shared domain of the elements of "multi".
1531 * If "multi" has an explicit domain, then return this domain.
1533 __isl_give isl_set
*FN(MULTI(BASE
),domain
)(__isl_take
MULTI(BASE
) *multi
)
1541 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
1542 dom
= FN(MULTI(BASE
),get_explicit_domain
)(multi
);
1543 FN(MULTI(BASE
),free
)(multi
);
1547 dom
= isl_set_universe(FN(MULTI(BASE
),get_domain_space
)(multi
));
1548 for (i
= 0; i
< multi
->n
; ++i
) {
1551 dom_i
= FN(EL
,domain
)(FN(FN(MULTI(BASE
),get
),BASE
)(multi
, i
));
1552 dom
= isl_set_intersect(dom
, dom_i
);
1555 FN(MULTI(BASE
),free
)(multi
);
1561 /* Return the opposite of "multi".
1563 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),neg
)(__isl_take
MULTI(BASE
) *multi
)
1567 multi
= FN(MULTI(BASE
),cow
)(multi
);
1571 for (i
= 0; i
< multi
->n
; ++i
) {
1572 multi
->u
.p
[i
] = FN(EL
,neg
)(multi
->u
.p
[i
]);
1574 return FN(MULTI(BASE
),free
)(multi
);