00001 /* Bit_Matrix class declaration. 00002 Copyright (C) 2001-2008 Roberto Bagnara <bagnara@cs.unipr.it> 00003 00004 This file is part of the Parma Polyhedra Library (PPL). 00005 00006 The PPL is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by the 00008 Free Software Foundation; either version 3 of the License, or (at your 00009 option) any later version. 00010 00011 The PPL is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software Foundation, 00018 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00019 00020 For the most up-to-date information see the Parma Polyhedra Library 00021 site: http://www.cs.unipr.it/ppl/ . */ 00022 00023 #ifndef PPL_Bit_Matrix_defs_hh 00024 #define PPL_Bit_Matrix_defs_hh 1 00025 00026 #include "Bit_Matrix.types.hh" 00027 #include "Linear_System.defs.hh" 00028 #include "Bit_Row.defs.hh" 00029 #include <vector> 00030 #include <iosfwd> 00031 00032 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00034 00035 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00036 class Parma_Polyhedra_Library::Bit_Matrix { 00037 public: 00039 Bit_Matrix(); 00040 00042 Bit_Matrix(dimension_type n_rows, dimension_type n_columns); 00043 00045 Bit_Matrix(const Bit_Matrix& y); 00046 00048 ~Bit_Matrix(); 00049 00051 Bit_Matrix& operator=(const Bit_Matrix& y); 00052 00054 void swap(Bit_Matrix& y); 00055 00057 Bit_Row& operator[](dimension_type k); 00058 00060 const Bit_Row& operator[](dimension_type k) const; 00061 00063 void clear(); 00064 00066 void transpose(); 00067 00069 void transpose_assign(const Bit_Matrix& y); 00070 00072 static dimension_type max_num_rows(); 00073 00075 dimension_type num_columns() const; 00076 00078 dimension_type num_rows() const; 00079 00081 void sort_rows(); 00082 00084 00094 bool sorted_contains(const Bit_Row& row) const; 00095 00097 void add_row(const Bit_Row& row); 00098 00100 void rows_erase_to_end(dimension_type first_to_erase); 00101 00103 void columns_erase_to_end(dimension_type first_to_erase); 00104 00106 void resize(dimension_type new_n_rows, dimension_type new_n_columns); 00107 00109 bool OK() const; 00110 00111 PPL_OUTPUT_DECLARATIONS 00112 00118 bool ascii_load(std::istream& s); 00119 00121 memory_size_type total_memory_in_bytes() const; 00122 00124 memory_size_type external_memory_in_bytes() const; 00125 00126 #ifndef NDEBUG 00128 bool check_sorted() const; 00129 #endif 00130 00131 private: 00133 std::vector<Bit_Row> rows; 00134 00136 dimension_type row_size; 00137 00139 00140 struct Bit_Row_Less_Than { 00141 bool operator()(const Bit_Row& x, const Bit_Row& y) const; 00142 }; 00143 00144 friend 00145 void Parma_Polyhedra_Library:: 00146 Linear_System::sort_and_remove_with_sat(Bit_Matrix& sat); 00147 00148 }; 00149 00150 namespace Parma_Polyhedra_Library { 00151 00152 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00154 00155 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00156 bool operator==(const Bit_Matrix& x, const Bit_Matrix& y); 00157 00158 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00160 00161 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00162 bool operator!=(const Bit_Matrix& x, const Bit_Matrix& y); 00163 00164 } // namespace Parma_Polyhedra_Library 00165 00166 namespace std { 00167 00168 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS 00170 00171 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) 00172 void swap(Parma_Polyhedra_Library::Bit_Matrix& x, 00173 Parma_Polyhedra_Library::Bit_Matrix& y); 00174 00175 } // namespace std 00176 00177 #include "Bit_Matrix.inlines.hh" 00178 00179 #endif // !defined(PPL_Bit_Matrix_defs_hh)