[PPL-devel] [GIT] ppl/ppl(master): Do not rely on doubles being supported.

Roberto Bagnara bagnara at cs.unipr.it
Mon Mar 26 15:43:55 CEST 2012


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

Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date:   Mon Mar 26 15:43:32 2012 +0200

Do not rely on doubles being supported.

---

 src/Linear_Form.templates.hh                 |   28 +++++++++++++-------------
 tests/Concrete_Expression/digitalfilters1.cc |    4 +-
 tests/Concrete_Expression/linearform1.cc     |   16 +++++++-------
 tests/Concrete_Expression/linearize.cc       |    4 +-
 tests/Concrete_Expression/polyhedron1.cc     |    2 +-
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/Linear_Form.templates.hh b/src/Linear_Form.templates.hh
index 2630f0f..3eca9ac 100644
--- a/src/Linear_Form.templates.hh
+++ b/src/Linear_Form.templates.hh
@@ -44,7 +44,7 @@ Linear_Form<C>::Linear_Form(const Variable v)
                             "space dimension.");
   vec.reserve(compute_capacity(space_dim+1, vec_type().max_size()));
   vec.resize(space_dim+1, zero);
-  vec[v.space_dimension()] = static_cast<C>(1.0);
+  vec[v.space_dimension()] = C(typename C::boundary_type(1));
 }
 
 template <typename C>
@@ -61,8 +61,8 @@ Linear_Form<C>::Linear_Form(const Variable v, const Variable w)
   vec.reserve(compute_capacity(space_dim+1, vec_type().max_size()));
   vec.resize(space_dim+1, zero);
   if (v_space_dim != w_space_dim) {
-    vec[v_space_dim] = static_cast<C>(1.0);
-    vec[w_space_dim] = static_cast<C>(-1.0);
+    vec[v_space_dim] = C(typename C::boundary_type(1));
+    vec[w_space_dim] = C(typename C::boundary_type(-1));
   }
 }
 
@@ -129,7 +129,7 @@ operator+(const Variable v, const Linear_Form<C>& f) {
   Linear_Form<C> r(f);
   if (v_space_dim > f.space_dimension())
     r.extend(v_space_dim+1);
-  r[v_space_dim] += static_cast<C>(1.0);
+  r[v_space_dim] += C(typename C::boundary_type(1));
   return r;
 }
 
@@ -203,7 +203,7 @@ operator-(const Variable v, const Linear_Form<C>& f) {
     r.extend(v_space_dim+1);
   for (dimension_type i = f.size(); i-- > 0; )
     r[i].neg_assign(r[i]);
-  r[v_space_dim] += static_cast<C>(1.0);
+  r[v_space_dim] += C(typename C::boundary_type(1));
   return r;
 }
 
@@ -220,7 +220,7 @@ operator-(const Linear_Form<C>& f, const Variable v) {
   Linear_Form<C> r(f);
   if (v_space_dim > f.space_dimension())
     r.extend(v_space_dim+1);
-  r[v_space_dim] -= static_cast<C>(1.0);
+  r[v_space_dim] -= C(typename C::boundary_type(1));
   return r;
 }
 
@@ -270,7 +270,7 @@ operator+=(Linear_Form<C>& f, const Variable v) {
 			    "v exceeds the maximum allowed space dimension.");
   if (v_space_dim > f.space_dimension())
     f.extend(v_space_dim+1);
-  f[v_space_dim] += static_cast<C>(1.0);
+  f[v_space_dim] += C(typename C::boundary_type(1));
   return f;
 }
 
@@ -298,7 +298,7 @@ operator-=(Linear_Form<C>& f, const Variable v) {
 			    "v exceeds the maximum allowed space dimension.");
   if (v_space_dim > f.space_dimension())
     f.extend(v_space_dim+1);
-  f[v_space_dim] -= static_cast<C>(1.0);
+  f[v_space_dim] -= C(typename C::boundary_type(1));
   return f;
 }
 
@@ -482,20 +482,20 @@ IO_Operators::operator<<(std::ostream& s, const Linear_Form<C>& f) {
   bool first = true;
   for (dimension_type v = 0; v < num_variables; ++v) {
     const C& fv = f[v+1];
-    if (fv != 0) {
+    if (fv != typename C::boundary_type(0)) {
       if (first) {
-        if (fv == -1.0)
+        if (fv == typename C::boundary_type(-1))
           s << "-";
-        else if (fv != 1.0)
+        else if (fv != typename C::boundary_type(1))
           s << fv << "*";
         first = false;
       }
       else {
-        if (fv == -1.0)
+        if (fv == typename C::boundary_type(-1))
           s << " - ";
         else {
           s << " + ";
-          if (fv != 1.0)
+          if (fv != typename C::boundary_type(1))
             s << fv << "*";
         }
       }
@@ -521,7 +521,7 @@ IO_Operators::operator<<(std::ostream& s, const Linear_Form<C>& f) {
 PPL_OUTPUT_TEMPLATE_DEFINITIONS(C, Linear_Form<C>)
 
 template <typename C>
-C Linear_Form<C>::zero(0.0);
+C Linear_Form<C>::zero(typename C::boundary_type(0));
 
 } // namespace Parma_Polyhedra_Library
 
diff --git a/tests/Concrete_Expression/digitalfilters1.cc b/tests/Concrete_Expression/digitalfilters1.cc
index 98490cc..2d00d3a 100644
--- a/tests/Concrete_Expression/digitalfilters1.cc
+++ b/tests/Concrete_Expression/digitalfilters1.cc
@@ -70,8 +70,8 @@ public:
 };
 
 using namespace Parma_Polyhedra_Library::IO_Operators;
-Concrete_Expression_Type FP_Type =
-  Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
+Concrete_Expression_Type FP_Type
+= Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
 
 typedef Integer_Interval Int_Interval;
 
diff --git a/tests/Concrete_Expression/linearform1.cc b/tests/Concrete_Expression/linearform1.cc
index 1f12c82..e29f9af 100644
--- a/tests/Concrete_Expression/linearform1.cc
+++ b/tests/Concrete_Expression/linearform1.cc
@@ -155,8 +155,8 @@ test05() {
   Variable B(1);
 
   FP_Linear_Form f = A;
-  FP_Interval x(2.0);
-  x /= FP_Interval(3.0);
+  FP_Interval x(FP_Interval::boundary_type(2));
+  x /= FP_Interval(FP_Interval::boundary_type(3));
   f *= x;
 
   FP_Linear_Form known_result = f + B;
@@ -205,12 +205,12 @@ test07() {
 
   bool result1 = (f1 == f2);
 
-  f2 += FP_Interval(1.0);
+  f2 += FP_Interval(FP_Interval::boundary_type(1));
   bool result2 = (f1 == f2);
 
   bool result3 = (f2 == f1);
 
-  f1 += FP_Interval(1.0);
+  f1 += FP_Interval(FP_Interval::boundary_type(1));
   bool result4 = (f2 == f1);
 
   nout << "*** known_result ***" << endl
@@ -312,11 +312,11 @@ test10() {
   Variable x5(5);
   Variable x2(2);
   FP_Interval x5_coefficient;
-  x5_coefficient.lower() = 2.0;
-  x5_coefficient.upper() = 3.0;
+  x5_coefficient.lower() = FP_Interval::boundary_type(2);
+  x5_coefficient.upper() = FP_Interval::boundary_type(3);
   FP_Interval inhomogeneous_term;
-  inhomogeneous_term.lower() = 4.0;
-  inhomogeneous_term.upper() = 8.0;
+  inhomogeneous_term.lower() = FP_Interval::boundary_type(4);
+  inhomogeneous_term.upper() = FP_Interval::boundary_type(8);
   FP_Linear_Form lf(x2);
   lf = -lf;
   lf += FP_Linear_Form(x2);
diff --git a/tests/Concrete_Expression/linearize.cc b/tests/Concrete_Expression/linearize.cc
index 29dee84..45d5b7d 100644
--- a/tests/Concrete_Expression/linearize.cc
+++ b/tests/Concrete_Expression/linearize.cc
@@ -244,8 +244,8 @@ test07() {
   linearize(div, oracle, FP_Linear_Form_Abstract_Store(), result);
 
   Variable A(0);
-  FP_Interval coeff = FP_Interval(1 / 2.0);
-  FP_Linear_Form known_result = FP_Linear_Form(A);
+  FP_Interval coeff(FP_Interval::boundary_type(1 / 2.0));
+  FP_Linear_Form known_result(A);
   FP_Linear_Form rel_err;
   known_result.relative_error(ANALYZED_FP_FORMAT, rel_err);
   known_result *= coeff;
diff --git a/tests/Concrete_Expression/polyhedron1.cc b/tests/Concrete_Expression/polyhedron1.cc
index 3672b7d..8c82f15 100644
--- a/tests/Concrete_Expression/polyhedron1.cc
+++ b/tests/Concrete_Expression/polyhedron1.cc
@@ -93,7 +93,7 @@ test03() {
   Variable A(0);
   Variable B(1);
   FP_Interval_Abstract_Store store(2);
-  FP_Interval tmp(1 / 2.0);
+  FP_Interval tmp(FP_Interval::boundary_type(1 / 2.0));
   store.set_interval(A, tmp);
   store.set_interval(B, tmp);
   Generator_System gs;




More information about the PPL-devel mailing list