[PPL-devel] [GIT] ppl/ppl(floating_point): Implemented export_interval_constraints.

Fabio Bossi bossi at cs.unipr.it
Wed Sep 29 14:14:52 CEST 2010


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

Author: Fabio Bossi <bossi at cs.unipr.it>
Date:   Wed Sep 29 14:00:23 2010 +0200

Implemented export_interval_constraints.

---

 src/BD_Shape.defs.hh      |   33 +++++++++++++++++++++++++++++++++
 src/BD_Shape.templates.hh |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/BD_Shape.defs.hh b/src/BD_Shape.defs.hh
index 3413c35..0ad832c 100644
--- a/src/BD_Shape.defs.hh
+++ b/src/BD_Shape.defs.hh
@@ -1037,6 +1037,39 @@ public:
                    const Linear_Form< Interval<T, Interval_Info> >& left,
                    const Linear_Form< Interval<T, Interval_Info> >& right);
 
+  //! Applies to \p dest the interval constraints embedded in \p *this.
+  /*!
+    \param dest
+    The object to which the constraints will be added.
+
+    \exception std::invalid_argument
+    Thrown if \p *this is dimension-incompatible with \p dest.
+
+    The template type parameter U must provide the following methods.
+    \code
+      dimension_type space_dimension() const
+    \endcode
+    returns the space dimension of the object.
+    \code
+      void set_empty()
+    \endcode
+    sets the object to an empty object.
+    \code
+      bool restrict_lower(dimension_type dim, const T& lb)
+    \endcode
+    restricts the object by applying the lower bound \p lb to the space
+    dimension \p dim and returns <CODE>false</CODE> if and only if the
+    object becomes empty.
+    \code
+      bool restrict_upper(dimension_type dim, const T& ub)
+    \endcode
+    restricts the object by applying the upper bound \p ub to the space
+    dimension \p dim and returns <CODE>false</CODE> if and only if the
+    object becomes empty.
+  */
+  template <typename U>
+  void export_interval_constraints(U& dest) const;
+
   /*! \brief
     Computes the \ref Cylindrification "cylindrification" of \p *this with
     respect to space dimension \p var, assigning the result to \p *this.
diff --git a/src/BD_Shape.templates.hh b/src/BD_Shape.templates.hh
index bbb5e1b..57e0672 100644
--- a/src/BD_Shape.templates.hh
+++ b/src/BD_Shape.templates.hh
@@ -4479,6 +4479,44 @@ void BD_Shape<T>::refine_with_linear_form_inequality(
 } // end of refine_with_linear_form_inequality
 
 template <typename T>
+template <typename U>
+void
+BD_Shape<T>
+::export_interval_constraints(U& dest) const {
+  const dimension_type space_dim = space_dimension();
+  if (space_dim > dest.space_dimension())
+    throw std::invalid_argument(
+               "BD_Shape<T>::export_interval_constraints");
+
+  // Expose all the interval constraints.
+  shortest_path_closure_assign();
+
+  if (is_empty()) {
+    dest.set_empty();
+    PPL_ASSERT(OK());
+    return;
+  }
+
+  PPL_DIRTY_TEMP(N, tmp);
+  const DB_Row<N>& dbm_0 = dbm[0];
+  for (dimension_type i = space_dim; i-- > 0; ) {
+    // Set the upper bound.
+    const N& u = dbm_0[i+1];
+    if (!is_plus_infinity(u))
+      dest.restrict_upper(i, u.raw_value());
+
+    // Set the lower bound.
+    const N& negated_l = dbm[i+1][0];
+    if (!is_plus_infinity(negated_l)) {
+      neg_assign_r(tmp, negated_l, ROUND_DOWN);
+      dest.restrict_lower(i, negated_l.raw_value());
+    }
+  }
+
+  PPL_ASSERT(OK());
+}
+
+template <typename T>
 template <typename Interval_Info>
 void
 BD_Shape<T>::left_inhomogeneous_refine(const dimension_type& right_t,




More information about the PPL-devel mailing list