From: Sven Verdoolaege Date: Fri, 24 Jun 2011 12:56:49 +0000 (+0200) Subject: add isl_map_from_pw_aff X-Git-Tag: isl-0.07~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0343f5178b05aa4ebbe8c527b2228308b480027d;p=platform%2Fupstream%2Fisl.git add isl_map_from_pw_aff Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index 4063f47..1727771 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1029,11 +1029,13 @@ C and C for sets and of C, C, C, C and C for relations. -A basic relation can also be constructed from an affine expression +A (basic) relation can also be constructed from a (piecewise) affine expression or a list of affine expressions (See L<"Piecewise Quasi Affine Expressions">). __isl_give isl_basic_map *isl_basic_map_from_aff( __isl_take isl_aff *aff); + __isl_give isl_map *isl_map_from_pw_aff( + __isl_take isl_pw_aff *pwaff); __isl_give isl_basic_map *isl_basic_map_from_aff_list( __isl_take isl_dim *domain_dim, __isl_take isl_aff_list *list); diff --git a/include/isl/aff.h b/include/isl/aff.h index 65abb1a..9de587e 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -91,6 +91,8 @@ __isl_give isl_pw_aff *isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_give isl_pw_aff *isl_pw_aff_copy(__isl_keep isl_pw_aff *pwaff); void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff); +__isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff); + __isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff); void isl_pw_aff_dump(__isl_keep isl_pw_aff *pwaff); diff --git a/isl_aff.c b/isl_aff.c index 055c46c..74c4b14 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -858,3 +858,36 @@ error: isl_pw_aff_free(pwaff2); return NULL; } + +/* Construct a map with as domain the domain of pwaff and + * one-dimensional range corresponding to the affine expressions. + */ +__isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff) +{ + int i; + isl_dim *dim; + isl_map *map; + + if (!pwaff) + return NULL; + + dim = isl_pw_aff_get_dim(pwaff); + dim = isl_dim_from_domain(dim); + dim = isl_dim_add(dim, isl_dim_out, 1); + map = isl_map_empty(dim); + + for (i = 0; i < pwaff->n; ++i) { + isl_basic_map *bmap; + isl_map *map_i; + + bmap = isl_basic_map_from_aff(isl_aff_copy(pwaff->p[i].aff)); + map_i = isl_map_from_basic_map(bmap); + map_i = isl_map_intersect_domain(map_i, + isl_set_copy(pwaff->p[i].set)); + map = isl_map_union_disjoint(map, map_i); + } + + isl_pw_aff_free(pwaff); + + return map; +}