[PPL-devel] [GIT] ppl/ppl(master): Partially reverted changes 71e9992afa9bc049b93d0b29fd9dbe52ead850cf.

Enea Zaffanella zaffanella at cs.unipr.it
Thu May 14 21:55:24 CEST 2009


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu May 14 21:51:58 2009 +0200

Partially reverted changes 71e9992afa9bc049b93d0b29fd9dbe52ead850cf.
The changes were not working on platforms where floating point rounding
mode could not be set (e.g., ARM), even though rounding control is not
actually needed.

---

 TODO               |    2 ++
 src/MIP_Problem.cc |   22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/TODO b/TODO
index f63140e..114ce6f 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,8 @@ Enhancements for PPL 0.11
 - Make all the *affine*image() methods uniform as far as the
   specification is concerned.
 - Check the use or the NOT_EQUAL Relation_Symbol everywhere.
+- Get rid of ugly assign functions defined in anonymous namespace of
+  MIP_Problem.cc replacing it with a more general-purpose approach.
 - Reconsider the datatype for the units parameter in the Watchdog
   constructors: should we prefer an unsigned?
 - Intervals are best instantiated with checked numbers with
diff --git a/src/MIP_Problem.cc b/src/MIP_Problem.cc
index e26afe6..3e6bcab 100644
--- a/src/MIP_Problem.cc
+++ b/src/MIP_Problem.cc
@@ -855,6 +855,22 @@ PPL::MIP_Problem::process_pending_constraints() {
   return true;
 }
 
+namespace {
+
+inline void
+assign(double& d, const mpz_class& c) {
+  d = c.get_d();
+}
+
+template <typename T, typename Policy>
+inline void
+assign(double& d,
+       const Parma_Polyhedra_Library::Checked_Number<T, Policy>& c) {
+  d = raw_value(c);
+}
+
+} // namespace
+
 PPL::dimension_type
 PPL::MIP_Problem::steepest_edge_float_entering_index() const {
   const dimension_type tableau_num_rows = tableau.num_rows();
@@ -871,7 +887,7 @@ PPL::MIP_Problem::steepest_edge_float_entering_index() const {
     if (sgn(cost_j) == cost_sign) {
       // We cannot compute the (exact) square root of abs(\Delta x_j).
       // The workaround is to compute the square of `cost[j]'.
-      assign_r(challenger_num, cost_j, ROUND_IGNORE);
+      assign(challenger_num, cost_j);
       challenger_num = fabs(challenger_num);
       // Due to our integer implementation, the `1' term in the denominator
       // of the original formula has to be replaced by `squared_lcm_basis'.
@@ -881,8 +897,8 @@ PPL::MIP_Problem::steepest_edge_float_entering_index() const {
 	const Coefficient& tableau_ij = tableau_i[j];
 	if (tableau_ij != 0) {
 	  assert(tableau_i[base[i]] != 0);
-	  assign_r(float_tableau_value, tableau_ij, ROUND_IGNORE);
-	  assign_r(float_tableau_denum, tableau_i[base[i]], ROUND_IGNORE);
+	  assign(float_tableau_value, tableau_ij);
+	  assign(float_tableau_denum, tableau_i[base[i]]);
 	  float_tableau_value /= float_tableau_denum;
 	  challenger_den += float_tableau_value * float_tableau_value;
 	}




More information about the PPL-devel mailing list