From daf854625fd18b93a3eabff19d64aee6ecd877e6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 18 Jun 2013 11:28:59 +0200 Subject: [PATCH] add isl_multi_*_scale_multi_val Signed-off-by: Sven Verdoolaege --- doc/user.pod | 12 ++++++++++++ include/isl/multi.h | 3 +++ isl_multi_templ.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 47af664..eb28452 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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 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 subtracts the second argument from the first. __isl_take isl_union_pw_multi_aff *upma, __isl_take isl_vec *v); +C scales the elements of C +by the corresponding elements of C. C scales the first elements of C by the corresponding elements of C. diff --git a/include/isl/multi.h b/include/isl/multi.h index a8f9b43..43f64c1 100644 --- a/include/isl/multi.h +++ b/include/isl/multi.h @@ -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); diff --git a/isl_multi_templ.c b/isl_multi_templ.c index d3fec83..d73eb50 100644 --- a/isl_multi_templ.c +++ b/isl_multi_templ.c @@ -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); +} -- 2.7.4