The base class for the square matrices. More...
#include <DB_Matrix.defs.hh>

Classes | |
| class | const_iterator |
| A read-only iterator over the rows of the matrix. More... | |
Public Member Functions | |
| DB_Matrix () | |
| Builds an empty matrix. | |
| DB_Matrix (dimension_type n_rows) | |
| Builds a square matrix having the specified dimension. | |
| DB_Matrix (const DB_Matrix &y) | |
| Copy constructor. | |
| template<typename U > | |
| DB_Matrix (const DB_Matrix< U > &y) | |
Constructs a conservative approximation of y. | |
| ~DB_Matrix () | |
| Destructor. | |
| DB_Matrix & | operator= (const DB_Matrix &y) |
| Assignment operator. | |
| const_iterator | begin () const |
Returns the const_iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator. | |
| const_iterator | end () const |
| Returns the past-the-end const_iterator. | |
| void | swap (DB_Matrix &y) |
Swaps *this with y. | |
| void | grow (dimension_type new_n_rows) |
| Makes the matrix grow by adding more rows and more columns. | |
| void | resize_no_copy (dimension_type new_n_rows) |
| Resizes the matrix without worrying about the old contents. | |
| dimension_type | num_rows () const |
| Returns the number of rows in the matrix. | |
| void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this. | |
| void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this. | |
| void | print () const |
Prints *this to std::cerr using operator<<. | |
| bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. | |
| memory_size_type | total_memory_in_bytes () const |
Returns the total size in bytes of the memory occupied by *this. | |
| memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this. | |
| bool | OK () const |
| Checks if all the invariants are satisfied. | |
Subscript operators. | |
| DB_Row< T > & | operator[] (dimension_type k) |
Returns a reference to the k-th row of the matrix. | |
| const DB_Row< T > & | operator[] (dimension_type k) const |
Returns a constant reference to the k-th row of the matrix. | |
Static Public Member Functions | |
| static dimension_type | max_num_rows () |
| Returns the maximum number of rows a DB_Matrix can handle. | |
| static dimension_type | max_num_columns () |
| Returns the maximum number of columns a DB_Matrix can handle. | |
Private Attributes | |
| std::vector< DB_Row< T > > | rows |
| The rows of the matrix. | |
| dimension_type | row_size |
| Size of the initialized part of each row. | |
| dimension_type | row_capacity |
Capacity allocated for each row, i.e., number of long objects that each row can contain. | |
Friends | |
| class | DB_Matrix |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &s, const DB_Matrix< T > &c) |
| Output operator. | |
| template<typename T > | |
| void | swap (Parma_Polyhedra_Library::DB_Matrix< T > &x, Parma_Polyhedra_Library::DB_Matrix< T > &y) |
Specializes std::swap. | |
| template<typename T > | |
| bool | operator== (const DB_Matrix< T > &x, const DB_Matrix< T > &y) |
Returns true if and only if x and y are identical. | |
| template<typename T > | |
| bool | operator!= (const DB_Matrix< T > &x, const DB_Matrix< T > &y) |
Returns true if and only if x and y are different. | |
| template<typename Temp , typename To , typename T > | |
| bool | rectilinear_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const DB_Matrix< T > &x, const DB_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the rectilinear (or Manhattan) distance between x and y. | |
| template<typename Temp , typename To , typename T > | |
| bool | euclidean_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const DB_Matrix< T > &x, const DB_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the euclidean distance between x and y. | |
| template<typename Temp , typename To , typename T > | |
| bool | l_infinity_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const DB_Matrix< T > &x, const DB_Matrix< T > &y, Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
Computes the distance between x and y. | |
| template<typename Specialization , typename Temp , typename To , typename T > | |
| bool | l_m_distance_assign (Checked_Number< To, Extended_Number_Policy > &r, const DB_Matrix< T > &x, const DB_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2) |
The base class for the square matrices.
The template class DB_Matrix<T> allows for the representation of a square matrix of T objects. Each DB_Matrix<T> object can be viewed as a multiset of DB_Row<T>.
Definition at line 62 of file DB_Matrix.defs.hh.
| Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix | ( | ) |
Builds an empty matrix.
DB_Rows' size and capacity are initialized to
.
| Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix | ( | dimension_type | n_rows | ) | [inline, explicit] |
Builds a square matrix having the specified dimension.
Definition at line 30 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::construct(), Parma_Polyhedra_Library::DB_Matrix< T >::OK(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, and Parma_Polyhedra_Library::DB_Matrix< T >::rows.
00031 : rows(n_rows), 00032 row_size(n_rows), 00033 row_capacity(compute_capacity(n_rows, max_num_columns())) { 00034 // Construct in direct order: will destroy in reverse order. 00035 for (dimension_type i = 0; i < n_rows; ++i) 00036 rows[i].construct(n_rows, row_capacity); 00037 PPL_ASSERT(OK()); 00038 }
| Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix | ( | const DB_Matrix< T > & | y | ) | [inline] |
Copy constructor.
Definition at line 179 of file DB_Matrix.inlines.hh.
00180 : rows(y.rows), 00181 row_size(y.row_size), 00182 row_capacity(compute_capacity(y.row_size, max_num_columns())) { 00183 }
| Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix | ( | const DB_Matrix< U > & | y | ) | [inline, explicit] |
Constructs a conservative approximation of y.
Definition at line 42 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::OK(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, and Parma_Polyhedra_Library::DB_Matrix< T >::rows.
00043 : rows(y.rows.size()), 00044 row_size(y.row_size), 00045 row_capacity(compute_capacity(y.row_size, max_num_columns())) { 00046 // Construct in direct order: will destroy in reverse order. 00047 for (dimension_type i = 0, n_rows = rows.size(); i < n_rows; ++i) 00048 rows[i].construct_upward_approximation(y[i], row_capacity); 00049 PPL_ASSERT(OK()); 00050 }
| Parma_Polyhedra_Library::DB_Matrix< T >::~DB_Matrix | ( | ) | [inline] |
| void Parma_Polyhedra_Library::DB_Matrix< T >::ascii_dump | ( | std::ostream & | s | ) | const [inline] |
Writes to s an ASCII representation of *this.
Definition at line 210 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::num_rows().
00210 { 00211 const DB_Matrix<T>& x = *this; 00212 const char separator = ' '; 00213 const dimension_type nrows = x.num_rows(); 00214 s << nrows << separator << "\n"; 00215 for (dimension_type i = 0; i < nrows; ++i) { 00216 for (dimension_type j = 0; j < nrows; ++j) { 00217 using namespace IO_Operators; 00218 s << x[i][j] << separator; 00219 } 00220 s << "\n"; 00221 } 00222 }
| void Parma_Polyhedra_Library::DB_Matrix< T >::ascii_dump | ( | ) | const |
Writes to std::cerr an ASCII representation of *this.
Referenced by Parma_Polyhedra_Library::BD_Shape< T >::ascii_dump().
| bool Parma_Polyhedra_Library::DB_Matrix< T >::ascii_load | ( | std::istream & | s | ) | [inline] |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.
Definition at line 228 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::is_minus_infinity(), Parma_Polyhedra_Library::Checked::Result, and Parma_Polyhedra_Library::Checked::result_relation().
00228 { 00229 dimension_type nrows; 00230 if (!(s >> nrows)) 00231 return false; 00232 resize_no_copy(nrows); 00233 DB_Matrix& x = *this; 00234 for (dimension_type i = 0; i < nrows; ++i) 00235 for (dimension_type j = 0; j < nrows; ++j) { 00236 Result r = input(x[i][j], s, ROUND_CHECK); 00237 if (result_relation(r) != VR_EQ || is_minus_infinity(x[i][j])) 00238 return false; 00239 } 00240 00241 // Check invariants. 00242 PPL_ASSERT(OK()); 00243 return true; 00244 }
| DB_Matrix< T >::const_iterator Parma_Polyhedra_Library::DB_Matrix< T >::begin | ( | ) | const [inline] |
Returns the const_iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the-end const_iterator.
Definition at line 125 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::rows.
00125 { 00126 return const_iterator(rows.begin()); 00127 }
| DB_Matrix< T >::const_iterator Parma_Polyhedra_Library::DB_Matrix< T >::end | ( | ) | const [inline] |
Returns the past-the-end const_iterator.
Definition at line 131 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::rows.
00131 { 00132 return const_iterator(rows.end()); 00133 }
| memory_size_type Parma_Polyhedra_Library::DB_Matrix< T >::external_memory_in_bytes | ( | ) | const [inline] |
Returns the size in bytes of the memory managed by *this.
Definition at line 263 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::num_rows(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, and Parma_Polyhedra_Library::DB_Matrix< T >::rows.
Referenced by Parma_Polyhedra_Library::BD_Shape< T >::external_memory_in_bytes(), and Parma_Polyhedra_Library::DB_Matrix< T >::total_memory_in_bytes().
00263 { 00264 memory_size_type n = rows.capacity() * sizeof(DB_Row<T>); 00265 for (dimension_type i = num_rows(); i-- > 0; ) 00266 n += rows[i].external_memory_in_bytes(row_capacity); 00267 return n; 00268 }
| void Parma_Polyhedra_Library::DB_Matrix< T >::grow | ( | dimension_type | new_n_rows | ) | [inline] |
Makes the matrix grow by adding more rows and more columns.
| new_n_rows | The number of rows and columns of the resized matrix. |
A new matrix, with the specified dimension, is created. The contents of the old matrix are copied in the upper, left-hand corner of the new matrix, which is then assigned to *this.
Definition at line 54 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::construct(), Parma_Polyhedra_Library::DB_Matrix< T >::max_num_columns(), Parma_Polyhedra_Library::DB_Matrix< T >::max_num_rows(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, Parma_Polyhedra_Library::DB_Matrix< T >::row_size, Parma_Polyhedra_Library::DB_Matrix< T >::rows, and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
Referenced by Parma_Polyhedra_Library::BD_Shape< T >::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::BD_Shape< T >::add_space_dimensions_and_project(), and Parma_Polyhedra_Library::BD_Shape< T >::concatenate_assign().
00054 { 00055 const dimension_type old_n_rows = rows.size(); 00056 PPL_ASSERT(new_n_rows >= old_n_rows); 00057 00058 if (new_n_rows > old_n_rows) { 00059 if (new_n_rows <= row_capacity) { 00060 // We can recycle the old rows. 00061 if (rows.capacity() < new_n_rows) { 00062 // Reallocation will take place. 00063 std::vector<DB_Row<T> > new_rows; 00064 new_rows.reserve(compute_capacity(new_n_rows, max_num_rows())); 00065 new_rows.insert(new_rows.end(), new_n_rows, DB_Row<T>()); 00066 // Construct the new rows. 00067 dimension_type i = new_n_rows; 00068 while (i-- > old_n_rows) 00069 new_rows[i].construct(new_n_rows, row_capacity); 00070 // Steal the old rows. 00071 ++i; 00072 while (i-- > 0) 00073 new_rows[i].swap(rows[i]); 00074 // Put the new vector into place. 00075 std::swap(rows, new_rows); 00076 } 00077 else { 00078 // Reallocation will NOT take place. 00079 rows.insert(rows.end(), new_n_rows - old_n_rows, DB_Row<T>()); 00080 for (dimension_type i = new_n_rows; i-- > old_n_rows; ) 00081 rows[i].construct(new_n_rows, row_capacity); 00082 } 00083 } 00084 else { 00085 // We cannot even recycle the old rows. 00086 DB_Matrix new_matrix; 00087 new_matrix.rows.reserve(compute_capacity(new_n_rows, max_num_rows())); 00088 new_matrix.rows.insert(new_matrix.rows.end(), new_n_rows, DB_Row<T>()); 00089 // Construct the new rows. 00090 new_matrix.row_size = new_n_rows; 00091 new_matrix.row_capacity = compute_capacity(new_n_rows, 00092 max_num_columns()); 00093 dimension_type i = new_n_rows; 00094 while (i-- > old_n_rows) 00095 new_matrix.rows[i].construct(new_matrix.row_size, 00096 new_matrix.row_capacity); 00097 // Copy the old rows. 00098 ++i; 00099 while (i-- > 0) { 00100 // FIXME: copying may be unnecessarily costly. 00101 DB_Row<T> new_row(rows[i], 00102 new_matrix.row_size, 00103 new_matrix.row_capacity); 00104 std::swap(new_matrix.rows[i], new_row); 00105 } 00106 // Put the new vector into place. 00107 swap(new_matrix); 00108 return; 00109 } 00110 } 00111 // Here we have the right number of rows. 00112 if (new_n_rows > row_size) { 00113 // We need more columns. 00114 if (new_n_rows <= row_capacity) 00115 // But we have enough capacity: we resize existing rows. 00116 for (dimension_type i = old_n_rows; i-- > 0; ) 00117 rows[i].expand_within_capacity(new_n_rows); 00118 else { 00119 // Capacity exhausted: we must reallocate the rows and 00120 // make sure all the rows have the same capacity. 00121 const dimension_type new_row_capacity 00122 = compute_capacity(new_n_rows, max_num_columns()); 00123 for (dimension_type i = old_n_rows; i-- > 0; ) { 00124 // FIXME: copying may be unnecessarily costly. 00125 DB_Row<T> new_row(rows[i], new_n_rows, new_row_capacity); 00126 std::swap(rows[i], new_row); 00127 } 00128 row_capacity = new_row_capacity; 00129 } 00130 // Rows have grown or shrunk. 00131 row_size = new_n_rows; 00132 } 00133 }
| dimension_type Parma_Polyhedra_Library::DB_Matrix< T >::max_num_columns | ( | ) | [inline, static] |
Returns the maximum number of columns a DB_Matrix can handle.
Definition at line 51 of file DB_Matrix.inlines.hh.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::grow(), Parma_Polyhedra_Library::DB_Matrix< T >::operator=(), and Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy().
| dimension_type Parma_Polyhedra_Library::DB_Matrix< T >::max_num_rows | ( | ) | [inline, static] |
Returns the maximum number of rows a DB_Matrix can handle.
Definition at line 45 of file DB_Matrix.inlines.hh.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::grow(), and Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy().
| dimension_type Parma_Polyhedra_Library::DB_Matrix< T >::num_rows | ( | ) | const [inline] |
Returns the number of rows in the matrix.
Definition at line 164 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::rows.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::ascii_dump(), Parma_Polyhedra_Library::BD_Shape< T >::constrains(), Parma_Polyhedra_Library::DB_Matrix< T >::external_memory_in_bytes(), Parma_Polyhedra_Library::BD_Shape< T >::forget_all_dbm_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::forget_binary_dbm_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::frequency(), Parma_Polyhedra_Library::DB_Matrix< T >::l_m_distance_assign(), Parma_Polyhedra_Library::DB_Matrix< T >::OK(), Parma_Polyhedra_Library::BD_Shape< T >::OK(), Parma_Polyhedra_Library::DB_Matrix< T >::operator==(), and Parma_Polyhedra_Library::BD_Shape< T >::space_dimension().
00164 { 00165 return rows.size(); 00166 }
| bool Parma_Polyhedra_Library::DB_Matrix< T >::OK | ( | ) | const [inline] |
Checks if all the invariants are satisfied.
Definition at line 272 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::num_rows(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, and Parma_Polyhedra_Library::DB_Matrix< T >::row_size.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix(), and Parma_Polyhedra_Library::BD_Shape< T >::OK().
00272 { 00273 #ifndef NDEBUG 00274 using std::endl; 00275 using std::cerr; 00276 #endif 00277 00278 // The matrix must be square. 00279 if (num_rows() != row_size) { 00280 #ifndef NDEBUG 00281 cerr << "DB_Matrix has fewer columns than rows:\n" 00282 << "row_size is " << row_size 00283 << ", num_rows() is " << num_rows() << "!" 00284 << endl; 00285 #endif 00286 return false; 00287 } 00288 00289 const DB_Matrix& x = *this; 00290 const dimension_type n_rows = x.num_rows(); 00291 for (dimension_type i = 0; i < n_rows; ++i) { 00292 if (!x[i].OK(row_size, row_capacity)) 00293 return false; 00294 } 00295 00296 // All checks passed. 00297 return true; 00298 }
| DB_Matrix< T > & Parma_Polyhedra_Library::DB_Matrix< T >::operator= | ( | const DB_Matrix< T > & | y | ) | [inline] |
Assignment operator.
Definition at line 187 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::DB_Matrix< T >::max_num_columns(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, Parma_Polyhedra_Library::DB_Matrix< T >::row_size, and Parma_Polyhedra_Library::DB_Matrix< T >::rows.
00187 { 00188 // Without the following guard against auto-assignments we would 00189 // recompute the row capacity based on row size, possibly without 00190 // actually increasing the capacity of the rows. This would lead to 00191 // an inconsistent state. 00192 if (this != &y) { 00193 // The following assignment may do nothing on auto-assignments... 00194 rows = y.rows; 00195 row_size = y.row_size; 00196 // ... hence the following assignment must not be done on 00197 // auto-assignments. 00198 row_capacity = compute_capacity(y.row_size, max_num_columns()); 00199 } 00200 return *this; 00201 }
| const DB_Row< T > & Parma_Polyhedra_Library::DB_Matrix< T >::operator[] | ( | dimension_type | k | ) | const [inline] |
Returns a constant reference to the k-th row of the matrix.
Definition at line 157 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::rows.
| DB_Row< T > & Parma_Polyhedra_Library::DB_Matrix< T >::operator[] | ( | dimension_type | k | ) | [inline] |
Returns a reference to the k-th row of the matrix.
Definition at line 150 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::rows.
| void Parma_Polyhedra_Library::DB_Matrix< T >::print | ( | ) | const |
Prints *this to std::cerr using operator<<.
| void Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy | ( | dimension_type | new_n_rows | ) | [inline] |
Resizes the matrix without worrying about the old contents.
| new_n_rows | The number of rows and columns of the resized matrix. |
A new matrix, with the specified dimension, is created without copying the content of the old matrix and assigned to *this.
Definition at line 137 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::compute_capacity(), Parma_Polyhedra_Library::construct(), Parma_Polyhedra_Library::DB_Matrix< T >::max_num_columns(), Parma_Polyhedra_Library::DB_Matrix< T >::max_num_rows(), Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, Parma_Polyhedra_Library::DB_Matrix< T >::row_size, Parma_Polyhedra_Library::DB_Matrix< T >::rows, and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
Referenced by Parma_Polyhedra_Library::BD_Shape< T >::remove_higher_space_dimensions(), and Parma_Polyhedra_Library::BD_Shape< T >::remove_space_dimensions().
00137 { 00138 dimension_type old_n_rows = rows.size(); 00139 00140 if (new_n_rows > old_n_rows) { 00141 // Rows will be inserted. 00142 if (new_n_rows <= row_capacity) { 00143 // We can recycle the old rows. 00144 if (rows.capacity() < new_n_rows) { 00145 // Reallocation (of vector `rows') will take place. 00146 std::vector<DB_Row<T> > new_rows; 00147 new_rows.reserve(compute_capacity(new_n_rows, max_num_rows())); 00148 new_rows.insert(new_rows.end(), new_n_rows, DB_Row<T>()); 00149 // Construct the new rows (be careful: each new row must have 00150 // the same capacity as each one of the old rows). 00151 dimension_type i = new_n_rows; 00152 while (i-- > old_n_rows) 00153 new_rows[i].construct(new_n_rows, row_capacity); 00154 // Steal the old rows. 00155 ++i; 00156 while (i-- > 0) 00157 new_rows[i].swap(rows[i]); 00158 // Put the new vector into place. 00159 std::swap(rows, new_rows); 00160 } 00161 else { 00162 // Reallocation (of vector `rows') will NOT take place. 00163 rows.insert(rows.end(), new_n_rows - old_n_rows, DB_Row<T>()); 00164 // Be careful: each new row must have 00165 // the same capacity as each one of the old rows. 00166 for (dimension_type i = new_n_rows; i-- > old_n_rows; ) 00167 rows[i].construct(new_n_rows, row_capacity); 00168 } 00169 } 00170 else { 00171 // We cannot even recycle the old rows: allocate a new matrix and swap. 00172 DB_Matrix new_matrix(new_n_rows); 00173 swap(new_matrix); 00174 return; 00175 } 00176 } 00177 else if (new_n_rows < old_n_rows) { 00178 // Drop some rows. 00179 rows.erase(rows.begin() + new_n_rows, rows.end()); 00180 // Shrink the existing rows. 00181 for (dimension_type i = new_n_rows; i-- > 0; ) 00182 rows[i].shrink(new_n_rows); 00183 old_n_rows = new_n_rows; 00184 } 00185 // Here we have the right number of rows. 00186 if (new_n_rows > row_size) { 00187 // We need more columns. 00188 if (new_n_rows <= row_capacity) 00189 // But we have enough capacity: we resize existing rows. 00190 for (dimension_type i = old_n_rows; i-- > 0; ) 00191 rows[i].expand_within_capacity(new_n_rows); 00192 else { 00193 // Capacity exhausted: we must reallocate the rows and 00194 // make sure all the rows have the same capacity. 00195 const dimension_type new_row_capacity 00196 = compute_capacity(new_n_rows, max_num_columns()); 00197 for (dimension_type i = old_n_rows; i-- > 0; ) { 00198 DB_Row<T> new_row(new_n_rows, new_row_capacity); 00199 std::swap(rows[i], new_row); 00200 } 00201 row_capacity = new_row_capacity; 00202 } 00203 } 00204 // DB_Rows have grown or shrunk. 00205 row_size = new_n_rows; 00206 }
| void Parma_Polyhedra_Library::DB_Matrix< T >::swap | ( | DB_Matrix< T > & | y | ) | [inline] |
Swaps *this with y.
Definition at line 37 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity, Parma_Polyhedra_Library::DB_Matrix< T >::row_size, and Parma_Polyhedra_Library::DB_Matrix< T >::rows.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::grow(), Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
| memory_size_type Parma_Polyhedra_Library::DB_Matrix< T >::total_memory_in_bytes | ( | ) | const [inline] |
Returns the total size in bytes of the memory occupied by *this.
Definition at line 57 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::external_memory_in_bytes().
00057 { 00058 return sizeof(*this) + external_memory_in_bytes(); 00059 }
Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix [friend] |
Definition at line 161 of file DB_Matrix.defs.hh.
| bool euclidean_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
| const DB_Matrix< T > & | x, | |||
| const DB_Matrix< T > & | y, | |||
| Rounding_Dir | dir, | |||
| Temp & | tmp0, | |||
| Temp & | tmp1, | |||
| Temp & | tmp2 | |||
| ) | [related] |
Computes the euclidean distance between x and y.
If the Euclidean distance between x and y is defined, stores an approximation of it into to r and returns true; returns false otherwise.
The direction of the approximation is specified by dir.
All computations are performed using the temporary variables tmp0, tmp1 and tmp2.
Definition at line 283 of file DB_Matrix.inlines.hh.
| bool l_infinity_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
| const DB_Matrix< T > & | x, | |||
| const DB_Matrix< T > & | y, | |||
| Rounding_Dir | dir, | |||
| Temp & | tmp0, | |||
| Temp & | tmp1, | |||
| Temp & | tmp2 | |||
| ) | [related] |
Computes the
distance between x and y.
If the
distance between x and y is defined, stores an approximation of it into to r and returns true; returns false otherwise.
The direction of the approximation is specified by dir.
All computations are performed using the temporary variables tmp0, tmp1 and tmp2.
Definition at line 303 of file DB_Matrix.inlines.hh.
| bool l_m_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
| const DB_Matrix< T > & | x, | |||
| const DB_Matrix< T > & | y, | |||
| const Rounding_Dir | dir, | |||
| Temp & | tmp0, | |||
| Temp & | tmp1, | |||
| Temp & | tmp2 | |||
| ) | [related] |
Definition at line 208 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::assign_r(), Parma_Polyhedra_Library::combine(), Parma_Polyhedra_Library::finalize(), Parma_Polyhedra_Library::is_plus_infinity(), Parma_Polyhedra_Library::maybe_assign(), Parma_Polyhedra_Library::DB_Matrix< T >::num_rows(), and Parma_Polyhedra_Library::PLUS_INFINITY.
00214 { 00215 const dimension_type x_num_rows = x.num_rows(); 00216 if (x_num_rows != y.num_rows()) 00217 return false; 00218 assign_r(tmp0, 0, ROUND_NOT_NEEDED); 00219 for (dimension_type i = x_num_rows; i-- > 0; ) { 00220 const DB_Row<T>& x_i = x[i]; 00221 const DB_Row<T>& y_i = y[i]; 00222 for (dimension_type j = x_num_rows; j-- > 0; ) { 00223 const T& x_i_j = x_i[j]; 00224 const T& y_i_j = y_i[j]; 00225 if (is_plus_infinity(x_i_j)) { 00226 if (is_plus_infinity(y_i_j)) 00227 continue; 00228 else { 00229 pinf: 00230 assign_r(r, PLUS_INFINITY, ROUND_NOT_NEEDED); 00231 return true; 00232 } 00233 } 00234 else if (is_plus_infinity(y_i_j)) 00235 goto pinf; 00236 00237 const Temp* tmp1p; 00238 const Temp* tmp2p; 00239 if (x_i_j > y_i_j) { 00240 maybe_assign(tmp1p, tmp1, x_i_j, dir); 00241 maybe_assign(tmp2p, tmp2, y_i_j, inverse(dir)); 00242 } 00243 else { 00244 maybe_assign(tmp1p, tmp1, y_i_j, dir); 00245 maybe_assign(tmp2p, tmp2, x_i_j, inverse(dir)); 00246 } 00247 sub_assign_r(tmp1, *tmp1p, *tmp2p, dir); 00248 PPL_ASSERT(sgn(tmp1) >= 0); 00249 Specialization::combine(tmp0, tmp1, dir); 00250 } 00251 } 00252 Specialization::finalize(tmp0, dir); 00253 assign_r(r, tmp0, dir); 00254 return true; 00255 }
| bool operator!= | ( | const DB_Matrix< T > & | x, | |
| const DB_Matrix< T > & | y | |||
| ) | [related] |
Returns true if and only if x and y are different.
Definition at line 173 of file DB_Matrix.inlines.hh.
| std::ostream & operator<< | ( | std::ostream & | s, | |
| const DB_Matrix< T > & | c | |||
| ) | [related] |
Output operator.
Definition at line 305 of file DB_Matrix.templates.hh.
00305 { 00306 const dimension_type n = c.num_rows(); 00307 for (dimension_type i = 0; i < n; ++i) { 00308 for (dimension_type j = 0; j < n; ++j) 00309 s << c[i][j] << " "; 00310 s << "\n"; 00311 } 00312 return s; 00313 }
| bool operator== | ( | const DB_Matrix< T > & | x, | |
| const DB_Matrix< T > & | y | |||
| ) | [related] |
Returns true if and only if x and y are identical.
Definition at line 251 of file DB_Matrix.templates.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::num_rows().
00251 { 00252 const dimension_type x_num_rows = x.num_rows(); 00253 if (x_num_rows != y.num_rows()) 00254 return false; 00255 for (dimension_type i = x_num_rows; i-- > 0; ) 00256 if (x[i] != y[i]) 00257 return false; 00258 return true; 00259 }
| bool rectilinear_distance_assign | ( | Checked_Number< To, Extended_Number_Policy > & | r, | |
| const DB_Matrix< T > & | x, | |||
| const DB_Matrix< T > & | y, | |||
| Rounding_Dir | dir, | |||
| Temp & | tmp0, | |||
| Temp & | tmp1, | |||
| Temp & | tmp2 | |||
| ) | [related] |
Computes the rectilinear (or Manhattan) distance between x and y.
If the rectilinear distance between x and y is defined, stores an approximation of it into to r and returns true; returns false otherwise.
The direction of the approximation is specified by dir.
All computations are performed using the temporary variables tmp0, tmp1 and tmp2.
Definition at line 262 of file DB_Matrix.inlines.hh.
| void swap | ( | Parma_Polyhedra_Library::DB_Matrix< T > & | x, | |
| Parma_Polyhedra_Library::DB_Matrix< T > & | y | |||
| ) | [related] |
Specializes std::swap.
Definition at line 327 of file DB_Matrix.inlines.hh.
References Parma_Polyhedra_Library::DB_Matrix< T >::swap().
00328 { 00329 x.swap(y); 00330 }
dimension_type Parma_Polyhedra_Library::DB_Matrix< T >::row_capacity [private] |
Capacity allocated for each row, i.e., number of long objects that each row can contain.
Definition at line 173 of file DB_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix(), Parma_Polyhedra_Library::DB_Matrix< T >::external_memory_in_bytes(), Parma_Polyhedra_Library::DB_Matrix< T >::grow(), Parma_Polyhedra_Library::DB_Matrix< T >::OK(), Parma_Polyhedra_Library::DB_Matrix< T >::operator=(), Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
dimension_type Parma_Polyhedra_Library::DB_Matrix< T >::row_size [private] |
Size of the initialized part of each row.
Definition at line 167 of file DB_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::grow(), Parma_Polyhedra_Library::DB_Matrix< T >::OK(), Parma_Polyhedra_Library::DB_Matrix< T >::operator=(), Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
std::vector<DB_Row<T> > Parma_Polyhedra_Library::DB_Matrix< T >::rows [private] |
The rows of the matrix.
Definition at line 164 of file DB_Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::DB_Matrix< T >::begin(), Parma_Polyhedra_Library::DB_Matrix< T >::DB_Matrix(), Parma_Polyhedra_Library::DB_Matrix< T >::end(), Parma_Polyhedra_Library::DB_Matrix< T >::external_memory_in_bytes(), Parma_Polyhedra_Library::DB_Matrix< T >::grow(), Parma_Polyhedra_Library::DB_Matrix< T >::num_rows(), Parma_Polyhedra_Library::DB_Matrix< T >::operator=(), Parma_Polyhedra_Library::DB_Matrix< T >::operator[](), Parma_Polyhedra_Library::DB_Matrix< T >::resize_no_copy(), and Parma_Polyhedra_Library::DB_Matrix< T >::swap().
1.6.3