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

index 0e416cf..e011ad5 100644 (file)
@@ -3899,6 +3899,13 @@ C<isl_multi_aff_sub> subtracts the second argument from the first.
        __isl_give isl_multi_aff *isl_multi_aff_scale(
                __isl_take isl_multi_aff *maff,
                isl_int f);
+       __isl_give isl_multi_aff *isl_multi_aff_scale_vec(
+               __isl_take isl_multi_aff *ma,
+               __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>.
+
        __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
                __isl_take isl_pw_multi_aff *pma,
                __isl_take isl_set *set);
index 9bcc74f..74532ea 100644 (file)
@@ -8,6 +8,7 @@
 #include <isl/list.h>
 #include <isl/multi.h>
 #include <isl/union_set_type.h>
+#include <isl/vec.h>
 
 #if defined(__cplusplus)
 extern "C" {
@@ -315,6 +316,8 @@ __isl_give isl_multi_aff *isl_multi_aff_sub(__isl_take isl_multi_aff *ma1,
 
 __isl_give isl_multi_aff *isl_multi_aff_scale(__isl_take isl_multi_aff *maff,
        isl_int f);
+__isl_give isl_multi_aff *isl_multi_aff_scale_vec(__isl_take isl_multi_aff *ma,
+       __isl_take isl_vec *v);
 
 __isl_give isl_multi_aff *isl_multi_aff_range_splice(
        __isl_take isl_multi_aff *ma1, unsigned pos,
index a81e4d1..c24462b 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2011      INRIA Saclay
  * Copyright 2011      Sven Verdoolaege
- * Copyright 2012      Ecole Normale Superieure
+ * Copyright 2012-2013 Ecole Normale Superieure
  *
  * Use of this software is governed by the MIT license
  *
@@ -4645,3 +4645,38 @@ error:
 #define BASE pw_aff
 
 #include <isl_multi_templ.c>
+
+/* Scale the first elements of "ma" by the corresponding elements of "vec".
+ */
+__isl_give isl_multi_aff *isl_multi_aff_scale_vec(__isl_take isl_multi_aff *ma,
+       __isl_take isl_vec *vec)
+{
+       int i, n;
+       isl_int v;
+
+       if (!ma || !vec)
+               goto error;
+
+       n = isl_multi_aff_dim(ma, isl_dim_out);
+       if (isl_vec_size(vec) < n)
+               n = isl_vec_size(vec);
+
+       isl_int_init(v);
+       for (i = 0; i < n; ++i) {
+               isl_aff *aff;
+
+               isl_vec_get_element(vec, i, &v);
+
+               aff = isl_multi_aff_get_aff(ma, i);
+               aff = isl_aff_scale(aff, v);
+               ma = isl_multi_aff_set_aff(ma, i, aff);
+       }
+       isl_int_clear(v);
+
+       isl_vec_free(vec);
+       return ma;
+error:
+       isl_vec_free(vec);
+       isl_multi_aff_free(ma);
+       return NULL;
+}