[PPL-devel] [GIT] ppl/ppl(floating_point): Added method export_interval_constraints.
Fabio Bossi
bossi at cs.unipr.it
Thu Sep 23 12:25:16 CEST 2010
Module: ppl/ppl
Branch: floating_point
Commit: 7bd3f0121f60355f34ba32c3a976983ff66607df
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=7bd3f0121f60355f34ba32c3a976983ff66607df
Author: Fabio Bossi <bossi at cs.unipr.it>
Date: Thu Sep 23 12:24:39 2010 +0200
Added method export_interval_constraints.
---
src/Octagonal_Shape.defs.hh | 33 ++++++++++++++++++++++++++++
src/Octagonal_Shape.templates.hh | 44 ++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/src/Octagonal_Shape.defs.hh b/src/Octagonal_Shape.defs.hh
index b84575a..2200ab9 100644
--- a/src/Octagonal_Shape.defs.hh
+++ b/src/Octagonal_Shape.defs.hh
@@ -1805,6 +1805,39 @@ public:
*/
void fold_space_dimensions(const Variables_Set& vars, Variable dest);
+ //! 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;
+
//! Refines \p store with the constraints defining \p *this.
/*!
\param store
diff --git a/src/Octagonal_Shape.templates.hh b/src/Octagonal_Shape.templates.hh
index 4b76797..44c04e2 100644
--- a/src/Octagonal_Shape.templates.hh
+++ b/src/Octagonal_Shape.templates.hh
@@ -7654,6 +7654,50 @@ Octagonal_Shape<T>
PPL_ASSERT(OK());
}
+template <typename T>
+template <typename U>
+void
+Octagonal_Shape<T>
+::export_interval_constraints(U& dest) const {
+ if (space_dim > dest.space_dimension())
+ throw std::invalid_argument(
+ "Octagonal_Shape<T>::export_interval_constraints");
+
+ strong_closure_assign();
+
+ if (marked_empty()) {
+ dest.set_empty();
+ return;
+ }
+
+ PPL_DIRTY_TEMP(N, lbound);
+ PPL_DIRTY_TEMP(N, ubound);
+ for (dimension_type i = space_dim; i-- > 0; ) {
+ const dimension_type ii = 2*i;
+ const dimension_type cii = ii + 1;
+
+ // Set the upper bound.
+ const N& twice_ub = matrix[cii][ii];
+ if (!is_plus_infinity(twice_ub)) {
+ assign_r(ubound, twice_ub, ROUND_NOT_NEEDED);
+ div_2exp_assign_r(ubound, ubound, 1, ROUND_UP);
+ if (!dest.restrict_upper(i, ubound))
+ return;
+ }
+
+ // Set the lower bound.
+ const N& twice_lb = matrix[ii][cii];
+ if (!is_plus_infinity(twice_lb)) {
+ assign_r(lbound, twice_lb, ROUND_NOT_NEEDED);
+ neg_assign_r(lbound, lbound, ROUND_NOT_NEEDED);
+ div_2exp_assign_r(lbound, lbound, 1, ROUND_DOWN);
+ if (!dest.restrict_lower(i, lbound))
+ return;
+ }
+ }
+
+}
+
/*! \relates Parma_Polyhedra_Library::Octagonal_Shape */
template <typename T>
std::ostream&
More information about the PPL-devel
mailing list