[PPL-devel] [GIT] ppl/ppl(floating_point): Fixed Cast_Floating_Point_Expression.inlines .hh and added a test.

Roberto Amadini r.amadini at virgilio.it
Tue Feb 16 15:21:33 CET 2010


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

Author: Roberto Amadini <r.amadini at virgilio.it>
Date:   Tue Feb 16 15:11:53 2010 +0100

Fixed Cast_Floating_Point_Expression.inlines.hh and added a test.

---

 src/Cast_Floating_Point_Expression.inlines.hh      |    2 +-
 src/Makefile.am                                    |    4 ++
 .../floatingpointexpr1.cc                          |   35 ++++++++++++++++++++
 tests/ppl_test.hh                                  |    7 ++++
 4 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/Cast_Floating_Point_Expression.inlines.hh b/src/Cast_Floating_Point_Expression.inlines.hh
index 7112467..4e65ad0 100644
--- a/src/Cast_Floating_Point_Expression.inlines.hh
+++ b/src/Cast_Floating_Point_Expression.inlines.hh
@@ -47,7 +47,7 @@ template <typename FP_Interval_Type, typename FP_Format>
 inline void
 Cast_Floating_Point_Expression<FP_Interval_Type, FP_Format>::swap(
 	 Cast_Floating_Point_Expression& y) {
-  std::swap(value, y.value);
+  std::swap(expr, y.expr);
 }
 
 } // namespace Parma_Polyhedra_Library
diff --git a/src/Makefile.am b/src/Makefile.am
index d919dd2..24ca746 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -354,6 +354,10 @@ Floating_Point_Expression.types.hh \
 Floating_Point_Expression.defs.hh \
 Floating_Point_Expression.inlines.hh \
 Floating_Point_Expression.templates.hh \
+Cast_Floating_Point_Expression.types.hh \
+Cast_Floating_Point_Expression.defs.hh \
+Cast_Floating_Point_Expression.inlines.hh \
+Cast_Floating_Point_Expression.templates.hh \
 Constant_Floating_Point_Expression.types.hh \
 Constant_Floating_Point_Expression.defs.hh \
 Constant_Floating_Point_Expression.inlines.hh \
diff --git a/tests/Floating_Point_Expression/floatingpointexpr1.cc b/tests/Floating_Point_Expression/floatingpointexpr1.cc
index 58615b3..ba917b3 100644
--- a/tests/Floating_Point_Expression/floatingpointexpr1.cc
+++ b/tests/Floating_Point_Expression/floatingpointexpr1.cc
@@ -332,6 +332,40 @@ test09() {
   return ok1 && ok2 && ok3;
 }
 
+// Tests linearization of cast(X + Y).
+bool
+test10() {
+  Variable X(0);
+  Variable Y(1);
+  FP_Interval_Abstract_Store as(2);
+  FP_Linear_Form_Abstract_Store lf_as;
+  FP_Linear_Form l_con_x;
+  FP_Linear_Form l_con_y;
+  FP_Linear_Form l_cast;
+  Con_FP_Expression* con_x = new Con_FP_Expression(1 / 3.0, 1 / 3.0);
+  con_x->linearize(as, lf_as, l_con_x);
+  Con_FP_Expression* con_y = new Con_FP_Expression(-1 / 2.0, 1 / 2.0);
+  con_y->linearize(as, lf_as, l_con_y);
+  as.affine_form_image(X, l_con_x);
+  as.affine_form_image(Y, l_con_y);
+  Var_FP_Expression* var_x = new Var_FP_Expression(0);
+  Var_FP_Expression* var_y = new Var_FP_Expression(1);
+  Sum_FP_Expression* x_sum_y = new Sum_FP_Expression(var_x, var_y);
+  Cast_FP_Expression cast(x_sum_y);
+  cast.linearize(as, lf_as, l_cast);
+
+  // FIXME: Computed result should over-approximates the known result.
+  FP_Interval result;
+  FP_Expression::intervalize(l_cast, as, result);
+  nout << "*** result ***" << endl << result << endl;
+  FP_Linear_Form l_kr(X);
+  l_kr += FP_Linear_Form(Y);
+  FP_Interval known_result;
+  FP_Expression::intervalize(l_kr, as, known_result);
+  nout << "*** known_result ***" << endl << known_result << endl;
+  return result.contains(known_result);
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -344,4 +378,5 @@ BEGIN_MAIN
   DO_TEST(test07);
   DO_TEST(test08);
   DO_TEST(test09);
+  DO_TEST(test10);
 END_MAIN
diff --git a/tests/ppl_test.hh b/tests/ppl_test.hh
index 930a903..06c2b8c 100644
--- a/tests/ppl_test.hh
+++ b/tests/ppl_test.hh
@@ -588,6 +588,13 @@ typedef Floating_Point_Expression<FP_Interval, ANALYZED_FP_FORMAT>
                                                          FP_Expression;
 
 /*! \brief
+  The incarnation of Cast_Floating_Point_Expression under test for
+  analyzing floating point computations.
+*/
+typedef Cast_Floating_Point_Expression<FP_Interval,
+                                ANALYZED_FP_FORMAT> Cast_FP_Expression;
+
+/*! \brief
   The incarnation of Constant_Floating_Point_Expression under test for
   analyzing floating point computations.
 */




More information about the PPL-devel mailing list