PPL  1.2
Grid_Certificate.cc
Go to the documentation of this file.
1 /* Grid_Certificate class implementation
2  (non-inline member functions).
3  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
4  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
5 
6 This file is part of the Parma Polyhedra Library (PPL).
7 
8 The PPL is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The PPL is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
21 
22 For the most up-to-date information see the Parma Polyhedra Library
23 site: http://bugseng.com/products/ppl/ . */
24 
25 #include "ppl-config.h"
26 #include "Grid_Certificate_defs.hh"
27 #include "Grid_defs.hh"
28 #include "assertions.hh"
29 #include <iostream>
30 
31 namespace PPL = Parma_Polyhedra_Library;
32 
34  : num_equalities(0), num_proper_congruences(0) {
35 
36  // As in Polyhedron assume that `gr' contains at least one point.
37  PPL_ASSERT(!gr.marked_empty());
38  if (gr.space_dimension() == 0) {
39  return;
40  }
41  // One of the systems must be in minimal form.
42  if (gr.congruences_are_up_to_date()) {
43  if (gr.congruences_are_minimized()) {
46  }
47  else {
49  // Calculate number of congruences from generators.
51  = gr.gen_sys.num_parameters() + 1 /* Integrality cg. */;
53  }
54  else {
55  // Minimize `gr' congruence system. As in Polyhedron assume
56  // that `gr' contains at least one point.
57  Grid& mgr = const_cast<Grid&>(gr);
58  const bool empty = Grid::simplify(mgr.con_sys, mgr.dim_kinds);
59  // Avoid possible compiler warning.
60  PPL_USED(empty);
61  PPL_ASSERT(!empty);
63 
66  }
67  }
68  }
69  else {
70  if (!gr.generators_are_minimized()) {
71  // Minimize `gr' generator system. As in Polyhedron assume that
72  // `gr' contains at least one point.
73  Grid& mgr = const_cast<Grid&>(gr);
75  // If gen_sys contained rows before being reduced, it should
76  // contain at least a single point afterward.
77  PPL_ASSERT(!mgr.gen_sys.empty());
79  }
80  // Calculate number of congruences from generators.
82  = gr.gen_sys.num_parameters() + 1 /* Integrality cg. */;
84  = gr.space_dimension() + 1 - gr.gen_sys.num_rows();
85  }
86 }
87 
88 int
90  PPL_ASSERT(OK() && y.OK());
91  if (num_equalities == y.num_equalities) {
92  if (num_proper_congruences == y.num_proper_congruences) {
93  return 0;
94  }
95  else {
96  return (num_proper_congruences > y.num_proper_congruences) ? 1 : -1;
97  }
98  }
99  return (num_equalities > y.num_equalities) ? 1 : -1;
100 }
101 
102 int
104  const Grid_Certificate gc(gr);
105  return compare(gc);
106 }
107 
108 bool
110  // There is nothing to test.
111  return true;
112 }
Grid_Generator_System gen_sys
The system of generators.
Definition: Grid_defs.hh:1973
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The convergence certificate for the Grid widening operator.
bool empty() const
Returns true if and only if *this has no generators.
Congruence_System con_sys
The system of congruences.
Definition: Grid_defs.hh:1970
int compare(const Grid_Certificate &y) const
The comparison function for certificates.
dimension_type num_equalities() const
Returns the number of equalities.
static bool simplify(Congruence_System &cgs, Dimension_Kinds &dim_kinds)
Converts cgs to upper triangular (i.e. minimized) form.
bool congruences_are_up_to_date() const
Returns true if the system of congruences is up-to-date.
Definition: Grid_inlines.hh:40
void set_generators_minimized()
Sets status to express that generators are minimized.
Definition: Grid_inlines.hh:76
dimension_type num_proper_congruences() const
Returns the number of proper congruences.
int compare(const Linear_Expression &x, const Linear_Expression &y)
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
Definition: Grid_inlines.hh:45
The entire library is confined to this namespace.
Definition: version.hh:61
bool OK() const
Check if gathered information is meaningful.
bool marked_empty() const
Returns true if the grid is known to be empty.
Definition: Grid_inlines.hh:35
dimension_type num_rows() const
Returns the number of rows (generators) in the system.
bool congruences_are_minimized() const
Returns true if the system of congruences is minimized.
Definition: Grid_inlines.hh:50
#define PPL_USED(v)
No-op macro that allows to avoid unused variable warnings from the compiler.
Definition: compiler.hh:39
dimension_type num_parameters() const
Returns the number of parameters in the system.
bool generators_are_minimized() const
Returns true if the system of generators is minimized.
Definition: Grid_inlines.hh:55
void set_congruences_minimized()
Sets status to express that congruences are minimized.
Definition: Grid_inlines.hh:70