PPL  1.2
Congruence_System_inlines.hh
Go to the documentation of this file.
1 /* Congruence_System class implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Congruence_System_inlines_hh
25 #define PPL_Congruence_System_inlines_hh 1
26 
27 #include "Congruence_defs.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 inline const Congruence&
33  return rows[k];
34 }
35 
36 inline dimension_type
38  return rows.size();
39 }
40 
41 inline bool
43  return num_rows() == 0;
44 }
45 
46 inline void
48  PPL_ASSERT(num_rows() >= n);
49  rows.resize(num_rows() - n);
50 }
51 
52 inline void
54  Congruence tmp = cg;
55  insert(tmp, Recycle_Input());
56 }
57 
58 inline void
60  PPL_ASSERT(cg.OK());
61  cg.strong_normalize();
62  PPL_ASSERT(cg.OK());
64  PPL_ASSERT(OK());
65 }
66 
67 inline
69  : rows(),
70  space_dimension_(0),
71  representation_(r) {
72 }
73 
74 inline
76  : rows(),
77  space_dimension_(0),
78  representation_(r) {
79  insert(cg);
80 }
81 
82 inline
84  : rows(),
85  space_dimension_(0),
86  representation_(r) {
87  insert(c);
88 }
89 
90 inline
92  : rows(cgs.rows),
93  space_dimension_(cgs.space_dimension_),
94  representation_(cgs.representation_) {
95 }
96 
97 inline
100  : rows(cgs.rows),
101  space_dimension_(cgs.space_dimension_),
102  representation_(r) {
103  if (cgs.representation() != r) {
104  for (dimension_type i = 0; i < num_rows(); ++i) {
105  rows[i].set_representation(representation());
106  }
107  }
108 }
109 
110 inline
112  : rows(),
113  space_dimension_(d),
114  representation_(r) {
115 }
116 
117 inline
119 }
120 
121 inline Congruence_System&
123  Congruence_System tmp = y;
124  swap(*this, tmp);
125  return *this;
126 }
127 
128 inline Representation
130  return representation_;
131 }
132 
133 inline void
135  if (representation_ == r) {
136  return;
137  }
138  representation_ = r;
139  for (dimension_type i = 0; i < num_rows(); ++i) {
140  rows[i].set_representation(r);
141  }
142  PPL_ASSERT(OK());
143 }
144 
145 inline dimension_type
148 }
149 
150 inline dimension_type
152  return space_dimension_;
153 }
154 
155 inline void
157  rows.clear();
158  space_dimension_ = 0;
159 }
160 
161 inline const Congruence_System&
163  PPL_ASSERT(zero_dim_empty_p != 0);
164  return *zero_dim_empty_p;
165 }
166 
167 inline
169  : i(), csp(0) {
170 }
171 
172 inline
174  : i(y.i), csp(y.csp) {
175 }
176 
177 inline
179 }
180 
183  i = y.i;
184  csp = y.csp;
185  return *this;
186 }
187 
188 inline const Congruence&
190  return *i;
191 }
192 
193 inline const Congruence*
195  return i.operator->();
196 }
197 
200  ++i;
201  skip_forward();
202  return *this;
203 }
204 
207  const const_iterator tmp = *this;
208  operator++();
209  return tmp;
210 }
211 
212 inline bool
214  return i == y.i;
215 }
216 
217 inline bool
219  return i != y.i;
220 }
221 
222 inline
225  const Congruence_System& cgs)
226  : i(iter), csp(&cgs.rows) {
227 }
228 
231  const_iterator i(rows.begin(), *this);
232  i.skip_forward();
233  return i;
234 }
235 
238  const const_iterator i(rows.end(), *this);
239  return i;
240 }
241 
242 inline bool
244  return begin() == end();
245 }
246 
247 inline void
249  using std::swap;
250  swap(rows, y.rows);
253  PPL_ASSERT(OK());
254  PPL_ASSERT(y.OK());
255 }
256 
257 inline memory_size_type
259  return rows.external_memory_in_bytes();
260 }
261 
262 inline memory_size_type
264  return rows.external_memory_in_bytes() + sizeof(*this);
265 }
266 
268 inline void
270  x.m_swap(y);
271 }
272 
273 } // namespace Parma_Polyhedra_Library
274 
275 #endif // !defined(PPL_Congruence_System_inlines_hh)
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
void set_representation(Representation r)
Converts *this to the specified representation.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Congruence_System can handle.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
const Congruence * operator->() const
Indirect member selector.
bool operator!=(const const_iterator &y) const
Returns true if and only if *this and y are different.
void strong_normalize()
Calls normalize, then divides out common factors.
Definition: Congruence.cc:84
const_iterator end() const
Returns the past-the-end const_iterator.
static const Congruence_System & zero_dim_empty()
Returns the system containing only Congruence::zero_dim_false().
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
const_iterator & operator=(const const_iterator &y)
Assignment operator.
const_iterator & operator++()
Prefix increment operator.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Congruence can handle.
const Congruence & operator*() const
Dereference operator.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
const Swapping_Vector< Congruence > * csp
A const pointer to the vector of congruences.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
const Congruence & operator[](dimension_type k) const
Returns a constant reference to the k- th congruence of the system.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
void swap(Congruence_System &x, Congruence_System &y)
Congruence_System & operator=(const Congruence_System &y)
Assignment operator.
static const Congruence_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
The entire library is confined to this namespace.
Definition: version.hh:61
dimension_type num_rows() const
Returns the number of rows in the system.
bool empty() const
Returns true if and only if *this has no congruences.
std::vector< T >::const_iterator const_iterator
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool has_no_rows() const
Returns true if num_rows()==0.
Coefficient c
Definition: PIP_Tree.cc:64
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
Swapping_Vector< Congruence >::const_iterator i
The const iterator over the vector of congruences.
void skip_forward()
*this skips to the next non-trivial congruence.
void m_swap(Congruence_System &y)
Swaps *this with y.
bool operator==(const const_iterator &y) const
Returns true if and only if *this and y are identical.
void clear()
Removes all the congruences and sets the space dimension to 0.