[GIT] ppl/ppl(floating_point): Added another test for the general case of affine_image.

Module: ppl/ppl Branch: floating_point Commit: 3e7c9713946e790f1894bc8d35c3ab97535fb7be URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=3e7c9713946e7...
Author: Roberto Amadini r.amadini@virgilio.it Date: Mon Sep 21 19:23:37 2009 +0200
Added another test for the general case of affine_image.
---
tests/Floating_Point_Expression/affineimage3.cc | 4 +- tests/Floating_Point_Expression/bdshape1.cc | 40 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/tests/Floating_Point_Expression/affineimage3.cc b/tests/Floating_Point_Expression/affineimage3.cc index f439275..5cd40be 100644 --- a/tests/Floating_Point_Expression/affineimage3.cc +++ b/tests/Floating_Point_Expression/affineimage3.cc @@ -287,7 +287,8 @@ bool test09() { }
-// tests affine_image(A, i + i0*A + i1*B) +// tests affine_image(A, i + i0*A + i1*B) where +// i = [0, 2], i0 = [1, 1] and i1 = [1, 2]. bool test10() {
Variable A(0); @@ -300,7 +301,6 @@ bool test10() { oc1.add_constraint(B <= 2); oc1.add_constraint(A - B >= 0); db_r_oc tmp(1); - tmp.join_assign(1); Linear_Form<db_r_oc> l(A); l *= tmp; tmp.lower() = 0; diff --git a/tests/Floating_Point_Expression/bdshape1.cc b/tests/Floating_Point_Expression/bdshape1.cc index 0c8e305..9d3053c 100644 --- a/tests/Floating_Point_Expression/bdshape1.cc +++ b/tests/Floating_Point_Expression/bdshape1.cc @@ -279,6 +279,45 @@ bool test09() { return ok; }
+// tests affine_image(A, i + i0*A + i1*B) where +// i = [0, 2], i0 = [1, 1] and i1 = [1, 2]. +bool test10() { + + Variable A(0); + Variable B(1); + + BD_Shape<double> bd1(2); + bd1.add_constraint(A >= 0); + bd1.add_constraint(A <= 2); + bd1.add_constraint(B >= 0); + bd1.add_constraint(B <= 2); + bd1.add_constraint(A - B >= 0); + db_r_oc tmp(1); + Linear_Form<db_r_oc> l(A); + l *= tmp; + tmp.lower() = 0; + tmp.upper() = 2; + l += tmp; + tmp.lower() = 1; + tmp.upper() = 2; + l += tmp * Linear_Form<db_r_oc>(B); + bd1.affine_image(A,l); + print_constraints(bd1, "*** bd1.affine_image(A, i + i0*A + i1*B) ***"); + + BD_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 <= 0); + print_constraints(know_result, "*** know_result ***"); + + bool ok = (bd1 == know_result); + + return ok; +} + } // namespace
BEGIN_MAIN @@ -291,4 +330,5 @@ BEGIN_MAIN DO_TEST(test07); DO_TEST(test08); DO_TEST(test09); + DO_TEST(test10); END_MAIN
participants (1)
-
Roberto Amadini