add isl_multi_*_scale_multi_val
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Jun 2013 09:28:59 +0000 (11:28 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Jun 2013 09:28:59 +0000 (11:28 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/multi.h
isl_multi_templ.c

index 47af664..eb28452 100644 (file)
@@ -3543,6 +3543,9 @@ Operations include
        __isl_give isl_multi_val *isl_multi_val_scale_val(
                __isl_take isl_multi_val *mv,
                __isl_take isl_val *v);
+       __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
+               __isl_take isl_multi_val *mv1,
+               __isl_take isl_multi_val *mv2);
 
 =head2 Vectors
 
@@ -4383,6 +4386,13 @@ C<isl_multi_aff_sub> subtracts the second argument from the first.
        __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
                __isl_take isl_multi_pw_aff *mpa,
                __isl_take isl_val *v);
+       __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
+               __isl_take isl_multi_aff *ma,
+               __isl_take isl_multi_val *mv);
+       __isl_give isl_multi_pw_aff *
+       isl_multi_pw_aff_scale_multi_val(
+               __isl_take isl_multi_pw_aff *mpa,
+               __isl_take isl_multi_val *mv);
        __isl_give isl_multi_aff *isl_multi_aff_scale_vec(
                __isl_take isl_multi_aff *ma,
                __isl_take isl_vec *v);
@@ -4393,6 +4403,8 @@ C<isl_multi_aff_sub> subtracts the second argument from the first.
                __isl_take isl_union_pw_multi_aff *upma,
                __isl_take isl_vec *v);
 
+C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
+by the corresponding elements of C<mv>.
 C<isl_multi_aff_scale_vec> scales the first elements of C<ma>
 by the corresponding elements of C<v>.
 
index a8f9b43..43f64c1 100644 (file)
@@ -63,6 +63,9 @@ __isl_give isl_multi_##BASE *isl_multi_##BASE##_range_product(                \
        __isl_take isl_multi_##BASE *multi2);                           \
 __isl_give isl_multi_##BASE *isl_multi_##BASE##_scale_val(             \
        __isl_take isl_multi_##BASE *multi, __isl_take isl_val *v);     \
+__isl_give isl_multi_##BASE *isl_multi_##BASE##_scale_multi_val(       \
+       __isl_take isl_multi_##BASE *multi,                             \
+       __isl_take isl_multi_val *mv);                                  \
 __isl_give isl_multi_##BASE *isl_multi_##BASE##_align_params(          \
        __isl_take isl_multi_##BASE *multi,                             \
        __isl_take isl_space *model);
index d3fec83..d73eb50 100644 (file)
@@ -873,3 +873,39 @@ error:
        isl_val_free(v);
        return FN(MULTI(BASE),free)(multi);
 }
+
+/* Multiply the elements of "multi" by the corresponding element of "mv"
+ * and return the result.
+ */
+__isl_give MULTI(BASE) *FN(MULTI(BASE),scale_multi_val)(
+       __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv)
+{
+       int i;
+
+       if (!multi || !mv)
+               goto error;
+
+       if (!isl_space_tuple_match(multi->space, isl_dim_out,
+                                       mv->space, isl_dim_set))
+               isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid,
+                       "spaces don't match", goto error);
+
+       multi = FN(MULTI(BASE),cow)(multi);
+       if (!multi)
+               return NULL;
+
+       for (i = 0; i < multi->n; ++i) {
+               isl_val *v;
+
+               v = isl_multi_val_get_val(mv, i);
+               multi->p[i] = FN(EL,scale_val)(multi->p[i], v);
+               if (!multi->p[i])
+                       goto error;
+       }
+
+       isl_multi_val_free(mv);
+       return multi;
+error:
+       isl_multi_val_free(mv);
+       return FN(MULTI(BASE),free)(multi);
+}