[PPL-devel] [GIT] ppl/ppl(master): Fixed a bug affecting method contains() of weakly-relational shapes.

Enea Zaffanella zaffanella at cs.unipr.it
Wed May 23 16:36:34 CEST 2012


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Wed May 23 16:25:11 2012 +0200

Fixed a bug affecting method contains() of weakly-relational shapes.

---

 src/BD_Shape.templates.hh        |   18 +++++++++---------
 src/Octagonal_Shape.templates.hh |   17 +++++++++--------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/BD_Shape.templates.hh b/src/BD_Shape.templates.hh
index d655cd6..f14bae4 100644
--- a/src/BD_Shape.templates.hh
+++ b/src/BD_Shape.templates.hh
@@ -596,15 +596,12 @@ BD_Shape<T>::contains(const BD_Shape& y) const {
   if (x_space_dim != y.space_dimension())
     throw_dimension_incompatible("contains(y)", y);
 
-  // The zero-dimensional universe shape contains any other
-  // dimension-compatible shape.
-  // The zero-dimensional empty shape only contains another
-  // zero-dimensional empty shape.
   if (x_space_dim == 0) {
-    if (!marked_empty())
-      return true;
-    else
-      return y.marked_empty();
+    // The zero-dimensional empty shape only contains another
+    // zero-dimensional empty shape.
+    // The zero-dimensional universe shape contains any other
+    // zero-dimensional shape.
+    return marked_empty() ? y.marked_empty() : true;
   }
 
   /*
@@ -630,11 +627,14 @@ BD_Shape<T>::contains(const BD_Shape& y) const {
     that containment does hold.
   */
   y.shortest_path_closure_assign();
-
   // An empty shape is contained in any other dimension-compatible shapes.
   if (y.marked_empty())
     return true;
 
+  // If `x' is empty it can not contain `y' (which is not empty).
+  if (x.is_empty())
+    return false;
+
   // `*this' contains `y' if and only if every cell of `dbm'
   // is greater than or equal to the correspondent one of `y.dbm'.
   for (dimension_type i = x_space_dim + 1; i-- > 0; ) {
diff --git a/src/Octagonal_Shape.templates.hh b/src/Octagonal_Shape.templates.hh
index 705ef69..817c158 100644
--- a/src/Octagonal_Shape.templates.hh
+++ b/src/Octagonal_Shape.templates.hh
@@ -1133,15 +1133,12 @@ Octagonal_Shape<T>::contains(const Octagonal_Shape& y) const {
   if (space_dim != y.space_dim)
     throw_dimension_incompatible("contains(y)", y);
 
-  // The zero-dimensional universe octagon contains any other
-  // dimension-compatible octagon.
-  // The zero-dimensional empty octagon only contains another
-  // zero-dimensional empty octagon.
   if (space_dim == 0) {
-    if (!marked_empty())
-      return true;
-    else
-      return y.marked_empty();
+    // The zero-dimensional empty octagon only contains another
+    // zero-dimensional empty octagon.
+    // The zero-dimensional universe octagon contains any other
+    // zero-dimensional octagon.
+    return marked_empty() ? y.marked_empty() : true;
   }
 
   // `y' needs to be transitively closed.
@@ -1150,6 +1147,10 @@ Octagonal_Shape<T>::contains(const Octagonal_Shape& y) const {
   if (y.marked_empty())
     return true;
 
+  // If `*this' is empty it can not contain `y' (which is not empty).
+  if (is_empty())
+    return false;
+
   // `*this' contains `y' if and only if every element of `*this'
   // is greater than or equal to the correspondent one of `y'.
   for (typename OR_Matrix<N>::const_element_iterator




More information about the PPL-devel mailing list