[PPL-devel] [GIT] ppl/ppl(master): A few optimizations applied to fill_constraint_systems_MS().

Enea Zaffanella zaffanella at cs.unipr.it
Fri Mar 26 16:55:43 CET 2010


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Fri Mar 26 16:54:00 2010 +0100

A few optimizations applied to fill_constraint_systems_MS().

---

 src/termination.cc |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/src/termination.cc b/src/termination.cc
index 93aaa88..a85962f 100644
--- a/src/termination.cc
+++ b/src/termination.cc
@@ -83,8 +83,7 @@ shift_unprimed_variables(Constraint_System& cs) {
   - \f$ x'_1, \ldots, x'_n \f$ go onto space dimensions
     \f$ 0, \ldots, n-1 \f$,
   - \f$ x_1, \ldots, x_n \f$ go onto space dimensions
-    \f$ n, \ldots, 2n-1 \f$,
-  .
+    \f$ n, \ldots, 2n-1 \f$.
   The system does not contain any equality.
 
   \param n
@@ -134,22 +133,27 @@ fill_constraint_systems_MS(const Constraint_System& cs,
   dimension_type z = z_begin;
   for (Constraint_System::const_iterator i = cs.begin(),
 	 cs_end = cs.end(); i != cs_end; ++i) {
+    Variable vy(y);
+    Variable vz(z);
+    ++y;
+    ++z;
+    cs_out1.insert(vy >= 0);
+    cs_out2.insert(vz >= 0);
     const Constraint& c_i = *i;
     Coefficient_traits::const_reference b_i = c_i.inhomogeneous_term();
-    // Note that b_i is to the left ot the relation sign, hence here
-    // we have -= and not += just to avoid negating b_i.
-    sub_mul_assign(y_le, b_i, Variable(y));
-    cs_out1.insert(Variable(y) >= 0);
-    // We have -= and not += for the same reason mentioned above.
-    sub_mul_assign(z_le, b_i, Variable(z));
-    cs_out2.insert(Variable(z) >= 0);
+    if (b_i != 0) {
+      // Note that b_i is to the left ot the relation sign, hence here
+      // we have -= and not += just to avoid negating b_i.
+      sub_mul_assign(y_le, b_i, vy);
+      sub_mul_assign(z_le, b_i, vz);
+    }
     for (dimension_type j = 2*n; j-- > 0; ) {
       Coefficient_traits::const_reference a_i_j = c_i.coefficient(Variable(j));
-      add_mul_assign(y_les[j], a_i_j, Variable(y));
-      add_mul_assign(z_les[j], a_i_j, Variable(z));
+      if (a_i_j != 0) {
+        add_mul_assign(y_les[j], a_i_j, vy);
+        add_mul_assign(z_les[j], a_i_j, vz);
+      }
     }
-    ++y;
-    ++z;
   }
   z_le += Variable(z);
   z_les[2*n] += Variable(z);




More information about the PPL-devel mailing list