add isl_union_pw_multi_aff_scale_vec
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 14 Mar 2013 17:21:47 +0000 (18:21 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 16 Mar 2013 13:45:52 +0000 (14:45 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_aff.c

index 8760ee0..5864d46 100644 (file)
@@ -3905,6 +3905,9 @@ C<isl_multi_aff_sub> subtracts the second argument from the first.
        __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_vec(
                __isl_take isl_pw_multi_aff *pma,
                __isl_take isl_vec *v);
+       __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_scale_vec(
+               __isl_take isl_union_pw_multi_aff *upma,
+               __isl_take isl_vec *v);
 
 C<isl_multi_aff_scale_vec> scales the first elements of C<ma>
 by the corresponding elements of C<v>.
index 2509202..b9b94be 100644 (file)
@@ -512,6 +512,9 @@ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
        __isl_take isl_union_pw_multi_aff *upma1,
        __isl_take isl_union_pw_multi_aff *upma2);
 
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_scale_vec(
+       __isl_take isl_union_pw_multi_aff *upma, __isl_take isl_vec *v);
+
 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_flat_range_product(
        __isl_take isl_union_pw_multi_aff *upma1,
        __isl_take isl_union_pw_multi_aff *upma2);
index 944017d..6ff07ad 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -4706,3 +4706,40 @@ error:
        isl_pw_multi_aff_free(pma);
        return NULL;
 }
+
+/* This function is called for each entry of an isl_union_pw_multi_aff.
+ * Replace the entry by the result of applying isl_pw_multi_aff_scale_vec
+ * to the original entry with the isl_vec in "user" as extra argument.
+ */
+static int union_pw_multi_aff_scale_vec_entry(void **entry, void *user)
+{
+       isl_pw_multi_aff **pma = (isl_pw_multi_aff **) entry;
+       isl_vec *v = user;
+
+       *pma = isl_pw_multi_aff_scale_vec(*pma, isl_vec_copy(v));
+       if (!*pma)
+               return -1;
+
+       return 0;
+}
+
+/* Scale the first elements of "upma" by the corresponding elements of "vec".
+ */
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_scale_vec(
+       __isl_take isl_union_pw_multi_aff *upma, __isl_take isl_vec *v)
+{
+       upma = isl_union_pw_multi_aff_cow(upma);
+       if (!upma || !v)
+               goto error;
+
+       if (isl_hash_table_foreach(upma->dim->ctx, &upma->table,
+                                  &union_pw_multi_aff_scale_vec_entry, v) < 0)
+               goto error;
+
+       isl_vec_free(v);
+       return upma;
+error:
+       isl_vec_free(v);
+       isl_union_pw_multi_aff_free(upma);
+       return NULL;
+}