add isl_constraint_get_aff
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 1 Jul 2011 10:12:28 +0000 (12:12 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 2 Jul 2011 09:40:00 +0000 (11:40 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/constraint.h
isl_constraint.c

index 0d2eae8..5fed4a9 100644 (file)
@@ -2218,6 +2218,13 @@ a non-zero coefficient for the specified dimension.
                __isl_keep isl_constraint *constraint,
                enum isl_dim_type type, int pos);
 
+The entire affine expression of the constraint can also be extracted
+using the following function.
+
+       #include <isl/constraint.h>
+       __isl_give isl_aff *isl_constraint_get_aff(
+               __isl_keep isl_constraint *constraint);
+
 Conversely, an equality constraint equating
 the affine expression to zero or an inequality constraint enforcing
 the affine expression to be non-negative, can be constructed using
index 96ad901..6bd554f 100644 (file)
@@ -117,6 +117,8 @@ struct isl_basic_set *isl_basic_set_from_constraint(
 
 __isl_give isl_aff *isl_constraint_get_bound(
        __isl_keep isl_constraint *constraint, enum isl_dim_type type, int pos);
+__isl_give isl_aff *isl_constraint_get_aff(
+       __isl_keep isl_constraint *constraint);
 __isl_give isl_constraint *isl_equality_from_aff(__isl_take isl_aff *aff);
 __isl_give isl_constraint *isl_inequality_from_aff(__isl_take isl_aff *aff);
 
index f65297d..442763f 100644 (file)
@@ -1022,6 +1022,36 @@ __isl_give isl_aff *isl_constraint_get_bound(
        return aff;
 }
 
+/* For an inequality constraint
+ *
+ *     f >= 0
+ *
+ * or an equality constraint
+ *
+ *     f = 0
+ *
+ * return the affine expression f.
+ */
+__isl_give isl_aff *isl_constraint_get_aff(
+       __isl_keep isl_constraint *constraint)
+{
+       isl_aff *aff;
+       isl_local_space *ls;
+
+       if (!constraint)
+               return NULL;
+
+       ls = isl_basic_set_get_local_space(constraint->bmap);
+       aff = isl_aff_alloc(ls);
+       if (!aff)
+               return NULL;
+
+       isl_seq_cpy(aff->v->el + 1, constraint->line[0], aff->v->size - 1);
+       isl_int_set_si(aff->v->el[0], 1);
+
+       return aff;
+}
+
 /* Construct an equality constraint equating the given affine expression
  * to zero.
  */