From dee13f902aacb50fcf024653600af1cf143a38f5 Mon Sep 17 00:00:00 2001 From: hschreiber Date: Wed, 25 Sep 2024 11:49:41 +0200 Subject: [PATCH] rename face as cell in persistence matrix --- .../concept/PersistenceMatrixColumn.h | 4 +- .../concept/PersistenceMatrixOptions.h | 8 +- .../doc/Intro_persistence_matrix.h | 4 +- src/Persistence_matrix/include/gudhi/Matrix.h | 148 +++++------ .../Persistence_matrix/Boundary_matrix.h | 46 ++-- .../gudhi/Persistence_matrix/Chain_matrix.h | 140 +++++----- .../Persistence_matrix/Id_to_index_overlay.h | 250 +++++++++--------- .../Position_to_index_overlay.h | 76 +++--- .../gudhi/Persistence_matrix/RU_matrix.h | 70 ++--- .../gudhi/Persistence_matrix/base_pairing.h | 12 +- ... => boundary_cell_position_to_id_mapper.h} | 14 +- .../Persistence_matrix/chain_vine_swap.h | 14 +- .../columns/chain_column_extra_properties.h | 4 +- .../matrix_dimension_holders.h | 16 +- .../gudhi/Persistence_matrix/ru_pairing.h | 12 +- .../gudhi/Persistence_matrix/ru_vine_swap.h | 18 +- src/Persistence_matrix/test/pm_matrix_tests.h | 6 +- 17 files changed, 421 insertions(+), 421 deletions(-) rename src/Persistence_matrix/include/gudhi/Persistence_matrix/{boundary_face_position_to_id_mapper.h => boundary_cell_position_to_id_mapper.h} (74%) diff --git a/src/Persistence_matrix/concept/PersistenceMatrixColumn.h b/src/Persistence_matrix/concept/PersistenceMatrixColumn.h index 6eaf75f7c9..8ae47e2924 100644 --- a/src/Persistence_matrix/concept/PersistenceMatrixColumn.h +++ b/src/Persistence_matrix/concept/PersistenceMatrixColumn.h @@ -86,7 +86,7 @@ class PersistenceMatrixColumn : PersistenceMatrixColumn(Column_settings* colSettings = nullptr); /** * @brief Constructs a column from the given range of @ref Matrix::Entry_representative. If the dimension is stored, - * the face is assumed to be simplicial and its dimension to be `nonZeroRowIndices length - 1` or `0`. + * the cell is assumed to be simplicial and its dimension to be `nonZeroRowIndices length - 1` or `0`. * Otherwise, the dimension should be specified with another constructor. * * @tparam Container Range of @ref Matrix::Entry_representative. Assumed to have a %begin(), %end() and %size() @@ -102,7 +102,7 @@ class PersistenceMatrixColumn : /** * @brief Constructs a column from the given range of @ref Matrix::Entry_representative such that the rows can be * accessed. Each new entry in the column is also inserted in a row using @ref Row_access::insert_entry. - * If the dimension is stored, the face is assumed to be simplicial and its dimension to be + * If the dimension is stored, the cell is assumed to be simplicial and its dimension to be * `nonZeroRowIndices length - 1` or `0`. Otherwise, the dimension should be specified with another constructor. * * @tparam Container Range of @ref Matrix::Entry_representative. Assumed to have a %begin(), %end() and %size() diff --git a/src/Persistence_matrix/concept/PersistenceMatrixOptions.h b/src/Persistence_matrix/concept/PersistenceMatrixOptions.h index b4d72dc82b..9d5cc83540 100644 --- a/src/Persistence_matrix/concept/PersistenceMatrixOptions.h +++ b/src/Persistence_matrix/concept/PersistenceMatrixOptions.h @@ -93,14 +93,14 @@ struct PersistenceMatrixOptions * If set to false, the container is a std::vector. By default, it is recommended to set it to false, but some * methods require it to be true to be enabled: * - @ref Matrix::remove_column(Index) "remove_column(Index)" for @ref basematrix "base matrices", - * - @ref Matrix::remove_maximal_face(Index) "remove_maximal_face(Index)" for @ref chainmatrix "chain matrices", - * - @ref Matrix::remove_maximal_face(Index, const std::vector&) - * "remove_maximal_face(ID_index, const std::vector&)" for @ref chainmatrix "chain matrices", + * - @ref Matrix::remove_maximal_cell(Index) "remove_maximal_cell(Index)" for @ref chainmatrix "chain matrices", + * - @ref Matrix::remove_maximal_cell(Index, const std::vector&) + * "remove_maximal_cell(ID_index, const std::vector&)" for @ref chainmatrix "chain matrices", * - @ref Matrix::remove_last "remove_last()" for @ref chainmatrix "chain matrices" if @ref has_vine_update is true. */ static const bool has_map_column_container; /** - * @brief If set to true, enables the methods @ref Matrix::remove_maximal_face and @ref Matrix::remove_last, + * @brief If set to true, enables the methods @ref Matrix::remove_maximal_cell and @ref Matrix::remove_last, * except for @ref basematrix "base matrices" when @ref has_column_compression is true. */ static const bool has_removable_columns; diff --git a/src/Persistence_matrix/doc/Intro_persistence_matrix.h b/src/Persistence_matrix/doc/Intro_persistence_matrix.h index 77b2657414..1185655b26 100644 --- a/src/Persistence_matrix/doc/Intro_persistence_matrix.h +++ b/src/Persistence_matrix/doc/Intro_persistence_matrix.h @@ -30,12 +30,12 @@ namespace persistence_matrix { * The main functionalities are: * @li column and row access, * @li column addition and scalar multiplication, - * @li removal of maximal faces while maintaining a valid reduced boundary matrix or compatible chain complex base + * @li removal of maximal cells while maintaining a valid reduced boundary matrix or compatible chain complex base * and a valid barcode with respect to the new filtration, * @li computation of persistent homology (but note that if the barcode is your only necessity, using the * @ref persistent_cohomology module is often more performant), * @li computation of representative cycles for the cycle classes, - * @li swapping of two consecutive faces in a filtration (cf. vineyards @cite vineyards) while maintaining a valid + * @li swapping of two consecutive cells in a filtration (cf. vineyards @cite vineyards) while maintaining a valid * reduced boundary matrix or compatible chain complex base and a valid barcode with respect to the new filtration, * * \note Matrix API is in a beta version and may change in incompatible ways in the near future. diff --git a/src/Persistence_matrix/include/gudhi/Matrix.h b/src/Persistence_matrix/include/gudhi/Matrix.h index a403ccaa81..d917bddc80 100644 --- a/src/Persistence_matrix/include/gudhi/Matrix.h +++ b/src/Persistence_matrix/include/gudhi/Matrix.h @@ -109,7 +109,7 @@ namespace persistence_matrix { * always take the same type of index as input (for optimization purposes). So, to avoid confusion, we will name and * define here the different possibilities, such that we can directly refer to it in the descriptions of the methods. * Note that every column and row in a @ref boundarymatrix "boundary" or @ref chainmatrix "chain matrix" is always - * associated to a single simplex/face, so in order to avoid repeating formulations like "of the simplex associated to + * associated to a single simplex/cell, so in order to avoid repeating formulations like "of the simplex associated to * the column" all the time, we will amalgamate both notions together. * * Let @f$ c @f$ be a column. @@ -134,7 +134,7 @@ namespace persistence_matrix { * indexed by its ID, so it correspond to the @ref IDIdx indexing scheme. If the matrix is not a * @ref chainmatrix "chain matrix", @f$ r @f$ will originally also be indexed by the ID, but when a swap occurs, * the rows also swap IDs and the new ID has to be used to access @f$ r @f$. This means that when the default - * @ref IDIdx scheme is used (the faces are numerated in order of appearance in the filtration starting at 0), + * @ref IDIdx scheme is used (the cells are numerated in order of appearance in the filtration starting at 0), * the indexation of the rows correspond to @ref PosIdx. * * @tparam PersistenceMatrixOptions Structure encoding all the options of the matrix. @@ -609,9 +609,9 @@ class Matrix { * (as in the implementation of the Zigzag algorithm @cite zigzag for example.) * * @param birthComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller birth than the bar associated to the second one. + * cell is associated to a bar with strictly smaller birth than the bar associated to the second one. * @param deathComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller death than the bar associated to the second one. + * cell is associated to a bar with strictly smaller death than the bar associated to the second one. */ Matrix(const std::function& birthComparator, const std::function& deathComparator); @@ -633,9 +633,9 @@ class Matrix { * method. * @param orderedBoundaries Vector of ordered boundaries in filtration order. Indexed continuously starting at 0. * @param birthComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller birth than the bar associated to the second one. + * cell is associated to a bar with strictly smaller birth than the bar associated to the second one. * @param deathComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller death than the bar associated to the second one. + * cell is associated to a bar with strictly smaller death than the bar associated to the second one. * @param characteristic Characteristic of the coefficient field. Has to be specified if * @ref PersistenceMatrixOptions::is_z2 is false. Default value is 11. * Ignored if @ref PersistenceMatrixOptions::is_z2 is true. @@ -660,9 +660,9 @@ class Matrix { * * @param numberOfColumns Number of columns to reserve space for. * @param birthComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller birth than the bar associated to the second one. + * cell is associated to a bar with strictly smaller birth than the bar associated to the second one. * @param deathComparator Method taking two @ref PosIdx indices as parameter and returns true if and only if the first - * face is associated to a bar with strictly smaller death than the bar associated to the second one. + * cell is associated to a bar with strictly smaller death than the bar associated to the second one. * @param characteristic Characteristic of the coefficient field. If not specified and * @ref PersistenceMatrixOptions::is_z2 is false, the characteristic has to be set later with the use of * @ref set_characteristic before calling for the first time a method needing it. @@ -736,10 +736,10 @@ class Matrix { /** * @brief 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, + * It also assumes that the cells 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 - * @ref insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim) "insert_boundary" - * instead by indicating the face ID used in the boundaries when the face is inserted. + * @ref insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) "insert_boundary" + * instead by indicating the cell ID used in the boundaries when the cell is inserted. * * Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from * a more general entry complex. This includes cubical complexes or Morse complexes for example. @@ -759,7 +759,7 @@ class Matrix { * * @tparam Boundary_range Range of @ref Entry_representative. Assumed to have a begin(), end() and size() method. * @param boundary Boundary generating the new column. The content should be ordered by ID. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. * @return If it is a @ref chainmatrix "chain matrix", the method returns the @ref MatIdx indices of the unpaired * chains used to reduce the boundary. Otherwise, nothing. @@ -768,26 +768,26 @@ class Matrix { Insertion_return insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** * @brief Only available for @ref mp_matrices "non-basic matrices". - * It does the same as the other version, but allows the boundary faces to be identified without restrictions + * It does the same as the other version, but allows the boundary cells 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 - * for @ref mp_matrices "non-basic matrices", the faces are inserted by order of filtration), it is sufficient to - * indicate the ID of the face being inserted. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * for @ref mp_matrices "non-basic matrices", the cells are inserted by order of filtration), it is sufficient to + * indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Entry_representative. Assumed to have a begin(), end() and size() method. - * @param faceIndex @ref IDIdx index to use to identify the new face. + * @param cellIndex @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceIndex values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellIndex values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. * @return If it is a @ref chainmatrix "chain matrix", the method returns the @ref MatIdx indices of the unpaired * chains used to reduce the boundary. Otherwise, nothing. */ template - Insertion_return insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim = -1); + Insertion_return insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1); /** * @brief Returns the column at the given @ref MatIdx index. @@ -895,10 +895,10 @@ class Matrix { * @brief Only available for @ref boundarymatrix "RU" and @ref chainmatrix "chain matrices" and if * @ref PersistenceMatrixOptions::has_removable_columns and @ref PersistenceMatrixOptions::has_vine_update are true. * For @ref chainmatrix "chain matrices", @ref PersistenceMatrixOptions::has_map_column_container and - * @ref PersistenceMatrixOptions::has_column_pairings also need to be true. Assumes that the face is maximal in the + * @ref PersistenceMatrixOptions::has_column_pairings also need to be true. Assumes that the cell 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 and chain is still a compatible bases of the chain complex in the sense - * of @cite zigzag). The maximality of the face is not verified. Also updates the barcode if it was computed. + * of @cite zigzag). The maximality of the cell is not verified. Also updates the barcode if it was computed. * * For @ref chainmatrix "chain matrices", using the other version of the method could perform better depending on how * the data is maintained on the side of the user. Then, @ref PersistenceMatrixOptions::has_column_pairings also do @@ -906,56 +906,56 @@ class Matrix { * * See also @ref remove_last and @ref remove_column. * - * @param columnIndex If @ref boundarymatrix "boundary matrix", @ref MatIdx index of the face to remove, otherwise the + * @param columnIndex If @ref boundarymatrix "boundary matrix", @ref MatIdx index of the cell to remove, otherwise the * @ref IDIdx index. */ - void remove_maximal_face(Index columnIndex); + void remove_maximal_cell(Index columnIndex); //TODO: See if it would be better to use something more general than a vector for columnsToSwap, such that // the user do not have to construct the vector from scratch. Like passing iterators instead. But it would be nice, - // to still be able to do (face, {})... + // to still be able to do (cell, {})... /** * @brief Only available for @ref chainmatrix "chain matrices" and if * @ref PersistenceMatrixOptions::has_removable_columns, @ref PersistenceMatrixOptions::has_vine_update and - * @ref PersistenceMatrixOptions::has_map_column_container are true. Assumes that the face is maximal in the current + * @ref PersistenceMatrixOptions::has_map_column_container are true. Assumes that the cell is maximal in the current * complex and removes it such that the matrix remains consistent (i.e., it is still a compatible bases of the chain - * complex in the sense of @cite zigzag). The maximality of the face is not verified. Also updates the barcode if it + * complex in the sense of @cite zigzag). The maximality of the cell is not verified. Also updates the barcode if it * was computed. * - * To maintain the compatibility, vine swaps are done to move the face up to the end of the filtration. Once at the + * To maintain the compatibility, vine swaps are done to move the cell up to the end of the filtration. Once at the * end, the removal is trivial. But for @ref chainmatrix "chain matrices", swaps do not actually swap the position of - * the column every time, so the faces appearing after @p faceIndex in the filtration have to be searched first within - * the matrix. If the user has an easy access to the @ref IDIdx of the faces in the order of filtration, passing them + * the column every time, so the cells appearing after @p cellIndex in the filtration have to be searched first within + * the matrix. If the user has an easy access to the @ref IDIdx of the cells in the order of filtration, passing them * by argument with @p columnsToSwap allows to skip a linear search process. Typically, if the user knows that the - * face he wants to remove is already the last face of the filtration, calling - * @ref remove_maximal_face(ID_index faceIndex, const std::vector& columnsToSwap) - * "remove_maximal_face(faceID, {})" will be faster than @ref remove_last(). + * cell he wants to remove is already the last cell of the filtration, calling + * @ref remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap) + * "remove_maximal_cell(cellID, {})" will be faster than @ref remove_last(). * * See also @ref remove_last. * - * @param faceIndex @ref IDIdx index of the face to remove - * @param columnsToSwap Vector of @ref IDIdx indices of the faces coming after @p faceIndex in the filtration. + * @param cellIndex @ref IDIdx index of the cell to remove + * @param columnsToSwap Vector of @ref IDIdx indices of the cells coming after @p cellIndex in the filtration. */ - void remove_maximal_face(ID_index faceIndex, const std::vector& columnsToSwap); + void remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap); /** - * @brief Removes the last inserted column/face from the matrix. + * @brief Removes the last inserted column/cell from the matrix. * If the matrix is @ref mp_matrices "non basic", @ref PersistenceMatrixOptions::has_removable_columns has to be true * for the method to be available. Additionally, if the matrix is a @ref chainmatrix "chain matrix", either * @ref PersistenceMatrixOptions::has_map_column_container has to be true or * @ref PersistenceMatrixOptions::has_vine_update has to be false. And if the matrix is a * @ref basematrix "base matrix" it should be without column compression. * - * See also @ref remove_maximal_face and @ref remove_column. + * See also @ref remove_maximal_cell and @ref remove_column. * - * For @ref chainmatrix "chain matrices", if @ref PersistenceMatrixOptions::has_vine_update is true, the last face + * For @ref chainmatrix "chain matrices", if @ref PersistenceMatrixOptions::has_vine_update is true, the last cell * does not have to be at the end of the matrix and therefore has to be searched first. In this case, if the user - * already knows the @ref IDIdx of the last face, calling - * @ref remove_maximal_face(ID_index faceIndex, const std::vector& columnsToSwap) - * "remove_maximal_face(faceID, {})" instead allows to skip the search. + * already knows the @ref IDIdx of the last cell, calling + * @ref remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap) + * "remove_maximal_cell(cellID, {})" instead allows to skip the search. */ void remove_last(); /** - * @brief Returns the maximal dimension of a face stored in the matrix. Only available for + * @brief Returns the maximal dimension of a cell stored in the matrix. Only available for * @ref mp_matrices "non-basic matrices" and if @ref PersistenceMatrixOptions::has_matrix_maximal_dimension_access * is true. * @@ -969,10 +969,10 @@ class Matrix { */ Index get_number_of_columns() const; /** - * @brief Returns the dimension of the given face. Only available for @ref mp_matrices "non-basic matrices". + * @brief Returns the dimension of the given cell. Only available for @ref mp_matrices "non-basic matrices". * - * @param columnIndex @ref MatIdx index of the column representing the face. - * @return Dimension of the face. + * @param columnIndex @ref MatIdx index of the column representing the cell. + * @return Dimension of the cell. */ Dimension get_column_dimension(Index columnIndex) const; @@ -1189,10 +1189,10 @@ class Matrix { * indices and that the @ref rowindex "row indices" for a @ref boundarymatrix "RU matrix" correspond to the updated * @ref IDIdx indices which got potentially swapped by a vine swap. * - * @param faceIndex @ref rowindex "Row index" of the pivot. + * @param cellIndex @ref rowindex "Row index" of the pivot. * @return @ref MatIdx index of the column with the given pivot. */ - Index get_column_with_pivot(ID_index faceIndex) const; + Index get_column_with_pivot(ID_index cellIndex) const; /** * @brief Returns the @ref rowindex "row index" of the pivot of the given column. Only available for * @ref mp_matrices "non-basic matrices". @@ -1280,7 +1280,7 @@ class Matrix { * Does the same than @ref vine_swap, but assumes that the swap is non trivial and therefore skips a part of the case * study. * - * @param index @ref PosIdx index of the first face to swap. The second one has to be at `index + 1`. Recall that for + * @param index @ref PosIdx index of the first cell to swap. The second one has to be at `index + 1`. Recall that for * @ref boundarymatrix "boundary matrices", @ref PosIdx == @ref MatIdx. * @return true If the barcode changed from the swap. * @return false Otherwise. @@ -1292,8 +1292,8 @@ class Matrix { * @ref Column_indexation_types::IDENTIFIER. Does the same than @ref vine_swap, but assumes that the swap is * non-trivial and therefore skips a part of the case study. * - * @param columnIndex1 @ref MatIdx index of the first face. - * @param columnIndex2 @ref MatIdx index of the second face. It is assumed that the @ref PosIdx of both only differs + * @param columnIndex1 @ref MatIdx index of the first cell. + * @param columnIndex2 @ref MatIdx index of the second cell. It is assumed that the @ref PosIdx of both only differs * by one. * @return Let \f$ pos1 \f$ be the @ref PosIdx index of @p columnIndex1 and \f$ pos2 \f$ be the @ref PosIdx index of * @p columnIndex2. The method returns the @ref MatIdx of the column which has now, after the swap, the @ref PosIdx @@ -1303,14 +1303,14 @@ class Matrix { /** * @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true and if it is either a * @ref boundarymatrix "boundary matrix" or @ref PersistenceMatrixOptions::column_indexation_type is set to - * @ref Column_indexation_types::POSITION. Does a vine swap between two faces which are consecutive in the + * @ref Column_indexation_types::POSITION. Does a vine swap between two cells which are consecutive in the * filtration. Roughly, if \f$ F \f$ is the current filtration represented by the matrix, the method modifies the * matrix such that the new state corresponds to a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but - * with the two faces at position `index` and `index + 1` swapped. Of course, the two faces should not have a + * with the two cells at position `index` and `index + 1` swapped. Of course, the two cells should not have a * face/coface relation which each other ; \f$ F' \f$ has to be a valid filtration. * See @cite vineyards for more information about vine and vineyards. * - * @param index @ref PosIdx index of the first face to swap. The second one has to be at `index + 1`. Recall that for + * @param index @ref PosIdx index of the first cell to swap. The second one has to be at `index + 1`. Recall that for * @ref boundarymatrix "boundary matrices", @ref PosIdx == @ref MatIdx. * @return true If the barcode changed from the swap. * @return false Otherwise. @@ -1319,15 +1319,15 @@ class Matrix { /** * @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true and if it is either a * @ref chainmatrix "chain matrix" or @ref PersistenceMatrixOptions::column_indexation_type is set to - * @ref Column_indexation_types::IDENTIFIER. Does a vine swap between two faces which are consecutive in the + * @ref Column_indexation_types::IDENTIFIER. Does a vine swap between two cells which are consecutive in the * filtration. Roughly, if \f$ F \f$ is the current filtration represented by the matrix, the method modifies the * matrix such that the new state corresponds to a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but - * with the two given faces at swapped positions. Of course, the two faces should not have a face/coface relation + * with the two given cells at swapped positions. Of course, the two cells should not have a face/coface relation * which each other ; \f$ F' \f$ has to be a valid filtration. * See @cite vineyards for more information about vine and vineyards. * - * @param columnIndex1 @ref MatIdx index of the first face. - * @param columnIndex2 @ref MatIdx index of the second face. It is assumed that the @ref PosIdx of both only differs + * @param columnIndex1 @ref MatIdx index of the first cell. + * @param columnIndex2 @ref MatIdx index of the second cell. It is assumed that the @ref PosIdx of both only differs * by one. * @return Let \f$ pos1 \f$ be the @ref PosIdx index of @p columnIndex1 and \f$ pos2 \f$ be the @ref PosIdx index of * @p columnIndex2. The method returns the @ref MatIdx of the column which has now, after the swap, the @ref PosIdx @@ -1531,7 +1531,7 @@ inline void Matrix::insert_column(const Container& col static_assert( !isNonBasic, - "'insert_column' not available for the chosen options. The input has to be in the form of a face boundary."); + "'insert_column' not available for the chosen options. The input has to be in the form of a cell boundary."); matrix_.insert_column(column); } @@ -1573,7 +1573,7 @@ Matrix::insert_boundary(const Boundary_range& boundary template template inline typename Matrix::Insertion_return -Matrix::insert_boundary(ID_index faceIndex, +Matrix::insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) { @@ -1586,9 +1586,9 @@ Matrix::insert_boundary(ID_index faceIndex, static_assert(isNonBasic, "Only enabled for non-basic matrices."); if constexpr (!PersistenceMatrixOptions::is_of_boundary_type && PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER) - return matrix_.insert_boundary(faceIndex, boundary, dim); + return matrix_.insert_boundary(cellIndex, boundary, dim); else - matrix_.insert_boundary(faceIndex, boundary, dim); + matrix_.insert_boundary(cellIndex, boundary, dim); } template @@ -1673,31 +1673,31 @@ inline void Matrix::erase_empty_row(ID_index rowIndex) } template -inline void Matrix::remove_maximal_face(Index columnIndex) +inline void Matrix::remove_maximal_cell(Index columnIndex) { static_assert(PersistenceMatrixOptions::has_removable_columns, - "'remove_maximal_face(ID_index)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index)' is not available for the chosen options."); static_assert(isNonBasic && PersistenceMatrixOptions::has_vine_update, - "'remove_maximal_face(ID_index)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index)' is not available for the chosen options."); static_assert(PersistenceMatrixOptions::is_of_boundary_type || (PersistenceMatrixOptions::has_map_column_container && PersistenceMatrixOptions::has_column_pairings), - "'remove_maximal_face(ID_index)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index)' is not available for the chosen options."); - matrix_.remove_maximal_face(columnIndex); + matrix_.remove_maximal_cell(columnIndex); } template -inline void Matrix::remove_maximal_face(ID_index faceIndex, +inline void Matrix::remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap) { static_assert(PersistenceMatrixOptions::has_removable_columns, - "'remove_maximal_face(ID_index,const std::vector&)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index,const std::vector&)' is not available for the chosen options."); static_assert(isNonBasic && !PersistenceMatrixOptions::is_of_boundary_type, - "'remove_maximal_face(ID_index,const std::vector&)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index,const std::vector&)' is not available for the chosen options."); static_assert(PersistenceMatrixOptions::has_map_column_container && PersistenceMatrixOptions::has_vine_update, - "'remove_maximal_face(ID_index,const std::vector&)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index,const std::vector&)' is not available for the chosen options."); - matrix_.remove_maximal_face(faceIndex, columnsToSwap); + matrix_.remove_maximal_cell(cellIndex, columnsToSwap); } template @@ -1902,14 +1902,14 @@ inline bool Matrix::is_zero_column(Index columnIndex, template inline typename Matrix::Index Matrix::get_column_with_pivot( - ID_index faceIndex) const + ID_index cellIndex) const { static_assert(isNonBasic && (!PersistenceMatrixOptions::is_of_boundary_type || (PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles)), "'get_column_with_pivot' is not available for the chosen options."); - return matrix_.get_column_with_pivot(faceIndex); + return matrix_.get_column_with_pivot(cellIndex); } template diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Boundary_matrix.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Boundary_matrix.h index 29c6f87d93..93de613c03 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Boundary_matrix.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Boundary_matrix.h @@ -32,7 +32,7 @@ namespace persistence_matrix { * * @brief %Matrix structure to store the ordered @ref boundarymatrix "boundary matrix" \f$ R \f$ of a filtered complex * in order to compute its persistent homology. Provides an access to its columns and rows as well as the possibility - * to remove the last faces of the filtration while maintaining a valid barcode. + * to remove the last cells of the filtration while maintaining a valid barcode. * * @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced. */ @@ -120,10 +120,10 @@ class Boundary_matrix : public Master_matrix::Matrix_dimension_option, /** * @brief 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, + * It also assumes that the cells 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 - * @ref insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim) "insert_boundary" - * instead by indicating the face ID used in the boundaries when the face is inserted. + * @ref insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) "insert_boundary" + * instead by indicating the cell ID used in the boundaries when the cell is inserted. * * Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from * a more general entry complex. This includes cubical complexes or Morse complexes for example. @@ -136,32 +136,32 @@ class Boundary_matrix : public Master_matrix::Matrix_dimension_option, * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. * @param boundary Boundary generating the new column. The content should be ordered by ID. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. * @return The @ref MatIdx index of the inserted boundary. */ template Index insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** - * @brief It does the same as the other version, but allows the boundary faces to be identified without restrictions + * @brief It does the same as the other version, but allows the boundary cells 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. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. - * @param faceIndex @ref IDIdx index to use to identify the new face. + * @param cellIndex @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceIndex values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellIndex values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. * @return The @ref MatIdx index of the inserted boundary. */ template - Index insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim = -1); + Index insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1); /** * @brief Returns the column at the given @ref MatIdx index. * The type of the column depends on the choosen options, see @ref PersistenceMatrixOptions::column_type. @@ -189,9 +189,9 @@ class Boundary_matrix : public Master_matrix::Matrix_dimension_option, Row& get_row(Index rowIndex); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true. - * Removes the last face in the filtration from the matrix and updates the barcode if this one was already computed. + * Removes the last cell in the filtration from the matrix and updates the barcode if this one was already computed. * - * @return The pivot of the removed face. + * @return The pivot of the removed cell. */ Index remove_last(); /** @@ -221,8 +221,8 @@ class Boundary_matrix : public Master_matrix::Matrix_dimension_option, /** * @brief Returns the dimension of the given column. * - * @param columnIndex @ref MatIdx index of the column representing the face. - * @return Dimension of the face. + * @param columnIndex @ref MatIdx index of the column representing the cell. + * @return Dimension of the cell. */ Dimension get_column_dimension(Index columnIndex) const; @@ -469,7 +469,7 @@ inline typename Boundary_matrix::Index Boundary_matrix template inline typename Boundary_matrix::Index Boundary_matrix::insert_boundary( - ID_index faceIndex, const Boundary_range& boundary, Dimension dim) + ID_index cellIndex, const Boundary_range& boundary, Dimension dim) { if (dim == -1) dim = boundary.size() == 0 ? 0 : boundary.size() - 1; @@ -492,12 +492,12 @@ inline typename Boundary_matrix::Index Boundary_matrix::Index Boundary_matrix std::vector insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** - * @brief It does the same as the other version, but allows the boundary faces to be identified without restrictions + * @brief It does the same as the other version, but allows the boundary cells 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. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. - * @param faceID @ref IDIdx index to use to identify the new face. + * @param cellID @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceID values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellID values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. * @return The @ref MatIdx index of the inserted boundary. */ template - std::vector insert_boundary(ID_index faceID, + std::vector insert_boundary(ID_index cellID, const Boundary_range& boundary, Dimension dim = -1); /** @@ -290,9 +290,9 @@ class Chain_matrix : public Master_matrix::Matrix_dimension_option, * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns and * @ref PersistenceMatrixOptions::has_vine_update are true, as well as, * @ref PersistenceMatrixOptions::has_map_column_container and @ref PersistenceMatrixOptions::has_column_pairings. - * Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent + * Assumes that the cell is maximal in the current complex and removes it such that the matrix remains consistent * (i.e., the matrix is still a compatible bases of the chain complex in the sense of @cite zigzag). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it is stored. * * Note that using the other version of the method could perform better depending on how the data is @@ -300,46 +300,46 @@ class Chain_matrix : public Master_matrix::Matrix_dimension_option, * * See also @ref remove_last. * - * @param faceID @ref IDIdx index of the face to remove + * @param cellID @ref IDIdx index of the cell to remove */ - void remove_maximal_face(ID_index faceID); + void remove_maximal_cell(ID_index cellID); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns, * @ref PersistenceMatrixOptions::has_vine_update and @ref PersistenceMatrixOptions::has_map_column_container * are true. - * Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent + * Assumes that the cell is maximal in the current complex and removes it such that the matrix remains consistent * (i.e., it is still a compatible bases of the chain complex in the sense of @cite zigzag). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it is stored. * - * To maintain the compatibility, vine swaps are done to move the face up to the end of the filtration. Once at + * To maintain the compatibility, vine swaps are done to move the cell up to the end of the filtration. Once at * the end, the removal is trivial. But for @ref chainmatrix "chain matrices", swaps do not actually swap the position - * of the column every time, so the faces appearing after @p faceID in the filtration have to be searched first within - * the matrix. If the user has an easy access to the @ref IDIdx of the faces in the order of filtration, passing them + * of the column every time, so the cells appearing after @p cellID in the filtration have to be searched first within + * the matrix. If the user has an easy access to the @ref IDIdx of the cells in the order of filtration, passing them * by argument with @p columnsToSwap allows to skip a linear search process. Typically, if the user knows that the - * face he wants to remove is already the last face of the filtration, calling - * @ref remove_maximal_face(ID_index faceIndex, const std::vector& columnsToSwap) - * "remove_maximal_face(faceID, {})" will be faster than @ref remove_last(). + * cell he wants to remove is already the last cell of the filtration, calling + * @ref remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap) + * "remove_maximal_cell(cellID, {})" will be faster than @ref remove_last(). * * See also @ref remove_last. * - * @param faceID @ref IDIdx index of the face to remove - * @param columnsToSwap Vector of @ref IDIdx indices of the faces coming after @p faceID in the filtration. + * @param cellID @ref IDIdx index of the cell to remove + * @param columnsToSwap Vector of @ref IDIdx indices of the cells coming after @p cellID in the filtration. */ - void remove_maximal_face(ID_index faceID, const std::vector& columnsToSwap); + void remove_maximal_cell(ID_index cellID, const std::vector& columnsToSwap); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true and, * if @ref PersistenceMatrixOptions::has_map_column_container is true or * @ref PersistenceMatrixOptions::has_vine_update is false. - * Removes the last face in the filtration from the matrix and updates the barcode if it is stored. + * Removes the last cell in the filtration from the matrix and updates the barcode if it is stored. * - * See also @ref remove_maximal_face. + * See also @ref remove_maximal_cell. * - * @warning If @ref PersistenceMatrixOptions::has_vine_update is true, the last face does not have to + * @warning If @ref PersistenceMatrixOptions::has_vine_update is true, the last cell does not have to * be at the end of the matrix container and therefore has to be searched first. In this case, if the user - * already knows the @ref IDIdx of the last face, calling - * @ref remove_maximal_face(ID_index faceIndex, const std::vector& columnsToSwap) - * "remove_maximal_face(faceID, {})" instead allows to skip the search. + * already knows the @ref IDIdx of the last cell, calling + * @ref remove_maximal_cell(ID_index cellIndex, const std::vector& columnsToSwap) + * "remove_maximal_cell(cellID, {})" instead allows to skip the search. */ void remove_last(); @@ -353,8 +353,8 @@ class Chain_matrix : public Master_matrix::Matrix_dimension_option, /** * @brief Returns the dimension of the given column. * - * @param columnIndex @ref MatIdx index of the column representing the face. - * @return Dimension of the face. + * @param columnIndex @ref MatIdx index of the column representing the cell. + * @return Dimension of the cell. */ Dimension get_column_dimension(Index columnIndex) const; @@ -422,10 +422,10 @@ class Chain_matrix : public Master_matrix::Matrix_dimension_option, /** * @brief Returns the column with given @ref rowindex "row index" as pivot. Assumes that the pivot exists. * - * @param faceID @ref rowindex "Row index" of the pivot. + * @param cellID @ref rowindex "Row index" of the pivot. * @return @ref MatIdx index of the column with the given pivot. */ - Index get_column_with_pivot(ID_index faceID) const; + Index get_column_with_pivot(ID_index cellID) const; /** * @brief Returns the @ref rowindex "row index" of the pivot of the given column. * @@ -499,10 +499,10 @@ class Chain_matrix : public Master_matrix::Matrix_dimension_option, Column_settings* colSettings_; /**< Entry factory. */ template - std::vector _reduce_boundary(ID_index faceID, const Boundary_range& boundary, Dimension dim); + std::vector _reduce_boundary(ID_index cellID, const Boundary_range& boundary, Dimension dim); void _reduce_by_G(Tmp_column& column, std::vector& chainsInH, Index currentPivot); void _reduce_by_F(Tmp_column& column, std::vector& chainsInF, Index currentPivot); - void _build_from_H(ID_index faceID, Tmp_column& column, std::vector& chainsInH); + void _build_from_H(ID_index cellID, Tmp_column& column, std::vector& chainsInH); void _update_largest_death_in_F(const std::vector& chainsInF); void _insert_chain(const Tmp_column& column, Dimension dimension); void _insert_chain(const Tmp_column& column, Dimension dimension, Index pair); @@ -681,21 +681,21 @@ inline std::vector Chain_matrix template inline std::vector Chain_matrix::insert_boundary( - ID_index faceID, const Boundary_range& boundary, Dimension dim) + ID_index cellID, const Boundary_range& boundary, Dimension dim) { if constexpr (!Master_matrix::Option_list::has_map_column_container) { - if (pivotToColumnIndex_.size() <= faceID) { - pivotToColumnIndex_.resize(faceID * 2 + 1, -1); + if (pivotToColumnIndex_.size() <= cellID) { + pivotToColumnIndex_.resize(cellID * 2 + 1, -1); } } if constexpr (Master_matrix::Option_list::has_vine_update && Master_matrix::Option_list::has_column_pairings) { if constexpr (Master_matrix::Option_list::has_map_column_container) { - Swap_opt::CP::pivotToPosition_.try_emplace(faceID, _nextPosition()); + Swap_opt::CP::pivotToPosition_.try_emplace(cellID, _nextPosition()); } else { - if (Swap_opt::CP::pivotToPosition_.size() <= faceID) + if (Swap_opt::CP::pivotToPosition_.size() <= cellID) Swap_opt::CP::pivotToPosition_.resize(pivotToColumnIndex_.size(), -1); - Swap_opt::CP::pivotToPosition_[faceID] = _nextPosition(); + Swap_opt::CP::pivotToPosition_[cellID] = _nextPosition(); } } @@ -703,7 +703,7 @@ inline std::vector Chain_matrix(-1) ? (boundary.size() == 0 ? 0 : boundary.size() - 1) : dim); } - return _reduce_boundary(faceID, boundary, dim); + return _reduce_boundary(cellID, boundary, dim); } template @@ -728,22 +728,22 @@ inline const typename Chain_matrix::Column& Chain_matrix -inline void Chain_matrix::remove_maximal_face(ID_index faceID) +inline void Chain_matrix::remove_maximal_cell(ID_index cellID) { static_assert(Master_matrix::Option_list::has_removable_columns, - "'remove_maximal_face' is not implemented for the chosen options."); + "'remove_maximal_cell' is not implemented for the chosen options."); static_assert(Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_vine_update && Master_matrix::Option_list::has_column_pairings, - "'remove_maximal_face' is not implemented for the chosen options."); + "'remove_maximal_cell' is not implemented for the chosen options."); // TODO: find simple test to verify that col at columnIndex is maximal even without row access. const auto& pivotToPosition = Swap_opt::CP::pivotToPosition_; - auto it = pivotToPosition.find(faceID); - if (it == pivotToPosition.end()) return; // face does not exists. TODO: put an assert instead? + auto it = pivotToPosition.find(cellID); + if (it == pivotToPosition.end()) return; // cell does not exists. TODO: put an assert instead? Pos_index startPos = it->second; - Index startIndex = pivotToColumnIndex_.at(faceID); + Index startIndex = pivotToColumnIndex_.at(cellID); if (startPos != _nextPosition() - 1) { std::vector colToSwap; @@ -765,17 +765,17 @@ inline void Chain_matrix::remove_maximal_face(ID_index faceID) } template -inline void Chain_matrix::remove_maximal_face(ID_index faceID, +inline void Chain_matrix::remove_maximal_cell(ID_index cellID, const std::vector& columnsToSwap) { static_assert(Master_matrix::Option_list::has_removable_columns, - "'remove_maximal_face' is not implemented for the chosen options."); + "'remove_maximal_cell' is not implemented for the chosen options."); static_assert(Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_vine_update, - "'remove_maximal_face' is not implemented for the chosen options."); + "'remove_maximal_cell' is not implemented for the chosen options."); // TODO: find simple test to verify that col at columnIndex is maximal even without row access. - Index startIndex = pivotToColumnIndex_.at(faceID); + Index startIndex = pivotToColumnIndex_.at(cellID); for (ID_index i : columnsToSwap) { startIndex = Swap_opt::vine_swap(startIndex, pivotToColumnIndex_.at(i)); @@ -797,7 +797,7 @@ inline void Chain_matrix::remove_last() if constexpr (Master_matrix::Option_list::has_vine_update) { // careful: linear because of the search of the last index. It is better to keep track of the @ref IDIdx index // of the last column while performing swaps (or the @ref MatIdx with the return values of `vine_swap` + get_pivot) - // and then call `remove_maximal_face` with it and an empty `columnsToSwap`. + // and then call `remove_maximal_cell` with it and an empty `columnsToSwap`. ID_index pivot = 0; Index colIndex = 0; @@ -869,12 +869,12 @@ inline bool Chain_matrix::is_zero_column(Index columnIndex) template inline typename Chain_matrix::Index Chain_matrix::get_column_with_pivot( - ID_index faceID) const + ID_index cellID) const { if constexpr (Master_matrix::Option_list::has_map_column_container) { - return pivotToColumnIndex_.at(faceID); + return pivotToColumnIndex_.at(cellID); } else { - return pivotToColumnIndex_[faceID]; + return pivotToColumnIndex_[cellID]; } } @@ -959,7 +959,7 @@ inline void Chain_matrix::print() const template template inline std::vector Chain_matrix::_reduce_boundary( - ID_index faceID, const Boundary_range& boundary, Dimension dim) + ID_index cellID, const Boundary_range& boundary, Dimension dim) { Tmp_column column(boundary.begin(), boundary.end()); if (dim == static_cast(-1)) dim = boundary.begin() == boundary.end() ? 0 : boundary.size() - 1; @@ -975,9 +975,9 @@ inline std::vector Chain_matrix Chain_matrix Chain_matrix::_reduce_by_F(Tmp_column& column, } template -inline void Chain_matrix::_build_from_H(ID_index faceID, +inline void Chain_matrix::_build_from_H(ID_index cellID, Tmp_column& column, std::vector& chainsInH) { if constexpr (Master_matrix::Option_list::is_z2) { - column.insert(faceID); + column.insert(cellID); for (Index idx_h : chainsInH) { _add_to(get_column(idx_h), column, 1u); } } else { - column.emplace(faceID, 1); + column.emplace(cellID, 1); for (std::pair& idx_h : chainsInH) { _add_to(get_column(idx_h.first), column, idx_h.second); } diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Id_to_index_overlay.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Id_to_index_overlay.h index 91b09f2659..be885d182a 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Id_to_index_overlay.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Id_to_index_overlay.h @@ -220,10 +220,10 @@ class Id_to_index_overlay /** * @brief 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, + * It also assumes that the cells 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 * @ref insert_boundary(ID_index, const Boundary_range&, Dimension) "insert_boundary" instead by indicating the - * face ID used in the boundaries when the face is inserted. + * cell ID used in the boundaries when the cell is inserted. * * Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from * a more general entry complex. This includes cubical complexes or Morse complexes for example. @@ -241,39 +241,39 @@ class Id_to_index_overlay * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. * @param boundary Boundary generating the new column. The content should be ordered by ID. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template void insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** - * @brief It does the same as the other version, but allows the boundary faces to be identified without restrictions + * @brief It does the same as the other version, but allows the boundary cells 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. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. - * @param faceIndex @ref IDIdx index to use to identify the new face. + * @param cellIndex @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceIndex values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellIndex values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template - void insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim = -1); + void insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1); /** * @brief Returns the column at the given @ref IDIdx index. * For @ref boundarymatrix "RU matrices", the returned column is from \f$ R \f$. * The type of the column depends on the choosen options, see @ref PersistenceMatrixOptions::column_type. * - * @param faceID @ref IDIdx index of the column to return. + * @param cellID @ref IDIdx index of the column to return. * @return Reference to the column. */ - Column& get_column(ID_index faceID); + Column& get_column(ID_index cellID); /** * @brief Only available if @ref PersistenceMatrixOptions::has_row_access is true. * Returns the row at the given @ref rowindex "row index". @@ -319,10 +319,10 @@ class Id_to_index_overlay * @ref PersistenceMatrixOptions::has_removable_columns and @ref PersistenceMatrixOptions::has_vine_update are true. * For @ref chainmatrix "chain matrices", @ref PersistenceMatrixOptions::has_map_column_container and * @ref PersistenceMatrixOptions::has_column_pairings also need to be true. - * Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent + * Assumes that the cell 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 @ref boundarymatrix "boundary matrix" and chain is * still a compatible bases of the chain complex in the sense of @cite zigzag). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it was computed. * * For @ref chainmatrix "chain matrices", using the other version of the method could perform better depending on @@ -331,51 +331,51 @@ class Id_to_index_overlay * * See also @ref remove_last. * - * @param faceID @ref IDIdx index of the face to remove. + * @param cellID @ref IDIdx index of the cell to remove. */ - void remove_maximal_face(ID_index faceID); + void remove_maximal_cell(ID_index cellID); /** * @brief Only available for @ref chainmatrix "chain matrices" and if * @ref PersistenceMatrixOptions::has_removable_columns, @ref PersistenceMatrixOptions::has_vine_update * and @ref PersistenceMatrixOptions::has_map_column_container are true. - * Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent + * Assumes that the cell is maximal in the current complex and removes it such that the matrix remains consistent * (i.e., it is still a compatible bases of the chain complex in the sense of @cite zigzag). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it was computed. * - * To maintain the compatibility, vine swaps are done to move the face up to the end of the filtration. Once at + * To maintain the compatibility, vine swaps are done to move the cell up to the end of the filtration. Once at * the end, the removal is trivial. But for @ref chainmatrix "chain matrices", swaps do not actually swap the position - * of the column every time, so the faces appearing after @p faceIndex in the filtration have to be searched first - * within the matrix. If the user has an easy access to the @ref IDIdx of the faces in the order of filtration, + * of the column every time, so the cells appearing after @p cellIndex in the filtration have to be searched first + * within the matrix. If the user has an easy access to the @ref IDIdx of the cells in the order of filtration, * passing them by argument with @p columnsToSwap allows to skip a linear search process. Typically, if the user knows - * that the face he wants to remove is already the last face of the filtration, calling - * @ref remove_maximal_face(ID_index, const std::vector&) "remove_maximal_face(faceID, {})" + * that the cell he wants to remove is already the last cell of the filtration, calling + * @ref remove_maximal_cell(ID_index, const std::vector&) "remove_maximal_cell(cellID, {})" * will be faster than @ref remove_last(). * * See also @ref remove_last. * - * @param faceID @ref IDIdx index of the face to remove. - * @param columnsToSwap Vector of @ref IDIdx indices of the faces coming after @p faceID in the filtration. + * @param cellID @ref IDIdx index of the cell to remove. + * @param columnsToSwap Vector of @ref IDIdx indices of the cells coming after @p cellID in the filtration. */ - void remove_maximal_face(ID_index faceID, const std::vector& columnsToSwap); + void remove_maximal_cell(ID_index cellID, const std::vector& columnsToSwap); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true. Additionally, if the * matrix is a @ref chainmatrix "chain matrix", either @ref PersistenceMatrixOptions::has_map_column_container has to * be true or @ref PersistenceMatrixOptions::has_vine_update has to be false. - * Removes the last face in the filtration from the matrix and updates the barcode if it is stored. + * Removes the last cell in the filtration from the matrix and updates the barcode if it is stored. * - * See also @ref remove_maximal_face. + * See also @ref remove_maximal_cell. * - * For @ref chainmatrix "chain matrices", if @ref PersistenceMatrixOptions::has_vine_update is true, the last face + * For @ref chainmatrix "chain matrices", if @ref PersistenceMatrixOptions::has_vine_update is true, the last cell * does not have to be at the end of the matrix and therefore has to be searched first. In this case, if the user - * already knows the @ref IDIdx of the last face, calling - * @ref remove_maximal_face(ID_index, const std::vector&) "remove_maximal_face(faceID, {})" + * already knows the @ref IDIdx of the last cell, calling + * @ref remove_maximal_cell(ID_index, const std::vector&) "remove_maximal_cell(cellID, {})" * instead allows to skip the search. */ void remove_last(); /** - * @brief Returns the maximal dimension of a face stored in the matrix. Only available + * @brief Returns the maximal dimension of a cell stored in the matrix. Only available * if @ref PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true. * * @return The maximal dimension. @@ -388,24 +388,24 @@ class Id_to_index_overlay */ Index get_number_of_columns() const; /** - * @brief Returns the dimension of the given face. Only available for @ref mp_matrices "non-basic matrices". + * @brief Returns the dimension of the given cell. Only available for @ref mp_matrices "non-basic matrices". * - * @param faceID @ref IDIdx index of the face. - * @return Dimension of the face. + * @param cellID @ref IDIdx index of the cell. + * @return Dimension of the cell. */ - Dimension get_column_dimension(ID_index faceID) const; + Dimension get_column_dimension(ID_index cellID) const; /** - * @brief Adds column corresponding to @p sourceFaceID onto the column corresponding to @p targetFaceID. + * @brief Adds column corresponding to @p sourceCellID onto the column corresponding to @p targetCellID. * * @warning They will be no verification to ensure that the addition makes sense for the validity of the matrix. * For example, a right-to-left addition could corrupt the computation of the barcode if done blindly. * So should be used with care. * - * @param sourceFaceID @ref IDIdx index of the source column. - * @param targetFaceID @ref IDIdx index of the target column. + * @param sourceCellID @ref IDIdx index of the source column. + * @param targetCellID @ref IDIdx index of the target column. */ - void add_to(ID_index sourceFaceID, ID_index targetFaceID); + void add_to(ID_index sourceCellID, ID_index targetCellID); /** * @brief Multiplies the target column with the coefficient and then adds the source column to it. * That is: `targetColumn = (targetColumn * coefficient) + sourceColumn`. @@ -414,11 +414,11 @@ class Id_to_index_overlay * For example, a right-to-left addition could corrupt the computation of the barcode if done blindly. * So should be used with care. * - * @param sourceFaceID @ref IDIdx index of the source column. + * @param sourceCellID @ref IDIdx index of the source column. * @param coefficient Value to multiply. - * @param targetFaceID @ref IDIdx index of the target column. + * @param targetCellID @ref IDIdx index of the target column. */ - void multiply_target_and_add_to(ID_index sourceFaceID, const Field_element& coefficient, ID_index targetFaceID); + void multiply_target_and_add_to(ID_index sourceCellID, const Field_element& coefficient, ID_index targetCellID); /** * @brief Multiplies the source column with the coefficient before adding it to the target column. * That is: `targetColumn += (coefficient * sourceColumn)`. The source column will **not** be modified. @@ -428,10 +428,10 @@ class Id_to_index_overlay * So should be used with care. * * @param coefficient Value to multiply. - * @param sourceFaceID @ref IDIdx index of the source column. - * @param targetFaceID @ref IDIdx index of the target column. + * @param sourceCellID @ref IDIdx index of the source column. + * @param targetCellID @ref IDIdx index of the target column. */ - void multiply_source_and_add_to(const Field_element& coefficient, ID_index sourceFaceID, ID_index targetFaceID); + void multiply_source_and_add_to(const Field_element& coefficient, ID_index sourceCellID, ID_index targetCellID); /** * @brief Zeroes the entry at the given coordinates. Not available for @ref chainmatrix "chain matrices". @@ -440,10 +440,10 @@ class Id_to_index_overlay * * For @ref boundarymatrix "RU matrices", zeros only the entry in \f$ R \f$. * - * @param faceID @ref IDIdx index of the face corresponding to the column of the entry. + * @param cellID @ref IDIdx index of the cell corresponding to the column of the entry. * @param rowIndex @ref rowindex "Row index" of the row of the entry. */ - void zero_entry(ID_index faceID, ID_index rowIndex); + void zero_entry(ID_index cellID, ID_index rowIndex); /** * @brief Zeroes the column at the given index. Not available for @ref chainmatrix "chain matrices". * In general, should be used with care to not destroy the validity @@ -451,20 +451,20 @@ class Id_to_index_overlay * * For @ref boundarymatrix "RU matrices", zeros only the column in \f$ R \f$. * - * @param faceID @ref IDIdx index of the face corresponding to the column. + * @param cellID @ref IDIdx index of the cell corresponding to the column. */ - void zero_column(ID_index faceID); + void zero_column(ID_index cellID); /** * @brief Indicates if the entry at given coordinates has value zero. * * For @ref boundarymatrix "RU matrices", looks into \f$ R \f$. * - * @param faceID @ref IDIdx index of the face corresponding to the column of the entry. + * @param cellID @ref IDIdx index of the cell corresponding to the column of the entry. * @param rowIndex @ref rowindex "Row index" of the row of the entry. * @return true If the entry has value zero. * @return false Otherwise. */ - bool is_zero_entry(ID_index faceID, ID_index rowIndex) const; + bool is_zero_entry(ID_index cellID, ID_index rowIndex) const; /** * @brief Indicates if the column at given index has value zero. * @@ -473,11 +473,11 @@ class Id_to_index_overlay * Note that for @ref chainmatrix "chain matrices", this method should always return false, as a valid * @ref chainmatrix "chain matrix" never has empty columns. * - * @param faceID @ref IDIdx index of the face corresponding to the column. + * @param cellID @ref IDIdx index of the cell corresponding to the column. * @return true If the column has value zero. * @return false Otherwise. */ - bool is_zero_column(ID_index faceID); + bool is_zero_column(ID_index cellID); /** * @brief Returns the @ref IDIdx index of the column which has the given @ref rowindex "row index" as pivot. @@ -487,17 +487,17 @@ class Id_to_index_overlay * the row indices for a @ref boundarymatrix "RU matrix" correspond to the updated @ref IDIdx indices which got * potentially swapped by a vine swap. * - * @param faceIndex @ref rowindex "Row index" of the pivot. + * @param cellIndex @ref rowindex "Row index" of the pivot. * @return @ref IDIdx index of the column with the given pivot. */ - ID_index get_column_with_pivot(ID_index faceIndex) const; + ID_index get_column_with_pivot(ID_index cellIndex) const; /** * @brief Returns the @ref rowindex "row index" of the pivot of the given column. * - * @param faceID @ref IDIdx index of the face corresponding to the column. + * @param cellID @ref IDIdx index of the cell corresponding to the column. * @return The @ref rowindex "row index" of the pivot. */ - ID_index get_pivot(ID_index faceID); + ID_index get_pivot(ID_index cellID); /** * @brief Resets the matrix to an empty matrix. @@ -549,10 +549,10 @@ class Id_to_index_overlay * Swaps the two given columns. Note that it really just swaps two columns and do not updates * anything else, nor performs additions to maintain some properties on the matrix. * - * @param faceID1 First column @ref IDIdx index to swap. - * @param faceID2 Second column @ref IDIdx index to swap. + * @param cellID1 First column @ref IDIdx index to swap. + * @param cellID2 Second column @ref IDIdx index to swap. */ - void swap_columns(ID_index faceID1, ID_index faceID2); + void swap_columns(ID_index cellID1, ID_index cellID2); /** * @brief Only available for simple @ref boundarymatrix "boundary matrices" (only storing R) * and if @ref PersistenceMatrixOptions::has_column_and_row_swaps is true. @@ -568,29 +568,29 @@ class Id_to_index_overlay * Does the same than @ref vine_swap, but assumes that the swap is non trivial and * therefore skips a part of the case study. * - * @param faceID1 @ref IDIdx index of the first face. - * @param faceID2 @ref IDIdx index of the second face. It is assumed that the @ref PosIdx of both only differs by one. + * @param cellID1 @ref IDIdx index of the first cell. + * @param cellID2 @ref IDIdx index of the second cell. It is assumed that the @ref PosIdx of both only differs by one. * @return Let \f$ pos1 \f$ be the @ref PosIdx index of @p columnIndex1 and \f$ pos2 \f$ be the @ref PosIdx index of * @p columnIndex2. The method returns the @ref MatIdx of the column which has now, after the swap, the @ref PosIdx * \f$ max(pos1, pos2) \f$. */ - ID_index vine_swap_with_z_eq_1_case(ID_index faceID1, ID_index faceID2); + ID_index vine_swap_with_z_eq_1_case(ID_index cellID1, ID_index cellID2); /** * @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true. - * Does a vine swap between two faces which are consecutive in the filtration. Roughly, if \f$ F \f$ is + * Does a vine swap between two cells which are consecutive in the filtration. Roughly, if \f$ F \f$ is * the current filtration represented by the matrix, the method modifies the matrix such that the new state - * corresponds to a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but with the two given faces - * at swapped positions. Of course, the two faces should not have a face/coface relation which each other ; + * corresponds to a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but with the two given cells + * at swapped positions. Of course, the two cells should not have a face/coface relation which each other ; * \f$ F' \f$ has to be a valid filtration. * See @cite vineyards for more information about vine and vineyards. * - * @param faceID1 @ref IDIdx index of the first face. - * @param faceID2 @ref IDIdx index of the second face. It is assumed that the @ref PosIdx of both only differs by one. + * @param cellID1 @ref IDIdx index of the first cell. + * @param cellID2 @ref IDIdx index of the second cell. It is assumed that the @ref PosIdx of both only differs by one. * @return Let \f$ pos1 \f$ be the @ref PosIdx index of @p columnIndex1 and \f$ pos2 \f$ be the @ref PosIdx index of * @p columnIndex2. The method returns the @ref MatIdx of the column which has now, after the swap, the @ref PosIdx * \f$ max(pos1, pos2) \f$. */ - ID_index vine_swap(ID_index faceID1, ID_index faceID2); + ID_index vine_swap(ID_index cellID1, ID_index cellID2); /** * @brief Only available if @ref PersistenceMatrixOptions::can_retrieve_representative_cycles is true. Pre-computes @@ -752,26 +752,26 @@ inline void Id_to_index_overlay::insert_bounda template template -inline void Id_to_index_overlay::insert_boundary(ID_index faceIndex, +inline void Id_to_index_overlay::insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) { if constexpr (Master_matrix::Option_list::has_map_column_container) { - GUDHI_CHECK(idToIndex_->find(faceIndex) == idToIndex_->end(), + GUDHI_CHECK(idToIndex_->find(cellIndex) == idToIndex_->end(), std::invalid_argument("Id_to_index_overlay::insert_boundary - Index for simplex already chosen!")); } else { - GUDHI_CHECK((idToIndex_->size() <= faceIndex || _id_to_index(faceIndex) == static_cast(-1)), + GUDHI_CHECK((idToIndex_->size() <= cellIndex || _id_to_index(cellIndex) == static_cast(-1)), std::invalid_argument("Id_to_index_overlay::insert_boundary - Index for simplex already chosen!")); } - matrix_.insert_boundary(faceIndex, boundary, dim); + matrix_.insert_boundary(cellIndex, boundary, dim); if constexpr (Master_matrix::Option_list::is_of_boundary_type) { if constexpr (Master_matrix::Option_list::has_map_column_container) { - idToIndex_->emplace(faceIndex, nextIndex_); + idToIndex_->emplace(cellIndex, nextIndex_); } else { - if (idToIndex_->size() <= faceIndex) { - idToIndex_->resize(faceIndex + 1, -1); + if (idToIndex_->size() <= cellIndex) { + idToIndex_->resize(cellIndex + 1, -1); } - _id_to_index(faceIndex) = nextIndex_; + _id_to_index(cellIndex) = nextIndex_; } ++nextIndex_; } @@ -779,9 +779,9 @@ inline void Id_to_index_overlay::insert_bounda template inline typename Id_to_index_overlay::Column& -Id_to_index_overlay::get_column(ID_index faceID) +Id_to_index_overlay::get_column(ID_index cellID) { - return matrix_.get_column(_id_to_index(faceID)); + return matrix_.get_column(_id_to_index(cellID)); } template @@ -798,7 +798,7 @@ inline void Id_to_index_overlay::erase_empty_r } template -inline void Id_to_index_overlay::remove_maximal_face(ID_index faceID) +inline void Id_to_index_overlay::remove_maximal_cell(ID_index cellID) { if constexpr (Master_matrix::Option_list::is_of_boundary_type) { std::vector indexToID(nextIndex_); @@ -812,34 +812,34 @@ inline void Id_to_index_overlay::remove_maxima } } --nextIndex_; - for (Index curr = _id_to_index(faceID); curr < nextIndex_; ++curr) { + for (Index curr = _id_to_index(cellID); curr < nextIndex_; ++curr) { matrix_.vine_swap(curr); std::swap(idToIndex_->at(indexToID[curr]), idToIndex_->at(indexToID[curr + 1])); } matrix_.remove_last(); - GUDHI_CHECK(_id_to_index(faceID) == nextIndex_, - std::logic_error("Id_to_index_overlay::remove_maximal_face - Indexation problem.")); + GUDHI_CHECK(_id_to_index(cellID) == nextIndex_, + std::logic_error("Id_to_index_overlay::remove_maximal_cell - Indexation problem.")); if constexpr (Master_matrix::Option_list::has_map_column_container) { - idToIndex_->erase(faceID); + idToIndex_->erase(cellID); } else { - _id_to_index(faceID) = -1; + _id_to_index(cellID) = -1; } } else { - matrix_.remove_maximal_face(faceID); + matrix_.remove_maximal_cell(cellID); } } template -inline void Id_to_index_overlay::remove_maximal_face( - ID_index faceID, const std::vector& columnsToSwap) +inline void Id_to_index_overlay::remove_maximal_cell( + ID_index cellID, const std::vector& columnsToSwap) { static_assert(!Master_matrix::Option_list::is_of_boundary_type, - "'remove_maximal_face(ID_index,const std::vector&)' is not available for the chosen options."); + "'remove_maximal_cell(ID_index,const std::vector&)' is not available for the chosen options."); std::vector translatedIndices; std::transform(columnsToSwap.cbegin(), columnsToSwap.cend(), std::back_inserter(translatedIndices), [&](ID_index id) { return _id_to_index(id); }); - matrix_.remove_maximal_face(faceID, translatedIndices); + matrix_.remove_maximal_cell(cellID, translatedIndices); } template @@ -881,54 +881,54 @@ Id_to_index_overlay::get_number_of_columns() c template inline typename Id_to_index_overlay::Dimension -Id_to_index_overlay::get_column_dimension(ID_index faceID) const +Id_to_index_overlay::get_column_dimension(ID_index cellID) const { - return matrix_.get_column_dimension(_id_to_index(faceID)); + return matrix_.get_column_dimension(_id_to_index(cellID)); } template -inline void Id_to_index_overlay::add_to(ID_index sourceFaceID, ID_index targetFaceID) +inline void Id_to_index_overlay::add_to(ID_index sourceCellID, ID_index targetCellID) { - return matrix_.add_to(_id_to_index(sourceFaceID), _id_to_index(targetFaceID)); + return matrix_.add_to(_id_to_index(sourceCellID), _id_to_index(targetCellID)); } template inline void Id_to_index_overlay::multiply_target_and_add_to( - ID_index sourceFaceID, const Field_element& coefficient, ID_index targetFaceID) + ID_index sourceCellID, const Field_element& coefficient, ID_index targetCellID) { - return matrix_.multiply_target_and_add_to(_id_to_index(sourceFaceID), coefficient, _id_to_index(targetFaceID)); + return matrix_.multiply_target_and_add_to(_id_to_index(sourceCellID), coefficient, _id_to_index(targetCellID)); } template inline void Id_to_index_overlay::multiply_source_and_add_to( - const Field_element& coefficient, ID_index sourceFaceID, ID_index targetFaceID) + const Field_element& coefficient, ID_index sourceCellID, ID_index targetCellID) { - return matrix_.multiply_source_and_add_to(coefficient, _id_to_index(sourceFaceID), _id_to_index(targetFaceID)); + return matrix_.multiply_source_and_add_to(coefficient, _id_to_index(sourceCellID), _id_to_index(targetCellID)); } template -inline void Id_to_index_overlay::zero_entry(ID_index faceID, ID_index rowIndex) +inline void Id_to_index_overlay::zero_entry(ID_index cellID, ID_index rowIndex) { - return matrix_.zero_entry(_id_to_index(faceID), rowIndex); + return matrix_.zero_entry(_id_to_index(cellID), rowIndex); } template -inline void Id_to_index_overlay::zero_column(ID_index faceID) +inline void Id_to_index_overlay::zero_column(ID_index cellID) { - return matrix_.zero_column(_id_to_index(faceID)); + return matrix_.zero_column(_id_to_index(cellID)); } template -inline bool Id_to_index_overlay::is_zero_entry(ID_index faceID, +inline bool Id_to_index_overlay::is_zero_entry(ID_index cellID, ID_index rowIndex) const { - return matrix_.is_zero_entry(_id_to_index(faceID), rowIndex); + return matrix_.is_zero_entry(_id_to_index(cellID), rowIndex); } template -inline bool Id_to_index_overlay::is_zero_column(ID_index faceID) +inline bool Id_to_index_overlay::is_zero_column(ID_index cellID) { - return matrix_.is_zero_column(_id_to_index(faceID)); + return matrix_.is_zero_column(_id_to_index(cellID)); } template @@ -947,12 +947,12 @@ Id_to_index_overlay::get_column_with_pivot(ID_ template inline typename Id_to_index_overlay::ID_index -Id_to_index_overlay::get_pivot(ID_index faceID) +Id_to_index_overlay::get_pivot(ID_index cellID) { if constexpr (Master_matrix::Option_list::is_of_boundary_type) { - return matrix_.get_pivot(_id_to_index(faceID)); + return matrix_.get_pivot(_id_to_index(cellID)); } else { - return faceID; + return cellID; } } @@ -1004,10 +1004,10 @@ Id_to_index_overlay::get_representative_cycle( } template -inline void Id_to_index_overlay::swap_columns(ID_index faceID1, ID_index faceID2) +inline void Id_to_index_overlay::swap_columns(ID_index cellID1, ID_index cellID2) { - matrix_.swap_columns(_id_to_index(faceID1), _id_to_index(faceID2)); - std::swap(idToIndex_->at(faceID1), idToIndex_->at(faceID2)); + matrix_.swap_columns(_id_to_index(cellID1), _id_to_index(cellID2)); + std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2)); } template @@ -1018,10 +1018,10 @@ inline void Id_to_index_overlay::swap_rows(Ind template inline typename Id_to_index_overlay::ID_index -Id_to_index_overlay::vine_swap_with_z_eq_1_case(ID_index faceID1, ID_index faceID2) +Id_to_index_overlay::vine_swap_with_z_eq_1_case(ID_index cellID1, ID_index cellID2) { - Index first = _id_to_index(faceID1); - Index second = _id_to_index(faceID2); + Index first = _id_to_index(cellID1); + Index second = _id_to_index(cellID2); if (first > second) std::swap(first, second); if constexpr (Master_matrix::Option_list::is_of_boundary_type) { @@ -1031,12 +1031,12 @@ Id_to_index_overlay::vine_swap_with_z_eq_1_cas bool change = matrix_.vine_swap_with_z_eq_1_case(first); - std::swap(idToIndex_->at(faceID1), idToIndex_->at(faceID2)); + std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2)); if (change) { - return faceID1; + return cellID1; } - return faceID2; + return cellID2; } else { return matrix_.vine_swap_with_z_eq_1_case(first, second); } @@ -1044,10 +1044,10 @@ Id_to_index_overlay::vine_swap_with_z_eq_1_cas template inline typename Id_to_index_overlay::ID_index -Id_to_index_overlay::vine_swap(ID_index faceID1, ID_index faceID2) +Id_to_index_overlay::vine_swap(ID_index cellID1, ID_index cellID2) { - Index first = _id_to_index(faceID1); - Index second = _id_to_index(faceID2); + Index first = _id_to_index(cellID1); + Index second = _id_to_index(cellID2); if (first > second) std::swap(first, second); if constexpr (Master_matrix::Option_list::is_of_boundary_type) { @@ -1056,12 +1056,12 @@ Id_to_index_overlay::vine_swap(ID_index faceID bool change = matrix_.vine_swap(first); - std::swap(idToIndex_->at(faceID1), idToIndex_->at(faceID2)); + std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2)); if (change) { - return faceID1; + return cellID1; } - return faceID2; + return cellID2; } else { return matrix_.vine_swap(first, second); } diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Position_to_index_overlay.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Position_to_index_overlay.h index 56cd2c2d27..4a19488230 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/Position_to_index_overlay.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/Position_to_index_overlay.h @@ -216,10 +216,10 @@ class Position_to_index_overlay /** * @brief 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, + * It also assumes that the cells 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 * @ref insert_boundary(ID_index, const Boundary_range&, Dimension) "insert_boundary" instead by indicating the - * face ID used in the boundaries when the face is inserted. + * cell ID used in the boundaries when the cell is inserted. * * Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from * a more general entry complex. This includes cubical complexes or Morse complexes for example. @@ -230,30 +230,30 @@ class Position_to_index_overlay * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. * @param boundary Boundary generating the new column. The content should be ordered by ID. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template void insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** - * @brief It does the same as the other version, but allows the boundary faces to be identified without restrictions + * @brief It does the same as the other version, but allows the boundary cells 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. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. - * @param faceIndex @ref IDIdx index to use to identify the new face. + * @param cellIndex @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceID values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellID values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template - void insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim = -1); + void insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1); /** * @brief Returns the column at the given @ref PosIdx index. * The type of the column depends on the choosen options, see @ref PersistenceMatrixOptions::column_type. @@ -307,28 +307,28 @@ class Position_to_index_overlay * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns, * @ref PersistenceMatrixOptions::has_vine_update and @ref PersistenceMatrixOptions::has_map_column_container * are true. - * Assumes that the face is maximal in the current complex and removes it such that the matrix remains consistent + * Assumes that the cell is maximal in the current complex and removes it such that the matrix remains consistent * (i.e., the matrix is still a compatible bases of the chain complex in the sense of @cite zigzag). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it was computed. * * See also @ref remove_last. * - * @param position @ref PosIdx index of the face to remove. + * @param position @ref PosIdx index of the cell to remove. */ - void remove_maximal_face(Pos_index position); + void remove_maximal_cell(Pos_index position); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true and, * if @ref PersistenceMatrixOptions::has_map_column_container is true or * @ref PersistenceMatrixOptions::has_vine_update is false. - * Removes the last face in the filtration from the matrix and updates the barcode if it is stored. + * Removes the last cell in the filtration from the matrix and updates the barcode if it is stored. * - * See also @ref remove_maximal_face. + * See also @ref remove_maximal_cell. */ void remove_last(); /** - * @brief Returns the maximal dimension of a face stored in the matrix. Only available + * @brief Returns the maximal dimension of a cell stored in the matrix. Only available * if @ref PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true. * * @return The maximal dimension. @@ -341,10 +341,10 @@ class Position_to_index_overlay */ Index get_number_of_columns() const; /** - * @brief Returns the dimension of the given face. + * @brief Returns the dimension of the given cell. * - * @param position @ref PosIdx index of the face. - * @return Dimension of the face. + * @param position @ref PosIdx index of the cell. + * @return Dimension of the cell. */ Dimension get_column_dimension(Pos_index position) const; @@ -393,7 +393,7 @@ class Position_to_index_overlay /** * @brief Indicates if the entry at given coordinates has value zero. * - * @param position @ref PosIdx index of the face corresponding to the column of the entry. + * @param position @ref PosIdx index of the cell corresponding to the column of the entry. * @param rowIndex @ref rowindex "Row index" of the row of the entry. * @return true If the entry has value zero. * @return false Otherwise. @@ -405,7 +405,7 @@ class Position_to_index_overlay * Note that this method should always return false, as a valid @ref chainmatrix "chain matrix" never has * empty columns. * - * @param position @ref PosIdx index of the face corresponding to the column. + * @param position @ref PosIdx index of the cell corresponding to the column. * @return true If the column has value zero. * @return false Otherwise. */ @@ -415,14 +415,14 @@ class Position_to_index_overlay * @brief Returns the @ref PosIdx index of the column which has the given @ref rowindex "row index" as pivot. * Assumes that the pivot exists. * - * @param faceIndex @ref rowindex "Row index" of the pivot. + * @param cellIndex @ref rowindex "Row index" of the pivot. * @return @ref PosIdx index of the column with the given pivot. */ - Pos_index get_column_with_pivot(ID_index faceIndex) const; // assumes that pivot exists + Pos_index get_column_with_pivot(ID_index cellIndex) const; // assumes that pivot exists /** * @brief Returns the @ref rowindex "row index" of the pivot of the given column. * - * @param position @ref PosIdx index of the face corresponding to the column. + * @param position @ref PosIdx index of the cell corresponding to the column. * @return The @ref rowindex "row index" of the pivot. */ ID_index get_pivot(Pos_index position); @@ -500,21 +500,21 @@ class Position_to_index_overlay * Does the same than @ref vine_swap, but assumes that the swap is non trivial and * therefore skips a part of the case study. * - * @param position @ref PosIdx index of the first face to swap. The second one has to be at `position + 1`. + * @param position @ref PosIdx index of the first cell to swap. The second one has to be at `position + 1`. * @return true If the barcode changed from the swap. * @return false Otherwise. */ bool vine_swap_with_z_eq_1_case(Pos_index position); /** * @brief Only available if @ref PersistenceMatrixOptions::has_vine_update is true. - * Does a vine swap between two faces which are consecutive in the filtration. Roughly, if \f$ F \f$ is the current + * Does a vine swap between two cells which are consecutive in the filtration. Roughly, if \f$ F \f$ is the current * filtration represented by the matrix, the method modifies the matrix such that the new state corresponds to - * a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but with the two faces at position `position` - * and `position + 1` swapped. Of course, the two faces should not have a face/coface relation which each other ; + * a valid state for the filtration \f$ F' \f$ equal to \f$ F \f$ but with the two cells at position `position` + * and `position + 1` swapped. Of course, the two cells should not have a face/coface relation which each other ; * \f$ F' \f$ has to be a valid filtration. * See @cite vineyards for more information about vine and vineyards. * - * @param position @ref PosIdx index of the first face to swap. The second one has to be at `position + 1`. + * @param position @ref PosIdx index of the first cell to swap. The second one has to be at `position + 1`. * @return true If the barcode changed from the swap. * @return false Otherwise. */ @@ -629,7 +629,7 @@ inline void Position_to_index_overlay::insert_ template template -inline void Position_to_index_overlay::insert_boundary(ID_index faceIndex, +inline void Position_to_index_overlay::insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) { @@ -639,7 +639,7 @@ inline void Position_to_index_overlay::insert_ positionToIndex_[nextPosition_++] = nextIndex_++; - matrix_.insert_boundary(faceIndex, boundary, dim); + matrix_.insert_boundary(cellIndex, boundary, dim); } template @@ -677,7 +677,7 @@ inline void Position_to_index_overlay::erase_e } template -inline void Position_to_index_overlay::remove_maximal_face(Pos_index position) +inline void Position_to_index_overlay::remove_maximal_cell(Pos_index position) { --nextPosition_; @@ -693,7 +693,7 @@ inline void Position_to_index_overlay::remove_ columnsToSwap.back() = positionToIndex_[nextPosition_]; } - matrix_.remove_maximal_face(pivot, columnsToSwap); + matrix_.remove_maximal_cell(pivot, columnsToSwap); } template @@ -702,9 +702,9 @@ inline void Position_to_index_overlay::remove_ --nextPosition_; if constexpr (Master_matrix::Option_list::has_vine_update) { std::vector columnsToSwap; - matrix_.remove_maximal_face(matrix_.get_pivot(positionToIndex_[nextPosition_]), columnsToSwap); + matrix_.remove_maximal_cell(matrix_.get_pivot(positionToIndex_[nextPosition_]), columnsToSwap); } else { - matrix_.remove_last(); // linear with vine updates, so it is better to use remove_maximal_face + matrix_.remove_last(); // linear with vine updates, so it is better to use remove_maximal_cell } } @@ -769,9 +769,9 @@ inline bool Position_to_index_overlay::is_zero template inline typename Position_to_index_overlay::Pos_index -Position_to_index_overlay::get_column_with_pivot(ID_index faceIndex) const +Position_to_index_overlay::get_column_with_pivot(ID_index cellIndex) const { - Index id = matrix_.get_column_with_pivot(faceIndex); + Index id = matrix_.get_column_with_pivot(cellIndex); Pos_index i = 0; while (positionToIndex_[i] != id) ++i; return i; diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/RU_matrix.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/RU_matrix.h index f738404e42..7c3661a8a9 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/RU_matrix.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/RU_matrix.h @@ -30,7 +30,7 @@ namespace persistence_matrix { * * @brief %Matrix structure to store the ordered @ref boundarymatrix "boundary matrix" \f$ R \cdot U \f$ of a filtered * complex in order to compute its persistent homology, as well as representative cycles. - * Supports vineyards (see @cite vineyards) and the removal of maximal faces while maintaining + * Supports vineyards (see @cite vineyards) and the removal of maximal cells while maintaining * a valid barcode. Provides an access to its columns and rows. * * @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced. @@ -115,10 +115,10 @@ class RU_matrix : public Master_matrix::RU_pairing_option, /** * @brief 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, + * It also assumes that the cells 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 * @ref insert_boundary(ID_index, const Boundary_range&, Dimension) "insert_boundary" instead by indicating the - * face ID used in the boundaries when the face is inserted. + * cell ID used in the boundaries when the cell is inserted. * * Different to the constructor, the boundaries do not have to come from a simplicial complex, but also from * a more general entry complex. This includes cubical complexes or Morse complexes for example. @@ -128,30 +128,30 @@ class RU_matrix : public Master_matrix::RU_pairing_option, * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. * @param boundary Boundary generating the new column. The content should be ordered by ID. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template void insert_boundary(const Boundary_range& boundary, Dimension dim = -1); /** - * @brief It does the same as the other version, but allows the boundary faces to be identified without restrictions + * @brief It does the same as the other version, but allows the boundary cells 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. + * As a cell has to be inserted before one of its cofaces in a valid filtration (recall that it is assumed that + * the cells are inserted by order of filtration), it is sufficient to indicate the ID of the cell being inserted. * * @tparam Boundary_range Range of @ref Matrix::Entry_representative. Assumed to have a begin(), end() and size() * method. - * @param faceIndex @ref IDIdx index to use to identify the new face. + * @param cellIndex @ref IDIdx index to use to identify the new cell. * @param boundary Boundary generating the new column. The indices of the boundary have to correspond to the - * @p faceIndex values of precedent calls of the method for the corresponding faces and should be ordered in + * @p cellIndex values of precedent calls of the method for the corresponding cells and should be ordered in * increasing order. - * @param dim Dimension of the face whose boundary is given. If the complex is simplicial, + * @param dim Dimension of the cell 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. */ template - void insert_boundary(ID_index faceIndex, const Boundary_range& boundary, Dimension dim = -1); + void insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim = -1); /** * @brief Returns the column at the given @ref MatIdx index in \f$ R \f$ if @p inR is true and * in \f$ U \f$ if @p inR is false. @@ -203,26 +203,26 @@ class RU_matrix : public Master_matrix::RU_pairing_option, /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns and * @ref 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 + * Assumes that the cell 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 @ref boundarymatrix "boundary matrix"). - * The maximality of the face is not verified. + * The maximality of the cell is not verified. * Also updates the barcode if it is stored. * * See also @ref remove_last. * - * @param columnIndex @ref MatIdx index of the face to remove. + * @param columnIndex @ref MatIdx index of the cell to remove. */ - void remove_maximal_face(Index columnIndex); + void remove_maximal_cell(Index columnIndex); /** * @brief Only available if @ref PersistenceMatrixOptions::has_removable_columns is true. - * Removes the last face in the filtration from the matrix and updates the barcode if it is stored. + * Removes the last cell in the filtration from the matrix and updates the barcode if it is stored. * - * See also @ref remove_maximal_face. + * See also @ref remove_maximal_cell. */ void remove_last(); /** - * @brief Returns the maximal dimension of a face stored in the matrix. + * @brief Returns the maximal dimension of a cell stored in the matrix. * Only available if @ref PersistenceMatrixOptions::has_matrix_maximal_dimension_access is true. * * @return The maximal dimension. @@ -237,8 +237,8 @@ class RU_matrix : public Master_matrix::RU_pairing_option, /** * @brief Returns the dimension of the given column. * - * @param columnIndex @ref MatIdx index of the column representing the face. - * @return Dimension of the face. + * @param columnIndex @ref MatIdx index of the column representing the cell. + * @return Dimension of the cell. */ Dimension get_column_dimension(Index columnIndex) const; @@ -331,10 +331,10 @@ class RU_matrix : public Master_matrix::RU_pairing_option, * @brief Returns the @ref MatIdx index of the column which has the given @ref rowindex "row index" as pivot in * \f$ R \f$. Assumes that the pivot exists. * - * @param faceIndex @ref rowindex "Row index" of the pivot. + * @param cellIndex @ref rowindex "Row index" of the pivot. * @return @ref MatIdx index of the column in \f$ R \f$ with the given pivot. */ - Index get_column_with_pivot(Index faceIndex) const; + Index get_column_with_pivot(Index cellIndex) const; /** * @brief Returns the @ref rowindex "row index" of the pivot of the given column in \f$ R \f$. * @@ -522,28 +522,28 @@ inline void RU_matrix::insert_boundary(const Boundary_range& boun template template -inline void RU_matrix::insert_boundary(ID_index faceIndex, +inline void RU_matrix::insert_boundary(ID_index cellIndex, const Boundary_range& boundary, Dimension dim) { // maps for possible shifting between column content and position indices used for birth events if constexpr (Master_matrix::Option_list::has_column_pairings && !Master_matrix::Option_list::has_vine_update) { - if (faceIndex != nextEventIndex_) { - Pair_opt::idToPosition_.emplace(faceIndex, nextEventIndex_); + if (cellIndex != nextEventIndex_) { + Pair_opt::idToPosition_.emplace(cellIndex, nextEventIndex_); if constexpr (Master_matrix::Option_list::has_removable_columns) { - Pair_opt::PIDM::map_.emplace(nextEventIndex_, faceIndex); + Pair_opt::PIDM::map_.emplace(nextEventIndex_, cellIndex); } } } if constexpr (Master_matrix::Option_list::has_vine_update) { - if (faceIndex != nextEventIndex_) { - Swap_opt::_positionToRowIdx().emplace(nextEventIndex_, faceIndex); + if (cellIndex != nextEventIndex_) { + Swap_opt::_positionToRowIdx().emplace(nextEventIndex_, cellIndex); if (Master_matrix::Option_list::has_column_pairings) { - Swap_opt::template RU_pairing::idToPosition_.emplace(faceIndex, nextEventIndex_); + Swap_opt::template RU_pairing::idToPosition_.emplace(cellIndex, nextEventIndex_); } } } - _insert_boundary(reducedMatrixR_.insert_boundary(faceIndex, boundary, dim)); + _insert_boundary(reducedMatrixR_.insert_boundary(cellIndex, boundary, dim)); } template @@ -573,10 +573,10 @@ inline void RU_matrix::erase_empty_row(Index rowIndex) } template -inline void RU_matrix::remove_maximal_face(Index columnIndex) +inline void RU_matrix::remove_maximal_cell(Index columnIndex) { static_assert(Master_matrix::Option_list::has_removable_columns && Master_matrix::Option_list::has_vine_update, - "'remove_maximal_face' is not implemented for the chosen options."); + "'remove_maximal_cell' is not implemented for the chosen options."); // TODO: is there an easy test to verify maximality even without row access? @@ -699,12 +699,12 @@ inline bool RU_matrix::is_zero_column(Index columnIndex, bool inR } template -inline typename RU_matrix::Index RU_matrix::get_column_with_pivot(Index faceIndex) const +inline typename RU_matrix::Index RU_matrix::get_column_with_pivot(Index cellIndex) const { if constexpr (Master_matrix::Option_list::has_map_column_container) { - return pivotToColumnIndex_.at(faceIndex); + return pivotToColumnIndex_.at(cellIndex); } else { - return pivotToColumnIndex_[faceIndex]; + return pivotToColumnIndex_[cellIndex]; } } diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/base_pairing.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/base_pairing.h index ac883fff38..8ce95ce743 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/base_pairing.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/base_pairing.h @@ -23,7 +23,7 @@ #include #include -#include "boundary_face_position_to_id_mapper.h" +#include "boundary_cell_position_to_id_mapper.h" namespace Gudhi { namespace persistence_matrix { @@ -50,7 +50,7 @@ struct Dummy_base_pairing { template class Base_pairing : public std::conditional< Master_matrix::Option_list::has_removable_columns, - Face_position_to_ID_mapper, + Cell_position_to_ID_mapper, Dummy_pos_mapper >::type { @@ -82,8 +82,8 @@ class Base_pairing : public std::conditional< */ friend void swap(Base_pairing& pairing1, Base_pairing& pairing2) { if constexpr (Master_matrix::Option_list::has_removable_columns) { - swap(static_cast&>(pairing1), - static_cast&>(pairing2)); + swap(static_cast&>(pairing1), + static_cast&>(pairing2)); } pairing1.barcode_.swap(pairing2.barcode_); pairing1.deathToBar_.swap(pairing2.deathToBar_); @@ -98,14 +98,14 @@ class Base_pairing : public std::conditional< using Base_matrix = typename Master_matrix::Master_boundary_matrix; //PIDM = Position to ID Map using PIDM = typename std::conditional, + Cell_position_to_ID_mapper, Dummy_pos_mapper >::type; Barcode barcode_; /**< Bar container. */ Dictionary deathToBar_; /**< Map from death index to bar index. */ /** - * @brief Map from face ID to face position. Only stores a pair if ID != position. + * @brief Map from cell ID to cell position. Only stores a pair if ID != position. */ std::unordered_map idToPosition_; //TODO: test other map types bool isReduced_; /**< True if `_reduce()` was called. */ diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h similarity index 74% rename from src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h rename to src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h index 5464804196..1b85b07c82 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h @@ -9,10 +9,10 @@ */ /** - * @file base_pairing.h + * @file boundary_cell_position_to_id_mapper.h * @author Hannah Schreiber - * @brief Contains the @ref Gudhi::persistence_matrix::Base_pairing class and - * @ref Gudhi::persistence_matrix::Dummy_base_pairing structure. + * @brief Contains the @ref Gudhi::persistence_matrix::Cell_position_to_ID_mapper class and + * @ref Gudhi::persistence_matrix::Dummy_pos_mapper structure. */ #ifndef PM_ID_POS_MAPPER_H @@ -28,7 +28,7 @@ namespace persistence_matrix { * @ingroup persistence_matrix * * @brief Empty structure. - * Inherited instead of @ref Face_position_to_ID_mapper. + * Inherited instead of @ref Cell_position_to_ID_mapper. */ struct Dummy_pos_mapper { friend void swap([[maybe_unused]] Dummy_pos_mapper& d1, [[maybe_unused]] Dummy_pos_mapper& d2) {} @@ -38,18 +38,18 @@ struct Dummy_pos_mapper { * @private * @ingroup persistence_matrix * - * @brief Map from face position to face ID. Only stores a pair if ID != position and has_removable_column is true. + * @brief Map from cell position to cell ID. Only stores a pair if ID != position and has_removable_column is true. * * @tparam ID_index @ref IDIdx index type * @tparam Pos_index @ref PosIdx index type */ template -struct Face_position_to_ID_mapper { +struct Cell_position_to_ID_mapper { using Index_map = std::unordered_map; //TODO: test other map types Index_map map_; - friend void swap(Face_position_to_ID_mapper& mapper1, Face_position_to_ID_mapper& mapper2) { + friend void swap(Cell_position_to_ID_mapper& mapper1, Cell_position_to_ID_mapper& mapper2) { mapper1.map_.swap(mapper2.map_); } }; diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/chain_vine_swap.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/chain_vine_swap.h index 887f89cb2c..3168b54031 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/chain_vine_swap.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/chain_vine_swap.h @@ -281,23 +281,23 @@ class Chain_vine_swap : public std::conditional dimensions_; /**< Number of faces by dimension. */ - Dimension maxDim_; /**< Current maximal dimension. */ + std::vector dimensions_; /**< Number of cells by dimension. */ + Dimension maxDim_; /**< Current maximal dimension. */ void update_up(unsigned int dimension) { if (dimensions_.size() <= dimension) dimensions_.resize(dimension + 1, 0); diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_pairing.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_pairing.h index f44e518e78..e6afe9fc89 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_pairing.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_pairing.h @@ -20,7 +20,7 @@ #include -#include "boundary_face_position_to_id_mapper.h" +#include "boundary_cell_position_to_id_mapper.h" namespace Gudhi { namespace persistence_matrix { @@ -48,7 +48,7 @@ struct Dummy_ru_pairing template class RU_pairing : public std::conditional< Master_matrix::Option_list::has_removable_columns, - Face_position_to_ID_mapper, + Cell_position_to_ID_mapper, Dummy_pos_mapper >::type { @@ -57,9 +57,9 @@ class RU_pairing : public std::conditional< using ID_index = typename Master_matrix::ID_index; //PIDM = Position to ID Map using PIDM = typename std::conditional, - Dummy_pos_mapper - >::type; + Cell_position_to_ID_mapper, + Dummy_pos_mapper + >::type; public: using Barcode = typename Master_matrix::Barcode; /**< Barcode type. */ @@ -93,7 +93,7 @@ class RU_pairing : public std::conditional< Barcode barcode_; /**< Bar container. */ Dictionary indexToBar_; /**< Map from @ref MatIdx index to bar index. */ /** - * @brief Map from face ID to face position. Only stores a pair if ID != position. + * @brief Map from cell ID to cell position. Only stores a pair if ID != position. */ std::unordered_map idToPosition_; //TODO: test other map types diff --git a/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_vine_swap.h b/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_vine_swap.h index 64561c8683..00c76749f7 100644 --- a/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_vine_swap.h +++ b/src/Persistence_matrix/include/gudhi/Persistence_matrix/ru_vine_swap.h @@ -25,7 +25,7 @@ #include //std::invalid_argument #include "ru_pairing.h" -#include "boundary_face_position_to_id_mapper.h" +#include "boundary_cell_position_to_id_mapper.h" namespace Gudhi { namespace persistence_matrix { @@ -68,7 +68,7 @@ class RU_vine_swap : public std::conditional >::type { @@ -98,20 +98,20 @@ class RU_vine_swap : public std::conditional&>(swap1), static_cast&>(swap2)); } if (!Master_matrix::Option_list::has_column_pairings || !Master_matrix::Option_list::has_removable_columns) { - swap(static_cast&>(swap1), - static_cast&>(swap2)); + swap(static_cast&>(swap1), + static_cast&>(swap2)); } } @@ -144,7 +144,7 @@ class RU_vine_swap : public std::conditional + Cell_position_to_ID_mapper >::type; constexpr auto& _positionToRowIdx(); diff --git a/src/Persistence_matrix/test/pm_matrix_tests.h b/src/Persistence_matrix/test/pm_matrix_tests.h index c6785b9b92..dd20612656 100644 --- a/src/Persistence_matrix/test/pm_matrix_tests.h +++ b/src/Persistence_matrix/test/pm_matrix_tests.h @@ -902,7 +902,7 @@ void test_ru_maximal_simplex_removal() { } if constexpr (Matrix::Option_list::has_vine_update) { - m.remove_maximal_face(6); + m.remove_maximal_cell(6); } else { m.remove_last(); } @@ -927,7 +927,7 @@ void test_chain_maximal_simplex_removal(Matrix& m) { if constexpr (Matrix::Option_list::has_vine_update && Matrix::Option_list::has_map_column_container && Matrix::Option_list::has_column_pairings) { - m.remove_maximal_face(6); + m.remove_maximal_cell(6); } else { m.remove_last(); } @@ -957,7 +957,7 @@ void test_maximal_dimension(Matrix& m) { if constexpr (Matrix::Option_list::has_vine_update && (Matrix::Option_list::is_of_boundary_type || (Matrix::Option_list::has_map_column_container && Matrix::Option_list::has_column_pairings))) { - m.remove_maximal_face(7); + m.remove_maximal_cell(7); BOOST_CHECK_EQUAL(m.get_max_dimension(), 3); } }