[GIT] ppl/ppl(floating_point): Use build method instead of join_assign to build convex intervals.

Module: ppl/ppl Branch: floating_point Commit: bdae3bb7bff529ab9864b997f66507f20db38719 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=bdae3bb7bff52...
Author: Roberto Amadini r.amadini@virgilio.it Date: Sat Feb 20 14:39:08 2010 +0100
Use build method instead of join_assign to build convex intervals.
---
src/Cast_Floating_Point_Expression.templates.hh | 6 +++--- src/Constant_Floating_Point_Expression.defs.hh | 2 -- src/Constant_Floating_Point_Expression.inlines.hh | 7 +++---- ...fference_Floating_Point_Expression.templates.hh | 6 +++--- ...Division_Floating_Point_Expression.templates.hh | 6 +++--- src/Floating_Point_Expression.templates.hh | 14 ++++++++------ ...lication_Floating_Point_Expression.templates.hh | 6 +++--- src/Sum_Floating_Point_Expression.templates.hh | 6 +++--- tests/Floating_Point_Expression/digitalfilters1.cc | 6 +++--- 9 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/src/Cast_Floating_Point_Expression.templates.hh b/src/Cast_Floating_Point_Expression.templates.hh index 671886c..b4c5ba8 100644 --- a/src/Cast_Floating_Point_Expression.templates.hh +++ b/src/Cast_Floating_Point_Expression.templates.hh @@ -36,9 +36,9 @@ bool Cast_Floating_Point_Expression<FP_Interval_Type, FP_Format> FP_Linear_Form rel_error; relative_error(result, rel_error); result += rel_error; - FP_Interval_Type abs_error(-this->absolute_error); - // FIXME: this may be incorrect for some policies. - abs_error.join_assign(this->absolute_error); + FP_Interval_Type abs_error; + abs_error.build(i_constraint(GREATER_OR_EQUAL, -this->absolute_error), + i_constraint(LESS_OR_EQUAL, this->absolute_error)); result += abs_error; return !this->overflows(result); } diff --git a/src/Constant_Floating_Point_Expression.defs.hh b/src/Constant_Floating_Point_Expression.defs.hh index 5f27a12..5036e75 100644 --- a/src/Constant_Floating_Point_Expression.defs.hh +++ b/src/Constant_Floating_Point_Expression.defs.hh @@ -151,8 +151,6 @@ public:
private:
- // FIXME: this is a temporary solution: we should find a way to convert - // a floating point with an arbitrary format to an interval. FP_Interval_Type value;
#ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS diff --git a/src/Constant_Floating_Point_Expression.inlines.hh b/src/Constant_Floating_Point_Expression.inlines.hh index df9c051..a3bd5a9 100644 --- a/src/Constant_Floating_Point_Expression.inlines.hh +++ b/src/Constant_Floating_Point_Expression.inlines.hh @@ -37,11 +37,10 @@ template <typename FP_Interval_Type, typename FP_Format> inline Constant_Floating_Point_Expression<FP_Interval_Type, FP_Format>:: Constant_Floating_Point_Expression(const boundary_type lb, - const boundary_type ub) - : value(lb) { + const boundary_type ub) { assert(lb <= ub); - // FIXME: this may be incorrect for some policies. - value.join_assign(ub); + value.build(i_constraint(GREATER_OR_EQUAL, lb), + i_constraint(LESS_OR_EQUAL, ub)); }
template <typename FP_Interval_Type, typename FP_Format> diff --git a/src/Difference_Floating_Point_Expression.templates.hh b/src/Difference_Floating_Point_Expression.templates.hh index d9cd388..4323d4e 100644 --- a/src/Difference_Floating_Point_Expression.templates.hh +++ b/src/Difference_Floating_Point_Expression.templates.hh @@ -43,9 +43,9 @@ bool Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format> result -= linearized_second_operand; relative_error(linearized_second_operand, rel_error); result += rel_error; - FP_Interval_Type abs_error(-this->absolute_error); - // FIXME: this may be incorrect for some policies. - abs_error.join_assign(this->absolute_error); + FP_Interval_Type abs_error; + abs_error.build(i_constraint(GREATER_OR_EQUAL, -this->absolute_error), + i_constraint(LESS_OR_EQUAL, this->absolute_error)); result += abs_error; return !this->overflows(result); } diff --git a/src/Division_Floating_Point_Expression.templates.hh b/src/Division_Floating_Point_Expression.templates.hh index 5de000e..ac87ecb 100644 --- a/src/Division_Floating_Point_Expression.templates.hh +++ b/src/Division_Floating_Point_Expression.templates.hh @@ -51,9 +51,9 @@ bool Division_Floating_Point_Expression<FP_Interval_Type, FP_Format> result /= intervalized_second_operand; rel_error /= intervalized_second_operand; result += rel_error; - FP_Interval_Type abs_error(-this->absolute_error); - // FIXME: this may be incorrect for some policies. - abs_error.join_assign(this->absolute_error); + FP_Interval_Type abs_error; + abs_error.build(i_constraint(GREATER_OR_EQUAL, -this->absolute_error), + i_constraint(LESS_OR_EQUAL, this->absolute_error)); result += abs_error; return !this->overflows(result); } diff --git a/src/Floating_Point_Expression.templates.hh b/src/Floating_Point_Expression.templates.hh index 62d5515..d8ab3fa 100644 --- a/src/Floating_Point_Expression.templates.hh +++ b/src/Floating_Point_Expression.templates.hh @@ -33,14 +33,16 @@ template<typename FP_Interval_Type, typename FP_Format> void Floating_Point_Expression<FP_Interval_Type, FP_Format> ::relative_error(const FP_Linear_Form& lf, FP_Linear_Form& result) { - /* FIXME: here we assume that boundary_type can represent - (2)^(-FP_Format::MANTISSA_BITS) precisely. */ - FP_Interval_Type error_propagator(-pow(FP_Format::BASE, + + FP_Interval_Type error_propagator; + error_propagator.build( + i_constraint(GREATER_OR_EQUAL, -pow(FP_Format::BASE, -static_cast<typename Floating_Point_Expression<FP_Interval_Type, FP_Format> - ::boundary_type>(FP_Format::MANTISSA_BITS))); - error_propagator.join_assign(FP_Interval_Type(pow(FP_Format::BASE, + ::boundary_type>(FP_Format::MANTISSA_BITS))), + i_constraint(LESS_OR_EQUAL, pow(FP_Format::BASE, -static_cast<typename Floating_Point_Expression<FP_Interval_Type, FP_Format> - ::boundary_type>(FP_Format::MANTISSA_BITS)))); + ::boundary_type>(FP_Format::MANTISSA_BITS))) + );
// Handle the inhomogeneous term. const FP_Interval_Type* current_term = &lf.inhomogeneous_term(); diff --git a/src/Multiplication_Floating_Point_Expression.templates.hh b/src/Multiplication_Floating_Point_Expression.templates.hh index 3922983..c15fdb8 100644 --- a/src/Multiplication_Floating_Point_Expression.templates.hh +++ b/src/Multiplication_Floating_Point_Expression.templates.hh @@ -98,9 +98,9 @@ bool Multiplication_Floating_Point_Expression<FP_Interval_Type, FP_Format> result += linearized_first_operand; }
- FP_Interval_Type abs_error(-this->absolute_error); - // FIXME: this may be incorrect for some policies. - abs_error.join_assign(this->absolute_error); + FP_Interval_Type abs_error; + abs_error.build(i_constraint(GREATER_OR_EQUAL, -this->absolute_error), + i_constraint(LESS_OR_EQUAL, this->absolute_error)); result += abs_error; return !this->overflows(result); } diff --git a/src/Sum_Floating_Point_Expression.templates.hh b/src/Sum_Floating_Point_Expression.templates.hh index 2c01484..6758848 100644 --- a/src/Sum_Floating_Point_Expression.templates.hh +++ b/src/Sum_Floating_Point_Expression.templates.hh @@ -43,9 +43,9 @@ bool Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format> result += linearized_second_operand; relative_error(linearized_second_operand, rel_error); result += rel_error; - FP_Interval_Type abs_error(-this->absolute_error); - // FIXME: this may be incorrect for some policies. - abs_error.join_assign(this->absolute_error); + FP_Interval_Type abs_error; + abs_error.build(i_constraint(GREATER_OR_EQUAL, -this->absolute_error), + i_constraint(LESS_OR_EQUAL, this->absolute_error)); result += abs_error; return !this->overflows(result); } diff --git a/tests/Floating_Point_Expression/digitalfilters1.cc b/tests/Floating_Point_Expression/digitalfilters1.cc index 2f84d73..4a04f40 100644 --- a/tests/Floating_Point_Expression/digitalfilters1.cc +++ b/tests/Floating_Point_Expression/digitalfilters1.cc @@ -456,7 +456,7 @@ test05() { cs.insert(Y <= M); cs.insert(Y >= -M);
- Con_FP_Expression con_y(0, 0); + Con_FP_Expression con_y("0"); // The constant floating point expression con_y is linearized into // the interval linear form lk. If linearization succeeded, we model // the assignment Y = 0, invoking affine_form_image method. @@ -627,7 +627,7 @@ test06() { cs.insert(Y <= N); cs.insert(Y >= -N);
- Con_FP_Expression con_y(0, 0); + Con_FP_Expression con_y("0"); // The constant floating point expression con_y is linearized into // the interval linear form lk. If linearization succeeded, we model // the assignment Y = 0, invoking affine_form_image method. @@ -795,7 +795,7 @@ test07() { cs.insert(Y <= M); cs.insert(Y >= -M);
- Con_FP_Expression con_y(0, 0); + Con_FP_Expression con_y("0"); // The constant floating point expression con_y is linearized into // the interval linear form lk. If linearization succeeded, we model // the assignment Y = 0, invoking affine_form_image method.
participants (1)
-
Roberto Amadini