#include <Matrix.defs.hh>
Public Member Functions | |
Matrix () | |
Builds an empty matrix. | |
Matrix (dimension_type n_rows, dimension_type n_columns, Row::Flags row_flags=Row::Flags()) | |
Builds a zero matrix with specified dimensions and flags. | |
Matrix (const Matrix &y) | |
Copy-constructor. | |
~Matrix () | |
Destructor. | |
Matrix & | operator= (const 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 (Matrix &y) |
Swaps *this with y . | |
void | add_zero_rows (dimension_type n, Row::Flags row_flags) |
Adds to the matrix n rows of zeroes with flags set to row_flags . | |
void | add_zero_columns (dimension_type n) |
Adds n columns of zeroes to the matrix. | |
void | add_zero_rows_and_columns (dimension_type n, dimension_type m, Row::Flags row_flags) |
Adds n rows and m columns of zeroes to the matrix. | |
void | add_row (const Row &y) |
Adds a copy of the row y to the matrix. | |
void | add_recycled_row (Row &y) |
Adds the row y to the matrix. | |
void | remove_trailing_columns (dimension_type n) |
Makes the matrix shrink by removing its n trailing columns. | |
void | resize_no_copy (dimension_type new_n_rows, dimension_type new_n_columns, Row::Flags row_flags) |
Resizes the matrix without worrying about the old contents. | |
void | swap_columns (dimension_type i, dimension_type j) |
Swaps the columns having indexes i and j . | |
void | permute_columns (const std::vector< dimension_type > &cycles) |
Permutes the columns of the matrix. | |
void | clear () |
Clears the matrix deallocating all its rows. | |
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) 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 . | |
void | erase_to_end (dimension_type first_to_erase) |
Erases from the matrix all the rows but those having an index less than first_to_erase . | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
Accessors | |
dimension_type | num_columns () const |
Returns the number of columns of the matrix (i.e., the size of the rows). | |
dimension_type | num_rows () const |
Returns the number of rows in the matrix. | |
Subscript operators | |
Row & | operator[] (dimension_type k) |
Returns a reference to the k-th row of the matrix. | |
const Row & | 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 of a Matrix. | |
static dimension_type | max_num_columns () |
Returns the maximum number of columns of a Matrix. | |
Protected Attributes | |
std::vector< Row > | rows |
Contains 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. | |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (Parma_Polyhedra_Library::Matrix &x, Parma_Polyhedra_Library::Matrix &y) |
Specializes std::swap . | |
bool | operator== (const Matrix &x, const Matrix &y) |
Returns true if and only if x and y are identical. | |
bool | operator!= (const Matrix &x, const Matrix &y) |
Returns true if and only if x and y are different. | |
Classes | |
class | const_iterator |
An iterator over a matrix. More... |
A Matrix object is a sequence of Row objects and is characterized by the matrix dimensions (the number of rows and columns). All the rows in a matrix, besides having the same size (corresponding to the number of columns of the matrix), are also bound to have the same capacity.
Definition at line 45 of file Matrix.defs.hh.
Parma_Polyhedra_Library::Matrix::Matrix | ( | ) | [inline] |
Builds an empty matrix.
Rows' size and capacity are initialized to .
Definition at line 117 of file Matrix.inlines.hh.
00118 : rows(), 00119 row_size(0), 00120 row_capacity(0) { 00121 }
Parma_Polyhedra_Library::Matrix::Matrix | ( | dimension_type | n_rows, | |
dimension_type | n_columns, | |||
Row::Flags | row_flags = Row::Flags() | |||
) |
Builds a zero matrix with specified dimensions and flags.
n_rows | The number of rows of the matrix that will be created; | |
n_columns | The number of columns of the matrix that will be created. | |
row_flags | The flags used to build the rows of the matrix; by default, the rows will have all flags unset. |
Definition at line 33 of file Matrix.cc.
References OK(), row_capacity, and rows.
00036 : rows((assert(n_rows <= max_num_rows()), 00037 n_rows)), 00038 row_size(n_columns), 00039 row_capacity(compute_capacity(n_columns, max_num_columns())) { 00040 // Construct in direct order: will destroy in reverse order. 00041 for (dimension_type i = 0; i < n_rows; ++i) 00042 rows[i].construct(n_columns, row_capacity, row_flags); 00043 assert(OK()); 00044 }
Parma_Polyhedra_Library::Matrix::Matrix | ( | const Matrix & | y | ) | [inline] |
Copy-constructor.
Definition at line 124 of file Matrix.inlines.hh.
00125 : rows(y.rows), 00126 row_size(y.row_size), 00127 row_capacity(compute_capacity(y.row_size, max_num_columns())) { 00128 }
Parma_Polyhedra_Library::Matrix::~Matrix | ( | ) | [inline] |
dimension_type Parma_Polyhedra_Library::Matrix::max_num_rows | ( | ) | [inline, static] |
Returns the maximum number of rows of a Matrix.
Definition at line 33 of file Matrix.inlines.hh.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), add_recycled_row(), add_zero_rows(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), and resize_no_copy().
dimension_type Parma_Polyhedra_Library::Matrix::max_num_columns | ( | ) | [inline, static] |
Returns the maximum number of columns of a Matrix.
Definition at line 38 of file Matrix.inlines.hh.
References Parma_Polyhedra_Library::Row::max_size().
Referenced by add_zero_columns(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::LP_Problem::compute_tableau(), Parma_Polyhedra_Library::Linear_System::max_space_dimension(), Parma_Polyhedra_Library::Congruence_System::max_space_dimension(), operator=(), Parma_Polyhedra_Library::LP_Problem::prepare_first_phase(), and resize_no_copy().
00038 { 00039 return Row::max_size(); 00040 }
Assignment operator.
Definition at line 135 of file Matrix.inlines.hh.
References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), row_capacity, row_size, and rows.
Referenced by Parma_Polyhedra_Library::Linear_System::assign_with_pending(), Parma_Polyhedra_Library::Linear_System::operator=(), and Parma_Polyhedra_Library::Congruence_System::operator=().
00135 { 00136 // Without the following guard against auto-assignments we would 00137 // recompute the row capacity based on row size, possibly without 00138 // actually increasing the capacity of the rows. This would lead to 00139 // an inconsistent state. 00140 if (this != &y) { 00141 // The following assignment may do nothing on auto-assignments... 00142 rows = y.rows; 00143 row_size = y.row_size; 00144 // ... hence the following assignment must not be done on 00145 // auto-assignments. 00146 row_capacity = compute_capacity(y.row_size, max_num_columns()); 00147 } 00148 return *this; 00149 }
Matrix::const_iterator Parma_Polyhedra_Library::Matrix::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.
Reimplemented in Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 100 of file Matrix.inlines.hh.
References rows.
Referenced by Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Constraint_System::begin(), and Parma_Polyhedra_Library::Congruence_System::begin().
00100 { 00101 return const_iterator(rows.begin()); 00102 }
Matrix::const_iterator Parma_Polyhedra_Library::Matrix::end | ( | ) | const [inline] |
Returns the past-the-end const_iterator.
Reimplemented in Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 105 of file Matrix.inlines.hh.
References rows.
Referenced by Parma_Polyhedra_Library::Generator_System::end(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Congruence_System::end(), Parma_Polyhedra_Library::Generator_System::const_iterator::skip_forward(), Parma_Polyhedra_Library::Constraint_System::const_iterator::skip_forward(), and Parma_Polyhedra_Library::Congruence_System::const_iterator::skip_forward().
00105 { 00106 return const_iterator(rows.end()); 00107 }
void Parma_Polyhedra_Library::Matrix::swap | ( | Matrix & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 110 of file Matrix.inlines.hh.
References row_capacity, row_size, and rows.
Referenced by add_zero_rows_and_columns(), clear(), resize_no_copy(), swap(), Parma_Polyhedra_Library::Linear_System::swap(), and Parma_Polyhedra_Library::Congruence_System::swap().
00110 { 00111 std::swap(rows, y.rows); 00112 std::swap(row_size, y.row_size); 00113 std::swap(row_capacity, y.row_capacity); 00114 }
void Parma_Polyhedra_Library::Matrix::add_zero_rows | ( | dimension_type | n, | |
Row::Flags | row_flags | |||
) |
Adds to the matrix n
rows of zeroes with flags set to row_flags
.
n | The number of rows to be added: must be strictly positive. | |
row_flags | Flags for the newly added rows. |
Definition at line 47 of file Matrix.cc.
References Parma_Polyhedra_Library::compute_capacity(), max_num_rows(), num_rows(), row_capacity, row_size, and rows.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_rows(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), and Parma_Polyhedra_Library::Grid::simplify().
00047 { 00048 assert(n > 0); 00049 assert(n <= max_num_rows() - num_rows()); 00050 const dimension_type old_num_rows = rows.size(); 00051 const dimension_type new_num_rows = old_num_rows + n; 00052 00053 if (rows.capacity() < new_num_rows) { 00054 // Reallocation will take place. 00055 std::vector<Row> new_rows; 00056 new_rows.reserve(compute_capacity(new_num_rows, max_num_rows())); 00057 new_rows.insert(new_rows.end(), new_num_rows, Row()); 00058 // Construct the new rows. 00059 dimension_type i = new_num_rows; 00060 while (i-- > old_num_rows) 00061 new_rows[i].construct(row_size, row_capacity, row_flags); 00062 // Steal the old rows. 00063 ++i; 00064 while (i-- > 0) 00065 new_rows[i].swap(rows[i]); 00066 // Put the new vector into place. 00067 std::swap(rows, new_rows); 00068 } 00069 else { 00070 // Reallocation will NOT take place. 00071 rows.insert(rows.end(), n, Row()); 00072 for (dimension_type i = new_num_rows; i-- > old_num_rows; ) 00073 rows[i].construct(row_size, row_capacity, row_flags); 00074 } 00075 }
void Parma_Polyhedra_Library::Matrix::add_zero_columns | ( | dimension_type | n | ) |
Adds n
columns of zeroes to the matrix.
n | The number of columns to be added: must be strictly positive. |
Definition at line 78 of file Matrix.cc.
References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), num_columns(), num_rows(), row_capacity, row_size, and rows.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Grid_Generator_System::clear(), Parma_Polyhedra_Library::Congruence_System::clear(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Constraint_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), and Parma_Polyhedra_Library::LP_Problem::prepare_first_phase().
00078 { 00079 assert(n > 0); 00080 assert(n <= max_num_columns() - num_columns()); 00081 const dimension_type num_rows = rows.size(); 00082 const dimension_type new_num_columns = row_size + n; 00083 00084 if (new_num_columns <= row_capacity) 00085 // We have enough capacity: we resize existing rows. 00086 for (dimension_type i = num_rows; i-- > 0; ) 00087 rows[i].expand_within_capacity(new_num_columns); 00088 else { 00089 // Capacity exhausted: we must reallocate the rows and 00090 // make sure all the rows have the same capacity. 00091 const dimension_type new_row_capacity 00092 = compute_capacity(new_num_columns, max_num_columns()); 00093 assert(new_row_capacity <= max_num_columns()); 00094 for (dimension_type i = num_rows; i-- > 0; ) { 00095 Row new_row(rows[i], new_num_columns, new_row_capacity); 00096 std::swap(rows[i], new_row); 00097 } 00098 row_capacity = new_row_capacity; 00099 } 00100 // Rows have been expanded. 00101 row_size = new_num_columns; 00102 }
void Parma_Polyhedra_Library::Matrix::add_zero_rows_and_columns | ( | dimension_type | n, | |
dimension_type | m, | |||
Row::Flags | row_flags | |||
) |
Adds n
rows and m
columns of zeroes to the matrix.
n | The number of rows to be added: must be strictly positive. | |
m | The number of columns to be added: must be strictly positive. | |
row_flags | Flags for the newly added rows. |
Definition at line 105 of file Matrix.cc.
References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), max_num_rows(), num_columns(), num_rows(), row_capacity, row_size, rows, and swap().
Referenced by Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), Parma_Polyhedra_Library::LP_Problem::compute_tableau(), Parma_Polyhedra_Library::Congruence_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), and Parma_Polyhedra_Library::Congruence_System::recycling_insert().
00107 { 00108 assert(n > 0); 00109 assert(n <= max_num_rows() - num_rows()); 00110 assert(m > 0); 00111 assert(m <= max_num_columns() - num_columns()); 00112 const dimension_type old_num_rows = rows.size(); 00113 const dimension_type new_num_rows = old_num_rows + n; 00114 const dimension_type new_num_columns = row_size + m; 00115 00116 if (new_num_columns <= row_capacity) { 00117 // We can recycle the old rows. 00118 if (rows.capacity() < new_num_rows) { 00119 // Reallocation will take place. 00120 std::vector<Row> new_rows; 00121 new_rows.reserve(compute_capacity(new_num_rows, max_num_rows())); 00122 new_rows.insert(new_rows.end(), new_num_rows, Row()); 00123 // Construct the new rows. 00124 dimension_type i = new_num_rows; 00125 while (i-- > old_num_rows) 00126 new_rows[i].construct(new_num_columns, row_capacity, row_flags); 00127 // Expand and steal the old rows. 00128 ++i; 00129 while (i-- > 0) { 00130 rows[i].expand_within_capacity(new_num_columns); 00131 new_rows[i].swap(rows[i]); 00132 } 00133 // Put the new vector into place. 00134 std::swap(rows, new_rows); 00135 } 00136 else { 00137 // Reallocation will NOT take place. 00138 rows.insert(rows.end(), n, Row()); 00139 // Construct the new rows. 00140 dimension_type i = new_num_rows; 00141 while (i-- > old_num_rows) 00142 rows[i].construct(new_num_columns, row_capacity, row_flags); 00143 // Expand the old rows. 00144 ++i; 00145 while (i-- > 0) 00146 rows[i].expand_within_capacity(new_num_columns); 00147 } 00148 row_size = new_num_columns; 00149 } 00150 else { 00151 // We cannot even recycle the old rows. 00152 Matrix new_matrix; 00153 new_matrix.rows.reserve(compute_capacity(new_num_rows, max_num_rows())); 00154 new_matrix.rows.insert(new_matrix.rows.end(), new_num_rows, Row()); 00155 // Construct the new rows. 00156 new_matrix.row_size = new_num_columns; 00157 new_matrix.row_capacity = compute_capacity(new_num_columns, 00158 max_num_columns()); 00159 dimension_type i = new_num_rows; 00160 while (i-- > old_num_rows) 00161 new_matrix.rows[i].construct(new_matrix.row_size, 00162 new_matrix.row_capacity, 00163 row_flags); 00164 // Copy the old rows. 00165 ++i; 00166 while (i-- > 0) { 00167 Row new_row(rows[i], 00168 new_matrix.row_size, 00169 new_matrix.row_capacity); 00170 std::swap(new_matrix.rows[i], new_row); 00171 } 00172 // Put the new vector into place. 00173 swap(new_matrix); 00174 } 00175 }
void Parma_Polyhedra_Library::Matrix::add_row | ( | const Row & | y | ) | [inline] |
Adds a copy of the row y
to the matrix.
y | The row to be copied: it must have the same number of columns as the matrix. |
Definition at line 152 of file Matrix.inlines.hh.
References add_recycled_row(), and row_capacity.
Referenced by Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), and Parma_Polyhedra_Library::Congruence_System::insert_verbatim().
00152 { 00153 Row new_row(y, row_capacity); 00154 add_recycled_row(new_row); 00155 }
void Parma_Polyhedra_Library::Matrix::add_recycled_row | ( | Row & | y | ) |
Adds the row y
to the matrix.
y | The row to be added: it must have the same size and capacity as this . |
Definition at line 178 of file Matrix.cc.
References Parma_Polyhedra_Library::compute_capacity(), max_num_rows(), OK(), Parma_Polyhedra_Library::Row::OK(), row_capacity, row_size, and rows.
Referenced by add_row(), Parma_Polyhedra_Library::Congruence_System::insert(), and Parma_Polyhedra_Library::Congruence_System::insert_verbatim().
00178 { 00179 // The added row must have the same size and capacity as the 00180 // existing rows of the system. 00181 assert(y.OK(row_size, row_capacity)); 00182 const dimension_type new_rows_size = rows.size() + 1; 00183 if (rows.capacity() < new_rows_size) { 00184 // Reallocation will take place. 00185 std::vector<Row> new_rows; 00186 new_rows.reserve(compute_capacity(new_rows_size, max_num_rows())); 00187 new_rows.insert(new_rows.end(), new_rows_size, Row()); 00188 // Put the new row in place. 00189 dimension_type i = new_rows_size-1; 00190 std::swap(new_rows[i], y); 00191 // Steal the old rows. 00192 while (i-- > 0) 00193 new_rows[i].swap(rows[i]); 00194 // Put the new rows into place. 00195 std::swap(rows, new_rows); 00196 } 00197 else 00198 // Reallocation will NOT take place. 00199 // Inserts a new empty row at the end, 00200 // then substitutes it with a copy of the given row. 00201 std::swap(*rows.insert(rows.end(), Row()), y); 00202 00203 assert(OK()); 00204 }
void Parma_Polyhedra_Library::Matrix::remove_trailing_columns | ( | dimension_type | n | ) |
Makes the matrix shrink by removing its n
trailing columns.
Reimplemented in Parma_Polyhedra_Library::Linear_System.
Definition at line 332 of file Matrix.cc.
References num_rows(), row_size, and rows.
Referenced by Parma_Polyhedra_Library::LP_Problem::erase_slacks(), Parma_Polyhedra_Library::Grid_Generator_System::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator_System::remove_space_dimensions(), and Parma_Polyhedra_Library::Linear_System::remove_trailing_columns().
00332 { 00333 assert(n > 0); 00334 assert(n <= row_size); 00335 row_size -= n; 00336 for (dimension_type i = num_rows(); i-- > 0; ) 00337 rows[i].shrink(row_size); 00338 }
void Parma_Polyhedra_Library::Matrix::resize_no_copy | ( | dimension_type | new_n_rows, | |
dimension_type | new_n_columns, | |||
Row::Flags | row_flags | |||
) |
Resizes the matrix without worrying about the old contents.
new_n_rows | The number of rows of the resized matrix; | |
new_n_columns | The number of columns of the resized matrix. | |
row_flags | The flags of the rows eventually added to the matrix. |
Definition at line 207 of file Matrix.cc.
References Parma_Polyhedra_Library::compute_capacity(), max_num_columns(), max_num_rows(), row_capacity, row_size, rows, and swap().
Referenced by ascii_load(), Parma_Polyhedra_Library::Linear_System::resize_no_copy(), and Parma_Polyhedra_Library::Congruence_System::resize_no_copy().
00209 { 00210 dimension_type old_n_rows = rows.size(); 00211 // Note that, if we have `new_n_rows <= old_n_rows' and 00212 // `new_n_columns >= row_size', the matrix will keep its sortedness. 00213 // This is obvious if `new_n_columns == row_size'. 00214 // If `new_n_columns > row_size', then sortedness is maintained 00215 // because trailing zeroes will be added to all rows. 00216 if (new_n_rows > old_n_rows) { 00217 if (new_n_columns <= row_capacity) { 00218 // We can recycle the old rows. 00219 if (rows.capacity() < new_n_rows) { 00220 // Reallocation (of vector `rows') will take place. 00221 std::vector<Row> new_rows; 00222 new_rows.reserve(compute_capacity(new_n_rows, max_num_rows())); 00223 new_rows.insert(new_rows.end(), new_n_rows, Row()); 00224 // Construct the new rows (be careful: each new row must have 00225 // the same capacity as each one of the old rows). 00226 dimension_type i = new_n_rows; 00227 while (i-- > old_n_rows) 00228 new_rows[i].construct(new_n_columns, row_capacity, row_flags); 00229 // Steal the old rows. 00230 ++i; 00231 while (i-- > 0) 00232 new_rows[i].swap(rows[i]); 00233 // Put the new vector into place. 00234 std::swap(rows, new_rows); 00235 } 00236 else { 00237 // Reallocation (of vector `rows') will NOT take place. 00238 rows.insert(rows.end(), new_n_rows - old_n_rows, Row()); 00239 // Be careful: each new row must have 00240 // the same capacity as each one of the old rows. 00241 for (dimension_type i = new_n_rows; i-- > old_n_rows; ) 00242 rows[i].construct(new_n_columns, row_capacity, row_flags); 00243 } 00244 } 00245 else { 00246 // We cannot even recycle the old rows: allocate a new matrix and swap. 00247 Matrix new_matrix(new_n_rows, new_n_columns, row_flags); 00248 swap(new_matrix); 00249 return; 00250 } 00251 } 00252 else if (new_n_rows < old_n_rows) { 00253 // Drop some rows. 00254 rows.erase(rows.begin() + new_n_rows, rows.end()); 00255 old_n_rows = new_n_rows; 00256 } 00257 // Here we have the right number of rows. 00258 if (new_n_columns != row_size) { 00259 if (new_n_columns < row_size) { 00260 // Shrink the existing rows. 00261 for (dimension_type i = old_n_rows; i-- > 0; ) 00262 rows[i].shrink(new_n_columns); 00263 } 00264 else 00265 // We need more columns. 00266 if (new_n_columns <= row_capacity) 00267 // But we have enough capacity: we resize existing rows. 00268 for (dimension_type i = old_n_rows; i-- > 0; ) 00269 rows[i].expand_within_capacity(new_n_columns); 00270 else { 00271 // Capacity exhausted: we must reallocate the rows and 00272 // make sure all the rows have the same capacity. 00273 const dimension_type new_row_capacity 00274 = compute_capacity(new_n_columns, max_num_columns()); 00275 for (dimension_type i = old_n_rows; i-- > 0; ) { 00276 Row new_row(new_n_columns, new_row_capacity, row_flags); 00277 std::swap(rows[i], new_row); 00278 } 00279 row_capacity = new_row_capacity; 00280 } 00281 // Rows have grown or shrunk. 00282 row_size = new_n_columns; 00283 } 00284 }
void Parma_Polyhedra_Library::Matrix::swap_columns | ( | dimension_type | i, | |
dimension_type | j | |||
) |
Swaps the columns having indexes i
and j
.
Definition at line 323 of file Matrix.cc.
References num_columns(), num_rows(), and rows.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator_System::remove_higher_space_dimensions(), and Parma_Polyhedra_Library::Grid_Generator_System::remove_space_dimensions().
00323 { 00324 assert(i != j && i < num_columns() && j < num_columns()); 00325 for (dimension_type k = num_rows(); k-- > 0; ) { 00326 Row& rows_k = rows[k]; 00327 std::swap(rows_k[i], rows_k[j]); 00328 } 00329 }
void Parma_Polyhedra_Library::Matrix::permute_columns | ( | const std::vector< dimension_type > & | cycles | ) |
Permutes the columns of the matrix.
Reimplemented in Parma_Polyhedra_Library::Linear_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 341 of file Matrix.cc.
References num_rows(), rows, and TEMP_INTEGER.
Referenced by Parma_Polyhedra_Library::Grid::map_space_dimensions(), and Parma_Polyhedra_Library::Linear_System::permute_columns().
00341 { 00342 TEMP_INTEGER(tmp); 00343 const dimension_type n = cycles.size(); 00344 assert(cycles[n - 1] == 0); 00345 for (dimension_type k = num_rows(); k-- > 0; ) { 00346 Row& rows_k = rows[k]; 00347 for (dimension_type i = 0, j = 0; i < n; i = ++j) { 00348 // Make `j' be the index of the next cycle terminator. 00349 while (cycles[j] != 0) 00350 ++j; 00351 // Cycles of length less than 2 are not allowed. 00352 assert(j - i >= 2); 00353 if (j - i == 2) 00354 // For cycles of length 2 no temporary is needed, just a swap. 00355 std::swap(rows_k[cycles[i]], rows_k[cycles[i+1]]); 00356 else { 00357 // Longer cycles need a temporary. 00358 std::swap(rows_k[cycles[j-1]], tmp); 00359 for (dimension_type l = j-1; l > i; --l) 00360 std::swap(rows_k[cycles[l-1]], rows_k[cycles[l]]); 00361 std::swap(tmp, rows_k[cycles[i]]); 00362 } 00363 } 00364 } 00365 }
dimension_type Parma_Polyhedra_Library::Matrix::num_columns | ( | ) | const [inline] |
Returns the number of columns of the matrix (i.e., the size of the rows).
Reimplemented in Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 175 of file Matrix.inlines.hh.
References row_size.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Grid::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), add_zero_columns(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), ascii_dump(), Parma_Polyhedra_Library::Linear_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_dump(), Parma_Polyhedra_Library::Constraint_System::ascii_dump(), Parma_Polyhedra_Library::Congruence_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_load(), Parma_Polyhedra_Library::Constraint_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::back_substitute(), Parma_Polyhedra_Library::LP_Problem::compute_simplex(), Parma_Polyhedra_Library::Congruence_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Grid::congruences(), Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Grid::conversion(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::LP_Problem::erase_slacks(), Parma_Polyhedra_Library::Linear_System::gauss(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::Congruence_System::has_linear_equalities(), Parma_Polyhedra_Library::Generator_System::has_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Congruence_System::is_equal_to(), Parma_Polyhedra_Library::LP_Problem::is_satisfiable(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Grid::lower_triangular(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Grid_Generator_System::num_columns(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::LP_Problem::OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), operator==(), Parma_Polyhedra_Library::Linear_System::operator==(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::LP_Problem::prepare_first_phase(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_congruence_with_equality(), Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Linear_System::space_dimension(), Parma_Polyhedra_Library::Congruence_System::space_dimension(), Parma_Polyhedra_Library::LP_Problem::steepest_edge(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and swap_columns().
00175 { 00176 return row_size; 00177 }
dimension_type Parma_Polyhedra_Library::Matrix::num_rows | ( | ) | const [inline] |
Returns the number of rows in the matrix.
Definition at line 170 of file Matrix.inlines.hh.
References rows.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_and_minimize(), Parma_Polyhedra_Library::LP_Problem::add_constraints(), Parma_Polyhedra_Library::Generator_System::add_corresponding_closure_points(), Parma_Polyhedra_Library::Generator_System::add_corresponding_points(), Parma_Polyhedra_Library::Polyhedron::add_generator(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), Parma_Polyhedra_Library::Grid::add_recycled_congruences(), Parma_Polyhedra_Library::Grid::add_recycled_congruences_and_minimize(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints_and_minimize(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators(), Parma_Polyhedra_Library::Polyhedron::add_recycled_generators_and_minimize(), Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Linear_System::add_rows(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_columns(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Grid::affine_dimension(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), ascii_dump(), Parma_Polyhedra_Library::Linear_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_dump(), Parma_Polyhedra_Library::Constraint_System::ascii_dump(), Parma_Polyhedra_Library::Congruence_System::ascii_dump(), Parma_Polyhedra_Library::Generator_System::ascii_load(), Parma_Polyhedra_Library::Constraint_System::ascii_load(), Parma_Polyhedra_Library::Congruence_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::back_substitute(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_points(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_evolving_rays(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_widening_assign(), Parma_Polyhedra_Library::Polyhedron::bounds(), Parma_Polyhedra_Library::LP_Problem::compute_simplex(), Parma_Polyhedra_Library::LP_Problem::compute_tableau(), Parma_Polyhedra_Library::Congruence_System::concatenate(), Parma_Polyhedra_Library::Polyhedron::concatenate_assign(), Parma_Polyhedra_Library::Grid::congruences(), Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::LP_Problem::erase_slacks(), external_memory_in_bytes(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::LP_Problem::get_exiting_base_index(), Parma_Polyhedra_Library::Polyhedron::H79_widening_assign(), Parma_Polyhedra_Library::Congruence_System::has_a_free_dimension(), Parma_Polyhedra_Library::Congruence_System::has_linear_equalities(), Parma_Polyhedra_Library::Generator_System::has_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), Parma_Polyhedra_Library::Congruence_System::increase_space_dimension(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Generator_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Grid::intersection_assign(), Parma_Polyhedra_Library::Polyhedron::is_bounded(), Parma_Polyhedra_Library::Congruence_System::is_equal_to(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), Parma_Polyhedra_Library::LP_Problem::is_satisfiable(), Parma_Polyhedra_Library::Polyhedron::is_topologically_closed(), Parma_Polyhedra_Library::Grid::is_topologically_closed(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Grid::is_universe(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::Grid::lower_triangular(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::max_min(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), Parma_Polyhedra_Library::Polyhedron::minimize(), Parma_Polyhedra_Library::Linear_System::normalize(), Parma_Polyhedra_Library::Congruence_System::normalize_moduli(), Parma_Polyhedra_Library::Constraint_System::num_equalities(), Parma_Polyhedra_Library::Congruence_System::num_equalities(), Parma_Polyhedra_Library::Grid_Generator_System::num_generators(), Parma_Polyhedra_Library::Constraint_System::num_inequalities(), Parma_Polyhedra_Library::Generator_System::num_lines(), Parma_Polyhedra_Library::Linear_System::num_lines_or_equalities(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), Parma_Polyhedra_Library::Congruence_System::num_proper_congruences(), Parma_Polyhedra_Library::Generator_System::num_rays(), Parma_Polyhedra_Library::Polyhedron::OK(), OK(), Parma_Polyhedra_Library::LP_Problem::OK(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid::OK(), Parma_Polyhedra_Library::Grid_Generator_System::OK(), Parma_Polyhedra_Library::Generator_System::OK(), Parma_Polyhedra_Library::Constraint_System::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), operator==(), Parma_Polyhedra_Library::Linear_System::operator==(), permute_columns(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::LP_Problem::prepare_first_phase(), Parma_Polyhedra_Library::Polyhedron::quick_equivalence_test(), Parma_Polyhedra_Library::Grid::quick_equivalence_test(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Congruence_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_congruence_with_equality(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), remove_trailing_columns(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), Parma_Polyhedra_Library::LP_Problem::second_phase(), Parma_Polyhedra_Library::Polyhedron::select_CH78_constraints(), Parma_Polyhedra_Library::Polyhedron::select_H79_constraints(), Parma_Polyhedra_Library::Linear_System::set_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::set_not_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::set_rows_topology(), Parma_Polyhedra_Library::Polyhedron::shrink_bounding_box(), Parma_Polyhedra_Library::Linear_System::sign_normalize(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Linear_System::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Linear_System::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), Parma_Polyhedra_Library::Linear_System::sort_rows(), Parma_Polyhedra_Library::LP_Problem::steepest_edge(), Parma_Polyhedra_Library::Linear_System::strong_normalize(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), Parma_Polyhedra_Library::LP_Problem::swap_base(), swap_columns(), Parma_Polyhedra_Library::Polyhedron::time_elapse_assign(), Parma_Polyhedra_Library::Polyhedron::topological_closure_assign(), Parma_Polyhedra_Library::Linear_System::unset_pending_rows(), and Parma_Polyhedra_Library::Grid::widening_assign().
00170 { 00171 return rows.size(); 00172 }
Row & Parma_Polyhedra_Library::Matrix::operator[] | ( | dimension_type | k | ) | [inline] |
Returns a reference to the k-th
row of the matrix.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 158 of file Matrix.inlines.hh.
References rows.
Referenced by Parma_Polyhedra_Library::Linear_System::operator[](), and Parma_Polyhedra_Library::Congruence_System::operator[]().
const Row & Parma_Polyhedra_Library::Matrix::operator[] | ( | dimension_type | k | ) | const [inline] |
Returns a constant reference to the k-th
row of the matrix.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 164 of file Matrix.inlines.hh.
References rows.
void Parma_Polyhedra_Library::Matrix::clear | ( | ) | [inline] |
Clears the matrix deallocating all its rows.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 193 of file Matrix.inlines.hh.
References row_capacity, row_size, rows, and swap().
Referenced by Parma_Polyhedra_Library::Linear_System::clear(), Parma_Polyhedra_Library::Congruence_System::clear(), and Parma_Polyhedra_Library::LP_Problem::is_satisfiable().
00193 { 00194 // Clear `rows' and minimize its capacity. 00195 std::vector<Row>().swap(rows); 00196 row_size = 0; 00197 row_capacity = 0; 00198 }
void Parma_Polyhedra_Library::Matrix::ascii_dump | ( | ) | const |
Writes to std::cerr
an ASCII representation of *this
.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Referenced by ascii_dump(), and Parma_Polyhedra_Library::LP_Problem::ascii_dump().
void Parma_Polyhedra_Library::Matrix::ascii_dump | ( | std::ostream & | s | ) | const |
Writes to s
an ASCII representation of *this
.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 287 of file Matrix.cc.
References ascii_dump(), num_columns(), and num_rows().
00287 { 00288 const Matrix& x = *this; 00289 dimension_type x_num_rows = x.num_rows(); 00290 dimension_type x_num_columns = x.num_columns(); 00291 s << x_num_rows << " x " << x_num_columns << "\n"; 00292 for (dimension_type i = 0; i < x_num_rows; ++i) 00293 x[i].ascii_dump(s); 00294 }
void Parma_Polyhedra_Library::Matrix::print | ( | ) | const |
Prints *this
to std::cerr
using operator<<
.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
bool Parma_Polyhedra_Library::Matrix::ascii_load | ( | std::istream & | s | ) |
Loads from s
an ASCII representation (as produced by ascii_dump) and sets *this
accordingly. Returns true
if successful, false
otherwise.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 299 of file Matrix.cc.
References OK(), and resize_no_copy().
00299 { 00300 Matrix& x = *this; 00301 std::string str; 00302 dimension_type x_num_rows; 00303 dimension_type x_num_cols; 00304 if (!(s >> x_num_rows)) 00305 return false; 00306 if (!(s >> str) || (str.compare("x") != 0)) 00307 return false; 00308 if (!(s >> x_num_cols)) 00309 return false; 00310 00311 resize_no_copy(x_num_rows, x_num_cols, Row::Flags()); 00312 00313 for (dimension_type row = 0; row < x_num_rows; ++row) 00314 if (!x[row].ascii_load(s)) 00315 return false; 00316 00317 // Check for well-formedness. 00318 assert(OK()); 00319 return true; 00320 }
memory_size_type Parma_Polyhedra_Library::Matrix::total_memory_in_bytes | ( | ) | const [inline] |
Returns the total size in bytes of the memory occupied by *this
.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 43 of file Matrix.inlines.hh.
References external_memory_in_bytes().
00043 { 00044 return sizeof(*this) + external_memory_in_bytes(); 00045 }
PPL::memory_size_type Parma_Polyhedra_Library::Matrix::external_memory_in_bytes | ( | ) | const |
Returns the size in bytes of the memory managed by *this
.
Reimplemented in Parma_Polyhedra_Library::Linear_System, Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 383 of file Matrix.cc.
References num_rows(), row_capacity, and rows.
Referenced by Parma_Polyhedra_Library::LP_Problem::external_memory_in_bytes(), and total_memory_in_bytes().
00383 { 00384 memory_size_type n = rows.capacity() * sizeof(Row); 00385 for (dimension_type i = num_rows(); i-- > 0; ) 00386 n += rows[i].external_memory_in_bytes(row_capacity); 00387 return n; 00388 }
void Parma_Polyhedra_Library::Matrix::erase_to_end | ( | dimension_type | first_to_erase | ) | [inline] |
Erases from the matrix all the rows but those having an index less than first_to_erase
.
Reimplemented in Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 186 of file Matrix.inlines.hh.
References rows.
Referenced by Parma_Polyhedra_Library::Generator_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::conversion(), Parma_Polyhedra_Library::LP_Problem::erase_slacks(), Parma_Polyhedra_Library::Grid_Generator_System::erase_to_end(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Generator_System::remove_invalid_lines_and_rays(), Parma_Polyhedra_Library::Polyhedron::simplify(), Parma_Polyhedra_Library::Linear_System::simplify(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Linear_System::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators(), and Parma_Polyhedra_Library::Polyhedron::time_elapse_assign().
00186 { 00187 assert(first_to_erase <= rows.size()); 00188 if (first_to_erase < rows.size()) 00189 rows.erase(rows.begin() + first_to_erase, rows.end()); 00190 }
bool Parma_Polyhedra_Library::Matrix::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Reimplemented in Parma_Polyhedra_Library::Constraint_System, Parma_Polyhedra_Library::Congruence_System, Parma_Polyhedra_Library::Generator_System, and Parma_Polyhedra_Library::Grid_Generator_System.
Definition at line 391 of file Matrix.cc.
References num_rows(), row_capacity, and row_size.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), add_recycled_row(), Parma_Polyhedra_Library::Linear_System::add_row(), Parma_Polyhedra_Library::Linear_System::add_rows(), Parma_Polyhedra_Library::Linear_System::add_rows_and_columns(), ascii_load(), Parma_Polyhedra_Library::Linear_System::ascii_load(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Matrix(), Parma_Polyhedra_Library::Linear_System::OK(), Parma_Polyhedra_Library::Grid_Generator_System::OK(), Parma_Polyhedra_Library::Generator_System::OK(), Parma_Polyhedra_Library::Constraint_System::OK(), Parma_Polyhedra_Library::Congruence_System::OK(), Parma_Polyhedra_Library::Linear_System::sort_pending_and_remove_duplicates(), and Parma_Polyhedra_Library::Linear_System::sort_rows().
00391 { 00392 if (row_size > row_capacity) { 00393 #ifndef NDEBUG 00394 std::cerr << "Matrix completely broken: " 00395 << "row_capacity is " << row_capacity 00396 << ", row_size is " << row_size 00397 << std::endl; 00398 #endif 00399 return false; 00400 } 00401 00402 const Matrix& x = *this; 00403 for (dimension_type i = 0, n_rows = num_rows(); i < n_rows; ++i) 00404 if (!x[i].OK(row_size, row_capacity)) 00405 return false; 00406 00407 // All checks passed. 00408 return true; 00409 }
void swap | ( | Parma_Polyhedra_Library::Matrix & | x, | |
Parma_Polyhedra_Library::Matrix & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 206 of file Matrix.inlines.hh.
References swap().
00207 { 00208 x.swap(y); 00209 }
Returns true
if and only if x
and y
are identical.
Definition at line 369 of file Matrix.cc.
References num_columns(), and num_rows().
00369 { 00370 if (x.num_columns() != y.num_columns()) 00371 return false; 00372 const dimension_type x_num_rows = x.num_rows(); 00373 const dimension_type y_num_rows = y.num_rows(); 00374 if (x_num_rows != y_num_rows) 00375 return false; 00376 for (dimension_type i = x_num_rows; i-- > 0; ) 00377 if (x[i] != y[i]) 00378 return false; 00379 return true; 00380 }
Returns true
if and only if x
and y
are different.
Definition at line 181 of file Matrix.inlines.hh.
std::vector<Row> Parma_Polyhedra_Library::Matrix::rows [protected] |
Contains the rows of the matrix.
Definition at line 155 of file Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), add_recycled_row(), Parma_Polyhedra_Library::Grid_Generator_System::add_universe_rows_and_columns(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), begin(), clear(), end(), erase_to_end(), external_memory_in_bytes(), Parma_Polyhedra_Library::Congruence_System::insert(), Matrix(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), num_rows(), operator=(), operator[](), permute_columns(), remove_trailing_columns(), resize_no_copy(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Linear_System::sort_and_remove_with_sat(), Parma_Polyhedra_Library::Linear_System::sort_rows(), swap(), and swap_columns().
Size of the initialized part of each row.
Definition at line 158 of file Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), add_recycled_row(), Parma_Polyhedra_Library::Linear_System::add_row(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), clear(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), Parma_Polyhedra_Library::Congruence_System::normalize_moduli(), num_columns(), OK(), Parma_Polyhedra_Library::Linear_System::OK(), operator=(), remove_trailing_columns(), resize_no_copy(), and swap().
Capacity allocated for each row.
Definition at line 161 of file Matrix.defs.hh.
Referenced by Parma_Polyhedra_Library::Linear_System::add_pending_row(), Parma_Polyhedra_Library::Linear_System::add_pending_rows(), add_recycled_row(), add_row(), add_zero_columns(), add_zero_rows(), add_zero_rows_and_columns(), clear(), external_memory_in_bytes(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Matrix(), Parma_Polyhedra_Library::Linear_System::merge_rows_assign(), OK(), Parma_Polyhedra_Library::Linear_System::OK(), operator=(), resize_no_copy(), and swap().