From efa3536a47d2648fdb9a456273518e414999236e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 19 Mar 2012 16:03:29 +0100 Subject: [PATCH] add isl_multi_aff_zero Signed-off-by: Sven Verdoolaege --- doc/user.pod | 6 +++++- include/isl/aff.h | 2 ++ isl_aff.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/user.pod b/doc/user.pod index 219c7ec..21eea0b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3209,13 +3209,17 @@ following function. __isl_take isl_space *space, __isl_take isl_aff_list *list); -An empty piecewise multiple quasi affine expression (one with no cells) or +An empty piecewise multiple quasi affine expression (one with no cells), +the zero piecewise multiple quasi affine expression (with value zero +for each output dimension) or a piecewise multiple quasi affine expression with a single cell can be created using the following functions. #include __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty( __isl_take isl_space *space); + __isl_give isl_multi_aff *isl_multi_aff_zero( + __isl_take isl_space *space); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc( __isl_take isl_set *set, __isl_take isl_multi_aff *maff); diff --git a/include/isl/aff.h b/include/isl/aff.h index 226c854..7f142dc 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -239,6 +239,8 @@ __isl_give isl_set *isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1, __isl_give isl_set *isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2); +__isl_give isl_multi_aff *isl_multi_aff_zero(__isl_take isl_space *space); + isl_ctx *isl_multi_aff_get_ctx(__isl_keep isl_multi_aff *maff); __isl_give isl_space *isl_multi_aff_get_space(__isl_keep isl_multi_aff *maff); __isl_give isl_multi_aff *isl_multi_aff_set_tuple_id( diff --git a/isl_aff.c b/isl_aff.c index becf73b..8ddd78c 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -2080,6 +2080,40 @@ __isl_give isl_pw_aff *isl_pw_aff_list_max(__isl_take isl_pw_aff_list *list) #include +/* Construct an isl_multi_aff in the given space with value zero in + * each of the output dimensions. + */ +__isl_give isl_multi_aff *isl_multi_aff_zero(__isl_take isl_space *space) +{ + int n; + isl_multi_aff *ma; + + if (!space) + return NULL; + + n = isl_space_dim(space , isl_dim_out); + ma = isl_multi_aff_alloc(isl_space_copy(space)); + + if (!n) + isl_space_free(space); + else { + int i; + isl_local_space *ls; + isl_aff *aff; + + space = isl_space_domain(space); + ls = isl_local_space_from_space(space); + aff = isl_aff_zero_on_domain(ls); + + for (i = 0; i < n; ++i) + ma = isl_multi_aff_set_aff(ma, i, isl_aff_copy(aff)); + + isl_aff_free(aff); + } + + return ma; +} + __isl_give isl_multi_aff *isl_multi_aff_add(__isl_take isl_multi_aff *maff1, __isl_take isl_multi_aff *maff2) { -- 2.7.4