From 36c89eb8a13b63f949b9ea18b5074c6ed7aea5a0 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 3 Apr 2010 11:08:29 +0200 Subject: [PATCH] add some qpolynomial test functions --- include/isl_polynomial.h | 4 ++++ isl_polynomial.c | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/isl_polynomial.h b/include/isl_polynomial.h index 4cef47d..a917f03 100644 --- a/include/isl_polynomial.h +++ b/include/isl_polynomial.h @@ -28,6 +28,10 @@ void isl_qpolynomial_free(__isl_take isl_qpolynomial *qp); int isl_qpolynomial_is_equal(__isl_keep isl_qpolynomial *qp1, __isl_keep isl_qpolynomial *qp2); +int isl_qpolynomial_is_nan(__isl_keep isl_qpolynomial *qp); +int isl_qpolynomial_is_infty(__isl_keep isl_qpolynomial *qp); +int isl_qpolynomial_is_neginfty(__isl_keep isl_qpolynomial *qp); +int isl_qpolynomial_sgn(__isl_keep isl_qpolynomial *qp); int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp, isl_int *n, isl_int *d); void isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp, isl_int *d); diff --git a/isl_polynomial.c b/isl_polynomial.c index abecc7f..0b3f3c4 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -107,6 +107,22 @@ int isl_upoly_is_zero(__isl_keep struct isl_upoly *up) return isl_int_is_zero(cst->n) && isl_int_is_pos(cst->d); } +int isl_upoly_sgn(__isl_keep struct isl_upoly *up) +{ + struct isl_upoly_cst *cst; + + if (!up) + return 0; + if (!isl_upoly_is_cst(up)) + return 0; + + cst = isl_upoly_as_cst(up); + if (!cst) + return 0; + + return isl_int_sgn(cst->n); +} + int isl_upoly_is_nan(__isl_keep struct isl_upoly *up) { struct isl_upoly_cst *cst; @@ -292,22 +308,32 @@ error: int isl_qpolynomial_is_zero(__isl_keep isl_qpolynomial *qp) { - struct isl_upoly_cst *cst; + return qp ? isl_upoly_is_zero(qp->upoly) : -1; +} - if (!qp) - return -1; +int isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp) +{ + return qp ? isl_upoly_is_one(qp->upoly) : -1; +} - return isl_upoly_is_zero(qp->upoly); +int isl_qpolynomial_is_nan(__isl_keep isl_qpolynomial *qp) +{ + return qp ? isl_upoly_is_nan(qp->upoly) : -1; } -int isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp) +int isl_qpolynomial_is_infty(__isl_keep isl_qpolynomial *qp) { - struct isl_upoly_cst *cst; + return qp ? isl_upoly_is_infty(qp->upoly) : -1; +} - if (!qp) - return -1; +int isl_qpolynomial_is_neginfty(__isl_keep isl_qpolynomial *qp) +{ + return qp ? isl_upoly_is_neginfty(qp->upoly) : -1; +} - return isl_upoly_is_one(qp->upoly); +int isl_qpolynomial_sgn(__isl_keep isl_qpolynomial *qp) +{ + return qp ? isl_upoly_sgn(qp->upoly) : 0; } static void upoly_free_cst(__isl_take struct isl_upoly_cst *cst) -- 2.7.4