add isl_pw_aff_cond
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 9 Jul 2011 10:03:55 +0000 (12:03 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 9 Jul 2011 14:17:06 +0000 (16:17 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_aff.c

index 76d82e5..9c6d2e6 100644 (file)
@@ -2412,6 +2412,17 @@ containing those elements in the domain
 of C<pwaff> where C<pwaff> is non-negative.
 
        #include <isl/aff.h>
+       __isl_give isl_pw_aff *isl_pw_aff_cond(
+               __isl_take isl_set *cond,
+               __isl_take isl_pw_aff *pwaff_true,
+               __isl_take isl_pw_aff *pwaff_false);
+
+The function C<isl_pw_aff_cond> performs a conditional operator
+and returns an expression that is equal to C<pwaff_true>
+for elements in C<cond> and equal to C<pwaff_false> for elements
+not in C<cond>.
+
+       #include <isl/aff.h>
        __isl_give isl_pw_aff *isl_pw_aff_max(
                __isl_take isl_pw_aff *pwaff1,
                __isl_take isl_pw_aff *pwaff2);
index 1b61942..4eec72e 100644 (file)
@@ -113,6 +113,9 @@ __isl_give isl_pw_aff *isl_pw_aff_neg(__isl_take isl_pw_aff *pwaff);
 __isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff);
 __isl_give isl_pw_aff *isl_pw_aff_floor(__isl_take isl_pw_aff *pwaff);
 
+__isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_set *cond,
+       __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false);
+
 __isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff,
        isl_int f);
 
index 6e01226..82d9a55 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -1270,3 +1270,19 @@ __isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff)
 
        return pwaff;
 }
+
+/* Return an affine expression that is equal to pwaff_true for elements
+ * in "cond" and to pwaff_false for elements not in "cond".
+ * That is, return cond ? pwaff_true : pwaff_false;
+ */
+__isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_set *cond,
+       __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false)
+{
+       isl_set *comp;
+
+       comp = isl_set_complement(isl_set_copy(cond));
+       pwaff_true = isl_pw_aff_intersect_domain(pwaff_true, cond);
+       pwaff_false = isl_pw_aff_intersect_domain(pwaff_false, comp);
+
+       return isl_pw_aff_add_disjoint(pwaff_true, pwaff_false);
+}