258
258
return FN(MULTI(BASE),set_at)(multi, pos, el);
261
/* Return the base expressions of "multi" as a list.
263
__isl_give LIST(EL) *FN(MULTI(BASE),get_list)(
264
__isl_keep MULTI(BASE) *multi)
270
n = FN(MULTI(BASE),size)(multi);
273
list = FN(LIST(EL),alloc)(FN(MULTI(BASE),get_ctx(multi)), n);
274
for (i = 0; i < n; ++i) {
275
EL *el = FN(MULTI(BASE),get_at)(multi, i);
276
list = FN(LIST(EL),add)(list, el);
261
282
/* Reset the space of "multi". This function is called from isl_pw_templ.c
262
283
* and doesn't know if the space of an element object is represented
263
284
* directly or through its domain. It therefore passes along both,
502
/* Align the parameters of "multi1" and "multi2" (if needed) and call "fn".
504
static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_params_multi_multi_and)(
505
__isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2,
506
__isl_give MULTI(BASE) *(*fn)(__isl_take MULTI(BASE) *multi1,
507
__isl_take MULTI(BASE) *multi2))
510
isl_bool equal_params;
524
#define TYPE MULTI(BASE)
512
if (!multi1 || !multi2)
514
equal_params = isl_space_has_equal_params(multi1->space, multi2->space);
515
if (equal_params < 0)
518
return fn(multi1, multi2);
519
ctx = FN(MULTI(BASE),get_ctx)(multi1);
520
if (!isl_space_has_named_params(multi1->space) ||
521
!isl_space_has_named_params(multi2->space))
522
isl_die(ctx, isl_error_invalid,
523
"unaligned unnamed parameters", goto error);
524
multi1 = FN(MULTI(BASE),align_params)(multi1,
525
FN(MULTI(BASE),get_space)(multi2));
526
multi2 = FN(MULTI(BASE),align_params)(multi2,
527
FN(MULTI(BASE),get_space)(multi1));
528
return fn(multi1, multi2);
530
FN(MULTI(BASE),free)(multi1);
531
FN(MULTI(BASE),free)(multi2);
526
#include "isl_check_named_params_templ.c"
528
#include "isl_align_params_bin_templ.c"
535
530
/* Given two MULTI(BASE)s A -> B and C -> D,
536
531
* construct a MULTI(BASE) (A * C) -> [B -> D].
538
* The parameters are assumed to have been aligned.
540
533
* If "multi1" and/or "multi2" has an explicit domain, then
541
534
* intersect the domain of the result with these explicit domains.
543
static __isl_give MULTI(BASE) *FN(MULTI(BASE),range_product_aligned)(
536
__isl_give MULTI(BASE) *FN(MULTI(BASE),range_product)(
544
537
__isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
549
542
isl_space *space;
550
543
MULTI(BASE) *res;
545
FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
552
546
n1 = FN(MULTI(BASE),size)(multi1);
553
547
n2 = FN(MULTI(BASE),size)(multi2);
554
548
if (n1 < 0 || n2 < 0)
585
/* Given two MULTI(BASE)s A -> B and C -> D,
586
* construct a MULTI(BASE) (A * C) -> [B -> D].
588
__isl_give MULTI(BASE) *FN(MULTI(BASE),range_product)(
589
__isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
591
return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2,
592
&FN(MULTI(BASE),range_product_aligned));
595
579
/* Is the range of "multi" a wrapped relation?
597
581
isl_bool FN(MULTI(BASE),range_is_wrapping)(__isl_keep MULTI(BASE) *multi)
758
/* Check that "multi1" and "multi2" live in the same space,
759
* reporting an error if they do not.
761
static isl_stat FN(MULTI(BASE),check_equal_space)(
762
__isl_keep MULTI(BASE) *multi1, __isl_keep MULTI(BASE) *multi2)
766
if (!multi1 || !multi2)
767
return isl_stat_error;
769
equal = isl_space_is_equal(multi1->space, multi2->space);
771
return isl_stat_error;
773
isl_die(FN(MULTI(BASE),get_ctx)(multi1), isl_error_invalid,
774
"spaces don't match", return isl_stat_error);
743
#define TYPE MULTI(BASE)
746
#include "isl_type_has_equal_space_bin_templ.c"
748
#include "isl_type_check_equal_space_templ.c"
779
750
/* This function is currently only used from isl_aff.c
769
FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
798
770
multi1 = FN(MULTI(BASE),cow)(multi1);
799
771
if (FN(MULTI(BASE),check_equal_space)(multi1, multi2) < 0)
844
816
return isl_bool_false;
819
/* Only used on some multi-expressions.
821
static isl_bool FN(MULTI(BASE),every)(__isl_keep MULTI(BASE) *multi,
822
isl_bool (*test)(__isl_keep EL *)) __attribute__ ((unused));
824
/* Does "test" succeed on every base expression of "multi"?
826
static isl_bool FN(MULTI(BASE),every)(__isl_keep MULTI(BASE) *multi,
827
isl_bool (*test)(__isl_keep EL *))
832
n = FN(MULTI(BASE),size)(multi);
834
return isl_bool_error;
836
for (i = 0; i < n; ++i) {
837
isl_bool every = test(multi->u.p[i]);
838
if (every < 0 || !every)
842
return isl_bool_true;
847
845
/* Convert a multiple expression defined over a parameter domain
848
846
* into one that is defined over a zero-dimensional set.