Polymake Template Library (PTL)
4.2
|
0/1 incidence matrix. More...
Public Member Functions | |
IncidenceMatrix () | |
Create an empty IncidenceMatrix. | |
IncidenceMatrix (Int r, Int c) | |
Create an empty IncidenceMatrix with r rows and c columns initialized with zeroes. | |
template<typename Iterator > | |
IncidenceMatrix (Int r, Int c, Iterator &&src) | |
Create an IncidenceMatrix IncidenceMatrix with r rows and c columns and initialize it from a data sequence. More... | |
template<typename How , typename... Sources, typename = std::enable_if_t<!symmetric::value && is_among<How, sparse2d::rowwise, sparse2d::columnwise>::value && mlist_and_nonempty<fits_for_append_to_IM<Sources>...>::value>> | |
IncidenceMatrix (How how, const Sources &... src) | |
template<typename Container , typename = std::enable_if_t<!symmetric::value && isomorphic_to_container_of<Container, Set<Int>, allow_conversion>::value>> | |
IncidenceMatrix (const Container &src) | |
template<typename Container , typename = std::enable_if_t<!symmetric::value && isomorphic_to_container_of<Container, Set<Int>, allow_conversion>::value>> | |
IncidenceMatrix (const Container &src, Int c) | |
Construct a matrix with a prescribed number of columns from a given sequence of row sets. | |
void | swap (IncidenceMatrix &M) |
Swap the contents with that of another matrix in an efficient way. | |
void | resize (Int m, Int n) |
Extend or truncate to new dimensions (m rows, n columns). Surviving elements keep their values, new elements are implicitly false . More... | |
void | clear () |
Clear contents. | |
void | clear (Int r, Int c) |
Clear contents. | |
reference | operator() (Int i, Int j) |
Entry at row i column j. | |
const_reference | operator() (Int i, Int j) const |
Entry at row i column j (const). | |
bool | exists (Int i, Int j) const |
Returns the entry at position (i,j). | |
void | squeeze () |
Delete empty rows and columns, renumber the rest and reduce the dimensions. | |
void | squeeze_rows () |
Delete empty rows, renumber the rest and reduce the dimensions. | |
void | squeeze_cols () |
Delete empty columns, renumber the rest and reduce the dimensions. | |
template<typename Permutation > | |
std::enable_if_t< isomorphic_to_container_of< Permutation, Int >::value > | permute_rows (const Permutation &perm) |
Permute the rows according to the given permutation. | |
template<typename Permutation > | |
std::enable_if_t< isomorphic_to_container_of< Permutation, Int >::value > | permute_cols (const Permutation &perm) |
Permute the columns according to the given permutation. | |
template<typename InvPermutation > | |
std::enable_if_t< isomorphic_to_container_of< InvPermutation, Int >::value > | permute_inv_rows (const InvPermutation &inv_perm) |
Permute the rows according to the inverse of the given permutation. | |
template<typename InvPermutation > | |
std::enable_if_t< isomorphic_to_container_of< InvPermutation, Int >::value > | permute_inv_cols (const InvPermutation &inv_perm) |
Permute the columns according to the inverse of the given permutation. | |
Protected Member Functions | |
template<typename Iterator > | |
void | init_impl (Iterator &&src, std::true_type) |
initialize from a dense boolean sequence in row order | |
template<typename Iterator > | |
void | init_rowwise (Iterator &&src, std::true_type) |
input already ordered | |
template<typename Iterator > | |
void | init_rowwise (Iterator &&src, std::false_type) |
input in uncertain order | |
template<typename Iterator > | |
void | init_impl (Iterator &&src, std::false_type) |
initialize rowwise from a sequence of sets | |
0/1 incidence matrix.
The only persistent class from the incidence matrix family. The implementation is based on a two-dimensional grid of balanced binary search (AVL) trees, the same as for
A symmetric incidence matrix is a square matrix whose elements (i,j)
and (j,i)
are always equal. Internally it is stored in a triangular form, avoiding redundant elements, but appears as a full square.
|
inline |
Create an IncidenceMatrix IncidenceMatrix with r rows and c columns and initialize it from a data sequence.
src should iterate either over r×c boolean values, corresponding to the elements in the row order (the column index changes first,) or over r sets with integer elements (or convertible to integer), which are assigned to the matrix rows.
In the symmetric case the redundant elements must be present in the input sequence; their values are ignored.
r | the number of rows |
c | the number of columns |
src | an iterator |
|
inline |
Construct a matrix by rowwise or columnwise concatenation of given matrices and/or sets. Dimensions are set automatically to encompass all input elements.
|
inlineexplicit |
Construct a matrix from a given sequence of row sets. Number of columns is set automatically to encompass all input elements.
|
inline |
Extend or truncate to new dimensions (m rows, n columns). Surviving elements keep their values, new elements are implicitly false
.
IncidenceMatrix
deploys an adaptive reallocation strategy similar to std::vector
, reserving additional stock memory by every reallocation. If you repeatedly increase the matrix dimensions by one, the amortized reallocation costs will be proportional to the logarithm of the final dimension.
A special case, looking at the first glance like a "no operation": { M.resize(M.rows(), M.cols()) }, gets rid of this extra allocated storage.