00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_Linear_System_inlines_hh
00024 #define PPL_Linear_System_inlines_hh 1
00025
00026 #include "Bit_Row.defs.hh"
00027
00028 namespace Parma_Polyhedra_Library {
00029
00030 inline memory_size_type
00031 Linear_System::external_memory_in_bytes() const {
00032 return Matrix::external_memory_in_bytes();
00033 }
00034
00035 inline memory_size_type
00036 Linear_System::total_memory_in_bytes() const {
00037 return sizeof(*this) + external_memory_in_bytes();
00038 }
00039
00040 inline bool
00041 Linear_System::is_sorted() const {
00042
00043
00044
00045
00046 assert(!sorted || check_sorted());
00047 return sorted;
00048 }
00049
00050 inline void
00051 Linear_System::set_sorted(const bool b) {
00052 sorted = b;
00053 }
00054
00055 inline
00056 Linear_System::Linear_System(Topology topol)
00057 : Matrix(),
00058 row_topology(topol),
00059 index_first_pending(0),
00060 sorted(true) {
00061 }
00062
00063 inline
00064 Linear_System::Linear_System(Topology topol,
00065 dimension_type n_rows, dimension_type n_columns)
00066 : Matrix(n_rows, n_columns, Linear_Row::Flags(topol)),
00067 row_topology(topol),
00068 index_first_pending(n_rows),
00069 sorted(true) {
00070 }
00071
00072 inline dimension_type
00073 Linear_System::first_pending_row() const {
00074 return index_first_pending;
00075 }
00076
00077 inline dimension_type
00078 Linear_System::num_pending_rows() const {
00079 assert(num_rows() >= first_pending_row());
00080 return num_rows() - first_pending_row();
00081 }
00082
00083 inline void
00084 Linear_System::unset_pending_rows() {
00085 index_first_pending = num_rows();
00086 }
00087
00088 inline void
00089 Linear_System::set_index_first_pending_row(const dimension_type i) {
00090 index_first_pending = i;
00091 }
00092
00093 inline
00094 Linear_System::Linear_System(const Linear_System& y)
00095 : Matrix(y),
00096 row_topology(y.row_topology) {
00097 unset_pending_rows();
00098
00099 sorted = (y.num_pending_rows() > 0) ? false : y.sorted;
00100 assert(num_pending_rows() == 0);
00101 }
00102
00103 inline
00104 Linear_System::Linear_System(const Linear_System& y, With_Pending)
00105 : Matrix(y),
00106 row_topology(y.row_topology),
00107 index_first_pending(y.index_first_pending),
00108 sorted(y.sorted) {
00109 }
00110
00111 inline Linear_System&
00112 Linear_System::operator=(const Linear_System& y) {
00113 Matrix::operator=(y);
00114 row_topology = y.row_topology;
00115 unset_pending_rows();
00116
00117 sorted = (y.num_pending_rows() > 0) ? false : y.sorted;
00118 assert(num_pending_rows() == 0);
00119 return *this;
00120 }
00121
00122 inline void
00123 Linear_System::assign_with_pending(const Linear_System& y) {
00124 Matrix::operator=(y);
00125 row_topology = y.row_topology;
00126 index_first_pending = y.index_first_pending;
00127 sorted = y.sorted;
00128 }
00129
00130 inline void
00131 Linear_System::swap(Linear_System& y) {
00132 Matrix::swap(y);
00133 std::swap(row_topology, y.row_topology);
00134 std::swap(index_first_pending, y.index_first_pending);
00135 std::swap(sorted, y.sorted);
00136 }
00137
00138 inline void
00139 Linear_System::clear() {
00140
00141 Matrix::clear();
00142 index_first_pending = 0;
00143 sorted = true;
00144 }
00145
00146 inline void
00147 Linear_System::resize_no_copy(const dimension_type new_n_rows,
00148 const dimension_type new_n_columns) {
00149 Matrix::resize_no_copy(new_n_rows, new_n_columns,
00150 Linear_Row::Flags(row_topology));
00151
00152
00153
00154
00155 set_sorted(false);
00156 }
00157
00158 inline void
00159 Linear_System::set_necessarily_closed() {
00160 row_topology = NECESSARILY_CLOSED;
00161 if (!has_no_rows())
00162 set_rows_topology();
00163 }
00164
00165 inline void
00166 Linear_System::set_not_necessarily_closed() {
00167 row_topology = NOT_NECESSARILY_CLOSED;
00168 if (!has_no_rows())
00169 set_rows_topology();
00170 }
00171
00172 inline bool
00173 Linear_System::is_necessarily_closed() const {
00174 return row_topology == NECESSARILY_CLOSED;
00175 }
00176
00177 inline Linear_Row&
00178 Linear_System::operator[](const dimension_type k) {
00179 return static_cast<Linear_Row&>(Matrix::operator[](k));
00180 }
00181
00182 inline const Linear_Row&
00183 Linear_System::operator[](const dimension_type k) const {
00184 return static_cast<const Linear_Row&>(Matrix::operator[](k));
00185 }
00186
00187 inline Topology
00188 Linear_System::topology() const {
00189 return row_topology;
00190 }
00191
00192 inline dimension_type
00193 Linear_System::max_space_dimension() {
00194
00195
00196
00197 return max_num_columns() - 2;
00198 }
00199
00200 inline dimension_type
00201 Linear_System::space_dimension() const {
00202 const dimension_type n_columns = num_columns();
00203 return (n_columns == 0)
00204 ? 0
00205 : n_columns - (is_necessarily_closed() ? 1 : 2);
00206 }
00207
00208 inline void
00209 Linear_System::remove_trailing_columns(const dimension_type n) {
00210 Matrix::remove_trailing_columns(n);
00211
00212
00213 strong_normalize();
00214 }
00215
00216 inline void
00217 Linear_System::permute_columns(const std::vector<dimension_type>& cycles) {
00218 Matrix::permute_columns(cycles);
00219
00220
00221 sign_normalize();
00222 }
00223
00225 inline bool
00226 operator!=(const Linear_System& x, const Linear_System& y) {
00227 return !(x == y);
00228 }
00229
00230 inline bool
00231 Linear_System::Row_Less_Than::operator()(const Row& x, const Row& y) const {
00232 return compare(static_cast<const Linear_Row&>(x),
00233 static_cast<const Linear_Row&>(y)) < 0;
00234 }
00235
00236 }
00237
00238 namespace std {
00239
00241 inline void
00242 swap(Parma_Polyhedra_Library::Linear_System& x,
00243 Parma_Polyhedra_Library::Linear_System& y) {
00244 x.swap(y);
00245 }
00246
00247 }
00248
00249
00250 namespace Parma_Polyhedra_Library {
00251
00252 inline
00253 Linear_System::With_Bit_Matrix_iterator::
00254 With_Bit_Matrix_iterator(Iter1 iter1, Iter2 iter2)
00255 : i1(iter1), i2(iter2) {
00256 }
00257
00258 inline
00259 Linear_System::With_Bit_Matrix_iterator::
00260 With_Bit_Matrix_iterator(const With_Bit_Matrix_iterator& y)
00261 : i1(y.i1), i2(y.i2) {
00262 }
00263
00264 inline
00265 Linear_System::With_Bit_Matrix_iterator::
00266 ~With_Bit_Matrix_iterator() {
00267 }
00268
00269 inline Linear_System::With_Bit_Matrix_iterator&
00270 Linear_System::With_Bit_Matrix_iterator::
00271 operator=(const With_Bit_Matrix_iterator& y) {
00272 i1 = y.i1;
00273 i2 = y.i2;
00274 return *this;
00275 }
00276
00277 inline Linear_System::With_Bit_Matrix_iterator&
00278 Linear_System::With_Bit_Matrix_iterator::operator++() {
00279 ++i1;
00280 ++i2;
00281 return *this;
00282 }
00283
00284 inline Linear_System::With_Bit_Matrix_iterator
00285 Linear_System::With_Bit_Matrix_iterator::operator++(int) {
00286 With_Bit_Matrix_iterator tmp = *this;
00287 operator++();
00288 return tmp;
00289 }
00290
00291 inline Linear_System::With_Bit_Matrix_iterator&
00292 Linear_System::With_Bit_Matrix_iterator::operator--() {
00293 --i1;
00294 --i2;
00295 return *this;
00296 }
00297
00298 inline Linear_System::With_Bit_Matrix_iterator
00299 Linear_System::With_Bit_Matrix_iterator::operator--(int) {
00300 With_Bit_Matrix_iterator tmp = *this;
00301 operator--();
00302 return tmp;
00303 }
00304
00305 inline Linear_System::With_Bit_Matrix_iterator&
00306 Linear_System::With_Bit_Matrix_iterator::operator+=(difference_type d) {
00307 i1 += d;
00308 i2 += d;
00309 return *this;
00310 }
00311
00312 inline Linear_System::With_Bit_Matrix_iterator
00313 Linear_System::With_Bit_Matrix_iterator::
00314 operator+(difference_type d) const {
00315 With_Bit_Matrix_iterator tmp = *this;
00316 tmp += d;
00317 return tmp;
00318 }
00319
00320 inline Linear_System::With_Bit_Matrix_iterator&
00321 Linear_System::With_Bit_Matrix_iterator::operator-=(difference_type d) {
00322 i1 -= d;
00323 i2 -= d;
00324 return *this;
00325 }
00326
00327 inline Linear_System::With_Bit_Matrix_iterator
00328 Linear_System::With_Bit_Matrix_iterator::
00329 operator-(difference_type d) const {
00330 With_Bit_Matrix_iterator tmp = *this;
00331 tmp -= d;
00332 return tmp;
00333 }
00334
00335 inline Linear_System::With_Bit_Matrix_iterator::difference_type
00336 Linear_System::With_Bit_Matrix_iterator::
00337 operator-(const With_Bit_Matrix_iterator& y) const {
00338 return i1 - y.i1;
00339 }
00340
00341 inline bool
00342 Linear_System::With_Bit_Matrix_iterator::
00343 operator==(const With_Bit_Matrix_iterator& y) const {
00344 return i1 == y.i1;
00345 }
00346
00347 inline bool
00348 Linear_System::With_Bit_Matrix_iterator::
00349 operator!=(const With_Bit_Matrix_iterator& y) const {
00350 return i1 != y.i1;
00351 }
00352
00353 inline bool
00354 Linear_System::With_Bit_Matrix_iterator::
00355 operator<(const With_Bit_Matrix_iterator& y) const {
00356 return i1 < y.i1;
00357 }
00358
00359 inline Linear_System::With_Bit_Matrix_iterator::reference
00360 Linear_System::With_Bit_Matrix_iterator::operator*() const {
00361 return *i1;
00362 }
00363
00364 inline Linear_System::With_Bit_Matrix_iterator::pointer
00365 Linear_System::With_Bit_Matrix_iterator::operator->() const {
00366 return &*i1;
00367 }
00368
00369 inline void
00370 Linear_System::With_Bit_Matrix_iterator::
00371 iter_swap(const With_Bit_Matrix_iterator& y) const {
00372 std::iter_swap(i1, y.i1);
00373 std::iter_swap(i2, y.i2);
00374 }
00375
00376 }
00377
00378 namespace std {
00379
00380 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00381
00382 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00383 inline void
00384 iter_swap(Parma_Polyhedra_Library
00385 ::Linear_System::With_Bit_Matrix_iterator x,
00386 Parma_Polyhedra_Library
00387 ::Linear_System::With_Bit_Matrix_iterator y) {
00388 x.iter_swap(y);
00389 }
00390
00391 }
00392
00393 #endif // !defined(PPL_Linear_System_inlines_hh)