[PPL-devel] [GIT] ppl/ppl(floating_point): Implemented linearization operator for
Fabio Bossi
bossi at cs.unipr.it
Thu Sep 3 09:36:58 CEST 2009
Module: ppl/ppl
Branch: floating_point
Commit: 26061d6f25e49ff71d3c99adefd96eec5b5696dd
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=26061d6f25e49ff71d3c99adefd96eec5b5696dd
Author: Fabio Bossi <bossi at cs.unipr.it>
Date: Thu Sep 3 09:39:33 2009 +0200
Implemented linearization operator for
Division_Floating_Point_Expression.
Fixed several typos.
---
...fference_Floating_Point_Expression.templates.hh | 2 +-
...Division_Floating_Point_Expression.templates.hh | 57 ++++++++++++++++++++
src/Makefile.am | 4 ++
...lication_Floating_Point_Expression.templates.hh | 2 +-
src/Sum_Floating_Point_Expression.templates.hh | 2 +-
5 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/src/Difference_Floating_Point_Expression.templates.hh b/src/Difference_Floating_Point_Expression.templates.hh
index f095c77..43c0bf6 100644
--- a/src/Difference_Floating_Point_Expression.templates.hh
+++ b/src/Difference_Floating_Point_Expression.templates.hh
@@ -37,7 +37,7 @@ typename Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format>
FP_Linear_Form linearized_second_operand = second_operand->linearize(store);
FP_Interval abs_error = FP_Interval_Type(-absolute_error);
// FIXME: this may be incorrect for some policies.
- error.join_assign(absolute_error);
+ abs_error.join_assign(absolute_error);
FP_Linear_Form result = linearized_first_operand - linearized_second_operand +
relative_error(linearized_first_operand) +
relative_error(linearized_second_operand) +
diff --git a/src/Division_Floating_Point_Expression.templates.hh b/src/Division_Floating_Point_Expression.templates.hh
new file mode 100644
index 0000000..ff2b8b0
--- /dev/null
+++ b/src/Division_Floating_Point_Expression.templates.hh
@@ -0,0 +1,57 @@
+/* Division_Floating_Point_Expression class implementation:
+ non-inline template functions.
+ 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/ . */
+
+#ifndef PPL_Division_Floating_Point_Expression_templates_hh
+#define PPL_Division_Floating_Point_Expression_templates_hh 1
+
+#include "Division_Floating_Point_Expression.defs.hh"
+
+namespace Parma_Polyhedra_Library {
+
+template <typename FP_Interval_Type, typename FP_Format>
+typename Division_Floating_Point_Expression<FP_Interval_Type, FP_Format>
+::FP_Linear_Form Division_Floating_Point_Expression<FP_Interval_Type,
+ FP_Format>
+::linearize(const FP_Interval_Abstract_Store& store) const {
+ FP_Interval_Type intervalized_second_operand = intervalize(
+ second_operand->linearize(store));
+ // Check if we may divide by zero.
+ // FIXME: check the assumption that boundary_type is comparable with zero.
+ if (intervalized_second_operand.lower() <= 0 &&
+ intervalized_second_operand.upper() >= 0)
+ throw Linearization_Failed();
+
+ FP_Linear_Form linearized_first_operand = first_operand->linearize(store);
+ FP_Interval abs_error = FP_Interval_Type(-absolute_error);
+ // FIXME: this may be incorrect for some policies.
+ abs_error.join_assign(absolute_error);
+ FP_Linear_Form result = linearized_first_operand / intervalized_second_operand
+ + relative_error(linearized_first_operand) / intervalized_second_operand
+ + abs_eror;
+
+ return result;
+}
+
+} // namespace Parma_Polyhedra_Library
+
+#endif // !defined(PPL_Division_Floating_Point_Expression_templates_hh)
diff --git a/src/Makefile.am b/src/Makefile.am
index 048dded..7e1650f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -363,6 +363,10 @@ Multiplication_Floating_Point_Expression.types.hh \
Multiplication_Floating_Point_Expression.defs.hh \
Multiplication_Floating_Point_Expression.inlines.hh \
Multiplication_Floating_Point_Expression.templates.hh \
+Division_Floating_Point_Expression.types.hh \
+Division_Floating_Point_Expression.defs.hh \
+Division_Floating_Point_Expression.inlines.hh \
+Division_Floating_Point_Expression.templates.hh \
Opposite_Floating_Point_Expression.types.hh \
Opposite_Floating_Point_Expression.defs.hh \
Opposite_Floating_Point_Expression.inlines.hh
diff --git a/src/Multiplication_Floating_Point_Expression.templates.hh b/src/Multiplication_Floating_Point_Expression.templates.hh
index 45b71ae..36cd274 100644
--- a/src/Multiplication_Floating_Point_Expression.templates.hh
+++ b/src/Multiplication_Floating_Point_Expression.templates.hh
@@ -77,7 +77,7 @@ typename Multiplication_Floating_Point_Expression<FP_Interval_Type, FP_Format>
FP_Linear_Form result;
FP_Interval abs_error = FP_Interval_Type(-absolute_error);
// FIXME: this may be incorrect for some policies.
- error.join_assign(absolute_error);
+ abs_error.join_assign(absolute_error);
if (intervalize_first) {
result = intervalized_first_operand * linearized_second_operand +
intervalized_first_operand * relative_error(linearized_second_operand) +
diff --git a/src/Sum_Floating_Point_Expression.templates.hh b/src/Sum_Floating_Point_Expression.templates.hh
index 646f6f9..5b53b44 100644
--- a/src/Sum_Floating_Point_Expression.templates.hh
+++ b/src/Sum_Floating_Point_Expression.templates.hh
@@ -36,7 +36,7 @@ typename Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
FP_Linear_Form linearized_second_operand = second_operand->linearize(store);
FP_Interval abs_error = FP_Interval_Type(-absolute_error);
// FIXME: this may be incorrect for some policies.
- error.join_assign(absolute_error);
+ abs_error.join_assign(absolute_error);
FP_Linear_Form result = linearized_first_operand + linearized_second_operand +
relative_error(linearized_first_operand) +
relative_error(linearized_second_operand) +
More information about the PPL-devel
mailing list