00001 /* Linear_System class declaration. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://www.cs.unipr.it/ppl/ . */ 00023 00024 #ifndef PPL_Linear_System_defs_hh 00025 #define PPL_Linear_System_defs_hh 1 00026 00027 #include "Linear_System.types.hh" 00028 #include "Row.types.hh" 00029 #include "Bit_Row.types.hh" 00030 #include "Bit_Matrix.types.hh" 00031 #include "Matrix.defs.hh" 00032 #include "Topology.hh" 00033 #include "Linear_Row.defs.hh" 00034 00035 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00036 00037 00053 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00054 00055 class Parma_Polyhedra_Library::Linear_System : public Matrix { 00056 public: 00058 00061 Linear_System(Topology topol); 00062 00064 00078 Linear_System(Topology topol, 00079 dimension_type n_rows, dimension_type n_columns); 00080 00081 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00082 00083 00088 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00089 struct With_Pending { 00090 }; 00091 00093 Linear_System(const Linear_System& y); 00094 00096 Linear_System(const Linear_System& y, With_Pending); 00097 00099 Linear_System& operator=(const Linear_System& y); 00100 00102 void assign_with_pending(const Linear_System& y); 00103 00105 void swap(Linear_System& y); 00106 00108 static dimension_type max_space_dimension(); 00109 00111 00119 dimension_type space_dimension() const; 00120 00122 void remove_trailing_columns(dimension_type n); 00123 00125 /* 00126 \param cycles 00127 A vector representing the non-trivial cycles of the permutation 00128 according to which the columns must be rearranged. 00129 00130 The \p cycles vector contains, one after the other, the 00131 non-trivial cycles (i.e., the cycles of length greater than one) 00132 of a permutation of non-zero column indexes. Each cycle is 00133 terminated by zero. For example, assuming the system has 6 00134 columns, the permutation \f$ \{ 1 \mapsto 3, 2 \mapsto 4, 00135 3 \mapsto 6, 4 \mapsto 2, 5 \mapsto 5, 6 \mapsto 1 \}\f$ can be 00136 represented by the non-trivial cycles \f$(1 3 6)(2 4)\f$ that, in 00137 turn can be represented by a vector of 6 elements containing 1, 3, 00138 6, 0, 2, 4, 0. 00139 */ 00140 void permute_columns(const std::vector<dimension_type>& cycles); 00141 00143 00144 00145 Linear_Row& operator[](dimension_type k); 00146 00148 const Linear_Row& operator[](dimension_type k) const; 00150 00152 void strong_normalize(); 00153 00155 void sign_normalize(); 00156 00158 00159 00160 Topology topology() const; 00161 00163 bool is_sorted() const; 00164 00169 bool is_necessarily_closed() const; 00170 00175 dimension_type num_lines_or_equalities() const; 00176 00178 dimension_type first_pending_row() const; 00179 00181 dimension_type num_pending_rows() const; 00183 00188 bool check_sorted() const; 00189 00191 void set_necessarily_closed(); 00192 00194 void set_not_necessarily_closed(); 00195 00197 void set_rows_topology(); 00198 00200 void unset_pending_rows(); 00201 00203 void set_index_first_pending_row(dimension_type i); 00204 00206 void set_sorted(bool b); 00207 00209 00220 void resize_no_copy(dimension_type new_n_rows, dimension_type new_n_columns); 00221 00223 00234 void add_rows_and_columns(dimension_type n); 00235 00240 void insert(const Linear_Row& r); 00241 00246 void insert_pending(const Linear_Row& r); 00247 00249 void add_row(const Linear_Row& r); 00250 00252 void add_pending_row(Linear_Row::Flags flags); 00253 00255 void add_pending_row(const Linear_Row& r); 00256 00258 00261 void add_rows(const Linear_System& y); 00262 00264 void add_pending_rows(const Linear_System& y); 00265 00270 void sort_rows(); 00271 00276 void sort_rows(dimension_type first_row, dimension_type last_row); 00277 00286 void merge_rows_assign(const Linear_System& y); 00287 00292 void sort_pending_and_remove_duplicates(); 00293 00294 class With_Bit_Matrix_iterator; 00295 00303 void sort_and_remove_with_sat(Bit_Matrix& sat); 00304 00306 00317 dimension_type gauss(dimension_type n_lines_or_equalities); 00318 00329 void back_substitute(dimension_type n_lines_or_equalities); 00330 00335 void simplify(); 00336 00341 void normalize(); 00342 00344 void clear(); 00345 00346 PPL_OUTPUT_DECLARATIONS 00347 00358 bool ascii_load(std::istream& s); 00359 00361 memory_size_type total_memory_in_bytes() const; 00362 00364 memory_size_type external_memory_in_bytes() const; 00365 00367 00377 bool OK(bool check_strong_normalized = true) const; 00378 00379 private: 00381 Topology row_topology; 00382 00384 dimension_type index_first_pending; 00385 00391 bool sorted; 00392 00394 struct Row_Less_Than { 00395 bool operator()(const Row& x, const Row& y) const; 00396 }; 00397 }; 00398 00399 namespace std { 00400 00401 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00402 00403 00404 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00405 void swap(Parma_Polyhedra_Library::Linear_System& x, 00406 Parma_Polyhedra_Library::Linear_System& y); 00407 00408 } // namespace std 00409 00410 namespace Parma_Polyhedra_Library { 00411 00412 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00413 00414 00415 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00416 bool operator==(const Linear_System& x, const Linear_System& y); 00417 00418 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00419 00420 00421 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00422 bool operator!=(const Linear_System& x, const Linear_System& y); 00423 00424 } // namespace Parma_Polyhedra_Library 00425 00426 #include "Linear_System.inlines.hh" 00427 00428 #endif // !defined(PPL_Linear_System_defs_hh)
1.6.3