[PPL-devel] [GIT] ppl/ppl(floating_point): Predisposed everything to start implementing our own customized version
Fabio Bossi
bossi at cs.unipr.it
Wed Sep 9 16:37:32 CEST 2009
Module: ppl/ppl
Branch: floating_point
Commit: edf215e958a23f0fe12b06c8f1481deaa7473676
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=edf215e958a23f0fe12b06c8f1481deaa7473676
Author: Fabio Bossi <bossi at cs.unipr.it>
Date: Wed Sep 9 16:33:27 2009 +0200
Predisposed everything to start implementing our own customized version
of method affine_image.
---
src/Octagonal_Shape.defs.hh | 11 ++++++
src/Octagonal_Shape.templates.hh | 64 ++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/src/Octagonal_Shape.defs.hh b/src/Octagonal_Shape.defs.hh
index 5235902..4035b35 100644
--- a/src/Octagonal_Shape.defs.hh
+++ b/src/Octagonal_Shape.defs.hh
@@ -44,6 +44,8 @@ site: http://www.cs.unipr.it/ppl/ . */
#include "Checked_Number.defs.hh"
#include "WRD_coefficient_types.defs.hh"
#include "Bit_Row.defs.hh"
+#include "Interval.types.hh"
+#include "Linear_Form.types.hh"
#include <vector>
#include <cstddef>
#include <climits>
@@ -1104,6 +1106,10 @@ public:
Coefficient_traits::const_reference denominator
= Coefficient_one());
+ template <typename Interval_Info>
+ void affine_image(Variable var,
+ const Linear_Form< Interval<T, Interval_Info> >& lf);
+
/*! \brief
Assigns to \p *this the \ref affine_relation "affine preimage"
of \p *this under the function mapping variable \p var into the
@@ -2106,6 +2112,11 @@ private:
const char* name_row,
const Linear_Expression& y) const;
+ template <typename C>
+ void throw_dimension_incompatible(const char* method,
+ const char* name_row,
+ const Linear_Form<C>& y) const;
+
void throw_constraint_incompatible(const char* method) const;
void throw_expression_too_complex(const char* method,
diff --git a/src/Octagonal_Shape.templates.hh b/src/Octagonal_Shape.templates.hh
index a9590a7..69cf0eb 100644
--- a/src/Octagonal_Shape.templates.hh
+++ b/src/Octagonal_Shape.templates.hh
@@ -27,6 +27,8 @@ site: http://www.cs.unipr.it/ppl/ . */
#include "Generator_System.inlines.hh"
#include "Congruence_System.defs.hh"
#include "Congruence_System.inlines.hh"
+#include "Interval.defs.hh"
+#include "Linear_Form.defs.hh"
#include "meta_programming.hh"
#include "assert.hh"
#include <vector>
@@ -4670,6 +4672,54 @@ Octagonal_Shape<T>::affine_image(const Variable var,
}
template <typename T>
+template <typename Interval_Info>
+void
+Octagonal_Shape<T>::affine_image(Variable var,
+ const Linear_Form< Interval<T, Interval_Info> >& lf) {
+ /*
+ FIXME: this way for checking that T is a floating point type is a bit
+ unelengant.
+ */
+ // Check that T is a floating point type.
+ PPL_ASSERT(std::numeric_limits<T>::max_exponent);
+
+ // Dimension-compatibility checks.
+ // The dimension of `lf' should not be greater than the dimension
+ // of `*this'.
+ const dimension_type lf_space_dim = lf.space_dimension();
+ if (space_dim < lf_space_dim)
+ throw_dimension_incompatible("affine_image(v, l)", "l", lf);
+
+ // `var' should be one of the dimensions of the octagon.
+ const dimension_type var_id = var.id();
+ if (space_dim < var_id + 1)
+ throw_dimension_incompatible("affine_image(v, l)", var.id()+1);
+
+ strong_closure_assign();
+ // The image of an empty octagon is empty too.
+ if (marked_empty())
+ return;
+
+ // Number of non-zero coefficients in `lf': will be set to
+ // 0, 1, or 2, the latter value meaning any value greater than 1.
+ dimension_type t = 0;
+ // Variable-index of the last non-zero coefficient in `lf', if any.
+ dimension_type w_id = 0;
+
+ // Get information about the number of non-zero coefficients in `lf'.
+ for (dimension_type i = lf_space_dim; i-- > 0; )
+ if (lf.coefficient(Variable(i)) != 0) {
+ if (t++ == 1)
+ break;
+ else
+ w_id = i;
+ }
+
+ // FIXME: complete the implementation.
+
+}
+
+template <typename T>
void
Octagonal_Shape<T>::affine_preimage(const Variable var,
const Linear_Expression& expr,
@@ -7065,6 +7115,20 @@ Octagonal_Shape<T>
throw std::invalid_argument(s.str());
}
+template <typename T>
+template <typename C>
+void
+Octagonal_Shape<T>
+::throw_dimension_incompatible(const char* method,
+ const char* name_row,
+ const Linear_Form<C>& y) const {
+ std::ostringstream s;
+ s << "PPL::Octagonal_Shape::" << method << ":\n"
+ << "this->space_dimension() == " << space_dimension()
+ << ", " << name_row << "->space_dimension() == "
+ << y.space_dimension() << ".";
+ throw std::invalid_argument(s.str());
+}
template <typename T>
void
More information about the PPL-devel
mailing list