[PPL-devel] [GIT] ppl/ppl(floating_point): Fixed test05.

Fabio Bossi bossi at cs.unipr.it
Thu Sep 24 18:21:00 CEST 2009


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

Author: Fabio Bossi <bossi at cs.unipr.it>
Date:   Thu Sep 24 18:20:28 2009 +0200

Fixed test05.
Added a new test file.

---

 tests/Floating_Point_Expression/polyhedron1.cc |    8 +--
 tests/Floating_Point_Expression/polyhedron2.cc |   70 ++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/tests/Floating_Point_Expression/polyhedron1.cc b/tests/Floating_Point_Expression/polyhedron1.cc
index 4ab4144..98a111d 100644
--- a/tests/Floating_Point_Expression/polyhedron1.cc
+++ b/tests/Floating_Point_Expression/polyhedron1.cc
@@ -149,8 +149,7 @@ test05() {
   Variable A(0);
   Variable B(1);
   FP_Interval_Abstract_Store store(2);
-  FP_Interval tmp(-2.5); //FIXME: Perturbation of inhomogeneous term in order
-  tmp.join_assign(6.5);  //to handle rounding errors.
+  FP_Interval tmp(2);
   store.set_interval(A, tmp);
   store.set_interval(B, tmp);
   C_Polyhedron ph(2);
@@ -161,15 +160,12 @@ test05() {
   FP_Linear_Form l(A);
   l += tmp;
   l -= B;
-  tmp = -1 / 3.0;
-  l *= tmp;
+  l /= FP_Interval(-3);
 
   ph.affine_image(B, l, store);
   print_constraints(ph,
     "*** ph.affine_image(B, (A - B + 2) / (-3), store) ***");
 
-  ph.affine_image(B, l, store);
-
   C_Polyhedron known_result(2, EMPTY);
   known_result.add_generator(point(2*A));
   known_result.add_generator(point(2*A - B));
diff --git a/tests/Floating_Point_Expression/polyhedron2.cc b/tests/Floating_Point_Expression/polyhedron2.cc
new file mode 100644
index 0000000..7ab1b68
--- /dev/null
+++ b/tests/Floating_Point_Expression/polyhedron2.cc
@@ -0,0 +1,70 @@
+/* Test Polyhedron::refine_fp_interval_abstract_store and
+   Polyhedron::refine_with_linear_form_inequality.
+   Copyright (C) 2001-2009 Roberto Bagnara <bagnara at cs.unipr.it>
+
+This file is part of the Parma Polyhedra Library (PPL).
+
+The PPL is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The PPL is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+
+For the most up-to-date information see the Parma Polyhedra Library
+site: http://www.cs.unipr.it/ppl/ . */
+
+#include "ppl_test.hh"
+
+namespace {
+
+bool
+test01() {
+  C_Polyhedron pol(1);
+  FP_Interval_Abstract_Store store(1);
+  store.set_interval(Variable(0), FP_Interval(0));
+  try {
+    FP_Linear_Form l1(Variable(3));
+    FP_Linear_Form l2;
+    pol.refine_with_linear_form_inequality(l1, l2, store);
+  }
+  catch (std::invalid_argument) {
+    try {
+      FP_Linear_Form l1;
+      FP_Linear_Form l2(Variable(3));
+      pol.refine_with_linear_form_inequality(l1, l2, store);
+    }
+    catch (std::invalid_argument) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+bool
+test02() {
+  C_Polyhedron pol(1);
+  FP_Interval_Abstract_Store store(1);
+  store.set_interval(Variable(0), FP_Interval(1.5));
+  FP_Interval interval(57);
+  FP_Linear_Form lf1(Variable(0));
+  FP_Linear_Form lf2(interval);
+  pol.refine_with_linear_form_inequality(lf1, lf2, store);
+  print_constraints(pol, "RESULT");
+  return true;
+}
+
+} // namespace
+
+BEGIN_MAIN
+  DO_TEST(test01);
+  DO_TEST(test02);
+END_MAIN




More information about the PPL-devel mailing list