add isl_aff_plain_is_zero
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 24 Jun 2011 11:12:13 +0000 (13:12 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 25 Jun 2011 20:22:20 +0000 (22:22 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_aff.c

index dce2a53..e1c7270 100644 (file)
@@ -2236,6 +2236,11 @@ set the I<numerator> of the constant or coefficient, while
 C<add_constant> and C<add_coefficient> add an integer value to
 the possibly rational constant or coefficient.
 
+To check whether an affine expressions is obviously zero, use
+
+       #include <isl/aff.h>
+       int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
+
 Operations include
 
        #include <isl/aff.h>
index 16fb947..da23d44 100644 (file)
@@ -42,6 +42,8 @@ __isl_give isl_aff *isl_aff_add_constant_si(__isl_take isl_aff *aff, int v);
 __isl_give isl_aff *isl_aff_add_coefficient_si(__isl_take isl_aff *aff,
        enum isl_dim_type type, int pos, int v);
 
+int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
+
 __isl_give isl_div *isl_aff_get_div(__isl_keep isl_aff *aff, int pos);
 
 __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff);
index 84f1fa4..1faa493 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -143,6 +143,14 @@ const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
        return aff ? isl_local_space_get_dim_name(aff->ls, type, pos) : 0;
 }
 
+int isl_aff_plain_is_zero(__isl_keep isl_aff *aff)
+{
+       if (!aff)
+               return -1;
+
+       return isl_seq_first_non_zero(aff->v->el + 1, aff->v->size - 1) < 0;
+}
+
 int isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v)
 {
        if (!aff)