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 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),set
),BASE
)(
239 __isl_take
MULTI(BASE
) *multi
, int pos
, __isl_take EL
*el
)
241 isl_space
*multi_space
= NULL
;
242 isl_space
*el_space
= NULL
;
245 multi
= FN(MULTI(BASE
),cow
)(multi
);
249 multi_space
= FN(MULTI(BASE
),get_space
)(multi
);
250 match
= FN(EL
,matching_params
)(el
, multi_space
);
254 multi
= FN(MULTI(BASE
),align_params
)(multi
,
255 FN(EL
,get_space
)(el
));
256 isl_space_free(multi_space
);
257 multi_space
= FN(MULTI(BASE
),get_space
)(multi
);
258 el
= FN(EL
,align_params
)(el
, isl_space_copy(multi_space
));
260 if (FN(EL
,check_match_domain_space
)(el
, multi_space
) < 0)
263 if (pos
< 0 || pos
>= multi
->n
)
264 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
265 "index out of bounds", goto error
);
267 FN(EL
,free
)(multi
->u
.p
[pos
]);
268 multi
->u
.p
[pos
] = el
;
270 isl_space_free(multi_space
);
271 isl_space_free(el_space
);
275 FN(MULTI(BASE
),free
)(multi
);
277 isl_space_free(multi_space
);
278 isl_space_free(el_space
);
282 /* Reset the space of "multi". This function is called from isl_pw_templ.c
283 * and doesn't know if the space of an element object is represented
284 * directly or through its domain. It therefore passes along both,
285 * which we pass along to the element function since we don't know how
286 * that is represented either.
288 * If "multi" has an explicit domain, then the caller is expected
289 * to make sure that any modification that would change the dimensions
290 * of the explicit domain has bee applied before this function is called.
292 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_space_and_domain
)(
293 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*space
,
294 __isl_take isl_space
*domain
)
298 multi
= FN(MULTI(BASE
),cow
)(multi
);
299 if (!multi
|| !space
|| !domain
)
302 for (i
= 0; i
< multi
->n
; ++i
) {
303 multi
->u
.p
[i
] = FN(EL
,reset_domain_space
)(multi
->u
.p
[i
],
304 isl_space_copy(domain
));
308 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
309 multi
= FN(MULTI(BASE
),reset_explicit_domain_space
)(multi
,
310 isl_space_copy(domain
));
314 isl_space_free(domain
);
315 isl_space_free(multi
->space
);
316 multi
->space
= space
;
320 isl_space_free(domain
);
321 isl_space_free(space
);
322 FN(MULTI(BASE
),free
)(multi
);
326 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_domain_space
)(
327 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*domain
)
331 space
= isl_space_extend_domain_with_range(isl_space_copy(domain
),
332 isl_space_copy(multi
->space
));
333 return FN(MULTI(BASE
),reset_space_and_domain
)(multi
, space
, domain
);
336 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_space
)(
337 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*space
)
341 domain
= isl_space_domain(isl_space_copy(space
));
342 return FN(MULTI(BASE
),reset_space_and_domain
)(multi
, space
, domain
);
345 /* Set the id of the given dimension of "multi" to "id".
347 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_dim_id
)(
348 __isl_take
MULTI(BASE
) *multi
,
349 enum isl_dim_type type
, unsigned pos
, __isl_take isl_id
*id
)
353 multi
= FN(MULTI(BASE
),cow
)(multi
);
357 space
= FN(MULTI(BASE
),get_space
)(multi
);
358 space
= isl_space_set_dim_id(space
, type
, pos
, id
);
360 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
363 FN(MULTI(BASE
),free
)(multi
);
367 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_tuple_name
)(
368 __isl_keep
MULTI(BASE
) *multi
, enum isl_dim_type type
,
373 multi
= FN(MULTI(BASE
),cow
)(multi
);
377 space
= FN(MULTI(BASE
),get_space
)(multi
);
378 space
= isl_space_set_tuple_name(space
, type
, s
);
380 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
383 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),set_tuple_id
)(
384 __isl_take
MULTI(BASE
) *multi
, enum isl_dim_type type
,
385 __isl_take isl_id
*id
)
389 multi
= FN(MULTI(BASE
),cow
)(multi
);
393 space
= FN(MULTI(BASE
),get_space
)(multi
);
394 space
= isl_space_set_tuple_id(space
, type
, id
);
396 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
402 /* Drop the id on the specified tuple.
404 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_tuple_id
)(
405 __isl_take
MULTI(BASE
) *multi
, enum isl_dim_type type
)
411 if (!FN(MULTI(BASE
),has_tuple_id
)(multi
, type
))
414 multi
= FN(MULTI(BASE
),cow
)(multi
);
418 space
= FN(MULTI(BASE
),get_space
)(multi
);
419 space
= isl_space_reset_tuple_id(space
, type
);
421 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
424 /* Reset the user pointer on all identifiers of parameters and tuples
425 * of the space of "multi".
427 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),reset_user
)(
428 __isl_take
MULTI(BASE
) *multi
)
432 space
= FN(MULTI(BASE
),get_space
)(multi
);
433 space
= isl_space_reset_user(space
);
435 return FN(MULTI(BASE
),reset_space
)(multi
, space
);
438 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),realign_domain
)(
439 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_reordering
*exp
)
444 multi
= FN(MULTI(BASE
),cow
)(multi
);
448 for (i
= 0; i
< multi
->n
; ++i
) {
449 multi
->u
.p
[i
] = FN(EL
,realign_domain
)(multi
->u
.p
[i
],
450 isl_reordering_copy(exp
));
455 space
= isl_reordering_get_space(exp
);
456 multi
= FN(MULTI(BASE
),reset_domain_space
)(multi
, space
);
458 isl_reordering_free(exp
);
461 isl_reordering_free(exp
);
462 FN(MULTI(BASE
),free
)(multi
);
466 /* Align the parameters of "multi" to those of "model".
468 * If "multi" has an explicit domain, then align the parameters
469 * of the domain first.
471 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),align_params
)(
472 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_space
*model
)
475 isl_bool equal_params
;
478 if (!multi
|| !model
)
481 equal_params
= isl_space_has_equal_params(multi
->space
, model
);
482 if (equal_params
< 0)
485 isl_space_free(model
);
489 ctx
= isl_space_get_ctx(model
);
490 if (!isl_space_has_named_params(model
))
491 isl_die(ctx
, isl_error_invalid
,
492 "model has unnamed parameters", goto error
);
493 if (!isl_space_has_named_params(multi
->space
))
494 isl_die(ctx
, isl_error_invalid
,
495 "input has unnamed parameters", goto error
);
497 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
498 multi
= FN(MULTI(BASE
),align_explicit_domain_params
)(multi
,
499 isl_space_copy(model
));
503 model
= isl_space_params(model
);
504 exp
= isl_parameter_alignment_reordering(multi
->space
, model
);
505 exp
= isl_reordering_extend_space(exp
,
506 FN(MULTI(BASE
),get_domain_space
)(multi
));
507 multi
= FN(MULTI(BASE
),realign_domain
)(multi
, exp
);
509 isl_space_free(model
);
512 isl_space_free(model
);
513 FN(MULTI(BASE
),free
)(multi
);
517 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),from
),LIST(BASE
))(
518 __isl_take isl_space
*space
, __isl_take
LIST(EL
) *list
)
528 ctx
= isl_space_get_ctx(space
);
529 n
= FN(FN(LIST(EL
),n
),BASE
)(list
);
530 if (n
!= isl_space_dim(space
, isl_dim_out
))
531 isl_die(ctx
, isl_error_invalid
,
532 "invalid number of elements in list", goto error
);
534 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
535 for (i
= 0; i
< n
; ++i
) {
536 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
,
537 FN(FN(LIST(EL
),get
),BASE
)(list
, i
));
540 isl_space_free(space
);
541 FN(LIST(EL
),free
)(list
);
544 isl_space_free(space
);
545 FN(LIST(EL
),free
)(list
);
550 /* Create a multi expression in the given space that maps each
551 * input dimension to the corresponding output dimension.
553 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),identity
)(__isl_take isl_space
*space
)
562 if (isl_space_is_set(space
))
563 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
564 "expecting map space", goto error
);
566 n
= isl_space_dim(space
, isl_dim_out
);
567 if (n
!= isl_space_dim(space
, isl_dim_in
))
568 isl_die(isl_space_get_ctx(space
), isl_error_invalid
,
569 "number of input and output dimensions needs to be "
570 "the same", goto error
);
572 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
575 isl_space_free(space
);
579 space
= isl_space_domain(space
);
580 ls
= isl_local_space_from_space(space
);
582 for (i
= 0; i
< n
; ++i
) {
584 el
= FN(EL
,var_on_domain
)(isl_local_space_copy(ls
),
586 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
, el
);
589 isl_local_space_free(ls
);
593 isl_space_free(space
);
599 /* Construct a multi expression in the given space with value zero in
600 * each of the output dimensions.
602 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),zero
)(__isl_take isl_space
*space
)
610 n
= isl_space_dim(space
, isl_dim_out
);
611 multi
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
614 isl_space_free(space
);
620 space
= isl_space_domain(space
);
621 ls
= isl_local_space_from_space(space
);
622 el
= FN(EL
,zero_on_domain
)(ls
);
624 for (i
= 0; i
< n
; ++i
)
625 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, i
,
636 /* Create a multiple expression with a single output/set dimension
638 * For most multiple expression types, the base type has a single
639 * output/set dimension and the space of the result is therefore
640 * the same as the space of the input.
641 * In the case of isl_multi_union_pw_aff, however, the base type
642 * lives in a parameter space and we therefore need to add
643 * a single set dimension.
645 __isl_give
MULTI(BASE
) *FN(FN(MULTI(BASE
),from
),BASE
)(__isl_take EL
*el
)
650 space
= FN(EL
,get_space(el
));
651 if (isl_space_is_params(space
)) {
652 space
= isl_space_set_from_params(space
);
653 space
= isl_space_add_dims(space
, isl_dim_set
, 1);
655 multi
= FN(MULTI(BASE
),alloc
)(space
);
656 multi
= FN(FN(MULTI(BASE
),set
),BASE
)(multi
, 0, el
);
662 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),drop_dims
)(
663 __isl_take
MULTI(BASE
) *multi
,
664 enum isl_dim_type type
, unsigned first
, unsigned n
)
669 multi
= FN(MULTI(BASE
),cow
)(multi
);
673 dim
= FN(MULTI(BASE
),dim
)(multi
, type
);
674 if (first
+ n
> dim
|| first
+ n
< first
)
675 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
676 "index out of bounds",
677 return FN(MULTI(BASE
),free
)(multi
));
679 multi
->space
= isl_space_drop_dims(multi
->space
, type
, first
, n
);
681 return FN(MULTI(BASE
),free
)(multi
);
683 if (type
== isl_dim_out
) {
684 for (i
= 0; i
< n
; ++i
)
685 FN(EL
,free
)(multi
->u
.p
[first
+ i
]);
686 for (i
= first
; i
+ n
< multi
->n
; ++i
)
687 multi
->u
.p
[i
] = multi
->u
.p
[i
+ n
];
689 if (n
> 0 && FN(MULTI(BASE
),has_explicit_domain
)(multi
))
690 multi
= FN(MULTI(BASE
),init_explicit_domain
)(multi
);
695 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
696 multi
= FN(MULTI(BASE
),drop_explicit_domain_dims
)(multi
,
701 for (i
= 0; i
< multi
->n
; ++i
) {
702 multi
->u
.p
[i
] = FN(EL
,drop_dims
)(multi
->u
.p
[i
], type
, first
, n
);
704 return FN(MULTI(BASE
),free
)(multi
);
710 /* Align the parameters of "multi1" and "multi2" (if needed) and call "fn".
712 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),align_params_multi_multi_and
)(
713 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
714 __isl_give
MULTI(BASE
) *(*fn
)(__isl_take
MULTI(BASE
) *multi1
,
715 __isl_take
MULTI(BASE
) *multi2
))
718 isl_bool equal_params
;
720 if (!multi1
|| !multi2
)
722 equal_params
= isl_space_has_equal_params(multi1
->space
, multi2
->space
);
723 if (equal_params
< 0)
726 return fn(multi1
, multi2
);
727 ctx
= FN(MULTI(BASE
),get_ctx
)(multi1
);
728 if (!isl_space_has_named_params(multi1
->space
) ||
729 !isl_space_has_named_params(multi2
->space
))
730 isl_die(ctx
, isl_error_invalid
,
731 "unaligned unnamed parameters", goto error
);
732 multi1
= FN(MULTI(BASE
),align_params
)(multi1
,
733 FN(MULTI(BASE
),get_space
)(multi2
));
734 multi2
= FN(MULTI(BASE
),align_params
)(multi2
,
735 FN(MULTI(BASE
),get_space
)(multi1
));
736 return fn(multi1
, multi2
);
738 FN(MULTI(BASE
),free
)(multi1
);
739 FN(MULTI(BASE
),free
)(multi2
);
743 /* Given two MULTI(BASE)s A -> B and C -> D,
744 * construct a MULTI(BASE) (A * C) -> [B -> D].
746 * The parameters are assumed to have been aligned.
748 * If "multi1" and/or "multi2" has an explicit domain, then
749 * intersect the domain of the result with these explicit domains.
751 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_product_aligned
)(
752 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
759 if (!multi1
|| !multi2
)
762 space
= isl_space_range_product(FN(MULTI(BASE
),get_space
)(multi1
),
763 FN(MULTI(BASE
),get_space
)(multi2
));
764 res
= FN(MULTI(BASE
),alloc
)(space
);
766 n1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
767 n2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_out
);
769 for (i
= 0; i
< n1
; ++i
) {
770 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi1
, i
);
771 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, i
, el
);
774 for (i
= 0; i
< n2
; ++i
) {
775 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi2
, i
);
776 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, n1
+ i
, el
);
779 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
))
780 res
= FN(MULTI(BASE
),intersect_explicit_domain
)(res
, multi1
);
781 if (FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
782 res
= FN(MULTI(BASE
),intersect_explicit_domain
)(res
, multi2
);
784 FN(MULTI(BASE
),free
)(multi1
);
785 FN(MULTI(BASE
),free
)(multi2
);
788 FN(MULTI(BASE
),free
)(multi1
);
789 FN(MULTI(BASE
),free
)(multi2
);
793 /* Given two MULTI(BASE)s A -> B and C -> D,
794 * construct a MULTI(BASE) (A * C) -> [B -> D].
796 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_product
)(
797 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
799 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
800 &FN(MULTI(BASE
),range_product_aligned
));
803 /* Is the range of "multi" a wrapped relation?
805 isl_bool
FN(MULTI(BASE
),range_is_wrapping
)(__isl_keep
MULTI(BASE
) *multi
)
808 return isl_bool_error
;
809 return isl_space_range_is_wrapping(multi
->space
);
812 /* Given a function A -> [B -> C], extract the function A -> B.
814 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_factor_domain
)(
815 __isl_take
MULTI(BASE
) *multi
)
822 if (!isl_space_range_is_wrapping(multi
->space
))
823 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
824 "range is not a product",
825 return FN(MULTI(BASE
),free
)(multi
));
827 space
= FN(MULTI(BASE
),get_space
)(multi
);
828 total
= isl_space_dim(space
, isl_dim_out
);
829 space
= isl_space_range_factor_domain(space
);
830 keep
= isl_space_dim(space
, isl_dim_out
);
831 multi
= FN(MULTI(BASE
),drop_dims
)(multi
,
832 isl_dim_out
, keep
, total
- keep
);
833 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
838 /* Given a function A -> [B -> C], extract the function A -> C.
840 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_factor_range
)(
841 __isl_take
MULTI(BASE
) *multi
)
848 if (!isl_space_range_is_wrapping(multi
->space
))
849 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
850 "range is not a product",
851 return FN(MULTI(BASE
),free
)(multi
));
853 space
= FN(MULTI(BASE
),get_space
)(multi
);
854 total
= isl_space_dim(space
, isl_dim_out
);
855 space
= isl_space_range_factor_range(space
);
856 keep
= isl_space_dim(space
, isl_dim_out
);
857 multi
= FN(MULTI(BASE
),drop_dims
)(multi
, isl_dim_out
, 0, total
- keep
);
858 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
863 /* Given a function [B -> C], extract the function C.
865 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),factor_range
)(
866 __isl_take
MULTI(BASE
) *multi
)
873 if (!isl_space_is_wrapping(multi
->space
))
874 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
875 "not a product", return FN(MULTI(BASE
),free
)(multi
));
877 space
= FN(MULTI(BASE
),get_space
)(multi
);
878 total
= isl_space_dim(space
, isl_dim_out
);
879 space
= isl_space_factor_range(space
);
880 keep
= isl_space_dim(space
, isl_dim_out
);
881 multi
= FN(MULTI(BASE
),drop_dims
)(multi
, isl_dim_out
, 0, total
- keep
);
882 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
888 /* Given two MULTI(BASE)s A -> B and C -> D,
889 * construct a MULTI(BASE) [A -> C] -> [B -> D].
891 * The parameters are assumed to have been aligned.
893 * If "multi1" and/or "multi2" has an explicit domain, then
894 * intersect the domain of the result with these explicit domains.
896 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),product_aligned
)(
897 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
903 int in1
, in2
, out1
, out2
;
905 in1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_in
);
906 in2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_in
);
907 out1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
908 out2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_out
);
909 space
= isl_space_product(FN(MULTI(BASE
),get_space
)(multi1
),
910 FN(MULTI(BASE
),get_space
)(multi2
));
911 res
= FN(MULTI(BASE
),alloc
)(isl_space_copy(space
));
912 space
= isl_space_domain(space
);
914 for (i
= 0; i
< out1
; ++i
) {
915 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi1
, i
);
916 el
= FN(EL
,insert_dims
)(el
, isl_dim_in
, in1
, in2
);
917 el
= FN(EL
,reset_domain_space
)(el
, isl_space_copy(space
));
918 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, i
, el
);
921 for (i
= 0; i
< out2
; ++i
) {
922 el
= FN(FN(MULTI(BASE
),get
),BASE
)(multi2
, i
);
923 el
= FN(EL
,insert_dims
)(el
, isl_dim_in
, 0, in1
);
924 el
= FN(EL
,reset_domain_space
)(el
, isl_space_copy(space
));
925 res
= FN(FN(MULTI(BASE
),set
),BASE
)(res
, out1
+ i
, el
);
928 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
) ||
929 FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
930 res
= FN(MULTI(BASE
),intersect_explicit_domain_product
)(res
,
933 isl_space_free(space
);
934 FN(MULTI(BASE
),free
)(multi1
);
935 FN(MULTI(BASE
),free
)(multi2
);
939 /* Given two MULTI(BASE)s A -> B and C -> D,
940 * construct a MULTI(BASE) [A -> C] -> [B -> D].
942 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),product
)(
943 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
945 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
946 &FN(MULTI(BASE
),product_aligned
));
950 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),flatten_range
)(
951 __isl_take
MULTI(BASE
) *multi
)
956 if (!multi
->space
->nested
[1])
959 multi
= FN(MULTI(BASE
),cow
)(multi
);
963 multi
->space
= isl_space_flatten_range(multi
->space
);
965 return FN(MULTI(BASE
),free
)(multi
);
970 /* Given two MULTI(BASE)s A -> B and C -> D,
971 * construct a MULTI(BASE) (A * C) -> (B, D).
973 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),flat_range_product
)(
974 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
978 multi
= FN(MULTI(BASE
),range_product
)(multi1
, multi2
);
979 multi
= FN(MULTI(BASE
),flatten_range
)(multi
);
983 /* Given two multi expressions, "multi1"
987 * where B2 starts at position "pos", and "multi2"
991 * return the multi expression
995 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),range_splice
)(
996 __isl_take
MULTI(BASE
) *multi1
, unsigned pos
,
997 __isl_take
MULTI(BASE
) *multi2
)
1002 if (!multi1
|| !multi2
)
1005 dim
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_out
);
1007 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1008 "index out of bounds", goto error
);
1010 res
= FN(MULTI(BASE
),copy
)(multi1
);
1011 res
= FN(MULTI(BASE
),drop_dims
)(res
, isl_dim_out
, pos
, dim
- pos
);
1012 multi1
= FN(MULTI(BASE
),drop_dims
)(multi1
, isl_dim_out
, 0, pos
);
1014 res
= FN(MULTI(BASE
),flat_range_product
)(res
, multi2
);
1015 res
= FN(MULTI(BASE
),flat_range_product
)(res
, multi1
);
1019 FN(MULTI(BASE
),free
)(multi1
);
1020 FN(MULTI(BASE
),free
)(multi2
);
1025 /* Given two multi expressions, "multi1"
1027 * [A1 A2] -> [B1 B2]
1029 * where A2 starts at position "in_pos" and B2 starts at position "out_pos",
1034 * return the multi expression
1036 * [A1 C A2] -> [B1 D B2]
1038 * We first insert input dimensions to obtain
1040 * [A1 C A2] -> [B1 B2]
1046 * and then apply range_splice.
1048 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),splice
)(
1049 __isl_take
MULTI(BASE
) *multi1
, unsigned in_pos
, unsigned out_pos
,
1050 __isl_take
MULTI(BASE
) *multi2
)
1055 if (!multi1
|| !multi2
)
1058 n_in1
= FN(MULTI(BASE
),dim
)(multi1
, isl_dim_in
);
1060 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1061 "index out of bounds", goto error
);
1063 n_in2
= FN(MULTI(BASE
),dim
)(multi2
, isl_dim_in
);
1065 multi1
= FN(MULTI(BASE
),insert_dims
)(multi1
, isl_dim_in
, in_pos
, n_in2
);
1066 multi2
= FN(MULTI(BASE
),insert_dims
)(multi2
, isl_dim_in
, n_in2
,
1068 multi2
= FN(MULTI(BASE
),insert_dims
)(multi2
, isl_dim_in
, 0, in_pos
);
1070 return FN(MULTI(BASE
),range_splice
)(multi1
, out_pos
, multi2
);
1072 FN(MULTI(BASE
),free
)(multi1
);
1073 FN(MULTI(BASE
),free
)(multi2
);
1078 /* Check that "multi1" and "multi2" live in the same space,
1079 * reporting an error if they do not.
1081 static isl_stat
FN(MULTI(BASE
),check_equal_space
)(
1082 __isl_keep
MULTI(BASE
) *multi1
, __isl_keep
MULTI(BASE
) *multi2
)
1086 if (!multi1
|| !multi2
)
1087 return isl_stat_error
;
1089 equal
= isl_space_is_equal(multi1
->space
, multi2
->space
);
1091 return isl_stat_error
;
1093 isl_die(FN(MULTI(BASE
),get_ctx
)(multi1
), isl_error_invalid
,
1094 "spaces don't match", return isl_stat_error
);
1099 /* This function is currently only used from isl_aff.c
1101 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),bin_op
)(
1102 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
1103 __isl_give EL
*(*fn
)(__isl_take EL
*, __isl_take EL
*))
1104 __attribute__ ((unused
));
1106 /* Pairwise perform "fn" to the elements of "multi1" and "multi2" and
1107 * return the result.
1109 * If "multi2" has an explicit domain, then
1110 * intersect the domain of the result with this explicit domain.
1112 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),bin_op
)(
1113 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
,
1114 __isl_give EL
*(*fn
)(__isl_take EL
*, __isl_take EL
*))
1118 multi1
= FN(MULTI(BASE
),cow
)(multi1
);
1119 if (FN(MULTI(BASE
),check_equal_space
)(multi1
, multi2
) < 0)
1122 for (i
= 0; i
< multi1
->n
; ++i
) {
1123 multi1
->u
.p
[i
] = fn(multi1
->u
.p
[i
],
1124 FN(EL
,copy
)(multi2
->u
.p
[i
]));
1125 if (!multi1
->u
.p
[i
])
1129 if (FN(MULTI(BASE
),has_explicit_domain
)(multi2
))
1130 multi1
= FN(MULTI(BASE
),intersect_explicit_domain
)(multi1
,
1133 FN(MULTI(BASE
),free
)(multi2
);
1136 FN(MULTI(BASE
),free
)(multi1
);
1137 FN(MULTI(BASE
),free
)(multi2
);
1141 /* Add "multi2" from "multi1" and return the result.
1143 * The parameters of "multi1" and "multi2" are assumed to have been aligned.
1145 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),add_aligned
)(
1146 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
1148 return FN(MULTI(BASE
),bin_op
)(multi1
, multi2
, &FN(EL
,add
));
1151 /* Add "multi2" from "multi1" and return the result.
1153 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),add
)(__isl_take
MULTI(BASE
) *multi1
,
1154 __isl_take
MULTI(BASE
) *multi2
)
1156 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
1157 &FN(MULTI(BASE
),add_aligned
));
1160 /* Subtract "multi2" from "multi1" and return the result.
1162 * The parameters of "multi1" and "multi2" are assumed to have been aligned.
1164 static __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),sub_aligned
)(
1165 __isl_take
MULTI(BASE
) *multi1
, __isl_take
MULTI(BASE
) *multi2
)
1167 return FN(MULTI(BASE
),bin_op
)(multi1
, multi2
, &FN(EL
,sub
));
1170 /* Subtract "multi2" from "multi1" and return the result.
1172 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),sub
)(__isl_take
MULTI(BASE
) *multi1
,
1173 __isl_take
MULTI(BASE
) *multi2
)
1175 return FN(MULTI(BASE
),align_params_multi_multi_and
)(multi1
, multi2
,
1176 &FN(MULTI(BASE
),sub_aligned
));
1179 /* Multiply the elements of "multi" by "v" and return the result.
1181 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_val
)(__isl_take
MULTI(BASE
) *multi
,
1182 __isl_take isl_val
*v
)
1189 if (isl_val_is_one(v
)) {
1194 if (!isl_val_is_rat(v
))
1195 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1196 "expecting rational factor", goto error
);
1198 multi
= FN(MULTI(BASE
),cow
)(multi
);
1202 for (i
= 0; i
< multi
->n
; ++i
) {
1203 multi
->u
.p
[i
] = FN(EL
,scale_val
)(multi
->u
.p
[i
],
1213 return FN(MULTI(BASE
),free
)(multi
);
1216 /* Divide the elements of "multi" by "v" and return the result.
1218 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_down_val
)(
1219 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_val
*v
)
1226 if (isl_val_is_one(v
)) {
1231 if (!isl_val_is_rat(v
))
1232 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1233 "expecting rational factor", goto error
);
1234 if (isl_val_is_zero(v
))
1235 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
1236 "cannot scale down by zero", goto error
);
1238 multi
= FN(MULTI(BASE
),cow
)(multi
);
1242 for (i
= 0; i
< multi
->n
; ++i
) {
1243 multi
->u
.p
[i
] = FN(EL
,scale_down_val
)(multi
->u
.p
[i
],
1253 return FN(MULTI(BASE
),free
)(multi
);
1256 /* Multiply the elements of "multi" by the corresponding element of "mv"
1257 * and return the result.
1259 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_multi_val
)(
1260 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1267 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1268 mv
->space
, isl_dim_set
))
1269 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1270 "spaces don't match", goto error
);
1272 multi
= FN(MULTI(BASE
),cow
)(multi
);
1276 for (i
= 0; i
< multi
->n
; ++i
) {
1279 v
= isl_multi_val_get_val(mv
, i
);
1280 multi
->u
.p
[i
] = FN(EL
,scale_val
)(multi
->u
.p
[i
], v
);
1285 isl_multi_val_free(mv
);
1288 isl_multi_val_free(mv
);
1289 return FN(MULTI(BASE
),free
)(multi
);
1292 /* Divide the elements of "multi" by the corresponding element of "mv"
1293 * and return the result.
1295 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),scale_down_multi_val
)(
1296 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1303 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1304 mv
->space
, isl_dim_set
))
1305 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1306 "spaces don't match", goto error
);
1308 multi
= FN(MULTI(BASE
),cow
)(multi
);
1312 for (i
= 0; i
< multi
->n
; ++i
) {
1315 v
= isl_multi_val_get_val(mv
, i
);
1316 multi
->u
.p
[i
] = FN(EL
,scale_down_val
)(multi
->u
.p
[i
], v
);
1321 isl_multi_val_free(mv
);
1324 isl_multi_val_free(mv
);
1325 return FN(MULTI(BASE
),free
)(multi
);
1328 /* Compute the residues of the elements of "multi" modulo
1329 * the corresponding element of "mv" and return the result.
1331 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),mod_multi_val
)(
1332 __isl_take
MULTI(BASE
) *multi
, __isl_take isl_multi_val
*mv
)
1339 if (!isl_space_tuple_is_equal(multi
->space
, isl_dim_out
,
1340 mv
->space
, isl_dim_set
))
1341 isl_die(isl_multi_val_get_ctx(mv
), isl_error_invalid
,
1342 "spaces don't match", goto error
);
1344 multi
= FN(MULTI(BASE
),cow
)(multi
);
1348 for (i
= 0; i
< multi
->n
; ++i
) {
1351 v
= isl_multi_val_get_val(mv
, i
);
1352 multi
->u
.p
[i
] = FN(EL
,mod_val
)(multi
->u
.p
[i
], v
);
1357 isl_multi_val_free(mv
);
1360 isl_multi_val_free(mv
);
1361 return FN(MULTI(BASE
),free
)(multi
);
1364 #ifndef NO_MOVE_DIMS
1365 /* Move the "n" dimensions of "src_type" starting at "src_pos" of "multi"
1366 * to dimensions of "dst_type" at "dst_pos".
1368 * We only support moving input dimensions to parameters and vice versa.
1370 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),move_dims
)(__isl_take
MULTI(BASE
) *multi
,
1371 enum isl_dim_type dst_type
, unsigned dst_pos
,
1372 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
)
1380 !isl_space_is_named_or_nested(multi
->space
, src_type
) &&
1381 !isl_space_is_named_or_nested(multi
->space
, dst_type
))
1384 if (dst_type
== isl_dim_out
|| src_type
== isl_dim_out
)
1385 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1386 "cannot move output/set dimension",
1387 return FN(MULTI(BASE
),free
)(multi
));
1388 if (dst_type
== isl_dim_div
|| src_type
== isl_dim_div
)
1389 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1391 return FN(MULTI(BASE
),free
)(multi
));
1392 if (src_pos
+ n
> isl_space_dim(multi
->space
, src_type
))
1393 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1394 "range out of bounds",
1395 return FN(MULTI(BASE
),free
)(multi
));
1396 if (dst_type
== src_type
)
1397 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_unsupported
,
1398 "moving dims within the same type not supported",
1399 return FN(MULTI(BASE
),free
)(multi
));
1401 multi
= FN(MULTI(BASE
),cow
)(multi
);
1405 multi
->space
= isl_space_move_dims(multi
->space
, dst_type
, dst_pos
,
1406 src_type
, src_pos
, n
);
1408 return FN(MULTI(BASE
),free
)(multi
);
1409 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
))
1410 multi
= FN(MULTI(BASE
),move_explicit_domain_dims
)(multi
,
1411 dst_type
, dst_pos
, src_type
, src_pos
, n
);
1415 for (i
= 0; i
< multi
->n
; ++i
) {
1416 multi
->u
.p
[i
] = FN(EL
,move_dims
)(multi
->u
.p
[i
],
1418 src_type
, src_pos
, n
);
1420 return FN(MULTI(BASE
),free
)(multi
);
1427 /* Convert a multiple expression defined over a parameter domain
1428 * into one that is defined over a zero-dimensional set.
1430 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),from_range
)(
1431 __isl_take
MULTI(BASE
) *multi
)
1437 if (!isl_space_is_set(multi
->space
))
1438 isl_die(FN(MULTI(BASE
),get_ctx
)(multi
), isl_error_invalid
,
1439 "not living in a set space",
1440 return FN(MULTI(BASE
),free
)(multi
));
1442 space
= FN(MULTI(BASE
),get_space
)(multi
);
1443 space
= isl_space_from_range(space
);
1444 multi
= FN(MULTI(BASE
),reset_space
)(multi
, space
);
1449 /* Are "multi1" and "multi2" obviously equal?
1451 isl_bool
FN(MULTI(BASE
),plain_is_equal
)(__isl_keep
MULTI(BASE
) *multi1
,
1452 __isl_keep
MULTI(BASE
) *multi2
)
1457 if (!multi1
|| !multi2
)
1458 return isl_bool_error
;
1459 if (multi1
->n
!= multi2
->n
)
1460 return isl_bool_false
;
1461 equal
= isl_space_is_equal(multi1
->space
, multi2
->space
);
1462 if (equal
< 0 || !equal
)
1465 for (i
= 0; i
< multi1
->n
; ++i
) {
1466 equal
= FN(EL
,plain_is_equal
)(multi1
->u
.p
[i
], multi2
->u
.p
[i
]);
1467 if (equal
< 0 || !equal
)
1471 if (FN(MULTI(BASE
),has_explicit_domain
)(multi1
) ||
1472 FN(MULTI(BASE
),has_explicit_domain
)(multi2
)) {
1473 equal
= FN(MULTI(BASE
),equal_explicit_domain
)(multi1
, multi2
);
1474 if (equal
< 0 || !equal
)
1478 return isl_bool_true
;
1481 /* Does "multi" involve any NaNs?
1483 isl_bool
FN(MULTI(BASE
),involves_nan
)(__isl_keep
MULTI(BASE
) *multi
)
1488 return isl_bool_error
;
1490 return isl_bool_false
;
1492 for (i
= 0; i
< multi
->n
; ++i
) {
1493 isl_bool has_nan
= FN(EL
,involves_nan
)(multi
->u
.p
[i
]);
1494 if (has_nan
< 0 || has_nan
)
1498 return isl_bool_false
;
1502 /* Return the shared domain of the elements of "multi".
1504 * If "multi" has an explicit domain, then return this domain.
1506 __isl_give isl_set
*FN(MULTI(BASE
),domain
)(__isl_take
MULTI(BASE
) *multi
)
1514 if (FN(MULTI(BASE
),has_explicit_domain
)(multi
)) {
1515 dom
= FN(MULTI(BASE
),get_explicit_domain
)(multi
);
1516 FN(MULTI(BASE
),free
)(multi
);
1520 dom
= isl_set_universe(FN(MULTI(BASE
),get_domain_space
)(multi
));
1521 for (i
= 0; i
< multi
->n
; ++i
) {
1524 dom_i
= FN(EL
,domain
)(FN(FN(MULTI(BASE
),get
),BASE
)(multi
, i
));
1525 dom
= isl_set_intersect(dom
, dom_i
);
1528 FN(MULTI(BASE
),free
)(multi
);
1534 /* Return the opposite of "multi".
1536 __isl_give
MULTI(BASE
) *FN(MULTI(BASE
),neg
)(__isl_take
MULTI(BASE
) *multi
)
1540 multi
= FN(MULTI(BASE
),cow
)(multi
);
1544 for (i
= 0; i
< multi
->n
; ++i
) {
1545 multi
->u
.p
[i
] = FN(EL
,neg
)(multi
->u
.p
[i
]);
1547 return FN(MULTI(BASE
),free
)(multi
);