[PPL-devel] [GIT] ppl/ppl(floating_point): Added a few more implementations of the linearization operator.

Fabio Bossi bossi at cs.unipr.it
Wed Sep 2 16:03:16 CEST 2009


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

Author: Fabio Bossi <bossi at cs.unipr.it>
Date:   Wed Sep  2 16:02:45 2009 +0200

Added a few more implementations of the linearization operator.

---

 src/Difference_Floating_Point_Expression.defs.hh   |    1 +
 ...Difference_Floating_Point_Expression.inlines.hh |   11 ----
 ...fference_Floating_Point_Expression.templates.hh |   51 ++++++++++++++++++++
 src/Makefile.am                                    |   10 ++++-
 src/Sum_Floating_Point_Expression.defs.hh          |    1 +
 src/Sum_Floating_Point_Expression.inlines.hh       |   11 ----
 src/Sum_Floating_Point_Expression.templates.hh     |   50 +++++++++++++++++++
 7 files changed, 112 insertions(+), 23 deletions(-)

diff --git a/src/Difference_Floating_Point_Expression.defs.hh b/src/Difference_Floating_Point_Expression.defs.hh
index f2c0ad6..304e92e 100644
--- a/src/Difference_Floating_Point_Expression.defs.hh
+++ b/src/Difference_Floating_Point_Expression.defs.hh
@@ -100,5 +100,6 @@ private:
 } // namespace Parma_Polyhedra_Library
 
 #include "Difference_Floating_Point_Expression.inlines.hh"
+#include "Difference_Floating_Point_Expression.templates.hh"
 
 #endif // !defined(PPL_Difference_Floating_Point_Expression_defs_hh)
diff --git a/src/Difference_Floating_Point_Expression.inlines.hh b/src/Difference_Floating_Point_Expression.inlines.hh
index 744207d..596b21e 100644
--- a/src/Difference_Floating_Point_Expression.inlines.hh
+++ b/src/Difference_Floating_Point_Expression.inlines.hh
@@ -55,17 +55,6 @@ Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format>
   std::swap(second_operand, y.second_operand);
 }
 
-  // FIXME: add function body
-template <typename FP_Interval_Type, typename FP_Format>
-inline
-typename Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format>
-::FP_Linear_Form
-Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format>
-::linearize(const FP_Interval_Abstract_Store& store) const {
-  FP_Linear_Form result = FP_Linear_Form();
-  return result;
-}
-
 } // namespace Parma_Polyhedra_Library
 
 namespace std {
diff --git a/src/Difference_Floating_Point_Expression.templates.hh b/src/Difference_Floating_Point_Expression.templates.hh
new file mode 100644
index 0000000..24eee4e
--- /dev/null
+++ b/src/Difference_Floating_Point_Expression.templates.hh
@@ -0,0 +1,51 @@
+/* Difference_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_Difference_Floating_Point_Expression_templates_hh
+#define PPL_Difference_Floating_Point_Expression_templates_hh 1
+
+#include "Difference_Floating_Point_Expression.defs.hh"
+
+namespace Parma_Polyhedra_Library {
+
+template <typename FP_Interval_Type, typename FP_Format>
+typename Difference_Floating_Point_Expression<FP_Interval_Type, FP_Format>
+::FP_Linear_Form Difference_Floating_Point_Expression<FP_Interval_Type,
+                                                      FP_Format>
+::linearize(const FP_Interval_Abstract_Store& store) const {
+  FP_Linear_Form linearized_first_operand = first_operand->linearize(store);
+  FP_Linear_Form linearized_second_operand = second_operand->linearize(store);
+  FP_Interval error = FP_Interval_Type(-absolute_error);
+  // FIXME: this may be incorrect for some policies.
+  error.join_assign(absolute_error);
+  FP_Linear_Form abs_error = FP_Linear_Form(error);
+  FP_Linear_Form result = linearized_first_operand - linearized_second_operand +
+                          relative_error(linearized_first_operand) +
+                          relative_error(linearized_second_operand) +
+                          abs_error;
+  return result;
+}
+
+} // namespace Parma_Polyhedra_Library
+
+#endif // !defined(PPL_Difference_Floating_Point_Expression_templates_hh)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9fd2582..90a3c86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -350,7 +350,15 @@ Constant_Floating_Point_Expression.defs.hh \
 Constant_Floating_Point_Expression.inlines.hh \
 Variable_Floating_Point_Expression.types.hh \
 Variable_Floating_Point_Expression.defs.hh \
-Variable_Floating_Point_Expression.inlines.hh
+Variable_Floating_Point_Expression.inlines.hh \
+Sum_Floating_Point_Expression.types.hh \
+Sum_Floating_Point_Expression.defs.hh \
+Sum_Floating_Point_Expression.inlines.hh \
+Sum_Floating_Point_Expression.templates.hh \
+Difference_Floating_Point_Expression.types.hh \
+Difference_Floating_Point_Expression.defs.hh \
+Difference_Floating_Point_Expression.inlines.hh \
+Difference_Floating_Point_Expression.templates.hh
 #Any_Pointset.types.hh \
 #Any_Pointset.defs.hh \
 #Any_Pointset.inlines.hh \
diff --git a/src/Sum_Floating_Point_Expression.defs.hh b/src/Sum_Floating_Point_Expression.defs.hh
index eec9115..57671ef 100644
--- a/src/Sum_Floating_Point_Expression.defs.hh
+++ b/src/Sum_Floating_Point_Expression.defs.hh
@@ -97,5 +97,6 @@ private:
 } // namespace Parma_Polyhedra_Library
 
 #include "Sum_Floating_Point_Expression.inlines.hh"
+#include "Sum_Floating_Point_Expression.templates.hh"
 
 #endif // !defined(PPL_Sum_Floating_Point_Expression_defs_hh)
diff --git a/src/Sum_Floating_Point_Expression.inlines.hh b/src/Sum_Floating_Point_Expression.inlines.hh
index 7051f16..aa73ba9 100644
--- a/src/Sum_Floating_Point_Expression.inlines.hh
+++ b/src/Sum_Floating_Point_Expression.inlines.hh
@@ -55,17 +55,6 @@ Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
   std::swap(second_operand, y.second_operand);
 }
 
-
-  // FIXME: add function body
-template <typename FP_Interval_Type, typename FP_Format>
-inline
-typename Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
-::FP_Linear_Form Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
-::linearize(const FP_Interval_Abstract_Store& store) const {
-  FP_Linear_Form result = FP_Linear_Form();
-  return result;
-}
-
 } // namespace Parma_Polyhedra_Library
 
 namespace std {
diff --git a/src/Sum_Floating_Point_Expression.templates.hh b/src/Sum_Floating_Point_Expression.templates.hh
new file mode 100644
index 0000000..0ac587a
--- /dev/null
+++ b/src/Sum_Floating_Point_Expression.templates.hh
@@ -0,0 +1,50 @@
+/* Sum_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_Sum_Floating_Point_Expression_templates_hh
+#define PPL_Sum_Floating_Point_Expression_templates_hh 1
+
+#include "Sum_Floating_Point_Expression.defs.hh"
+
+namespace Parma_Polyhedra_Library {
+
+template <typename FP_Interval_Type, typename FP_Format>
+typename Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
+::FP_Linear_Form Sum_Floating_Point_Expression<FP_Interval_Type, FP_Format>
+::linearize(const FP_Interval_Abstract_Store& store) const {
+  FP_Linear_Form linearized_first_operand = first_operand->linearize(store);
+  FP_Linear_Form linearized_second_operand = second_operand->linearize(store);
+  FP_Interval error = FP_Interval_Type(-absolute_error);
+  // FIXME: this may be incorrect for some policies.
+  error.join_assign(absolute_error);
+  FP_Linear_Form abs_error = FP_Linear_Form(error);
+  FP_Linear_Form result = linearized_first_operand + linearized_second_operand +
+                          relative_error(linearized_first_operand) +
+                          relative_error(linearized_second_operand) +
+                          abs_error;
+  return result;
+}
+
+} // namespace Parma_Polyhedra_Library
+
+#endif // !defined(PPL_Sum_Floating_Point_Expression_templates_hh)




More information about the PPL-devel mailing list