add isl_set_max_val
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 13 Apr 2013 10:52:51 +0000 (12:52 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 16:27:13 +0000 (18:27 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/ilp.h
isl_ilp.c

index b009aef..562a72f 100644 (file)
@@ -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>.
index f910b1d..332d52e 100644 (file)
@@ -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)
 }
index 1f6b70d..b10c3c2 100644 (file)
--- a/isl_ilp.c
+++ b/isl_ilp.c
@@ -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);
+}