[GIT] ppl/ppl(master): Implemented the constructors from generator systems.

Module: ppl/ppl Branch: master Commit: 39c378347808c8a522f00b53cc8eac1123486229 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=39c378347808c...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Sun Aug 1 18:30:57 2010 +0200
Implemented the constructors from generator systems.
---
src/Affine_Space.cc | 76 +++++++++++++++++++++++++++++++------------ src/Affine_Space.defs.hh | 39 +--------------------- src/Affine_Space.inlines.hh | 29 ++++++++++++---- 3 files changed, 79 insertions(+), 65 deletions(-)
diff --git a/src/Affine_Space.cc b/src/Affine_Space.cc index cfd81e1..75087b7 100644 --- a/src/Affine_Space.cc +++ b/src/Affine_Space.cc @@ -23,33 +23,67 @@ site: http://www.cs.unipr.it/ppl/ . */ #include <ppl-config.h>
#include "Affine_Space.defs.hh" -#if 0 -#include "Topology.hh" -#include "Scalar_Products.defs.hh" - -#include "assert.hh" -#endif #include <iostream>
namespace PPL = Parma_Polyhedra_Library;
-PPL::Affine_Space::Affine_Space(const Affine_Space& y, - Complexity_Class complexity) - : gr(y.gr, complexity) { -} - -PPL::Affine_Space::Affine_Space(const Constraint_System& cs) - : gr(cs) { -} - -PPL::Affine_Space::Affine_Space(Constraint_System& cs, Recycle_Input ri) - : gr(cs, ri) { +PPL::Affine_Space::Affine_Space(const Generator_System& gs) { + dimension_type space_dim = gs.space_dimension(); + // First find a point or closure point and convert it to a + // grid point and add to the (initially empty) set of grid generators. + Grid_Generator_System ggs(space_dim); + Linear_Expression point_expr; + PPL_DIRTY_TEMP_COEFFICIENT(point_divisor); + for (Generator_System::const_iterator g = gs.begin(), + gs_end = gs.end(); g != gs_end; ++g) { + if (g->is_ray()) + throw std::invalid_argument("Affine_Space::Affine_Space(gs):\n" + "gs contains rays."); + else if (g->is_point() || g->is_closure_point()) { + for (dimension_type i = space_dim; i-- > 0; ) { + const Variable v(i); + point_expr += g->coefficient(v) * v; + point_divisor = g->divisor(); + } + ggs.insert(grid_point(point_expr, point_divisor)); + goto non_empty; + } + } + // No (closure) point was found. + Grid(EMPTY).swap(gr); + return; + + non_empty: + // Add a grid line for each line. If the generator is a (closure) + // point, the grid line must have the direction given by a line + // that joins the grid point already inserted and the new point. + PPL_DIRTY_TEMP_COEFFICIENT(coeff); + PPL_DIRTY_TEMP_COEFFICIENT(g_divisor); + for (Generator_System::const_iterator g = gs.begin(), + gs_end = gs.end(); g != gs_end; ++g) { + Linear_Expression e; + if (g->is_point() || g->is_closure_point()) { + g_divisor = g->divisor(); + for (dimension_type i = space_dim; i-- > 0; ) { + const Variable v(i); + coeff = point_expr.coefficient(v) * g_divisor; + coeff -= g->coefficient(v) * point_divisor; + e += coeff * v; + } + if (e.all_homogeneous_terms_are_zero()) + continue; + } + else + for (dimension_type i = space_dim; i-- > 0; ) { + const Variable v(i); + e += g->coefficient(v) * v; + } + ggs.insert(grid_line(e)); + } + Grid(ggs).swap(gr); + PPL_ASSERT(OK()); }
-PPL::Affine_Space::Affine_Space(const Polyhedron& ph, - Complexity_Class complexity) - : gr(ph, complexity) { -}
PPL::Affine_Space& PPL::Affine_Space::operator=(const Affine_Space& y) { diff --git a/src/Affine_Space.defs.hh b/src/Affine_Space.defs.hh index c7bc820..fa42333 100644 --- a/src/Affine_Space.defs.hh +++ b/src/Affine_Space.defs.hh @@ -24,30 +24,20 @@ site: http://www.cs.unipr.it/ppl/ . */ #define PPL_Affine_Space_defs_hh 1
#include "Affine_Space.types.hh" -#if 0 -#include "globals.defs.hh" #include "Variable.defs.hh" #include "Variables_Set.types.hh" -#include "Linear_Expression.defs.hh" -#include "Constraint.defs.hh" +#include "Linear_Expression.types.hh" +#include "Constraint.types.hh" #include "Constraint_System.defs.hh" #include "Constraint_System.inlines.hh" #include "Congruence_System.defs.hh" #include "Congruence_System.inlines.hh" -#include "Grid_Generator_System.defs.hh" -#include "Grid_Generator_System.inlines.hh" -#include "Grid_Generator.types.hh" #include "Poly_Con_Relation.defs.hh" #include "Poly_Gen_Relation.defs.hh" -#include "Grid_Certificate.types.hh" #include "Box.types.hh" -#include "Polyhedron.defs.hh" #include "Polyhedron.types.hh" -#include "Polyhedron.inlines.hh" #include "BD_Shape.types.hh" #include "Octagonal_Shape.types.hh" -#include <vector> -#endif #include "Grid.defs.hh" #include <iosfwd>
@@ -1696,31 +1686,6 @@ protected: void throw_dimension_incompatible(const char* method, const char* as_name, const Affine_Space& as) const; -#if 0 - void throw_dimension_incompatible(const char* method, - const char* e_name, - const Linear_Expression& e) const; - void throw_dimension_incompatible(const char* method, - const char* cg_name, - const Congruence& cg) const; - void throw_dimension_incompatible(const char* method, - const char* c_name, - const Constraint& c) const; - void throw_dimension_incompatible(const char* method, - const char* g_name, - const Generator& g) const; - void throw_dimension_incompatible(const char* method, - const char* cgs_name, - const Congruence_System& cgs) const; - void throw_dimension_incompatible(const char* method, - const char* cs_name, - const Constraint_System& cs) const; - void throw_dimension_incompatible(const char* method, - const char* var_name, - Variable var) const; - void throw_dimension_incompatible(const char* method, - dimension_type required_space_dim) const; -#endif
// Note: it has to be a static method, because it can be called inside // constructors (before actually constructing the grid object). diff --git a/src/Affine_Space.inlines.hh b/src/Affine_Space.inlines.hh index 97a65d2..1b4f595 100644 --- a/src/Affine_Space.inlines.hh +++ b/src/Affine_Space.inlines.hh @@ -37,16 +37,31 @@ Affine_Space::Affine_Space(dimension_type num_dimensions, }
inline -Affine_Space::Affine_Space(const Generator_System& /*gs*/) { - // FIXME(0.11): implement by building the grid generators. - // Throw std::invalid_argument if `gs' contains rays. - abort(); +Affine_Space::Affine_Space(const Affine_Space& y, + Complexity_Class complexity) + : gr(y.gr, complexity) { +} + +inline +Affine_Space::Affine_Space(const Constraint_System& cs) + : gr(cs) { +} + +inline +Affine_Space::Affine_Space(Constraint_System& cs, Recycle_Input ri) + : gr(cs, ri) { +} + +inline +Affine_Space::Affine_Space(const Polyhedron& ph, + Complexity_Class complexity) + : gr(ph, complexity) { }
inline -Affine_Space::Affine_Space(Generator_System& /*gs*/, Recycle_Input) { - // FIXME(0.11): implement by building the grid generators. - abort(); +Affine_Space::Affine_Space(Generator_System& gs, Recycle_Input) + : gr(EMPTY) { + Affine_Space(gs).swap(*this); }
template <typename U>
participants (1)
-
Roberto Bagnara