generalize isl_multi_aff_zero
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 12:57:58 +0000 (14:57 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 12:57:58 +0000 (14:57 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_aff.c
isl_multi_templ.c

index 5affddc..1fb8580 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -2514,40 +2514,6 @@ __isl_give isl_pw_aff *isl_pw_aff_list_max(__isl_take isl_pw_aff_list *list)
 
 #include <isl_multi_templ.c>
 
-/* Construct an isl_multi_aff in the given space with value zero in
- * each of the output dimensions.
- */
-__isl_give isl_multi_aff *isl_multi_aff_zero(__isl_take isl_space *space)
-{
-       int n;
-       isl_multi_aff *ma;
-
-       if (!space)
-               return NULL;
-
-       n = isl_space_dim(space , isl_dim_out);
-       ma = isl_multi_aff_alloc(isl_space_copy(space));
-
-       if (!n)
-               isl_space_free(space);
-       else {
-               int i;
-               isl_local_space *ls;
-               isl_aff *aff;
-
-               space = isl_space_domain(space);
-               ls = isl_local_space_from_space(space);
-               aff = isl_aff_zero_on_domain(ls);
-
-               for (i = 0; i < n; ++i)
-                       ma = isl_multi_aff_set_aff(ma, i, isl_aff_copy(aff));
-
-               isl_aff_free(aff);
-       }
-
-       return ma;
-}
-
 /* Create an isl_pw_multi_aff with the given isl_multi_aff on a universe
  * domain.
  */
index 8ecd892..17b4e0c 100644 (file)
@@ -456,3 +456,38 @@ error:
        isl_space_free(space);
        return NULL;
 }
+
+/* Construct a multi expression in the given space with value zero in
+ * each of the output dimensions.
+ */
+__isl_give MULTI(BASE) *FN(MULTI(BASE),zero)(__isl_take isl_space *space)
+{
+       int n;
+       MULTI(BASE) *multi;
+
+       if (!space)
+               return NULL;
+
+       n = isl_space_dim(space , isl_dim_out);
+       multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
+
+       if (!n)
+               isl_space_free(space);
+       else {
+               int i;
+               isl_local_space *ls;
+               EL *el;
+
+               space = isl_space_domain(space);
+               ls = isl_local_space_from_space(space);
+               el = FN(EL,zero_on_domain)(ls);
+
+               for (i = 0; i < n; ++i)
+                       multi = FN(FN(MULTI(BASE),set),BASE)(multi, i,
+                                                           FN(EL,copy)(el));
+
+               FN(EL,free)(el);
+       }
+
+       return multi;
+}