add isl_pw_*_intersect_domain
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 11 Mar 2010 14:26:38 +0000 (15:26 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 12 Mar 2010 11:56:43 +0000 (12:56 +0100)
doc/user.pod
include/isl_polynomial.h
isl_polynomial.c
isl_polynomial_private.h
isl_pw_templ.c

index e309e26..c0b1740 100644 (file)
@@ -1292,6 +1292,9 @@ are returned in C<*n> and C<*d>, respectively.
 
        __isl_give isl_set *isl_pw_qpolynomial_domain(
                __isl_take isl_pw_qpolynomial *pwqp);
+       __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
+               __isl_take isl_pw_qpolynomial *pwpq,
+               __isl_take isl_set *set);
 
 =head2 Dependence Analysis
 
index fa88725..5861fdb 100644 (file)
@@ -73,6 +73,8 @@ unsigned isl_pw_qpolynomial_dim(__isl_keep isl_pw_qpolynomial *pwqp,
        enum isl_dim_type type);
 
 __isl_give isl_set *isl_pw_qpolynomial_domain(__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
+       __isl_take isl_pw_qpolynomial *pwpq, __isl_take isl_set *set);
 
 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
        __isl_take isl_pw_qpolynomial *pwqp1,
@@ -153,6 +155,8 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_zero(
 
 __isl_give isl_set *isl_pw_qpolynomial_fold_domain(
        __isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_intersect_domain(
+       __isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *set);
 
 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
        __isl_take isl_pw_qpolynomial_fold *pwf1,
index 1a4772d..0b063ad 100644 (file)
@@ -1319,18 +1319,6 @@ int isl_pw_qpolynomial_is_one(__isl_keep isl_pw_qpolynomial *pwqp)
        return isl_qpolynomial_is_one(pwqp->p[0].qp);
 }
 
-__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_cow(
-       __isl_take isl_pw_qpolynomial *pwqp)
-{
-       if (!pwqp)
-               return NULL;
-
-       if (pwqp->ref == 1)
-               return pwqp;
-       pwqp->ref--;
-       return isl_pw_qpolynomial_dup(pwqp);
-}
-
 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
        __isl_take isl_pw_qpolynomial *pwqp1,
        __isl_take isl_pw_qpolynomial *pwqp2)
index d3d3f2f..b13b86e 100644 (file)
@@ -125,8 +125,14 @@ __isl_give isl_qpolynomial *isl_qpolynomial_div_pow(__isl_take isl_div *div,
 int isl_qpolynomial_is_zero(__isl_keep isl_qpolynomial *qp);
 int isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp);
 
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_cow(
+       __isl_take isl_pw_qpolynomial *pwqp);
+
 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_piece(
        __isl_take isl_pw_qpolynomial *pwqp,
        __isl_take isl_set *set, __isl_take isl_qpolynomial *qp);
 int isl_pw_qpolynomial_is_zero(__isl_keep isl_pw_qpolynomial *pwqp);
 int isl_pw_qpolynomial_is_one(__isl_keep isl_pw_qpolynomial *pwqp);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_cow(
+       __isl_take isl_pw_qpolynomial_fold *pwf);
index ef6dc0c..0f74263 100644 (file)
@@ -95,6 +95,17 @@ error:
        return NULL;
 }
 
+__isl_give PW *FN(PW,cow)(__isl_take PW *pw)
+{
+       if (!pw)
+               return NULL;
+
+       if (pw->ref == 1)
+               return pw;
+       pw->ref--;
+       return FN(PW,dup)(pw);
+}
+
 __isl_give PW *FN(PW,copy)(__isl_keep PW *pw)
 {
        if (!pw)
@@ -283,3 +294,33 @@ __isl_give isl_set *FN(PW,domain)(__isl_take PW *pw)
 
        return dom;
 }
+
+__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw, __isl_take isl_set *set)
+{
+       int i;
+
+       if (!pw || !set)
+               goto error;
+
+       if (pw->n == 0) {
+               isl_set_free(set);
+               return pw;
+       }
+
+       pw = FN(PW,cow)(pw);
+       if (!pw)
+               goto error;
+
+       for (i = 0; i < pw->n; ++i) {
+               pw->p[i].set = isl_set_intersect(pw->p[i].set, isl_set_copy(set));
+               if (!pw->p[i].set)
+                       goto error;
+       }
+       
+       isl_set_free(set);
+       return pw;
+error:
+       isl_set_free(set);
+       FN(PW,free)(pw);
+       return NULL;
+}