isl_*_eval: return an isl_val instead of an isl_qpolynomial
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 19 Apr 2013 07:15:40 +0000 (19 09:15 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 25 Jun 2013 18:39:09 +0000 (25 20:39 +0200)
These functions have always returned a rational value, but until
recently, the only way we could represent such a rational value
was as a (degenerate) isl_qpolynomial.  Now that we have an isl_val
abstraction, we can return a proper rational value.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
bound.c
doc/user.pod
include/isl/polynomial.h
isl_fold.c
isl_polynomial.c
isl_polynomial_private.h
isl_pw_templ.c
isl_range.c
isl_union_templ.c

diff --git a/bound.c b/bound.c
index 7e4bfee..4aaaf13 100644 (file)
--- a/bound.c
+++ b/bound.c
@@ -67,8 +67,8 @@ static int verify_point(__isl_take isl_point *pnt, void *user)
        isl_int t;
        isl_ctx *ctx;
        isl_pw_qpolynomial_fold *pwf;
-       isl_qpolynomial *bound = NULL;
-       isl_qpolynomial *opt = NULL;
+       isl_val *bound = NULL;
+       isl_val *opt = NULL;
        isl_set *dom = NULL;
        isl_printer *p;
        const char *minmax;
@@ -120,13 +120,12 @@ static int verify_point(__isl_take isl_point *pnt, void *user)
                opt = isl_pw_qpolynomial_fold_min(isl_pw_qpolynomial_fold_copy(pwf));
 
        nvar = isl_set_dim(dom, isl_dim_set);
-       opt = isl_qpolynomial_project_domain_on_params(opt);
        if (vpb->exact && bounded)
-               ok = isl_qpolynomial_plain_is_equal(opt, bound);
+               ok = isl_val_eq(opt, bound);
        else if (sign > 0)
-               ok = isl_qpolynomial_le_cst(opt, bound);
+               ok = isl_val_le(opt, bound);
        else
-               ok = isl_qpolynomial_le_cst(bound, opt);
+               ok = isl_val_le(bound, opt);
        if (ok < 0)
                goto error;
 
@@ -140,11 +139,11 @@ static int verify_point(__isl_take isl_point *pnt, void *user)
                        p = isl_printer_print_isl_int(p, t);
                }
                p = isl_printer_print_str(p, ") = ");
-               p = isl_printer_print_qpolynomial(p, bound);
+               p = isl_printer_print_val(p, bound);
                p = isl_printer_print_str(p, ", ");
                p = isl_printer_print_str(p, bounded ? "opt" : "sample");
                p = isl_printer_print_str(p, " = ");
-               p = isl_printer_print_qpolynomial(p, opt);
+               p = isl_printer_print_val(p, opt);
                if (ok)
                        p = isl_printer_print_str(p, ". OK");
                else
@@ -161,8 +160,8 @@ error:
        }
 
        isl_pw_qpolynomial_fold_free(pwf);
-       isl_qpolynomial_free(bound);
-       isl_qpolynomial_free(opt);
+       isl_val_free(bound);
+       isl_val_free(opt);
        isl_point_free(pnt);
        isl_set_free(dom);
 
index 9c1eaf5..b65d4c7 100644 (file)
@@ -189,6 +189,11 @@ C<isl_set_dim_has_upper_bound> have slightly different meanings.
 Some of the old functions are still available in C<isl/deprecated/*.h>
 but they will be removed in the future.
 
+=item * The functions C<isl_pw_qpolynomial_eval>,
+C<isl_union_pw_qpolynomial_eval>, C<isl_pw_qpolynomial_fold_eval>
+and C<isl_union_pw_qpolynomial_fold_eval> have been changed to return
+an C<isl_val> instead of an C<isl_qpolynomial>.
+
 =back
 
 =head1 License
@@ -4687,11 +4692,11 @@ obviously equal, use
                __isl_take isl_union_pw_qpolynomial *upwqp1,
                __isl_take isl_union_pw_qpolynomial *upwqp2);
 
-       __isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
+       __isl_give isl_val *isl_pw_qpolynomial_eval(
                __isl_take isl_pw_qpolynomial *pwqp,
                __isl_take isl_point *pnt);
 
-       __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
+       __isl_give isl_val *isl_union_pw_qpolynomial_eval(
                __isl_take isl_union_pw_qpolynomial *upwqp,
                __isl_take isl_point *pnt);
 
@@ -4904,11 +4909,11 @@ obviously equal, use
                __isl_take isl_union_pw_qpolynomial_fold *upwf1,
                __isl_take isl_union_pw_qpolynomial_fold *upwf2);
 
-       __isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
+       __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
                __isl_take isl_pw_qpolynomial_fold *pwf,
                __isl_take isl_point *pnt);
 
-       __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
+       __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
                __isl_take isl_union_pw_qpolynomial_fold *upwf,
                __isl_take isl_point *pnt);
 
index 80799b4..adbdd05 100644 (file)
@@ -109,8 +109,8 @@ __isl_give isl_aff *isl_term_get_div(__isl_keep isl_term *term, unsigned pos);
 int isl_qpolynomial_foreach_term(__isl_keep isl_qpolynomial *qp,
        int (*fn)(__isl_take isl_term *term, void *user), void *user);
 
-__isl_give isl_qpolynomial *isl_qpolynomial_eval(
-       __isl_take isl_qpolynomial *qp, __isl_take isl_point *pnt);
+__isl_give isl_val *isl_qpolynomial_eval(__isl_take isl_qpolynomial *qp,
+       __isl_take isl_point *pnt);
 
 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
        __isl_take isl_qpolynomial *qp, __isl_take isl_set *context);
@@ -212,13 +212,11 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
        __isl_take isl_pw_qpolynomial *pwqp,
        enum isl_dim_type type, unsigned n, __isl_take isl_val *v);
 
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
+__isl_give isl_val *isl_pw_qpolynomial_eval(
        __isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_point *pnt);
 
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_max(
-       __isl_take isl_pw_qpolynomial *pwqp);
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_min(
-       __isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_val *isl_pw_qpolynomial_max(__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_val *isl_pw_qpolynomial_min(__isl_take isl_pw_qpolynomial *pwqp);
 
 int isl_pw_qpolynomial_foreach_piece(__isl_keep isl_pw_qpolynomial *pwqp,
        int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial *qp,
@@ -290,7 +288,7 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_substitute(
        enum isl_dim_type type, unsigned first, unsigned n,
        __isl_keep isl_qpolynomial **subs);
 
-__isl_give isl_qpolynomial *isl_qpolynomial_fold_eval(
+__isl_give isl_val *isl_qpolynomial_fold_eval(
        __isl_take isl_qpolynomial_fold *fold, __isl_take isl_point *pnt);
 
 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params(
@@ -376,7 +374,7 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_move_dims(
        enum isl_dim_type dst_type, unsigned dst_pos,
        enum isl_dim_type src_type, unsigned src_pos, unsigned n);
 
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
+__isl_give isl_val *isl_pw_qpolynomial_fold_eval(
        __isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_point *pnt);
 
 int isl_pw_qpolynomial_fold_foreach_piece(
@@ -401,9 +399,9 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist_params(
        __isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *context);
 
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_max(
+__isl_give isl_val *isl_pw_qpolynomial_fold_max(
        __isl_take isl_pw_qpolynomial_fold *pwf);
-__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_min(
+__isl_give isl_val *isl_pw_qpolynomial_fold_min(
        __isl_take isl_pw_qpolynomial_fold *pwf);
 
 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
@@ -465,7 +463,7 @@ __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_params(
 __isl_give isl_space *isl_union_pw_qpolynomial_get_space(
        __isl_keep isl_union_pw_qpolynomial *upwqp);
 
-__isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
+__isl_give isl_val *isl_union_pw_qpolynomial_eval(
        __isl_take isl_union_pw_qpolynomial *upwqp, __isl_take isl_point *pnt);
 
 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
@@ -533,7 +531,7 @@ enum isl_fold isl_union_pw_qpolynomial_fold_get_type(
 __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
        __isl_keep isl_union_pw_qpolynomial_fold *upwf);
 
-__isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
+__isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
        __isl_take isl_union_pw_qpolynomial_fold *upwf,
        __isl_take isl_point *pnt);
 
index 3792236..934ecc1 100644 (file)
@@ -1004,39 +1004,41 @@ int isl_qpolynomial_fold_plain_is_equal(__isl_keep isl_qpolynomial_fold *fold1,
        return 1;
 }
 
-__isl_give isl_qpolynomial *isl_qpolynomial_fold_eval(
+__isl_give isl_val *isl_qpolynomial_fold_eval(
        __isl_take isl_qpolynomial_fold *fold, __isl_take isl_point *pnt)
 {
-       isl_qpolynomial *qp;
+       isl_ctx *ctx;
+       isl_val *v;
 
        if (!fold || !pnt)
                goto error;
+       ctx = isl_point_get_ctx(pnt);
        isl_assert(pnt->dim->ctx, isl_space_is_equal(pnt->dim, fold->dim), goto error);
        isl_assert(pnt->dim->ctx,
                fold->type == isl_fold_max || fold->type == isl_fold_min,
                goto error);
 
        if (fold->n == 0)
-               qp = isl_qpolynomial_zero_on_domain(isl_space_copy(fold->dim));
+               v = isl_val_zero(ctx);
        else {
                int i;
-               qp = isl_qpolynomial_eval(isl_qpolynomial_copy(fold->qp[0]),
+               v = isl_qpolynomial_eval(isl_qpolynomial_copy(fold->qp[0]),
                                                isl_point_copy(pnt));
                for (i = 1; i < fold->n; ++i) {
-                       isl_qpolynomial *qp_i;
-                       qp_i = isl_qpolynomial_eval(
+                       isl_val *v_i;
+                       v_i = isl_qpolynomial_eval(
                                            isl_qpolynomial_copy(fold->qp[i]),
                                            isl_point_copy(pnt));
                        if (fold->type == isl_fold_max)
-                               qp = isl_qpolynomial_max_cst(qp, qp_i);
+                               v = isl_val_max(v, v_i);
                        else
-                               qp = isl_qpolynomial_min_cst(qp, qp_i);
+                               v = isl_val_min(v, v_i);
                }
        }
        isl_qpolynomial_fold_free(fold);
        isl_point_free(pnt);
 
-       return qp;
+       return v;
 error:
        isl_qpolynomial_fold_free(fold);
        isl_point_free(pnt);
@@ -1054,33 +1056,33 @@ size_t isl_pw_qpolynomial_fold_size(__isl_keep isl_pw_qpolynomial_fold *pwf)
        return n;
 }
 
-__isl_give isl_qpolynomial *isl_qpolynomial_fold_opt_on_domain(
+__isl_give isl_val *isl_qpolynomial_fold_opt_on_domain(
        __isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *set, int max)
 {
        int i;
-       isl_qpolynomial *opt;
+       isl_val *opt;
 
        if (!set || !fold)
                goto error;
 
        if (fold->n == 0) {
-               isl_space *dim = isl_space_copy(fold->dim);
+               opt = isl_val_zero(isl_set_get_ctx(set));
                isl_set_free(set);
                isl_qpolynomial_fold_free(fold);
-               return isl_qpolynomial_zero_on_domain(dim);
+               return opt;
        }
 
        opt = isl_qpolynomial_opt_on_domain(isl_qpolynomial_copy(fold->qp[0]),
                                                isl_set_copy(set), max);
        for (i = 1; i < fold->n; ++i) {
-               isl_qpolynomial *opt_i;
+               isl_val *opt_i;
                opt_i = isl_qpolynomial_opt_on_domain(
                                isl_qpolynomial_copy(fold->qp[i]),
                                isl_set_copy(set), max);
                if (max)
-                       opt = isl_qpolynomial_max_cst(opt, opt_i);
+                       opt = isl_val_max(opt, opt_i);
                else
-                       opt = isl_qpolynomial_min_cst(opt, opt_i);
+                       opt = isl_val_min(opt, opt_i);
        }
 
        isl_set_free(set);
index 8a79e68..a69b654 100644 (file)
@@ -2870,17 +2870,19 @@ error:
        return NULL;
 }
 
-__isl_give struct isl_upoly *isl_upoly_eval(
-       __isl_take struct isl_upoly *up, __isl_take isl_vec *vec)
+__isl_give isl_val *isl_upoly_eval(__isl_take struct isl_upoly *up,
+       __isl_take isl_vec *vec)
 {
        int i;
        struct isl_upoly_rec *rec;
-       struct isl_upoly *res;
-       struct isl_upoly *base;
+       isl_val *res;
+       isl_val *base;
 
        if (isl_upoly_is_cst(up)) {
                isl_vec_free(vec);
-               return up;
+               res = isl_upoly_get_constant_val(up);
+               isl_upoly_free(up);
+               return res;
        }
 
        rec = isl_upoly_as_rec(up);
@@ -2889,19 +2891,20 @@ __isl_give struct isl_upoly *isl_upoly_eval(
 
        isl_assert(up->ctx, rec->n >= 1, goto error);
 
-       base = isl_upoly_rat_cst(up->ctx, vec->el[1 + up->var], vec->el[0]);
+       base = isl_val_rat_from_isl_int(up->ctx,
+                                       vec->el[1 + up->var], vec->el[0]);
 
        res = isl_upoly_eval(isl_upoly_copy(rec->p[rec->n - 1]),
                                isl_vec_copy(vec));
 
        for (i = rec->n - 2; i >= 0; --i) {
-               res = isl_upoly_mul(res, isl_upoly_copy(base));
-               res = isl_upoly_sum(res, 
+               res = isl_val_mul(res, isl_val_copy(base));
+               res = isl_val_add(res,
                            isl_upoly_eval(isl_upoly_copy(rec->p[i]),
                                                            isl_vec_copy(vec)));
        }
 
-       isl_upoly_free(base);
+       isl_val_free(base);
        isl_upoly_free(up);
        isl_vec_free(vec);
        return res;
@@ -2911,12 +2914,11 @@ error:
        return NULL;
 }
 
-__isl_give isl_qpolynomial *isl_qpolynomial_eval(
-       __isl_take isl_qpolynomial *qp, __isl_take isl_point *pnt)
+__isl_give isl_val *isl_qpolynomial_eval(__isl_take isl_qpolynomial *qp,
+       __isl_take isl_point *pnt)
 {
        isl_vec *ext;
-       struct isl_upoly *up;
-       isl_space *dim;
+       isl_val *v;
 
        if (!qp || !pnt)
                goto error;
@@ -2940,15 +2942,12 @@ __isl_give isl_qpolynomial *isl_qpolynomial_eval(
                }
        }
 
-       up = isl_upoly_eval(isl_upoly_copy(qp->upoly), ext);
-       if (!up)
-               goto error;
+       v = isl_upoly_eval(isl_upoly_copy(qp->upoly), ext);
 
-       dim = isl_space_copy(qp->dim);
        isl_qpolynomial_free(qp);
        isl_point_free(pnt);
 
-       return isl_qpolynomial_alloc(dim, 0, up);
+       return v;
 error:
        isl_qpolynomial_free(qp);
        isl_point_free(pnt);
@@ -2968,79 +2967,6 @@ int isl_upoly_cmp(__isl_keep struct isl_upoly_cst *cst1,
        return cmp;
 }
 
-int isl_qpolynomial_le_cst(__isl_keep isl_qpolynomial *qp1,
-       __isl_keep isl_qpolynomial *qp2)
-{
-       struct isl_upoly_cst *cst1, *cst2;
-
-       if (!qp1 || !qp2)
-               return -1;
-       isl_assert(qp1->dim->ctx, isl_upoly_is_cst(qp1->upoly), return -1);
-       isl_assert(qp2->dim->ctx, isl_upoly_is_cst(qp2->upoly), return -1);
-       if (isl_qpolynomial_is_nan(qp1))
-               return -1;
-       if (isl_qpolynomial_is_nan(qp2))
-               return -1;
-       cst1 = isl_upoly_as_cst(qp1->upoly);
-       cst2 = isl_upoly_as_cst(qp2->upoly);
-
-       return isl_upoly_cmp(cst1, cst2) <= 0;
-}
-
-__isl_give isl_qpolynomial *isl_qpolynomial_min_cst(
-       __isl_take isl_qpolynomial *qp1, __isl_take isl_qpolynomial *qp2)
-{
-       struct isl_upoly_cst *cst1, *cst2;
-       int cmp;
-
-       if (!qp1 || !qp2)
-               goto error;
-       isl_assert(qp1->dim->ctx, isl_upoly_is_cst(qp1->upoly), goto error);
-       isl_assert(qp2->dim->ctx, isl_upoly_is_cst(qp2->upoly), goto error);
-       cst1 = isl_upoly_as_cst(qp1->upoly);
-       cst2 = isl_upoly_as_cst(qp2->upoly);
-       cmp = isl_upoly_cmp(cst1, cst2);
-
-       if (cmp <= 0) {
-               isl_qpolynomial_free(qp2);
-       } else {
-               isl_qpolynomial_free(qp1);
-               qp1 = qp2;
-       }
-       return qp1;
-error:
-       isl_qpolynomial_free(qp1);
-       isl_qpolynomial_free(qp2);
-       return NULL;
-}
-
-__isl_give isl_qpolynomial *isl_qpolynomial_max_cst(
-       __isl_take isl_qpolynomial *qp1, __isl_take isl_qpolynomial *qp2)
-{
-       struct isl_upoly_cst *cst1, *cst2;
-       int cmp;
-
-       if (!qp1 || !qp2)
-               goto error;
-       isl_assert(qp1->dim->ctx, isl_upoly_is_cst(qp1->upoly), goto error);
-       isl_assert(qp2->dim->ctx, isl_upoly_is_cst(qp2->upoly), goto error);
-       cst1 = isl_upoly_as_cst(qp1->upoly);
-       cst2 = isl_upoly_as_cst(qp2->upoly);
-       cmp = isl_upoly_cmp(cst1, cst2);
-
-       if (cmp >= 0) {
-               isl_qpolynomial_free(qp2);
-       } else {
-               isl_qpolynomial_free(qp1);
-               qp1 = qp2;
-       }
-       return qp1;
-error:
-       isl_qpolynomial_free(qp1);
-       isl_qpolynomial_free(qp2);
-       return NULL;
-}
-
 __isl_give isl_qpolynomial *isl_qpolynomial_insert_dims(
        __isl_take isl_qpolynomial *qp, enum isl_dim_type type,
        unsigned first, unsigned n)
@@ -3990,29 +3916,29 @@ error:
 struct isl_opt_data {
        isl_qpolynomial *qp;
        int first;
-       isl_qpolynomial *opt;
+       isl_val *opt;
        int max;
 };
 
 static int opt_fn(__isl_take isl_point *pnt, void *user)
 {
        struct isl_opt_data *data = (struct isl_opt_data *)user;
-       isl_qpolynomial *val;
+       isl_val *val;
 
        val = isl_qpolynomial_eval(isl_qpolynomial_copy(data->qp), pnt);
        if (data->first) {
                data->first = 0;
                data->opt = val;
        } else if (data->max) {
-               data->opt = isl_qpolynomial_max_cst(data->opt, val);
+               data->opt = isl_val_max(data->opt, val);
        } else {
-               data->opt = isl_qpolynomial_min_cst(data->opt, val);
+               data->opt = isl_val_min(data->opt, val);
        }
 
        return 0;
 }
 
-__isl_give isl_qpolynomial *isl_qpolynomial_opt_on_domain(
+__isl_give isl_val *isl_qpolynomial_opt_on_domain(
        __isl_take isl_qpolynomial *qp, __isl_take isl_set *set, int max)
 {
        struct isl_opt_data data = { NULL, 1, NULL, max };
@@ -4022,7 +3948,9 @@ __isl_give isl_qpolynomial *isl_qpolynomial_opt_on_domain(
 
        if (isl_upoly_is_cst(qp->upoly)) {
                isl_set_free(set);
-               return qp;
+               data.opt = isl_qpolynomial_get_constant_val(qp);
+               isl_qpolynomial_free(qp);
+               return data.opt;
        }
 
        set = fix_inactive(set, qp);
@@ -4031,10 +3959,8 @@ __isl_give isl_qpolynomial *isl_qpolynomial_opt_on_domain(
        if (isl_set_foreach_point(set, opt_fn, &data) < 0)
                goto error;
 
-       if (data.first) {
-               isl_space *space = isl_qpolynomial_get_domain_space(qp);
-               data.opt = isl_qpolynomial_zero_on_domain(space);
-       }
+       if (data.first)
+               data.opt = isl_val_zero(isl_set_get_ctx(set));
 
        isl_set_free(set);
        isl_qpolynomial_free(qp);
@@ -4042,7 +3968,7 @@ __isl_give isl_qpolynomial *isl_qpolynomial_opt_on_domain(
 error:
        isl_set_free(set);
        isl_qpolynomial_free(qp);
-       isl_qpolynomial_free(data.opt);
+       isl_val_free(data.opt);
        return NULL;
 }
 
index 08b28e8..685c8e2 100644 (file)
@@ -139,13 +139,6 @@ __isl_give isl_qpolynomial *isl_qpolynomial_add_on_domain(
        __isl_take isl_qpolynomial *qp1,
        __isl_take isl_qpolynomial *qp2);
 
-int isl_qpolynomial_le_cst(__isl_keep isl_qpolynomial *qp1,
-       __isl_keep isl_qpolynomial *qp2);
-__isl_give isl_qpolynomial *isl_qpolynomial_max_cst(
-       __isl_take isl_qpolynomial *qp1, __isl_take isl_qpolynomial *qp2);
-__isl_give isl_qpolynomial *isl_qpolynomial_min_cst(
-       __isl_take isl_qpolynomial *qp1, __isl_take isl_qpolynomial *qp2);
-
 int isl_qpolynomial_degree(__isl_keep isl_qpolynomial *poly);
 __isl_give isl_qpolynomial *isl_qpolynomial_coeff(
        __isl_keep isl_qpolynomial *poly,
@@ -168,7 +161,7 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_out(
        __isl_take isl_pw_qpolynomial *pwqp,
        enum isl_dim_type type, unsigned first, unsigned n);
 
-__isl_give isl_qpolynomial *isl_qpolynomial_opt_on_domain(
+__isl_give isl_val *isl_qpolynomial_opt_on_domain(
        __isl_take isl_qpolynomial *qp, __isl_take isl_set *set, int max);
 
 enum isl_fold isl_fold_type_negate(enum isl_fold type);
@@ -190,7 +183,7 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_fold_on_domain(
        __isl_take isl_qpolynomial_fold *fold1,
        __isl_take isl_qpolynomial_fold *fold2);
 
-__isl_give isl_qpolynomial *isl_qpolynomial_fold_opt_on_domain(
+__isl_give isl_val *isl_qpolynomial_fold_opt_on_domain(
        __isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *set, int max);
 
 int isl_pw_qpolynomial_fold_covers(__isl_keep isl_pw_qpolynomial_fold *pwf1,
index 3921c81..c8c7894 100644 (file)
@@ -639,14 +639,13 @@ __isl_give PW *FN(PW,sub)(__isl_take PW *pw1, __isl_take PW *pw2)
 #endif
 
 #ifndef NO_EVAL
-__isl_give isl_qpolynomial *FN(PW,eval)(__isl_take PW *pw,
-       __isl_take isl_point *pnt)
+__isl_give isl_val *FN(PW,eval)(__isl_take PW *pw, __isl_take isl_point *pnt)
 {
        int i;
        int found = 0;
        isl_ctx *ctx;
        isl_space *pnt_dim = NULL;
-       isl_qpolynomial *qp;
+       isl_val *v;
 
        if (!pw || !pnt)
                goto error;
@@ -663,14 +662,14 @@ __isl_give isl_qpolynomial *FN(PW,eval)(__isl_take PW *pw,
                        break;
        }
        if (found)
-               qp = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
+               v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
                                            isl_point_copy(pnt));
        else
-               qp = isl_qpolynomial_zero_on_domain(FN(PW,get_domain_space)(pw));
+               v = isl_val_zero(ctx);
        FN(PW,free)(pw);
        isl_space_free(pnt_dim);
        isl_point_free(pnt);
-       return qp;
+       return v;
 error:
        FN(PW,free)(pw);
        isl_space_free(pnt_dim);
@@ -1199,42 +1198,42 @@ error:
  * In the worst case, the domain is scanned completely,
  * so the domain is assumed to be bounded.
  */
-__isl_give isl_qpolynomial *FN(PW,opt)(__isl_take PW *pw, int max)
+__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
 {
        int i;
-       isl_qpolynomial *opt;
+       isl_val *opt;
 
        if (!pw)
                return NULL;
 
        if (pw->n == 0) {
-               isl_space *dim = isl_space_copy(pw->dim);
+               opt = isl_val_zero(FN(PW,get_ctx)(pw));
                FN(PW,free)(pw);
-               return isl_qpolynomial_zero_on_domain(isl_space_domain(dim));
+               return opt;
        }
 
        opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
                                        isl_set_copy(pw->p[0].set), max);
        for (i = 1; i < pw->n; ++i) {
-               isl_qpolynomial *opt_i;
+               isl_val *opt_i;
                opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
                                                isl_set_copy(pw->p[i].set), max);
                if (max)
-                       opt = isl_qpolynomial_max_cst(opt, opt_i);
+                       opt = isl_val_max(opt, opt_i);
                else
-                       opt = isl_qpolynomial_min_cst(opt, opt_i);
+                       opt = isl_val_min(opt, opt_i);
        }
 
        FN(PW,free)(pw);
        return opt;
 }
 
-__isl_give isl_qpolynomial *FN(PW,max)(__isl_take PW *pw)
+__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
 {
        return FN(PW,opt)(pw, 1);
 }
 
-__isl_give isl_qpolynomial *FN(PW,min)(__isl_take PW *pw)
+__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
 {
        return FN(PW,opt)(pw, 0);
 }
index c31c460..5599582 100644 (file)
@@ -32,7 +32,7 @@ static int has_sign(__isl_keep isl_basic_set *bset,
        unsigned nvar;
        unsigned nparam;
        isl_space *dim;
-       isl_qpolynomial *opt;
+       isl_val *opt;
        int r;
        enum isl_fold type;
 
@@ -70,14 +70,14 @@ static int has_sign(__isl_keep isl_basic_set *bset,
 
        if (!opt)
                r = -1;
-       else if (isl_qpolynomial_is_nan(opt) ||
-                isl_qpolynomial_is_infty(opt) ||
-                isl_qpolynomial_is_neginfty(opt))
+       else if (isl_val_is_nan(opt) ||
+                isl_val_is_infty(opt) ||
+                isl_val_is_neginfty(opt))
                r = 0;
        else
-               r = sign * isl_qpolynomial_sgn(opt) >= 0;
+               r = sign * isl_val_sgn(opt) >= 0;
 
-       isl_qpolynomial_free(opt);
+       isl_val_free(opt);
 
        return r;
 error:
index 65ab08f..f9131ee 100644 (file)
@@ -672,13 +672,13 @@ __isl_give UNION *FN(UNION,gist)(__isl_take UNION *u,
 }
 
 #ifndef NO_EVAL
-__isl_give isl_qpolynomial *FN(UNION,eval)(__isl_take UNION *u,
+__isl_give isl_val *FN(UNION,eval)(__isl_take UNION *u,
        __isl_take isl_point *pnt)
 {
        uint32_t hash;
        struct isl_hash_table_entry *entry;
        isl_space *space;
-       isl_qpolynomial *qp;
+       isl_val *v;
 
        if (!u || !pnt)
                goto error;
@@ -693,13 +693,13 @@ __isl_give isl_qpolynomial *FN(UNION,eval)(__isl_take UNION *u,
                                    hash, &has_dim, space, 0);
        isl_space_free(space);
        if (!entry) {
-               qp = isl_qpolynomial_zero_on_domain(isl_space_copy(pnt->dim));
+               v = isl_val_zero(isl_point_get_ctx(pnt));
                isl_point_free(pnt);
        } else {
-               qp = FN(PART,eval)(FN(PART,copy)(entry->data), pnt);
+               v = FN(PART,eval)(FN(PART,copy)(entry->data), pnt);
        }
        FN(UNION,free)(u);
-       return qp;
+       return v;
 error:
        FN(UNION,free)(u);
        isl_point_free(pnt);