return NULL;
}
-/* Given two isl_multi_affs A -> B and C -> D,
- * construct an isl_multi_aff (A * C) -> (B, D).
- */
-__isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
- __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
-{
- int i, n1, n2;
- isl_aff *aff;
- isl_space *space;
- isl_multi_aff *res;
-
- if (!ma1 || !ma2)
- goto error;
-
- space = isl_space_range_product(isl_multi_aff_get_space(ma1),
- isl_multi_aff_get_space(ma2));
- space = isl_space_flatten_range(space);
- res = isl_multi_aff_alloc(space);
-
- n1 = isl_multi_aff_dim(ma1, isl_dim_out);
- n2 = isl_multi_aff_dim(ma2, isl_dim_out);
-
- for (i = 0; i < n1; ++i) {
- aff = isl_multi_aff_get_aff(ma1, i);
- res = isl_multi_aff_set_aff(res, i, aff);
- }
-
- for (i = 0; i < n2; ++i) {
- aff = isl_multi_aff_get_aff(ma2, i);
- res = isl_multi_aff_set_aff(res, n1 + i, aff);
- }
-
- isl_multi_aff_free(ma1);
- isl_multi_aff_free(ma2);
- return res;
-error:
- isl_multi_aff_free(ma1);
- isl_multi_aff_free(ma2);
- return NULL;
-}
-
/* Given two aligned isl_pw_multi_affs A -> B and C -> D,
* construct an isl_pw_multi_aff (A * C) -> (B, D).
*/
/*
* Copyright 2011 Sven Verdoolaege
+ * Copyright 2012 Ecole Normale Superieure
*
* Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege,
+ * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
*/
#define xCAT(A,B) A ## B
return multi;
}
+
+/* Given two MULTI(BASE)s A -> B and C -> D,
+ * construct a MULTI(BASE) (A * C) -> (B, D).
+ */
+__isl_give MULTI(BASE) *FN(MULTI(BASE),flat_range_product)(
+ __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
+{
+ int i, n1, n2;
+ EL *el;
+ isl_space *space;
+ MULTI(BASE) *res;
+
+ if (!multi1 || !multi2)
+ goto error;
+
+ space = isl_space_range_product(FN(MULTI(BASE),get_space)(multi1),
+ FN(MULTI(BASE),get_space)(multi2));
+ space = isl_space_flatten_range(space);
+ res = FN(MULTI(BASE),alloc)(space);
+
+ n1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
+ n2 = FN(MULTI(BASE),dim)(multi2, isl_dim_out);
+
+ for (i = 0; i < n1; ++i) {
+ el = FN(FN(MULTI(BASE),get),BASE)(multi1, i);
+ res = FN(FN(MULTI(BASE),set),BASE)(res, i, el);
+ }
+
+ for (i = 0; i < n2; ++i) {
+ el = FN(FN(MULTI(BASE),get),BASE)(multi2, i);
+ res = FN(FN(MULTI(BASE),set),BASE)(res, n1 + i, el);
+ }
+
+ FN(MULTI(BASE),free)(multi1);
+ FN(MULTI(BASE),free)(multi2);
+ return res;
+error:
+ FN(MULTI(BASE),free)(multi1);
+ FN(MULTI(BASE),free)(multi2);
+ return NULL;
+}