|
PPL
1.2
|
A sparse matrix of Coefficient. More...
#include <Matrix_defs.hh>


Public Types | |
| typedef Swapping_Vector< Row >::iterator | iterator |
| typedef Swapping_Vector< Row >::const_iterator | const_iterator |
Public Member Functions | |
| Matrix (dimension_type n=0) | |
| Constructs a square matrix with the given size, filled with unstored zeroes. More... | |
| Matrix (dimension_type num_rows, dimension_type num_columns) | |
| Constructs a matrix with the given dimensions, filled with unstored zeroes. More... | |
| void | m_swap (Matrix &x) |
| Swaps (*this) with x. More... | |
| dimension_type | num_rows () const |
| Returns the number of rows in the matrix. More... | |
| dimension_type | num_columns () const |
| Returns the number of columns in the matrix. More... | |
| dimension_type | capacity () const |
| Returns the capacity of the row vector. More... | |
| bool | has_no_rows () const |
Returns true if and only if *this has no rows. More... | |
| void | resize (dimension_type n) |
| Equivalent to resize(n, n). More... | |
| void | reserve_rows (dimension_type n) |
Reserves space for at least n rows. More... | |
| void | resize (dimension_type num_rows, dimension_type num_columns) |
| Resizes this matrix to the specified dimensions. More... | |
| void | add_zero_rows_and_columns (dimension_type n, dimension_type m) |
Adds n rows and m columns of zeroes to the matrix. More... | |
| void | add_zero_rows (dimension_type n) |
Adds to the matrix n rows of zeroes. More... | |
| void | add_row (const Row &x) |
Adds a copy of the row x at the end of the matrix. More... | |
| void | add_recycled_row (Row &y) |
Adds the row y to the matrix. More... | |
| void | remove_trailing_rows (dimension_type n) |
Removes from the matrix the last n rows. More... | |
| void | remove_rows (iterator first, iterator last) |
| void | permute_columns (const std::vector< dimension_type > &cycles) |
| Permutes the columns of the matrix. More... | |
| void | swap_columns (dimension_type i, dimension_type j) |
Swaps the columns having indexes i and j. More... | |
| void | add_zero_columns (dimension_type n) |
Adds n columns of zeroes to the matrix. More... | |
| void | add_zero_columns (dimension_type n, dimension_type i) |
Adds n columns of non-stored zeroes to the matrix before column i. More... | |
| void | remove_column (dimension_type i) |
| Removes the i-th from the matrix, shifting other columns to the left. More... | |
| void | remove_trailing_columns (dimension_type n) |
Shrinks the matrix by removing its n trailing columns. More... | |
| void | clear () |
| Equivalent to resize(0,0). More... | |
| iterator | begin () |
| Returns an iterator pointing to the first row. More... | |
| iterator | end () |
| Returns an iterator pointing after the last row. More... | |
| const_iterator | begin () const |
| Returns an iterator pointing to the first row. More... | |
| const_iterator | end () const |
| Returns an iterator pointing after the last row. More... | |
| Row & | operator[] (dimension_type i) |
| Returns a reference to the i-th row. More... | |
| const Row & | operator[] (dimension_type i) const |
| Returns a const reference to the i-th row. More... | |
| bool | ascii_load (std::istream &s) |
| Loads the row from an ASCII representation generated using ascii_dump(). More... | |
| void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this. More... | |
| void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this. More... | |
| void | print () const |
Prints *this to std::cerr using operator<<. More... | |
| memory_size_type | total_memory_in_bytes () const |
Returns the total size in bytes of the memory occupied by *this. More... | |
| memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this. More... | |
| bool | OK () const |
| Checks if all the invariants are satisfied. More... | |
Static Public Member Functions | |
| static dimension_type | max_num_rows () |
| Returns the maximum number of rows of a Sparse_Matrix. More... | |
| static dimension_type | max_num_columns () |
| Returns the maximum number of columns of a Sparse_Matrix. More... | |
Private Attributes | |
| Swapping_Vector< Row > | rows |
| The vector that stores the matrix's elements. More... | |
| dimension_type | num_columns_ |
| The number of columns in this matrix. More... | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename Row > | |
| void | swap (Matrix< Row > &x, Matrix< Row > &y) |
| template<typename Row > | |
| bool | operator== (const Matrix< Row > &x, const Matrix< Row > &y) |
Returns true if and only if x and y are identical. More... | |
| template<typename Row > | |
| bool | operator!= (const Matrix< Row > &x, const Matrix< Row > &y) |
Returns true if and only if x and y are different. More... | |
| template<typename Row > | |
| bool | operator== (const Matrix< Row > &x, const Matrix< Row > &y) |
| template<typename Row > | |
| bool | operator!= (const Matrix< Row > &x, const Matrix< Row > &y) |
A sparse matrix of Coefficient.
Definition at line 37 of file Matrix_defs.hh.
| typedef Swapping_Vector<Row>::const_iterator Parma_Polyhedra_Library::Matrix< Row >::const_iterator |
Definition at line 41 of file Matrix_defs.hh.
| typedef Swapping_Vector<Row>::iterator Parma_Polyhedra_Library::Matrix< Row >::iterator |
Definition at line 40 of file Matrix_defs.hh.
|
explicit |
Constructs a square matrix with the given size, filled with unstored zeroes.
| n | The size of the new square matrix. |
This method takes
time.
Definition at line 30 of file Matrix_templates.hh.
References Parma_Polyhedra_Library::Matrix< Row >::num_columns_, Parma_Polyhedra_Library::Matrix< Row >::OK(), Parma_Polyhedra_Library::Swapping_Vector< T >::resize(), Parma_Polyhedra_Library::Matrix< Row >::rows, and Parma_Polyhedra_Library::Swapping_Vector< T >::size().
| Parma_Polyhedra_Library::Matrix< Row >::Matrix | ( | dimension_type | num_rows, |
| dimension_type | num_columns | ||
| ) |
Constructs a matrix with the given dimensions, filled with unstored zeroes.
| num_rows | The number of rows in the new matrix. |
| num_columns | The number of columns in the new matrix. |
This method takes
time, where n is num_rows.
Definition at line 39 of file Matrix_templates.hh.
References Parma_Polyhedra_Library::Matrix< Row >::num_columns_, Parma_Polyhedra_Library::Matrix< Row >::OK(), Parma_Polyhedra_Library::Swapping_Vector< T >::resize(), Parma_Polyhedra_Library::Matrix< Row >::rows, and Parma_Polyhedra_Library::Swapping_Vector< T >::size().
|
inline |
Adds the row y to the matrix.
| y | The row to be added: it must have the same size and capacity as *this. It is not declared const because its data-structures will recycled to build the new matrix row. |
Turns the
matrix
into the
matrix
. The matrix is expanded avoiding reallocation whenever possible.
Definition at line 111 of file Matrix_inlines.hh.
References Parma_Polyhedra_Library::swap().
|
inline |
Adds a copy of the row x at the end of the matrix.
| x | The row that will be appended to the matrix. |
This operation invalidates existing iterators.
This method takes
amortized time, where n is the numer of elements stored in x.
Definition at line 100 of file Matrix_inlines.hh.
References Parma_Polyhedra_Library::swap().
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), and Parma_Polyhedra_Library::PIP_Solution_Node::solve().
|
inline |
Adds n columns of zeroes to the matrix.
| n | The number of columns to be added: must be strictly positive. |
Turns the
matrix
into the
matrix
.
This method takes
amortized time, where r is the numer of the matrix's rows.
Definition at line 131 of file Matrix_inlines.hh.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut().
| void Parma_Polyhedra_Library::Matrix< Row >::add_zero_columns | ( | dimension_type | n, |
| dimension_type | i | ||
| ) |
Adds n columns of non-stored zeroes to the matrix before column i.
| n | The numer of columns that will be added. |
| i | The index of the column before which the new columns will be added. |
This operation invalidates existing iterators.
This method takes
time, where r is the number of rows,
is the number of elements stored in the columns of the j-th row that must be shifted and
is the number of elements stored in the j-th row. A weaker (but simpler) bound is
time, where k is the number of elements that must be shifted, r is the number of the rows and c is the number of the columns.
Definition at line 120 of file Matrix_templates.hh.
|
inline |
Adds to the matrix n rows of zeroes.
| n | The number of rows to be added: must be strictly positive. |
Turns the
matrix
into the
matrix
. The matrix is expanded avoiding reallocation whenever possible.
This method takes
amortized time, where k is the number of the new rows.
Definition at line 94 of file Matrix_inlines.hh.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), and Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut().
|
inline |
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. |
Turns the
matrix
into the
matrix
. The matrix is expanded avoiding reallocation whenever possible.
This method takes
time, where r is the number of the matrix's rows after the operation.
Definition at line 88 of file Matrix_inlines.hh.
| void Parma_Polyhedra_Library::Matrix< Row >::ascii_dump | ( | std::ostream & | s | ) | const |
Writes to s an ASCII representation of *this.
Definition at line 140 of file Matrix_templates.hh.
| void Parma_Polyhedra_Library::Matrix< Row >::ascii_dump | ( | ) | const |
Writes to std::cerr an ASCII representation of *this.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::solve().
| bool Parma_Polyhedra_Library::Matrix< Row >::ascii_load | ( | std::istream & | s | ) |
Loads the row from an ASCII representation generated using ascii_dump().
| s | The stream from which read the ASCII representation. |
This method takes
time.
Definition at line 152 of file Matrix_templates.hh.
References Parma_Polyhedra_Library::ascii_load().
|
inline |
Returns an iterator pointing to the first row.
This method takes
time.
Definition at line 150 of file Matrix_inlines.hh.
|
inline |
Returns an iterator pointing to the first row.
This method takes
time.
Definition at line 162 of file Matrix_inlines.hh.
|
inline |
Returns the capacity of the row vector.
Definition at line 63 of file Matrix_inlines.hh.
|
inline |
Equivalent to resize(0,0).
Definition at line 144 of file Matrix_inlines.hh.
|
inline |
Returns an iterator pointing after the last row.
This method takes
time.
Definition at line 156 of file Matrix_inlines.hh.
|
inline |
Returns an iterator pointing after the last row.
This method takes
time.
Definition at line 168 of file Matrix_inlines.hh.
| memory_size_type Parma_Polyhedra_Library::Matrix< Row >::external_memory_in_bytes | ( | ) | const |
Returns the size in bytes of the memory managed by *this.
This method is
, where r is the number of rows and k is the number of elements stored in the matrix.
Definition at line 186 of file Matrix_templates.hh.
|
inline |
Returns true if and only if *this has no rows.
empty because this would cause an error prone name clash with the corresponding methods in derived classes Constraint_System and Congruence_System (which have a different semantics). Definition at line 69 of file Matrix_inlines.hh.
|
inline |
Swaps (*this) with x.
| x | The matrix that will be swapped with *this. |
This method takes
time.
Definition at line 43 of file Matrix_inlines.hh.
References Parma_Polyhedra_Library::Matrix< Row >::num_columns_, Parma_Polyhedra_Library::Matrix< Row >::rows, and Parma_Polyhedra_Library::swap().
Referenced by Parma_Polyhedra_Library::swap().
|
inlinestatic |
Returns the maximum number of columns of a Sparse_Matrix.
Definition at line 37 of file Matrix_inlines.hh.
|
inlinestatic |
Returns the maximum number of rows of a Sparse_Matrix.
Definition at line 31 of file Matrix_inlines.hh.
|
inline |
Returns the number of columns in the matrix.
This method takes
time.
Definition at line 57 of file Matrix_inlines.hh.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), and Parma_Polyhedra_Library::Matrix< Row >::operator==().
|
inline |
Returns the number of rows in the matrix.
This method takes
time.
Definition at line 51 of file Matrix_inlines.hh.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), Parma_Polyhedra_Library::Matrix< Row >::operator==(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
| bool Parma_Polyhedra_Library::Matrix< Row >::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Definition at line 192 of file Matrix_templates.hh.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check(), and Parma_Polyhedra_Library::Matrix< Row >::Matrix().
|
inline |
Returns a reference to the i-th row.
| i | The index of the desired row. |
This method takes
time.
Definition at line 174 of file Matrix_inlines.hh.
|
inline |
Returns a const reference to the i-th row.
| i | The index of the desired row. |
This method takes
time.
Definition at line 181 of file Matrix_inlines.hh.
| void Parma_Polyhedra_Library::Matrix< Row >::permute_columns | ( | const std::vector< dimension_type > & | cycles | ) |
Permutes the columns of the matrix.
This method may be slow for some Row types, and should be avoided if possible.
| cycles | A vector representing the non-trivial cycles of the permutation according to which the columns must be rearranged. |
The cycles vector contains, one after the other, the non-trivial cycles (i.e., the cycles of length greater than one) of a permutation of non-zero column indexes. Each cycle is terminated by zero. For example, assuming the matrix has 7 columns, the permutation
can be represented by the non-trivial cycles
that, in turn can be represented by a vector of 6 elements containing 1, 3, 6, 0, 2, 4, 0.
This method takes
expected time, where k is the size of the cycles vector, r the number of rows and
the number of elements stored in row j. A weaker (but simpler) bound is
, where k is the size of the cycles vector, r is the number of rows and c is the number of columns.
Definition at line 75 of file Matrix_templates.hh.
References PPL_DIRTY_TEMP_COEFFICIENT, and Parma_Polyhedra_Library::swap().
| void Parma_Polyhedra_Library::Matrix< Row >::print | ( | ) | const |
Prints *this to std::cerr using operator<<.
| void Parma_Polyhedra_Library::Matrix< Row >::remove_column | ( | dimension_type | i | ) |
Removes the i-th from the matrix, shifting other columns to the left.
| i | The index of the column that will be removed. |
This operation invalidates existing iterators on rows' elements.
This method takes
amortized time, where k is the number of elements stored with column index greater than i, r the number of rows in this matrix and
the number of elements stored in row j. A weaker (but simpler) bound is
, where r is the number of rows, c is the number of columns and i is the parameter passed to this method.
Definition at line 130 of file Matrix_templates.hh.
|
inline |
Definition at line 125 of file Matrix_inlines.hh.
|
inline |
Shrinks the matrix by removing its n trailing columns.
| n | The number of trailing columns that will be removed. |
This operation invalidates existing iterators.
This method takes
amortized time, where r is the number of rows,
is the number of elements that have to be removed from row j and
is the total number of elements stored in row j. A weaker (but simpler) bound is
, where r is the number of rows, c the number of columns and n the parameter passed to this method.
Definition at line 137 of file Matrix_inlines.hh.
|
inline |
Removes from the matrix the last n rows.
| n | The number of row that will be removed. |
It is equivalent to num_rows() - n, num_columns()).
This method takes
amortized time, where k is the total number of elements stored in the removed rows and n is the number of removed rows.
Definition at line 119 of file Matrix_inlines.hh.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check().
|
inline |
Reserves space for at least n rows.
Definition at line 81 of file Matrix_inlines.hh.
|
inline |
Equivalent to resize(n, n).
Definition at line 75 of file Matrix_inlines.hh.
| void Parma_Polyhedra_Library::Matrix< Row >::resize | ( | dimension_type | num_rows, |
| dimension_type | num_columns | ||
| ) |
Resizes this matrix to the specified dimensions.
| num_rows | The desired numer of rows. |
| num_columns | The desired numer of columns. |
New rows and columns will contain non-stored zeroes.
This operation invalidates existing iterators.
Adding n rows takes
amortized time.
Adding n columns takes
time, where r is num_rows.
Removing n rows takes
amortized time, where k is the total number of elements stored in the removed rows.
Removing n columns takes
time, where r is the number of rows,
is the number of elements stored in the columns of the j-th row that must be removed and
is the total number of elements stored in the j-th row. A weaker (but simpler) bound is
, where r is the number of rows, k is the number of elements that have to be removed and c is the number of columns.
Definition at line 49 of file Matrix_templates.hh.
| void Parma_Polyhedra_Library::Matrix< Row >::swap_columns | ( | dimension_type | i, |
| dimension_type | j | ||
| ) |
Swaps the columns having indexes i and j.
Definition at line 112 of file Matrix_templates.hh.
|
inline |
Returns the total size in bytes of the memory occupied by *this.
This method is
, where r is the number of rows and k is the number of elements stored in the matrix.
Definition at line 188 of file Matrix_inlines.hh.
References Parma_Polyhedra_Library::external_memory_in_bytes().
|
related |
Definition at line 222 of file Matrix_templates.hh.
|
related |
Returns true if and only if x and y are different.
|
related |
Definition at line 204 of file Matrix_templates.hh.
References Parma_Polyhedra_Library::Matrix< Row >::num_columns(), and Parma_Polyhedra_Library::Matrix< Row >::num_rows().
|
related |
Returns true if and only if x and y are identical.
Definition at line 194 of file Matrix_inlines.hh.
|
private |
The number of columns in this matrix.
Definition at line 406 of file Matrix_defs.hh.
Referenced by Parma_Polyhedra_Library::Matrix< Row >::m_swap(), and Parma_Polyhedra_Library::Matrix< Row >::Matrix().
|
private |
The vector that stores the matrix's elements.
Definition at line 403 of file Matrix_defs.hh.
Referenced by Parma_Polyhedra_Library::Matrix< Row >::m_swap(), and Parma_Polyhedra_Library::Matrix< Row >::Matrix().