Matrix structure to store the ordered boundary matrix \( R \cdot U \) of a filtered complex in order to compute its persistent homology, as well as representative cycles. Supports vineyards (see [21]) and the removal of maximal faces while maintaining a valid barcode. Provides an access to its columns and rows. More...
Public Types | |
using | Field_operators = typename Master_matrix::Field_operators |
Field operators class. Necessary only if PersistenceMatrixOptions::is_z2 is false. | |
using | Field_element_type = typename Master_matrix::element_type |
using | Column_type = typename Master_matrix::Column_type |
using | Row_type = typename Master_matrix::Row_type |
using | Cell_constructor = typename Master_matrix::Cell_constructor |
using | Column_settings = typename Master_matrix::Column_settings |
using | boundary_type = typename Master_matrix::boundary_type |
using | index = typename Master_matrix::index |
using | id_index = typename Master_matrix::id_index |
using | pos_index = typename Master_matrix::pos_index |
using | dimension_type = typename Master_matrix::dimension_type |
Public Member Functions | |
RU_matrix (Column_settings *colSettings) | |
Constructs an empty matrix. More... | |
template<class Boundary_type = boundary_type> | |
RU_matrix (const std::vector< Boundary_type > &orderedBoundaries, Column_settings *colSettings) | |
Constructs a new matrix from the given ranges of Matrix::cell_rep_type. Each range corresponds to a column (the order of the ranges are preserved). The content of the ranges is assumed to be sorted by increasing IDs. The IDs of the simplices are also assumed to be consecutifs, ordered by filtration value, starting with 0. More... | |
RU_matrix (unsigned int numberOfColumns, Column_settings *colSettings) | |
Constructs a new empty matrix and reserves space for the given number of columns. More... | |
RU_matrix (const RU_matrix &matrixToCopy, Column_settings *colSettings=nullptr) | |
Copy constructor. If colSettings is not a null pointer, its value is kept instead of the one in the copied matrix. More... | |
RU_matrix (RU_matrix &&other) noexcept | |
Move constructor. More... | |
template<class Boundary_type = boundary_type> | |
void | insert_boundary (const Boundary_type &boundary, dimension_type dim=-1) |
Inserts at the end of the matrix a new ordered column corresponding to the given boundary. This means that it is assumed that this method is called on boundaries in the order of the filtration. It also assumes that the faces in the given boundary are identified by their relative position in the filtration, starting at 0. If it is not the case, use the other insert_boundary instead by indicating the face ID used in the boundaries when the face is inserted. More... | |
template<class Boundary_type = boundary_type> | |
void | insert_boundary (id_index faceIndex, const Boundary_type &boundary, dimension_type dim=-1) |
It does the same as the other version, but allows the boundary faces to be identified without restrictions except that all IDs have to be strictly increasing in the order of filtration. Note that you should avoid then to use the other insertion method to avoid overwriting IDs. More... | |
Column_type & | get_column (index columnIndex, bool inR=true) |
Returns the column at the given MatIdx index in \( R \) if inR is true and in \( U \) if inR is false. The type of the column depends on the choosen options, see PersistenceMatrixOptions::column_type. More... | |
Row_type & | get_row (index rowIndex, bool inR=true) |
Returns the row at the given row index in \( R \) if inR is true and in \( U \) if inR is false. The type of the row depends on the choosen options, see PersistenceMatrixOptions::has_intrusive_rows. More... | |
void | erase_empty_row (index rowIndex) |
If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true: assumes that the row is empty in \( R \) and removes it from \( R \). If the matrix is valid, a row will never be empty in \( U \), so \( U \) won't be affected. If PersistenceMatrixOptions::has_map_column_container and PersistenceMatrixOptions::has_column_and_row_swaps are true: cleans up maps used for the lazy row swaps. Otherwise, does nothing. More... | |
void | remove_maximal_face (index columnIndex) |
Only available if PersistenceMatrixOptions::has_removable_columns and PersistenceMatrixOptions::has_vine_update are true. Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent (i.e., RU is still an upper triangular decomposition of the boundary matrix). The maximality of the face is not verified. Also updates the barcode if it is stored. More... | |
void | remove_last () |
Only available if PersistenceMatrixOptions::has_removable_columns is true. Removes the last face in the filtration from the matrix and updates the barcode if it is stored. More... | |
dimension_type | get_max_dimension () const |
Returns the maximal dimension of a face stored in the matrix. Only available if PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true. More... | |
index | get_number_of_columns () const |
Returns the current number of columns in the matrix. More... | |
dimension_type | get_column_dimension (index columnIndex) const |
Returns the dimension of the given column. More... | |
void | add_to (index sourceColumnIndex, index targetColumnIndex) |
Adds column at sourceColumnIndex onto the column at targetColumnIndex in the matrix. More... | |
void | multiply_target_and_add_to (index sourceColumnIndex, const Field_element_type &coefficient, index targetColumnIndex) |
Multiplies the target column with the coefficiant and then adds the source column to it. That is: targetColumn = (targetColumn * coefficient) + sourceColumn . More... | |
void | multiply_source_and_add_to (const Field_element_type &coefficient, index sourceColumnIndex, index targetColumnIndex) |
Multiplies the source column with the coefficiant before adding it to the target column. That is: targetColumn += (coefficient * sourceColumn) . The source column will not be modified. More... | |
void | zero_cell (index columnIndex, index rowIndex, bool inR=true) |
Zeroes the cell at the given coordinates in \( R \) if inR is true or in \( U \) if inR is false. Should be used with care to not destroy the validity of the persistence related properties of the matrix. More... | |
void | zero_column (index columnIndex, bool inR=true) |
Zeroes the column at the given index in \( R \) if inR is true or in \( U \) if inR is false. Should be used with care to not destroy the validity of the persistence related properties of the matrix. More... | |
bool | is_zero_cell (index columnIndex, index rowIndex, bool inR=true) const |
Indicates if the cell at given coordinates has value zero in \( R \) if inR is true or in \( U \) if inR is false. More... | |
bool | is_zero_column (index columnIndex, bool inR=true) |
Indicates if the column at given index has value zero in \( R \) if inR is true or in \( U \) if inR is false. More... | |
index | get_column_with_pivot (index faceIndex) const |
Returns the MatIdx index of the column which has the given row index as pivot in \( R \). Assumes that the pivot exists. More... | |
index | get_pivot (index columnIndex) |
Returns the row index of the pivot of the given column in \( R \). More... | |
void | reset (Column_settings *colSettings) |
Resets the matrix to an empty matrix. More... | |
RU_matrix & | operator= (const RU_matrix &other) |
Assign operator. | |
Friends | |
void | swap (RU_matrix &matrix1, RU_matrix &matrix2) |
Swap operator. | |
Matrix structure to store the ordered boundary matrix \( R \cdot U \) of a filtered complex in order to compute its persistent homology, as well as representative cycles. Supports vineyards (see [21]) and the removal of maximal faces while maintaining a valid barcode. Provides an access to its columns and rows.
Master_matrix | An instanciation of Matrix from which all types and options are deduced. |
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::boundary_type = typename Master_matrix::boundary_type |
Type of an input column.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::Cell_constructor = typename Master_matrix::Cell_constructor |
Factory of Cell classes.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::Column_settings = typename Master_matrix::Column_settings |
Structure giving access to the columns to necessary external classes.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::Column_type = typename Master_matrix::Column_type |
Column type.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::dimension_type = typename Master_matrix::dimension_type |
Dimension value type.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::Field_element_type = typename Master_matrix::element_type |
Type of an field element.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::id_index = typename Master_matrix::id_index |
IDIdx index type.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::index = typename Master_matrix::index |
MatIdx index type.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::pos_index = typename Master_matrix::pos_index |
PosIdx index type.
using Gudhi::persistence_matrix::RU_matrix< Master_matrix >::Row_type = typename Master_matrix::Row_type |
Row type, only necessary with row access option.
|
inline |
Constructs an empty matrix.
colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the choosen column type, such as custom allocators. |
|
inline |
Constructs a new matrix from the given ranges of Matrix::cell_rep_type. Each range corresponds to a column (the order of the ranges are preserved). The content of the ranges is assumed to be sorted by increasing IDs. The IDs of the simplices are also assumed to be consecutifs, ordered by filtration value, starting with 0.
Boundary_type | Range type for Matrix::cell_rep_type ranges. Assumed to have a begin(), end() and size() method. |
orderedBoundaries | Range of boundaries: orderedBoundaries is interpreted as a boundary matrix of a filtered simplicial complex, whose boundaries are ordered by filtration order. Therefore, orderedBoundaries[i] should store the boundary of the \( i^{th} \) simplex in the filtration, as an ordered list of indices of its facets (again those indices correspond to their respective position in the matrix). That is why the indices of the simplices are assumed to be consecutifs and starting with 0 (an empty boundary is interpreted as a vertex boundary and not as a non existing simplex). All dimensions up to the maximal dimension of interest have to be present. If only a higher dimension is of interest and not everything should be stored, then use the insert_boundary method instead (after creating the matrix with the RU_matrix(unsigned int, Column_settings*) constructor preferably). |
colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the choosen column type, such as custom allocators. |
|
inline |
Constructs a new empty matrix and reserves space for the given number of columns.
numberOfColumns | Number of columns to reserve space for. |
colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the choosen column type, such as custom allocators. |
|
inline |
Copy constructor. If colSettings
is not a null pointer, its value is kept instead of the one in the copied matrix.
matrixToCopy | Matrix to copy. |
colSettings | Either a pointer to an existing setting structure for the columns or a null pointer. The structure should contain all the necessary external classes specifically necessary for the choosen column type, such as custom allocators. If null pointer, the pointer stored in matrixToCopy is used instead. |
|
inlinenoexcept |
Move constructor.
other | Matrix to move. |
|
inline |
Adds column at sourceColumnIndex
onto the column at targetColumnIndex
in the matrix.
|
inline |
If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true: assumes that the row is empty in \( R \) and removes it from \( R \). If the matrix is valid, a row will never be empty in \( U \), so \( U \) won't be affected. If PersistenceMatrixOptions::has_map_column_container and PersistenceMatrixOptions::has_column_and_row_swaps are true: cleans up maps used for the lazy row swaps. Otherwise, does nothing.
rowIndex | Row index of the empty row. |
|
inline |
Returns the column at the given MatIdx index in \( R \) if inR
is true and in \( U \) if inR
is false. The type of the column depends on the choosen options, see PersistenceMatrixOptions::column_type.
Note that before returning the column, all column cells can eventually be reordered, if lazy swaps occurred. It is therefore recommended to avoid calling get_column between vine swaps, otherwise the benefits of the the lazyness is lost.
columnIndex | MatIdx index of the column to return. |
inR | If true, returns the column in \( R \), if false, returns the column in \( U \). Default value: true. |
|
inline |
Returns the dimension of the given column.
columnIndex | MatIdx index of the column representing the face. |
|
inline |
|
inline |
Returns the maximal dimension of a face stored in the matrix. Only available if PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true.
|
inline |
Returns the current number of columns in the matrix.
|
inline |
|
inline |
Returns the row at the given row index in \( R \) if inR
is true and in \( U \) if inR
is false. The type of the row depends on the choosen options, see PersistenceMatrixOptions::has_intrusive_rows.
Note that before returning the row, all column cells can eventually be reordered, if lazy swaps occurred. It is therefore recommended to avoid calling get_row between vine swaps, otherwise the benefits of the the lazyness is lost.
rowIndex | Row index of the row to return. |
inR | If true, returns the row in \( R \), if false, returns the row in \( U \). Default value: true. |
|
inline |
Inserts at the end of the matrix a new ordered column corresponding to the given boundary. This means that it is assumed that this method is called on boundaries in the order of the filtration. It also assumes that the faces in the given boundary are identified by their relative position in the filtration, starting at 0. If it is not the case, use the other insert_boundary instead by indicating the face ID used in the boundaries when the face is inserted.
Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from a more general cell complex. This includes cubical complexes or Morse complexes for example.
At the insertion, the boundary is stored in its reduced form and the barcode, if enabled, is updated.
Boundary_type | Range of Matrix::cell_rep_type. Assumed to have a begin(), end() and size() method. |
boundary | Boundary generating the new column. The content should be ordered by ID. |
dim | Dimension of the face whose boundary is given. If the complex is simplicial, this parameter can be omitted as it can be deduced from the size of the boundary. |
|
inline |
It does the same as the other version, but allows the boundary faces to be identified without restrictions except that all IDs have to be strictly increasing in the order of filtration. Note that you should avoid then to use the other insertion method to avoid overwriting IDs.
As a face has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that the faces are inserted by order of filtration), it is sufficient to indicate the ID of the face being inserted.
Boundary_type | Range of Matrix::cell_rep_type. Assumed to have a begin(), end() and size() method. |
faceIndex | IDIdx index to use to indentify the new face. |
boundary | Boundary generating the new column. The indices of the boundary have to correspond to the faceIndex values of precedent calls of the method for the corresponding faces and should be ordered in increasing order. |
dim | Dimension of the face whose boundary is given. If the complex is simplicial, this parameter can be omitted as it can be deduced from the size of the boundary. |
|
inline |
Indicates if the cell at given coordinates has value zero in \( R \) if inR
is true or in \( U \) if inR
is false.
columnIndex | MatIdx index of the column of the cell. |
rowIndex | Row index of the row of the cell. |
inR | Boolean indicating in which matrix to look: if true in \( R \) and if false in \( U \). Default value: true. |
|
inline |
Indicates if the column at given index has value zero in \( R \) if inR
is true or in \( U \) if inR
is false.
Note that if inR
is false, this method should usually return false.
columnIndex | MatIdx index of the column. |
inR | Boolean indicating in which matrix to look: if true in \( R \) and if false in \( U \). Default value: true. |
|
inline |
Multiplies the source column with the coefficiant before adding it to the target column. That is: targetColumn += (coefficient * sourceColumn)
. The source column will not be modified.
|
inline |
Multiplies the target column with the coefficiant and then adds the source column to it. That is: targetColumn = (targetColumn * coefficient) + sourceColumn
.
|
inline |
Only available if PersistenceMatrixOptions::has_removable_columns is true. Removes the last face in the filtration from the matrix and updates the barcode if it is stored.
See also remove_maximal_face.
|
inline |
Only available if PersistenceMatrixOptions::has_removable_columns and PersistenceMatrixOptions::has_vine_update are true. Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent (i.e., RU is still an upper triangular decomposition of the boundary matrix). The maximality of the face is not verified. Also updates the barcode if it is stored.
See also remove_last.
columnIndex | MatIdx index of the face to remove. |
|
inline |
Resets the matrix to an empty matrix.
colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the choosen column type, such as custom allocators. |
|
inline |
Zeroes the cell at the given coordinates in \( R \) if inR
is true or in \( U \) if inR
is false. Should be used with care to not destroy the validity of the persistence related properties of the matrix.
|
inline |
Zeroes the column at the given index in \( R \) if inR
is true or in \( U \) if inR
is false. Should be used with care to not destroy the validity of the persistence related properties of the matrix.
columnIndex | MatIdx index of the column to zero. |
inR | Boolean indicating in which matrix to zero: if true in \( R \) and if false in \( U \). Default value: true. |