From 98f276f537c59a4af1787f415fd8545904931dee Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 1 Jul 2011 12:12:28 +0200 Subject: [PATCH] add isl_constraint_get_aff Signed-off-by: Sven Verdoolaege --- doc/user.pod | 7 +++++++ include/isl/constraint.h | 2 ++ isl_constraint.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 0d2eae88..5fed4a9b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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_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 diff --git a/include/isl/constraint.h b/include/isl/constraint.h index 96ad9014..6bd554f5 100644 --- a/include/isl/constraint.h +++ b/include/isl/constraint.h @@ -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); diff --git a/isl_constraint.c b/isl_constraint.c index f65297d5..442763f5 100644 --- a/isl_constraint.c +++ b/isl_constraint.c @@ -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. */ -- 2.11.4.GIT