1 /* Grid_Generator_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_Grid_Generator_System_inlines_hh
25 #define PPL_Grid_Generator_System_inlines_hh 1
26
27 #include "Grid_Generator_defs.hh"
28
29 namespace Parma_Polyhedra_Library {
30
31 inline void
set_sorted(bool b)32 Grid_Generator_System::set_sorted(bool b) {
33 sys.set_sorted(b);
34 }
35
36 inline void
unset_pending_rows()37 Grid_Generator_System::unset_pending_rows() {
38 sys.unset_pending_rows();
39 }
40
41 inline void
set_index_first_pending_row(const dimension_type i)42 Grid_Generator_System::set_index_first_pending_row(const dimension_type i) {
43 sys.set_index_first_pending_row(i);
44 }
45
46 inline void
47 Grid_Generator_System
permute_space_dimensions(const std::vector<Variable> & cycle)48 ::permute_space_dimensions(const std::vector<Variable>& cycle) {
49 return sys.permute_space_dimensions(cycle);
50 }
51
52 inline bool
is_equal_to(const Grid_Generator_System & y) const53 Grid_Generator_System::is_equal_to(const Grid_Generator_System& y) const {
54 return (sys == y.sys);
55 }
56
57 inline
Grid_Generator_System(Representation r)58 Grid_Generator_System::Grid_Generator_System(Representation r)
59 : sys(NECESSARILY_CLOSED, r) {
60 sys.set_sorted(false);
61 PPL_ASSERT(space_dimension() == 0);
62 }
63
64 inline
Grid_Generator_System(const Grid_Generator_System & gs)65 Grid_Generator_System::Grid_Generator_System(const Grid_Generator_System& gs)
66 : sys(gs.sys) {
67 }
68
69 inline
Grid_Generator_System(const Grid_Generator_System & gs,Representation r)70 Grid_Generator_System::Grid_Generator_System(const Grid_Generator_System& gs,
71 Representation r)
72 : sys(gs.sys, r) {
73 }
74
75 inline
Grid_Generator_System(dimension_type dim,Representation r)76 Grid_Generator_System::Grid_Generator_System(dimension_type dim,
77 Representation r)
78 : sys(NECESSARILY_CLOSED, r) {
79 sys.set_space_dimension(dim);
80 sys.set_sorted(false);
81 PPL_ASSERT(space_dimension() == dim);
82 }
83
84 inline
Grid_Generator_System(const Grid_Generator & g,Representation r)85 Grid_Generator_System::Grid_Generator_System(const Grid_Generator& g,
86 Representation r)
87 : sys(NECESSARILY_CLOSED, r) {
88 sys.insert(g);
89 sys.set_sorted(false);
90 }
91
92 inline
~Grid_Generator_System()93 Grid_Generator_System::~Grid_Generator_System() {
94 }
95
96 inline Grid_Generator_System&
operator =(const Grid_Generator_System & y)97 Grid_Generator_System::operator=(const Grid_Generator_System& y) {
98 Grid_Generator_System tmp = y;
99 swap(*this, tmp);
100 return *this;
101 }
102
103 inline Representation
representation() const104 Grid_Generator_System::representation() const {
105 return sys.representation();
106 }
107
108 inline void
set_representation(Representation r)109 Grid_Generator_System::set_representation(Representation r) {
110 sys.set_representation(r);
111 }
112
113 inline dimension_type
max_space_dimension()114 Grid_Generator_System::max_space_dimension() {
115 // Grid generators use an extra column for the parameter divisor.
116 return Linear_System<Grid_Generator>::max_space_dimension() - 1;
117 }
118
119 inline dimension_type
space_dimension() const120 Grid_Generator_System::space_dimension() const {
121 return sys.space_dimension();
122 }
123
124 inline const Grid_Generator_System&
zero_dim_univ()125 Grid_Generator_System::zero_dim_univ() {
126 PPL_ASSERT(zero_dim_univ_p != 0);
127 return *zero_dim_univ_p;
128 }
129
130 inline void
clear()131 Grid_Generator_System::clear() {
132 sys.clear();
133 sys.set_sorted(false);
134 sys.unset_pending_rows();
135 PPL_ASSERT(space_dimension() == 0);
136 }
137
138 inline void
m_swap(Grid_Generator_System & y)139 Grid_Generator_System::m_swap(Grid_Generator_System& y) {
140 swap(sys, y.sys);
141 }
142
143 inline memory_size_type
external_memory_in_bytes() const144 Grid_Generator_System::external_memory_in_bytes() const {
145 return sys.external_memory_in_bytes();
146 }
147
148 inline memory_size_type
total_memory_in_bytes() const149 Grid_Generator_System::total_memory_in_bytes() const {
150 return external_memory_in_bytes() + sizeof(*this);
151 }
152
153 inline dimension_type
num_rows() const154 Grid_Generator_System::num_rows() const {
155 return sys.num_rows();
156 }
157
158 inline
const_iterator()159 Grid_Generator_System::const_iterator::const_iterator()
160 : i() {
161 }
162
163 inline
const_iterator(const const_iterator & y)164 Grid_Generator_System::const_iterator::const_iterator(const const_iterator& y)
165 : i(y.i) {
166 }
167
168 inline
~const_iterator()169 Grid_Generator_System::const_iterator::~const_iterator() {
170 }
171
172 inline Grid_Generator_System::const_iterator&
operator =(const const_iterator & y)173 Grid_Generator_System::const_iterator::operator=(const const_iterator& y) {
174 i = y.i;
175 return *this;
176 }
177
178 inline const Grid_Generator&
operator *() const179 Grid_Generator_System::const_iterator::operator*() const {
180 return *i;
181 }
182
183 inline const Grid_Generator*
operator ->() const184 Grid_Generator_System::const_iterator::operator->() const {
185 return i.operator->();
186 }
187
188 inline Grid_Generator_System::const_iterator&
operator ++()189 Grid_Generator_System::const_iterator::operator++() {
190 ++i;
191 return *this;
192 }
193
194 inline Grid_Generator_System::const_iterator
operator ++(int)195 Grid_Generator_System::const_iterator::operator++(int) {
196 const const_iterator tmp = *this;
197 operator++();
198 return tmp;
199 }
200
201 inline bool
202 Grid_Generator_System
operator ==(const const_iterator & y) const203 ::const_iterator::operator==(const const_iterator& y) const {
204 return i == y.i;
205 }
206
207 inline bool
208 Grid_Generator_System
operator !=(const const_iterator & y) const209 ::const_iterator::operator!=(const const_iterator& y) const {
210 return i != y.i;
211 }
212
213 inline bool
empty() const214 Grid_Generator_System::empty() const {
215 return sys.has_no_rows();
216 }
217
218 inline
219 Grid_Generator_System::const_iterator
const_iterator(const Linear_System<Grid_Generator>::const_iterator & y)220 ::const_iterator(const Linear_System<Grid_Generator>::const_iterator& y)
221 : i(y) {
222 }
223
224 inline Grid_Generator_System::const_iterator
begin() const225 Grid_Generator_System::begin() const {
226 return static_cast<Grid_Generator_System::const_iterator>(sys.begin());
227 }
228
229 inline Grid_Generator_System::const_iterator
end() const230 Grid_Generator_System::end() const {
231 return static_cast<Grid_Generator_System::const_iterator>(sys.end());
232 }
233
234 inline const Grid_Generator&
operator [](const dimension_type k) const235 Grid_Generator_System::operator[](const dimension_type k) const {
236 return sys[k];
237 }
238
239 inline bool
has_no_rows() const240 Grid_Generator_System::has_no_rows() const {
241 return sys.has_no_rows();
242 }
243
244 inline void
remove_trailing_rows(dimension_type n)245 Grid_Generator_System::remove_trailing_rows(dimension_type n) {
246 sys.remove_trailing_rows(n);
247 }
248
249 inline void
insert_verbatim(const Grid_Generator & g)250 Grid_Generator_System::insert_verbatim(const Grid_Generator& g) {
251 sys.insert(g);
252 }
253
254 inline Topology
topology() const255 Grid_Generator_System::topology() const {
256 return sys.topology();
257 }
258
259 inline dimension_type
first_pending_row() const260 Grid_Generator_System::first_pending_row() const {
261 return sys.first_pending_row();
262 }
263
264 /*! \relates Grid_Generator_System */
265 inline bool
operator ==(const Grid_Generator_System & x,const Grid_Generator_System & y)266 operator==(const Grid_Generator_System& x,
267 const Grid_Generator_System& y) {
268 return x.is_equal_to(y);
269 }
270
271 /*! \relates Grid_Generator_System */
272 inline void
swap(Grid_Generator_System & x,Grid_Generator_System & y)273 swap(Grid_Generator_System& x, Grid_Generator_System& y) {
274 x.m_swap(y);
275 }
276
277 } // namespace Parma_Polyhedra_Library
278
279 #endif // !defined(PPL_Grid_Generator_System_inlines_hh)
280