A basic matrix structure allowing to easily manipulate and access entire columns and rows, but not individual cells. More...
Public Types | |
using | index = typename Master_matrix::index |
using | dimension_type = typename Master_matrix::dimension_type |
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 | container_type = typename Master_matrix::boundary_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 |
Public Member Functions | |
Base_matrix (Column_settings *colSettings) | |
Constructs an empty matrix. More... | |
template<class Container_type = container_type> | |
Base_matrix (const std::vector< Container_type > &columns, Column_settings *colSettings) | |
Constructs a matrix from the given ordered columns. The columns are inserted in the given order. More... | |
Base_matrix (unsigned int numberOfColumns, Column_settings *colSettings) | |
Constructs a new empty matrix and reserves space for the given number of columns. More... | |
Base_matrix (const Base_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... | |
Base_matrix (Base_matrix &&other) noexcept | |
Move constructor. More... | |
template<class Container_type = container_type> | |
void | insert_column (const Container_type &column) |
Inserts a new ordered column at the end of the matrix by copying the given range of Matrix::cell_rep_type. The content of the range is assumed to be sorted by increasing ID value. More... | |
template<class Container_type = container_type> | |
void | insert_column (const Container_type &column, index columnIndex) |
Inserts a new ordered column at the given index by copying the given range of Matrix::cell_rep_type. There should not be any other column inserted at that index which was not explicitely removed before. The content of the range is assumed to be sorted by increasing ID value. Not available when row access is enabled. More... | |
template<class Boundary_type > | |
void | insert_boundary (const Boundary_type &boundary, dimension_type dim=-1) |
Same as insert_column, only for interface purposes. The given dimension is ignored and not stored. More... | |
Column_type & | get_column (index columnIndex) |
Returns the column at the given MatIdx index. The type of the column depends on the choosen options, see PersistenceMatrixOptions::column_type. More... | |
Row_type & | get_row (index rowIndex) |
Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row index of the matrix. The type of the row depends on the choosen options, see PersistenceMatrixOptions::has_intrusive_rows. More... | |
void | remove_column (index columnIndex) |
Only available if PersistenceMatrixOptions::has_map_column_container is true. Otherwise, see remove_last. Erases the given column from the matrix. If the given column index corresponded to the last used column index, the "new last column index" will be columnIndex - 1 , even if a column was never explicitely inserted at this index (possible when insert_column(column, columnIndex) was used). If the column didn't existed, it will simply be considered as an empty column. More... | |
void | remove_last () |
Removes the last column from the matrix. The last column is at index max(ins1, ins2, rem - 1) , where: 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 and removes it. 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... | |
index | get_number_of_columns () const |
Returns the current number of columns in the matrix. More... | |
template<class Cell_range_or_column_index > | |
void | add_to (const Cell_range_or_column_index &sourceColumn, index targetColumnIndex) |
Adds column represented by sourceColumn onto the column at targetColumnIndex in the matrix. More... | |
template<class Cell_range_or_column_index > | |
void | multiply_target_and_add_to (const Cell_range_or_column_index &sourceColumn, 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... | |
template<class Cell_range_or_column_index > | |
void | multiply_source_and_add_to (const Field_element_type &coefficient, const Cell_range_or_column_index &sourceColumn, 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) |
Zeroes the cell at the given coordinates. More... | |
void | zero_column (index columnIndex) |
Zeroes the column at the given index. More... | |
bool | is_zero_cell (index columnIndex, index rowIndex) const |
Indicates if the cell at given coordinates has value zero. More... | |
bool | is_zero_column (index columnIndex) |
Indicates if the column at given index has value zero. More... | |
void | reset (Column_settings *colSettings) |
Resets the matrix to an empty matrix. More... | |
Base_matrix & | operator= (const Base_matrix &other) |
Assign operator. | |
Friends | |
void | swap (Base_matrix &matrix1, Base_matrix &matrix2) |
Swap operator. | |
A basic matrix structure allowing to easily manipulate and access entire columns and rows, but not individual cells.
Master_matrix | An instanciation of Matrix from which all types and options are deduced. |
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Cell_constructor = typename Master_matrix::Cell_constructor |
Factory of Cell classes.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Column_settings = typename Master_matrix::Column_settings |
Structure giving access to the columns to necessary external classes.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Column_type = typename Master_matrix::Column_type |
Column type.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::container_type = typename Master_matrix::boundary_type |
Type of the column container.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::dimension_type = typename Master_matrix::dimension_type |
Dimension value type.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Field_element_type = typename Master_matrix::element_type |
Type of a field element.
using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::index = typename Master_matrix::index |
Container index type.
using Gudhi::persistence_matrix::Base_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 matrix from the given ordered columns. The columns are inserted in the given order.
Container_type | Range type for Matrix::cell_rep_type ranges. Assumed to have a begin(), end() and size() method. |
columns | A vector of Matrix::cell_rep_type ranges to construct the columns from. The content of the ranges are assumed to be sorted by increasing ID value. |
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 represented by sourceColumn
onto the column at targetColumnIndex
in the matrix.
Cell_range_or_column_index | Either a range of Cell with a begin() and end() method, or any integer type. |
|
inline |
If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true: assumes that the row is empty and removes it. 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. 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 column or row swaps, otherwise the benefits of the the lazyness is lost.
columnIndex | MatIdx index of the column to return. |
|
inline |
Returns the current number of columns in the matrix.
|
inline |
Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row index of the matrix. 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 column or row swaps, otherwise the benefits of the the lazyness is lost.
rowIndex | Row index of the row to return. |
|
inline |
Same as insert_column, only for interface purposes. The given dimension is ignored and not stored.
Boundary_type | Range of Matrix::cell_rep_type. Assumed to have a begin(), end() and size() method. |
boundary | Range of Matrix::cell_rep_type from which the column has to be constructed. Assumed to be ordered by increasing ID value. |
dim | Ignored. |
|
inline |
Inserts a new ordered column at the end of the matrix by copying the given range of Matrix::cell_rep_type. The content of the range is assumed to be sorted by increasing ID value.
Container_type | Range of Matrix::cell_rep_type. Assumed to have a begin(), end() and size() method. |
column | Range of Matrix::cell_rep_type from which the column has to be constructed. Assumed to be ordered by increasing ID value. |
|
inline |
Inserts a new ordered column at the given index by copying the given range of Matrix::cell_rep_type. There should not be any other column inserted at that index which was not explicitely removed before. The content of the range is assumed to be sorted by increasing ID value. Not available when row access is enabled.
Container_type | Range of Matrix::cell_rep_type. Assumed to have a begin(), end() and size() method. |
column | Range of Matrix::cell_rep_type from which the column has to be constructed. Assumed to be ordered by increasing ID value. |
columnIndex | MatIdx index to which the column has to be inserted. |
|
inline |
|
inline |
Indicates if the column at given index has value zero.
columnIndex | MatIdx index of the column. |
|
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.
Cell_range_or_column_index | Either a range of Cell with a begin() and end() method, or any integer type. |
|
inline |
Multiplies the target column with the coefficiant and then adds the source column to it. That is: targetColumn = (targetColumn * coefficient) + sourceColumn
.
Cell_range_or_column_index | Either a range of Cell with a begin() and end() method, or any integer type. |
|
inline |
Only available if PersistenceMatrixOptions::has_map_column_container is true. Otherwise, see remove_last. Erases the given column from the matrix. If the given column index corresponded to the last used column index, the "new last column index" will be columnIndex - 1
, even if a column was never explicitely inserted at this index (possible when insert_column(column, columnIndex) was used). If the column didn't existed, it will simply be considered as an empty column.
If PersistenceMatrixOptions::has_row_access is also true, the deleted column cells are also automatically removed from their respective rows.
columnIndex | MatIdx index of the column to remove. |
|
inline |
Removes the last column from the matrix. The last column is at index max(ins1, ins2, rem - 1) , where:
If max(ins1, ins2, rem - 1) = rem - 1 but no column was explicitely inserted at that index (possible by the use of insert_column(column, columnIndex)), the column is assumed to be an empty column.
See also remove_column.
|
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 |
|
inline |
Zeroes the column at the given index.
columnIndex | MatIdx index of the column to zero. |