[PPL-devel] [GIT] ppl/ppl(floating_point): Fixed a bug in Linear_Form::operator<<()
Fabio Biselli
fabio.biselli at studenti.unipr.it
Wed Sep 16 12:17:19 CEST 2009
Module: ppl/ppl
Branch: floating_point
Commit: 56bd6524e6e38b943e424cdd83365c053edffad5
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=56bd6524e6e38b943e424cdd83365c053edffad5
Author: Fabio Biselli <fabio.biselli at studenti.unipr.it>
Date: Wed Sep 16 14:10:28 2009 +0200
Fixed a bug in Linear_Form::operator<<()
Fixed a bug in Octagonal_Shape::linear_form_upper_bound()
Added a test
---
src/Linear_Form.templates.hh | 2 +-
src/Octagonal_Shape.templates.hh | 2 +-
tests/Floating_Point_Expression/affineimage3.cc | 49 ++++++++++++++++++++--
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/Linear_Form.templates.hh b/src/Linear_Form.templates.hh
index fc7e81e..46aaf8c 100644
--- a/src/Linear_Form.templates.hh
+++ b/src/Linear_Form.templates.hh
@@ -385,7 +385,7 @@ IO_Operators::operator<<(std::ostream& s, const Linear_Form<C>& f) {
const C& fv = f[v+1];
if (fv != 0) {
if (first) {
- if (fv == 1.0)
+ if (fv == -1.0)
s << "-";
else if (fv != 1.0)
s << fv << "*";
diff --git a/src/Octagonal_Shape.templates.hh b/src/Octagonal_Shape.templates.hh
index 9251559..9d4e70c 100644
--- a/src/Octagonal_Shape.templates.hh
+++ b/src/Octagonal_Shape.templates.hh
@@ -5151,7 +5151,7 @@ linear_form_upper_bound(const Linear_Form< Interval<T, Interval_Info> >& lf,
curr_coefficient = &(lf.coefficient(Variable(curr_var)));
assign_r(curr_lb, curr_coefficient->lower(), ROUND_NOT_NEEDED);
assign_r(curr_ub, curr_coefficient->upper(), ROUND_NOT_NEEDED);
- if (curr_lb != 0 && curr_ub != 0) {
+ if (curr_lb != 0 || curr_ub != 0) {
// FIXME: ensure that ROUND_IGNORE works fine with divisions by 2.
assign_r(curr_var_ub, matrix[n_var+1][n_var], ROUND_NOT_NEEDED);
div_2exp_assign_r(curr_var_ub, curr_var_ub, 1, ROUND_IGNORE);
diff --git a/tests/Floating_Point_Expression/affineimage3.cc b/tests/Floating_Point_Expression/affineimage3.cc
index a2bdc0f..8be7386 100644
--- a/tests/Floating_Point_Expression/affineimage3.cc
+++ b/tests/Floating_Point_Expression/affineimage3.cc
@@ -260,9 +260,48 @@ bool test08() {
return true;
}
-// tests affine_image(A, i + i1 * A + i2 * B)
+// tests affine_image(A, i1*A + i2*B + i3)
bool test09() {
- return true;
+
+ Variable A(0);
+ Variable B(1);
+
+ Octagonal_Shape<double> oc1(2);
+ oc1.add_constraint(A >= 0);
+ oc1.add_constraint(A <= 2);
+ oc1.add_constraint(B >= 0);
+ oc1.add_constraint(B <= 2);
+ oc1.add_constraint(A - B >= 0);
+
+ print_constraints(oc1, "*** oc1 ***");
+
+ db_r_oc i3(0);
+ i3.join_assign(2);
+ db_r_oc i2(1);
+ i2.join_assign(2);
+ db_r_oc i1(1);
+ i1.join_assign(1);
+
+ Linear_Form<db_r_oc> l(i3);
+
+ l += i1*Linear_Form<db_r_oc>(A);
+ l += i2*Linear_Form<db_r_oc>(B);;
+ print_constraints(oc1, "*** oc1.affine_image(A,i1*A+i2*B+i3) ***");
+ oc1.affine_image(A,l);
+
+ Octagonal_Shape<double> know_result(2);
+ know_result.add_constraint(A >= 0);
+ know_result.add_constraint(A <= 8);
+ know_result.add_constraint(B >= 0);
+ know_result.add_constraint(B <= 2);
+ know_result.add_constraint(A - B <= 6);
+ know_result.add_constraint(A + B <= 10);
+ know_result.add_constraint(-A + B <= 0);
+ know_result.add_constraint(-A - B <= 0);
+
+ bool ok = (oc1 == know_result);
+
+ return ok;
}
} //namespace
@@ -270,11 +309,11 @@ bool test09() {
BEGIN_MAIN
DO_TEST(test01);
DO_TEST(test02);
- DO_TEST(test03); /* FIXME: Not yet tested!
+ DO_TEST(test03); /* FIXME: Not yet tested
DO_TEST(test04);
DO_TEST(test05);
DO_TEST(test06);
DO_TEST(test07);
- DO_TEST(test08);
- DO_TEST(test09); */
+ DO_TEST(test08); */
+ DO_TEST(test09);
END_MAIN
More information about the PPL-devel
mailing list