24 #ifndef PPL_Polyhedron_minimize_templates_hh
25 #define PPL_Polyhedron_minimize_templates_hh 1
69 template <
typename Source_Linear_System,
typename Dest_Linear_System>
72 Source_Linear_System& source,
73 Dest_Linear_System& dest,
76 typedef typename Dest_Linear_System::row_type dest_row_type;
79 PPL_ASSERT(source.topology() == dest.topology());
85 PPL_ASSERT(!source.has_no_rows());
88 if (!source.is_sorted()) {
100 : source.space_dimension() + 2;
103 dest.set_space_dimension(source.space_dimension());
117 dest_i.mark_as_not_necessarily_closed();
123 dest.set_sorted(
false);
141 Bit_Matrix tmp_sat(dest_num_rows, source.num_rows());
150 =
conversion(source, 0U, dest, tmp_sat, dest_num_rows);
152 dest_num_rows = dest.num_rows();
156 PPL_ASSERT(dest[i].
OK());
167 if (dest.is_necessarily_closed()) {
168 for (first_point = num_lines_or_equalities;
169 first_point < dest_num_rows;
171 if (dest[first_point].expr.inhomogeneous_term() > 0) {
177 for (first_point = num_lines_or_equalities;
178 first_point < dest_num_rows;
180 if (dest[first_point].expr.get(
Variable(dest.space_dimension())) > 0) {
186 if (first_point == dest_num_rows) {
264 template <
typename Source_Linear_System1,
typename Source_Linear_System2,
265 typename Dest_Linear_System>
268 Source_Linear_System1& source1,
269 Dest_Linear_System& dest,
271 const Source_Linear_System2& source2) {
273 PPL_ASSERT(!source1.has_no_rows() && !source2.has_no_rows());
276 PPL_ASSERT(source1.num_columns() == source2.num_columns());
278 PPL_ASSERT(source1.is_sorted() && source1.num_pending_rows() == 0);
279 PPL_ASSERT(source2.is_sorted() && source2.num_pending_rows() == 0);
280 PPL_ASSERT(dest.num_pending_rows() == 0);
287 while (k1 < old_source1_num_rows && k2 < source2_num_rows) {
294 const int cmp =
compare(source1[k1], source2[k2]);
310 source1.add_pending_row(source2[k2]);
316 if (k2 < source2_num_rows) {
320 for ( ; k2 < source2_num_rows; ++k2) {
321 source1.add_pending_row(source2[k2]);
325 if (source1.num_pending_rows() == 0) {
370 template <
typename Source_Linear_System,
typename Dest_Linear_System>
373 Source_Linear_System& source,
374 Dest_Linear_System& dest,
376 PPL_ASSERT(source.num_pending_rows() > 0);
377 PPL_ASSERT(source.space_dimension() == dest.space_dimension());
378 PPL_ASSERT(source.is_sorted());
382 sat.
resize(dest.num_rows(), source.num_rows());
387 =
conversion(source, source.first_pending_row(),
389 dest.num_lines_or_equalities());
401 if (dest.is_necessarily_closed()) {
402 for (first_point = num_lines_or_equalities;
403 first_point < dest_num_rows;
405 if (dest[first_point].expr.inhomogeneous_term() > 0) {
411 for (first_point = num_lines_or_equalities;
412 first_point < dest_num_rows;
414 if (dest[first_point].expr.get(
Variable(dest.space_dimension())) > 0) {
420 if (first_point == dest_num_rows) {
456 #endif // !defined(PPL_Polyhedron_minimize_templates_hh)
bool minimize() const
Applies (weak) minimization to both the constraints and generators.
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
size_t dimension_type
An unsigned integral type for representing space dimensions.
void resize(dimension_type new_n_rows, dimension_type new_n_columns)
Resizes the matrix copying the old contents.
static dimension_type simplify(Linear_System1 &sys, Bit_Matrix &sat)
Uses Gauss' elimination method to simplify the result of conversion().
A dimension of the vector space.
static dimension_type conversion(Source_Linear_System &source, dimension_type start, Dest_Linear_System &dest, Bit_Matrix &sat, dimension_type num_lines_or_equalities)
Performs the conversion from constraints to generators and vice versa.
int compare(const Linear_Expression &x, const Linear_Expression &y)
The entire library is confined to this namespace.
int cmp(const GMP_Integer &x, const GMP_Integer &y)
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
static bool add_and_minimize(bool con_to_gen, Source_Linear_System1 &source1, Dest_Linear_System &dest, Bit_Matrix &sat, const Source_Linear_System2 &source2)
Adds given constraints and builds minimized corresponding generators or vice versa.
void transpose_assign(const Bit_Matrix &y)
Makes *this a transposed copy of y.