[PPL-devel] [GIT] ppl/ppl(floating_point): Added a test.

Fabio Biselli fabio.biselli at studenti.unipr.it
Tue Sep 29 13:25:19 CEST 2009


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

Author: Fabio Biselli <fabio.biselli at studenti.unipr.it>
Date:   Tue Sep 29 15:24:11 2009 +0200

Added a test.
Fixed a bug in left_one_var_refine().

---

 src/BD_Shape.templates.hh                   |    4 +-
 tests/Floating_Point_Expression/bdshape2.cc |   39 ++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/src/BD_Shape.templates.hh b/src/BD_Shape.templates.hh
index 46ba6b7..8a96555 100644
--- a/src/BD_Shape.templates.hh
+++ b/src/BD_Shape.templates.hh
@@ -4496,7 +4496,7 @@ BD_Shape<T>
 	// where k is an overaproximation of b - y
         return;
       }
-      if (is_left_coeff_minus_one && is_right_coeff_one) {
+      if (is_left_coeff_minus_one && is_right_coeff_minus_one) {
         PPL_DIRTY_TEMP(N, c_plus_minus_a_minus);
         const FP_Interval_Type& left_a = left.inhomogeneous_term();
         const FP_Interval_Type& right_c = right.inhomogeneous_term();
@@ -4505,7 +4505,7 @@ BD_Shape<T>
         add_dbm_constraint(right_w_id+1, left_w_id+1, c_plus_minus_a_minus);
         return;
       }
-      if (is_left_coeff_minus_one && is_right_coeff_minus_one) {
+      if (is_left_coeff_minus_one && is_right_coeff_one) {
         // if right and left coefficents are negative the constraint 
 	// - x - y <= b
 	// is ignored;
diff --git a/tests/Floating_Point_Expression/bdshape2.cc b/tests/Floating_Point_Expression/bdshape2.cc
index fab904b..daf8527 100644
--- a/tests/Floating_Point_Expression/bdshape2.cc
+++ b/tests/Floating_Point_Expression/bdshape2.cc
@@ -178,11 +178,48 @@ test04() {
 
 }
 
+// tests [1, 3] + A <= [4, 4] - B and [4, 4] - B <= [1, 3] + A
+bool
+test05() {
+  Variable A(0);
+  Variable B(1);
+
+  FP_BD_Shape bd1(2);
+  bd1.add_constraint(A <= 2);
+  bd1.add_constraint(A - B <= 3);
+  bd1.add_constraint(B <= 2);
+  FP_BD_Shape known_result(bd1);
+  FP_Interval tmp(4);
+  FP_Linear_Form l2(-B);
+  l2 += tmp;
+  FP_Linear_Form l1(A);
+  tmp.lower() = 1;
+  tmp.upper() = 3;
+  l1 += tmp;
+  bd1.refine_with_linear_form_inequality(l1, l2);
+  print_constraints(bd1, "*** [1, 3] + A <= [4, 4] - B ***");
+  
+  print_constraints(known_result, "*** known_result ***");
+  
+  bool ok1 = (bd1 == known_result);
+
+  bd1.refine_with_linear_form_inequality(l2, l1);
+  print_constraints(bd1, "*** [4, 4] - B <= [1, 3] + A ***");
+
+  print_constraints(known_result, "*** known_result2 ***");
+
+  bool ok2 = (bd1 == known_result);
+
+  return ok1 && ok2;
+
+}
+
 } // namespace
 
 BEGIN_MAIN
 //DO_TEST(test01);
 //DO_TEST(test02);
 //DO_TEST(test03);
-  DO_TEST(test04);
+//DO_TEST(test04);
+  DO_TEST(test05);
 END_MAIN




More information about the PPL-devel mailing list