From 02d2884e6d1547774fd632afc66ca38b70df8955 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 28 Jun 2013 12:20:02 +0200 Subject: [PATCH] add isl_multi_pw_aff_from_pw_multi_aff Signed-off-by: Sven Verdoolaege --- doc/user.pod | 7 ++++++- include/isl/aff.h | 2 ++ isl_aff.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/user.pod b/doc/user.pod index f3bb341a..3020f4e4 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3973,13 +3973,18 @@ and C. __isl_take isl_aff_list *list); An C can be converted to an C -using the following function. Note however that the domain +using the function C below. +Note however that the domain of the result is the intersection of the domains of the input. +The reverse conversion is exact. #include __isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_pw_aff( __isl_take isl_multi_pw_aff *mpa); + __isl_give isl_multi_pw_aff * + isl_multi_pw_aff_from_pw_multi_aff( + __isl_take isl_pw_multi_aff *pma); An empty piecewise multiple quasi affine expression (one with no cells), the zero piecewise multiple quasi affine expression (with value zero diff --git a/include/isl/aff.h b/include/isl/aff.h index 89da8757..683e5a46 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -551,6 +551,8 @@ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims( __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_multi_pw_aff( __isl_take isl_multi_pw_aff *mpa); +__isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_multi_aff( + __isl_take isl_pw_multi_aff *pma); __isl_give isl_printer *isl_printer_print_multi_pw_aff( __isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa); diff --git a/isl_aff.c b/isl_aff.c index 3c87e9bc..6e3a32c1 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -5653,6 +5653,34 @@ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_multi_aff( return mpa; } +/* Construct and return a multi piecewise affine expression + * that is equal to the given piecewise multi affine expression. + */ +__isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_multi_aff( + __isl_take isl_pw_multi_aff *pma) +{ + int i, n; + isl_space *space; + isl_multi_pw_aff *mpa; + + if (!pma) + return NULL; + + n = isl_pw_multi_aff_dim(pma, isl_dim_out); + space = isl_pw_multi_aff_get_space(pma); + mpa = isl_multi_pw_aff_alloc(space); + + for (i = 0; i < n; ++i) { + isl_pw_aff *pa; + + pa = isl_pw_multi_aff_get_pw_aff(pma, i); + mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa); + } + + isl_pw_multi_aff_free(pma); + return mpa; +} + /* Do "pa1" and "pa2" represent the same function? * * We first check if they are obviously equal. -- 2.11.4.GIT