00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <ppl-config.h>
00025
00026 #include "C_Polyhedron.defs.hh"
00027 #include "NNC_Polyhedron.defs.hh"
00028 #include "Grid.defs.hh"
00029 #include "algorithms.hh"
00030
00031 namespace PPL = Parma_Polyhedra_Library;
00032
00033 PPL::C_Polyhedron::C_Polyhedron(const NNC_Polyhedron& y, Complexity_Class)
00034 : Polyhedron(NECESSARILY_CLOSED, y.space_dimension(), UNIVERSE) {
00035 const Constraint_System& cs = y.constraints();
00036 for (Constraint_System::const_iterator i = cs.begin(),
00037 cs_end = cs.end(); i != cs_end; ++i) {
00038 const Constraint& c = *i;
00039 add_constraint(c.is_strict_inequality() ? (Linear_Expression(c) >= 0) : c);
00040 }
00041 PPL_ASSERT_HEAVY(OK());
00042 }
00043
00044 PPL::C_Polyhedron::C_Polyhedron(const Congruence_System& cgs)
00045 : Polyhedron(NECESSARILY_CLOSED,
00046 cgs.space_dimension() <= max_space_dimension()
00047 ? cgs.space_dimension()
00048 : (throw_space_dimension_overflow(NECESSARILY_CLOSED,
00049 "C_Polyhedron(cgs)",
00050 "the space dimension of cgs "
00051 "exceeds the maximum allowed "
00052 "space dimension"), 0),
00053 UNIVERSE) {
00054 add_congruences(cgs);
00055 }
00056
00057 PPL::C_Polyhedron::C_Polyhedron(Congruence_System& cgs, Recycle_Input)
00058 : Polyhedron(NECESSARILY_CLOSED,
00059 cgs.space_dimension() <= max_space_dimension()
00060 ? cgs.space_dimension()
00061 : (throw_space_dimension_overflow(NECESSARILY_CLOSED,
00062 "NNC_Polyhedron"
00063 "(cgs, recycle)",
00064 "the space dimension of cgs "
00065 "exceeds the maximum allowed "
00066 "space dimension"), 0),
00067 UNIVERSE) {
00068 add_congruences(cgs);
00069 }
00070
00071 PPL::C_Polyhedron::C_Polyhedron(const Grid& grid, Complexity_Class)
00072 : Polyhedron(NECESSARILY_CLOSED,
00073 grid.space_dimension() <= max_space_dimension()
00074 ? grid.space_dimension()
00075 : (throw_space_dimension_overflow(NECESSARILY_CLOSED,
00076 "C_Polyhedron(grid)",
00077 "the space dimension of grid "
00078 "exceeds the maximum allowed "
00079 "space dimension"), 0),
00080 UNIVERSE) {
00081 add_constraints(grid.constraints());
00082 }
00083
00084 bool
00085 PPL::C_Polyhedron::poly_hull_assign_if_exact(const C_Polyhedron& y) {
00086
00087 if (space_dimension() != y.space_dimension())
00088 throw_dimension_incompatible("poly_hull_assign_if_exact(y)", "y", y);
00089 #define USE_BHZ09 0
00090 #define USE_BFT00 1
00091 #if USE_BHZ09 // [BagnaraHZ09]
00092 return BHZ09_poly_hull_assign_if_exact(y);
00093 #elif USE_BFT00 // [BemporadFT00TR].
00094 return BFT00_poly_hull_assign_if_exact(y);
00095 #else // Old implementation.
00096 return PPL::poly_hull_assign_if_exact(*this, y);
00097 #endif
00098 #undef USE_BHZ09
00099 #undef USE_BFT00
00100 }