diff options
author | Sven Verdoolaege <skimo@kotnet.org> | 2013-04-13 12:52:51 +0200 |
---|---|---|
committer | Sven Verdoolaege <skimo@kotnet.org> | 2013-05-28 18:27:13 +0200 |
commit | 8275a9dd270568eb1d72f8a2253edfd75caf0c24 (patch) | |
tree | dac1bae1ebb0e80a96a37a34b3c548c7d6c685df | |
parent | 83df5261cdcb85fcfd9aebeaaf77f377216dd82e (diff) | |
download | isl-8275a9dd270568eb1d72f8a2253edfd75caf0c24.tar.gz isl-8275a9dd270568eb1d72f8a2253edfd75caf0c24.tar.bz2 isl-8275a9dd270568eb1d72f8a2253edfd75caf0c24.zip |
add isl_set_max_val
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
-rw-r--r-- | doc/user.pod | 3 | ||||
-rw-r--r-- | include/isl/ilp.h | 2 | ||||
-rw-r--r-- | isl_ilp.c | 38 |
3 files changed, 43 insertions, 0 deletions
diff --git a/doc/user.pod b/doc/user.pod index b009aef5..562a72f4 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2583,6 +2583,9 @@ a singleton subset of the input. Otherwise, return an empty set. __isl_keep isl_aff *obj, isl_int *opt); enum isl_lp_result isl_set_max(__isl_keep isl_set *set, __isl_keep isl_aff *obj, isl_int *opt); + __isl_give isl_val *isl_set_max_val( + __isl_keep isl_set *set, + __isl_keep isl_aff *obj); Compute the minimum or maximum of the integer affine expression C<obj> over the points in C<set>, returning the result in C<opt>. diff --git a/include/isl/ilp.h b/include/isl/ilp.h index f910b1d9..332d52e6 100644 --- a/include/isl/ilp.h +++ b/include/isl/ilp.h @@ -29,6 +29,8 @@ enum isl_lp_result isl_set_min(__isl_keep isl_set *set, __isl_keep isl_aff *obj, isl_int *opt); enum isl_lp_result isl_set_max(__isl_keep isl_set *set, __isl_keep isl_aff *obj, isl_int *opt); +__isl_give isl_val *isl_set_max_val(__isl_keep isl_set *set, + __isl_keep isl_aff *obj); #if defined(__cplusplus) } @@ -583,3 +583,41 @@ __isl_give isl_val *isl_basic_set_max_val(__isl_keep isl_basic_set *bset, { return isl_basic_set_opt_val(bset, 1, obj); } + +/* Return the minimum (maximum if max is set) of the integer affine + * expression "obj" over the points in "set". + * + * Return infinity or negative infinity if the optimal value is unbounded and + * NaN if "bset" is empty. + * + * Call isl_set_opt and translate the results. + */ +__isl_give isl_val *isl_set_opt_val(__isl_keep isl_set *set, int max, + __isl_keep isl_aff *obj) +{ + isl_ctx *ctx; + isl_val *res; + enum isl_lp_result lp_res; + + if (!set || !obj) + return NULL; + + ctx = isl_aff_get_ctx(obj); + res = isl_val_alloc(ctx); + if (!res) + return NULL; + lp_res = isl_set_opt(set, max, obj, &res->n); + return convert_lp_result(lp_res, res, max); +} + +/* Return the maximum of the integer affine + * expression "obj" over the points in "set". + * + * Return infinity or negative infinity if the optimal value is unbounded and + * NaN if "bset" is empty. + */ +__isl_give isl_val *isl_set_max_val(__isl_keep isl_set *set, + __isl_keep isl_aff *obj) +{ + return isl_set_opt_val(set, 1, obj); +} |