From a375d8331bc507207c7aee6f6807044023e05136 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 25 Jul 2011 09:01:53 +0200 Subject: [PATCH] add isl_pw_qpolynomial_from_pw_aff Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/polynomial.h | 3 +++ isl_polynomial.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 96107d1c..0ef1e1e1 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2814,6 +2814,8 @@ be combined to create more complicated piecewise quasipolynomials. __isl_take isl_qpolynomial *qp); __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial( __isl_take isl_qpolynomial *qp); + __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff( + __isl_take isl_pw_aff *pwaff); __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero( __isl_take isl_dim *dim); diff --git a/include/isl/polynomial.h b/include/isl/polynomial.h index efefe740..2b2ac4c6 100644 --- a/include/isl/polynomial.h +++ b/include/isl/polynomial.h @@ -228,6 +228,9 @@ int isl_pw_qpolynomial_foreach_lifted_piece(__isl_keep isl_pw_qpolynomial *pwqp, int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial *qp, void *user), void *user); +__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff( + __isl_take isl_pw_aff *pwaff); + __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_str(isl_ctx *ctx, const char *str); __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_file(isl_ctx *ctx, diff --git a/isl_polynomial.c b/isl_polynomial.c index 5a78619a..14a7b52d 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -3026,6 +3026,30 @@ error: return NULL; } +__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff( + __isl_take isl_pw_aff *pwaff) +{ + int i; + isl_pw_qpolynomial *pwqp; + + if (!pwaff) + return NULL; + + pwqp = isl_pw_qpolynomial_alloc_(isl_pw_aff_get_dim(pwaff), pwaff->n); + + for (i = 0; i < pwaff->n; ++i) { + isl_set *dom; + isl_qpolynomial *qp; + + dom = isl_set_copy(pwaff->p[i].set); + qp = isl_qpolynomial_from_aff(isl_aff_copy(pwaff->p[i].aff)); + pwqp = isl_pw_qpolynomial_add_piece(pwqp, dom, qp); + } + + isl_pw_aff_free(pwaff); + return pwqp; +} + __isl_give isl_qpolynomial *isl_qpolynomial_from_constraint( __isl_take isl_constraint *c, enum isl_dim_type type, unsigned pos) { -- 2.11.4.GIT