[PPL-devel] [GIT] ppl/ppl(master): Fixed a precision problem in method

Enea Zaffanella zaffanella at cs.unipr.it
Thu Aug 30 15:21:10 CEST 2012


Module: ppl/ppl
Branch: master
Commit: cd98130f36755b94076e4a870bf399a8cac4b873
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=cd98130f36755b94076e4a870bf399a8cac4b873

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu Aug 30 15:14:19 2012 +0200

Fixed a precision problem in method
  Polyhedron::drop_some_non_integer_points().

---

 src/Polyhedron_nonpublic.cc |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/Polyhedron_nonpublic.cc b/src/Polyhedron_nonpublic.cc
index 7d38f3e..5657e32 100644
--- a/src/Polyhedron_nonpublic.cc
+++ b/src/Polyhedron_nonpublic.cc
@@ -2130,14 +2130,25 @@ PPL::Polyhedron::drop_some_non_integer_points(const Variables_Set* vars_p,
 
   const bool con_sys_was_sorted = con_sys.is_sorted();
 
+  Variables_Set other_vars;
+  if (vars_p != 0) {
+    // Compute the complement of `*vars_p'.
+    for (dimension_type i = 0; i < space_dim; ++i) {
+      if (vars_p->find(i) == vars_p->end())
+        other_vars.insert(Variable(i));
+    }
+  }
+
   for (dimension_type j = con_sys.sys.rows.size(); j-- > 0; ) {
     Constraint& c = con_sys.sys.rows[j];
     if (c.is_tautological())
       continue;
 
-    if (vars_p != 0) {
-      if (!c.expression().all_zeroes(*vars_p))
-        goto next_constraint;
+    if (!other_vars.empty()) {
+      // Skip constraints having a nonzero coefficient for a variable
+      // that does not occurr in the input set.
+      if (!c.expression().all_zeroes(other_vars))
+        continue;
     }
 
     if (!is_necessarily_closed()) {
@@ -2180,22 +2191,17 @@ PPL::Polyhedron::drop_some_non_integer_points(const Variables_Set* vars_p,
       PPL_ASSERT(c.OK());
       changed = true;
     }
-
-  next_constraint:
-    ;
   }
 
   con_sys.set_sorted(!changed && con_sys_was_sorted);
   PPL_ASSERT(con_sys.sys.OK());
 
   if (changed) {
-    if (!is_necessarily_closed())
+    if (is_necessarily_closed())
+      con_sys.insert(Constraint::zero_dim_positivity());
+    else
       con_sys.insert(Constraint::epsilon_leq_one());
 
-    // FIXME: make sure this is correct (otherwise it should be removed).
-    if (is_necessarily_closed() && con_sys_was_sorted)
-      con_sys.set_sorted(true);
-
     // After changing the system of constraints, the generators
     // are no longer up-to-date and the constraints are no longer
     // minimized.




More information about the PPL-devel mailing list