00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_Linear_System_inlines_hh
00025 #define PPL_Linear_System_inlines_hh 1
00026
00027 #include "Bit_Row.defs.hh"
00028
00029 namespace Parma_Polyhedra_Library {
00030
00031 inline memory_size_type
00032 Linear_System::external_memory_in_bytes() const {
00033 return Matrix::external_memory_in_bytes();
00034 }
00035
00036 inline memory_size_type
00037 Linear_System::total_memory_in_bytes() const {
00038 return sizeof(*this) + external_memory_in_bytes();
00039 }
00040
00041 inline bool
00042 Linear_System::is_sorted() const {
00043
00044
00045
00046
00047 PPL_ASSERT(!sorted || check_sorted());
00048 return sorted;
00049 }
00050
00051 inline void
00052 Linear_System::set_sorted(const bool b) {
00053 sorted = b;
00054 }
00055
00056 inline
00057 Linear_System::Linear_System(Topology topol)
00058 : Matrix(),
00059 row_topology(topol),
00060 index_first_pending(0),
00061 sorted(true) {
00062 }
00063
00064 inline
00065 Linear_System::Linear_System(Topology topol,
00066 dimension_type n_rows, dimension_type n_columns)
00067 : Matrix(n_rows, n_columns, Linear_Row::Flags(topol)),
00068 row_topology(topol),
00069 index_first_pending(n_rows),
00070 sorted(true) {
00071 }
00072
00073 inline dimension_type
00074 Linear_System::first_pending_row() const {
00075 return index_first_pending;
00076 }
00077
00078 inline dimension_type
00079 Linear_System::num_pending_rows() const {
00080 PPL_ASSERT(num_rows() >= first_pending_row());
00081 return num_rows() - first_pending_row();
00082 }
00083
00084 inline void
00085 Linear_System::unset_pending_rows() {
00086 index_first_pending = num_rows();
00087 }
00088
00089 inline void
00090 Linear_System::set_index_first_pending_row(const dimension_type i) {
00091 index_first_pending = i;
00092 }
00093
00094 inline
00095 Linear_System::Linear_System(const Linear_System& y)
00096 : Matrix(y),
00097 row_topology(y.row_topology) {
00098 unset_pending_rows();
00099
00100 sorted = (y.num_pending_rows() > 0) ? false : y.sorted;
00101 PPL_ASSERT(num_pending_rows() == 0);
00102 }
00103
00104 inline
00105 Linear_System::Linear_System(const Linear_System& y, With_Pending)
00106 : Matrix(y),
00107 row_topology(y.row_topology),
00108 index_first_pending(y.index_first_pending),
00109 sorted(y.sorted) {
00110 }
00111
00112 inline Linear_System&
00113 Linear_System::operator=(const Linear_System& y) {
00114 Matrix::operator=(y);
00115 row_topology = y.row_topology;
00116 unset_pending_rows();
00117
00118 sorted = (y.num_pending_rows() > 0) ? false : y.sorted;
00119 PPL_ASSERT(num_pending_rows() == 0);
00120 return *this;
00121 }
00122
00123 inline void
00124 Linear_System::assign_with_pending(const Linear_System& y) {
00125 Matrix::operator=(y);
00126 row_topology = y.row_topology;
00127 index_first_pending = y.index_first_pending;
00128 sorted = y.sorted;
00129 }
00130
00131 inline void
00132 Linear_System::swap(Linear_System& y) {
00133 Matrix::swap(y);
00134 std::swap(row_topology, y.row_topology);
00135 std::swap(index_first_pending, y.index_first_pending);
00136 std::swap(sorted, y.sorted);
00137 }
00138
00139 inline void
00140 Linear_System::clear() {
00141
00142 Matrix::clear();
00143 index_first_pending = 0;
00144 sorted = true;
00145 }
00146
00147 inline void
00148 Linear_System::resize_no_copy(const dimension_type new_n_rows,
00149 const dimension_type new_n_columns) {
00150 Matrix::resize_no_copy(new_n_rows, new_n_columns,
00151 Linear_Row::Flags(row_topology));
00152
00153
00154
00155
00156 set_sorted(false);
00157 }
00158
00159 inline void
00160 Linear_System::set_necessarily_closed() {
00161 row_topology = NECESSARILY_CLOSED;
00162 if (!has_no_rows())
00163 set_rows_topology();
00164 }
00165
00166 inline void
00167 Linear_System::set_not_necessarily_closed() {
00168 row_topology = NOT_NECESSARILY_CLOSED;
00169 if (!has_no_rows())
00170 set_rows_topology();
00171 }
00172
00173 inline bool
00174 Linear_System::is_necessarily_closed() const {
00175 return row_topology == NECESSARILY_CLOSED;
00176 }
00177
00178 inline Linear_Row&
00179 Linear_System::operator[](const dimension_type k) {
00180 return static_cast<Linear_Row&>(Matrix::operator[](k));
00181 }
00182
00183 inline const Linear_Row&
00184 Linear_System::operator[](const dimension_type k) const {
00185 return static_cast<const Linear_Row&>(Matrix::operator[](k));
00186 }
00187
00188 inline Topology
00189 Linear_System::topology() const {
00190 return row_topology;
00191 }
00192
00193 inline dimension_type
00194 Linear_System::max_space_dimension() {
00195
00196
00197
00198 return max_num_columns() - 2;
00199 }
00200
00201 inline dimension_type
00202 Linear_System::space_dimension() const {
00203 const dimension_type n_columns = num_columns();
00204 return (n_columns == 0)
00205 ? 0
00206 : n_columns - (is_necessarily_closed() ? 1 : 2);
00207 }
00208
00209 inline void
00210 Linear_System::remove_trailing_columns(const dimension_type n) {
00211 Matrix::remove_trailing_columns(n);
00212
00213
00214 strong_normalize();
00215 }
00216
00217 inline void
00218 Linear_System::permute_columns(const std::vector<dimension_type>& cycles) {
00219 Matrix::permute_columns(cycles);
00220
00221
00222 sign_normalize();
00223 }
00224
00226 inline bool
00227 operator!=(const Linear_System& x, const Linear_System& y) {
00228 return !(x == y);
00229 }
00230
00231 inline bool
00232 Linear_System::Row_Less_Than::operator()(const Row& x, const Row& y) const {
00233 return compare(static_cast<const Linear_Row&>(x),
00234 static_cast<const Linear_Row&>(y)) < 0;
00235 }
00236
00237 }
00238
00239 namespace std {
00240
00242 inline void
00243 swap(Parma_Polyhedra_Library::Linear_System& x,
00244 Parma_Polyhedra_Library::Linear_System& y) {
00245 x.swap(y);
00246 }
00247
00248 }
00249
00250 #endif // !defined(PPL_Linear_System_inlines_hh)