From: Sven Verdoolaege Date: Sat, 5 Mar 2011 18:24:07 +0000 (+0100) Subject: change isl_map_power interface X-Git-Tag: isl-0.06~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8858e22dc68c399b803d1b7710e56275a4fcf98;p=platform%2Fupstream%2Fisl.git change isl_map_power interface The old interface could not be extended to union maps, while the new interface exploits nested spaces. Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index be81874..bf68cb7 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -73,6 +73,10 @@ of a B as input. An old call C can be rewritten to C. +=item * The function C no longer takes +a parameter position as input. Instead, the exponent +is now expressed as the domain of the resulting relation. + =back =head1 Installation @@ -1441,10 +1445,11 @@ per space. =item * Power __isl_give isl_map *isl_map_power(__isl_take isl_map *map, - unsigned param, int *exact); + int *exact); Compute a parametric representation for all positive powers I of C. -The power I is equated to the parameter at position C. +The result maps I to a nested relation corresponding to the +Ith power of C. The result may be an overapproximation. If the result is known to be exact, then C<*exact> is set to C<1>. diff --git a/include/isl/map.h b/include/isl/map.h index d73f0aa..7e4ef78 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -410,8 +410,7 @@ int isl_map_foreach_basic_map(__isl_keep isl_map *map, __isl_give isl_map *isl_set_lifting(__isl_take isl_set *set); -__isl_give isl_map *isl_map_power(__isl_take isl_map *map, unsigned param, - int *exact); +__isl_give isl_map *isl_map_power(__isl_take isl_map *map, int *exact); __isl_give isl_map *isl_map_reaching_path_lengths(__isl_take isl_map *map, int *exact); __isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map, diff --git a/isl_test.c b/isl_test.c index 58ebea1..1e7a6b5 100644 --- a/isl_test.c +++ b/isl_test.c @@ -950,11 +950,11 @@ void test_closure(struct isl_ctx *ctx) /* COCOA example 1 */ map = isl_map_read_from_str(ctx, - "[n,k] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and " + "[n] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and " "1 <= i and i < n and 1 <= j and j < n or " "i2 = i + 1 and j2 = j - 1 and " "1 <= i and i < n and 2 <= j and j <= n }", -1); - map = isl_map_power(map, 1, &exact); + map = isl_map_power(map, &exact); assert(exact); isl_map_free(map); @@ -1020,14 +1020,14 @@ void test_closure(struct isl_ctx *ctx) /* COCOA Fig.2 right */ map = isl_map_read_from_str(ctx, - "[n,k] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and " + "[n] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and " "i <= 2 j - 4 and i <= n - 3 and j <= 2 i - 1 and " "j <= n or " "i2 = i and j2 = j + 3 and i <= 2 j - 1 and i <= n and " "j <= 2 i - 4 and j <= n - 3 or " "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and " "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }", -1); - map = isl_map_power(map, 1, &exact); + map = isl_map_power(map, &exact); assert(exact); isl_map_free(map); diff --git a/isl_transitive_closure.c b/isl_transitive_closure.c index 106131a..37b5142 100644 --- a/isl_transitive_closure.c +++ b/isl_transitive_closure.c @@ -2135,50 +2135,57 @@ error: } /* Compute the positive powers of "map", or an overapproximation. - * The power is given by parameter "param". If the result is exact, - * then *exact is set to 1. + * The result maps the exponent to a nested copy of the corresponding power. + * If the result is exact, then *exact is set to 1. * map_power constructs an extended relation with the path lengths * encoded as the difference between the final coordinates. - * In the final step, this difference is equated to the parameter "param" - * and made positive. The extra coordinates are subsequently projected out. + * In the final step, this difference is equated to an extra parameter + * and made positive. The extra coordinates are subsequently projected out + * and the parameter is turned into the domain of the result. */ -__isl_give isl_map *isl_map_power(__isl_take isl_map *map, unsigned param, - int *exact) +__isl_give isl_map *isl_map_power(__isl_take isl_map *map, int *exact) { isl_dim *target_dim; isl_dim *dim; isl_map *diff; unsigned d; + unsigned param; if (!map) return NULL; - isl_assert(map->ctx, param < isl_map_dim(map, isl_dim_param), - goto error); - d = isl_map_dim(map, isl_dim_in); + param = isl_map_dim(map, isl_dim_param); map = isl_map_compute_divs(map); map = isl_map_coalesce(map); - if (isl_map_fast_is_empty(map)) + if (isl_map_fast_is_empty(map)) { + map = isl_map_from_range(isl_map_wrap(map)); + map = isl_map_add_dims(map, isl_dim_in, 1); + map = isl_map_set_dim_name(map, isl_dim_in, 0, "k"); return map; + } target_dim = isl_map_get_dim(map); + target_dim = isl_dim_from_range(isl_dim_wrap(target_dim)); + target_dim = isl_dim_add(target_dim, isl_dim_in, 1); + target_dim = isl_dim_set_name(target_dim, isl_dim_in, 0, "k"); + map = map_power(map, exact, 0); + map = isl_map_add_dims(map, isl_dim_param, 1); dim = isl_map_get_dim(map); diff = equate_parameter_to_length(dim, param); map = isl_map_intersect(map, diff); map = isl_map_project_out(map, isl_dim_in, d, 1); map = isl_map_project_out(map, isl_dim_out, d, 1); + map = isl_map_from_range(isl_map_wrap(map)); + map = isl_map_move_dims(map, isl_dim_in, 0, isl_dim_param, param, 1); map = isl_map_reset_dim(map, target_dim); return map; -error: - isl_map_free(map); - return NULL; } /* Compute a relation that maps each element in the range of the input