Loading...
Searching...
No Matches
Id_to_index_overlay.h
Go to the documentation of this file.
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2022-24 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef PM_ID_TO_POS_TRANSLATION_H
#define PM_ID_TO_POS_TRANSLATION_H
#include <cmath>
#include <vector>
#include <cassert>
#include <utility> //std::swap, std::move & std::exchange
#include <algorithm> //std::transform
#include <stdexcept> //std::invalid_argument
namespace Gudhi {
namespace persistence_matrix {
template <class Underlying_matrix, class Master_matrix>
class Id_to_index_overlay
{
public:
using Index = typename Master_matrix::Index;
using ID_index = typename Master_matrix::ID_index;
using Pos_index = typename Master_matrix::Pos_index;
using Dimension = typename Master_matrix::Dimension;
using Field_operators = typename Master_matrix::Field_operators;
using Field_element = typename Master_matrix::Element;
using Boundary = typename Master_matrix::Boundary;
using Column = typename Master_matrix::Column;
using Row = typename Master_matrix::Row;
using Bar = typename Master_matrix::Bar;
using Barcode = typename Master_matrix::Barcode;
using Cycle = typename Master_matrix::Cycle;
using Entry_constructor = typename Master_matrix::Entry_constructor;
using Column_settings = typename Master_matrix::Column_settings;
Id_to_index_overlay(Column_settings* colSettings);
template <class Boundary_range = Boundary>
Id_to_index_overlay(const std::vector<Boundary_range>& orderedBoundaries,
Column_settings* colSettings);
Id_to_index_overlay(unsigned int numberOfColumns, Column_settings* colSettings);
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
Id_to_index_overlay(Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator);
template <typename BirthComparatorFunction, typename DeathComparatorFunction, class Boundary_range>
Id_to_index_overlay(const std::vector<Boundary_range>& orderedBoundaries,
Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator);
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
Id_to_index_overlay(unsigned int numberOfColumns,
Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator);
Id_to_index_overlay(const Id_to_index_overlay& matrixToCopy,
Column_settings* colSettings = nullptr);
Id_to_index_overlay(Id_to_index_overlay&& other) noexcept;
~Id_to_index_overlay();
template <class Boundary_range = Boundary>
void insert_boundary(const Boundary_range& boundary,
Dimension dim = Master_matrix::template get_null_value<Dimension>());
template <class Boundary_range = Boundary>
void insert_boundary(ID_index cellIndex, const Boundary_range& boundary,
Dimension dim = Master_matrix::template get_null_value<Dimension>());
Column& get_column(ID_index cellID);
Row& get_row(ID_index rowIndex);
void erase_empty_row(ID_index rowIndex);
void remove_maximal_cell(ID_index cellID);
void remove_maximal_cell(ID_index cellID, const std::vector<ID_index>& columnsToSwap);
void remove_last();
Dimension get_max_dimension() const;
Index get_number_of_columns() const;
Dimension get_column_dimension(ID_index cellID) const;
void add_to(ID_index sourceCellID, ID_index targetCellID);
void multiply_target_and_add_to(ID_index sourceCellID, const Field_element& coefficient, ID_index targetCellID);
void multiply_source_and_add_to(const Field_element& coefficient, ID_index sourceCellID, ID_index targetCellID);
void zero_entry(ID_index cellID, ID_index rowIndex);
void zero_column(ID_index cellID);
bool is_zero_entry(ID_index cellID, ID_index rowIndex) const;
bool is_zero_column(ID_index cellID);
ID_index get_column_with_pivot(ID_index cellIndex) const;
ID_index get_pivot(ID_index cellID);
void reset(Column_settings* colSettings) {
matrix_.reset(colSettings);
nextIndex_ = 0;
}
// void set_operators(Field_operators* operators) { matrix_.set_operators(operators); }
Id_to_index_overlay& operator=(const Id_to_index_overlay& other);
friend void swap(Id_to_index_overlay& matrix1, Id_to_index_overlay& matrix2) {
swap(matrix1.matrix_, matrix2.matrix_);
if (Master_matrix::Option_list::is_of_boundary_type) std::swap(matrix1.idToIndex_, matrix2.idToIndex_);
std::swap(matrix1.nextIndex_, matrix2.nextIndex_);
}
void print(); // for debug
// access to optional methods
const Barcode& get_current_barcode();
void swap_columns(ID_index cellID1, ID_index cellID2);
void swap_rows(Index rowIndex1, Index rowIndex2);
ID_index vine_swap_with_z_eq_1_case(ID_index cellID1, ID_index cellID2);
ID_index vine_swap(ID_index cellID1, ID_index cellID2);
void update_representative_cycles();
const std::vector<Cycle>& get_representative_cycles();
const Cycle& get_representative_cycle(const Bar& bar);
private:
using Dictionary = typename Master_matrix::template Dictionary<Index>;
Underlying_matrix matrix_;
Dictionary* idToIndex_;
Index nextIndex_;
void _initialize_map(unsigned int size);
Index _id_to_index(ID_index id) const;
Index& _id_to_index(ID_index id);
};
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(Column_settings* colSettings)
: matrix_(colSettings), idToIndex_(nullptr), nextIndex_(0)
{
_initialize_map(0);
}
template <class Underlying_matrix, class Master_matrix>
template <class Boundary_range>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(
const std::vector<Boundary_range>& orderedBoundaries, Column_settings* colSettings)
: matrix_(orderedBoundaries, colSettings), idToIndex_(nullptr), nextIndex_(orderedBoundaries.size())
{
_initialize_map(orderedBoundaries.size());
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
for (unsigned int i = 0; i < orderedBoundaries.size(); i++) {
_id_to_index(i) = i;
}
}
}
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(unsigned int numberOfColumns,
Column_settings* colSettings)
: matrix_(numberOfColumns, colSettings), idToIndex_(nullptr), nextIndex_(0)
{
_initialize_map(numberOfColumns);
}
template <class Underlying_matrix, class Master_matrix>
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(
Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator)
: matrix_(colSettings, birthComparator, deathComparator), idToIndex_(nullptr), nextIndex_(0)
{
_initialize_map(0);
}
template <class Underlying_matrix, class Master_matrix>
template <typename BirthComparatorFunction, typename DeathComparatorFunction, class Boundary_range>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(
const std::vector<Boundary_range>& orderedBoundaries,
Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator)
: matrix_(orderedBoundaries, colSettings, birthComparator, deathComparator),
idToIndex_(nullptr),
nextIndex_(orderedBoundaries.size())
{
_initialize_map(orderedBoundaries.size());
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
for (unsigned int i = 0; i < orderedBoundaries.size(); i++) {
_id_to_index(i) = i;
}
}
}
template <class Underlying_matrix, class Master_matrix>
template <typename BirthComparatorFunction, typename DeathComparatorFunction>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(
unsigned int numberOfColumns,
Column_settings* colSettings,
const BirthComparatorFunction& birthComparator,
const DeathComparatorFunction& deathComparator)
: matrix_(numberOfColumns, colSettings, birthComparator, deathComparator),
idToIndex_(nullptr),
nextIndex_(0)
{
_initialize_map(numberOfColumns);
}
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(
const Id_to_index_overlay& matrixToCopy, Column_settings* colSettings)
: matrix_(matrixToCopy.matrix_, colSettings),
idToIndex_(nullptr),
nextIndex_(matrixToCopy.nextIndex_)
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
idToIndex_ = new Dictionary(*matrixToCopy.idToIndex_);
} else {
idToIndex_ = &matrix_.pivotToColumnIndex_;
}
}
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::Id_to_index_overlay(Id_to_index_overlay&& other) noexcept
: matrix_(std::move(other.matrix_)),
idToIndex_(std::exchange(other.idToIndex_, nullptr)),
nextIndex_(std::exchange(other.nextIndex_, 0))
{}
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>::~Id_to_index_overlay()
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
if (idToIndex_ != nullptr) delete idToIndex_;
}
}
template <class Underlying_matrix, class Master_matrix>
template <class Boundary_range>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::insert_boundary(const Boundary_range& boundary,
Dimension dim)
{
matrix_.insert_boundary(boundary, dim);
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
idToIndex_->emplace(nextIndex_, nextIndex_);
} else {
if (idToIndex_->size() == nextIndex_) {
idToIndex_->push_back(nextIndex_);
} else {
_id_to_index(nextIndex_) = nextIndex_;
}
}
++nextIndex_;
}
}
template <class Underlying_matrix, class Master_matrix>
template <class Boundary_range>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::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(cellIndex) == idToIndex_->end(),
std::invalid_argument("Id_to_index_overlay::insert_boundary - Index for simplex already chosen!"));
} else {
GUDHI_CHECK(
(idToIndex_->size() <= cellIndex || _id_to_index(cellIndex) == Master_matrix::template get_null_value<Index>()),
std::invalid_argument("Id_to_index_overlay::insert_boundary - Index for simplex already chosen!"));
}
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(cellIndex, nextIndex_);
} else {
if (idToIndex_->size() <= cellIndex) {
idToIndex_->resize(cellIndex + 1, Master_matrix::template get_null_value<Index>());
}
_id_to_index(cellIndex) = nextIndex_;
}
++nextIndex_;
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Column&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_column(ID_index cellID)
{
return matrix_.get_column(_id_to_index(cellID));
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Row&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_row(ID_index rowIndex)
{
return matrix_.get_row(rowIndex);
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::erase_empty_row(ID_index rowIndex)
{
return matrix_.erase_empty_row(rowIndex);
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::remove_maximal_cell(ID_index cellID)
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
std::vector<ID_index> indexToID(nextIndex_);
if constexpr (Master_matrix::Option_list::has_map_column_container) {
for (auto& p : *idToIndex_) {
indexToID[p.second] = p.first;
}
} else {
for (ID_index i = 0; i < idToIndex_->size(); ++i) {
if (_id_to_index(i) != Master_matrix::template get_null_value<Index>()) indexToID[_id_to_index(i)] = i;
}
}
--nextIndex_;
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(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(cellID);
} else {
_id_to_index(cellID) = Master_matrix::template get_null_value<Index>();
}
} else {
matrix_.remove_maximal_cell(cellID);
}
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::remove_maximal_cell(
ID_index cellID, const std::vector<ID_index>& columnsToSwap)
{
static_assert(!Master_matrix::Option_list::is_of_boundary_type,
"'remove_maximal_cell(ID_index,const std::vector<Index>&)' is not available for the chosen options.");
std::vector<Index> translatedIndices;
std::transform(columnsToSwap.cbegin(), columnsToSwap.cend(), std::back_inserter(translatedIndices),
[&](ID_index id) { return _id_to_index(id); });
matrix_.remove_maximal_cell(cellID, translatedIndices);
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::remove_last()
{
if (idToIndex_->empty()) return; //empty matrix
matrix_.remove_last();
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
--nextIndex_;
if constexpr (Master_matrix::Option_list::has_map_column_container) {
auto it = idToIndex_->begin();
while (it->second != nextIndex_) ++it; //should never reach idToIndex_->end()
idToIndex_->erase(it);
} else {
Index id = idToIndex_->size() - 1;
// should always stop before reaching -1
while (_id_to_index(id) == Master_matrix::template get_null_value<Index>()) --id;
GUDHI_CHECK(_id_to_index(id) == nextIndex_,
std::logic_error("Id_to_index_overlay::remove_last - Indexation problem."));
_id_to_index(id) = Master_matrix::template get_null_value<Index>();
}
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Dimension
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_max_dimension() const
{
return matrix_.get_max_dimension();
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_number_of_columns() const
{
return matrix_.get_number_of_columns();
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Dimension
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_column_dimension(ID_index cellID) const
{
return matrix_.get_column_dimension(_id_to_index(cellID));
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::add_to(ID_index sourceCellID, ID_index targetCellID)
{
return matrix_.add_to(_id_to_index(sourceCellID), _id_to_index(targetCellID));
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::multiply_target_and_add_to(
ID_index sourceCellID, const Field_element& coefficient, ID_index targetCellID)
{
return matrix_.multiply_target_and_add_to(_id_to_index(sourceCellID), coefficient, _id_to_index(targetCellID));
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::multiply_source_and_add_to(
const Field_element& coefficient, ID_index sourceCellID, ID_index targetCellID)
{
return matrix_.multiply_source_and_add_to(coefficient, _id_to_index(sourceCellID), _id_to_index(targetCellID));
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::zero_entry(ID_index cellID, ID_index rowIndex)
{
return matrix_.zero_entry(_id_to_index(cellID), rowIndex);
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::zero_column(ID_index cellID)
{
return matrix_.zero_column(_id_to_index(cellID));
}
template <class Underlying_matrix, class Master_matrix>
inline bool Id_to_index_overlay<Underlying_matrix, Master_matrix>::is_zero_entry(ID_index cellID,
ID_index rowIndex) const
{
return matrix_.is_zero_entry(_id_to_index(cellID), rowIndex);
}
template <class Underlying_matrix, class Master_matrix>
inline bool Id_to_index_overlay<Underlying_matrix, Master_matrix>::is_zero_column(ID_index cellID)
{
return matrix_.is_zero_column(_id_to_index(cellID));
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::ID_index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_column_with_pivot(ID_index simplexIndex) const
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
Index pos = matrix_.get_column_with_pivot(simplexIndex);
ID_index i = 0;
while (_id_to_index(i) != pos) ++i;
return i;
} else {
return simplexIndex;
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::ID_index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_pivot(ID_index cellID)
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
return matrix_.get_pivot(_id_to_index(cellID));
} else {
return cellID;
}
}
template <class Underlying_matrix, class Master_matrix>
inline Id_to_index_overlay<Underlying_matrix, Master_matrix>&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::operator=(const Id_to_index_overlay& other)
{
matrix_ = other.matrix_;
if (Master_matrix::Option_list::is_of_boundary_type)
idToIndex_ = other.idToIndex_;
else
idToIndex_ = &matrix_.pivotToColumnIndex_;
nextIndex_ = other.nextIndex_;
return *this;
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::print()
{
return matrix_.print();
}
template <class Underlying_matrix, class Master_matrix>
inline const typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Barcode&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_current_barcode()
{
return matrix_.get_current_barcode();
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::update_representative_cycles()
{
matrix_.update_representative_cycles();
}
template <class Underlying_matrix, class Master_matrix>
inline const std::vector<typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Cycle>&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_representative_cycles()
{
return matrix_.get_representative_cycles();
}
template <class Underlying_matrix, class Master_matrix>
inline const typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Cycle&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::get_representative_cycle(const Bar& bar)
{
return matrix_.get_representative_cycle(bar);
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::swap_columns(ID_index cellID1, ID_index cellID2)
{
matrix_.swap_columns(_id_to_index(cellID1), _id_to_index(cellID2));
std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2));
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::swap_rows(Index rowIndex1, Index rowIndex2)
{
matrix_.swap_rows(rowIndex1, rowIndex2);
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::ID_index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::vine_swap_with_z_eq_1_case(ID_index cellID1, ID_index cellID2)
{
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) {
GUDHI_CHECK(second - first == 1,
std::invalid_argument(
"Id_to_index_overlay::vine_swap_with_z_eq_1_case - The columns to swap are not contiguous."));
bool change = matrix_.vine_swap_with_z_eq_1_case(first);
std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2));
if (change) {
return cellID1;
}
return cellID2;
} else {
return matrix_.vine_swap_with_z_eq_1_case(first, second);
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::ID_index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::vine_swap(ID_index cellID1, ID_index cellID2)
{
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) {
GUDHI_CHECK(second - first == 1,
std::invalid_argument("Id_to_index_overlay::vine_swap - The columns to swap are not contiguous."));
bool change = matrix_.vine_swap(first);
std::swap(idToIndex_->at(cellID1), idToIndex_->at(cellID2));
if (change) {
return cellID1;
}
return cellID2;
} else {
return matrix_.vine_swap(first, second);
}
}
template <class Underlying_matrix, class Master_matrix>
inline void Id_to_index_overlay<Underlying_matrix, Master_matrix>::_initialize_map([[maybe_unused]] unsigned int size)
{
if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
idToIndex_ = new Dictionary(size);
} else {
idToIndex_ = new Dictionary(size, Master_matrix::template get_null_value<Index>());
}
} else {
idToIndex_ = &matrix_.pivotToColumnIndex_;
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Index
Id_to_index_overlay<Underlying_matrix, Master_matrix>::_id_to_index(ID_index id) const
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return idToIndex_->at(id);
} else {
return idToIndex_->operator[](id);
}
}
template <class Underlying_matrix, class Master_matrix>
inline typename Id_to_index_overlay<Underlying_matrix, Master_matrix>::Index&
Id_to_index_overlay<Underlying_matrix, Master_matrix>::_id_to_index(ID_index id)
{
return idToIndex_->operator[](id); //for maps, the entry is created if not existing as needed in the constructors
}
} // namespace persistence_matrix
} // namespace Gudhi
#endif // PM_ID_TO_POS_TRANSLATION_H
Gudhi::persistence_matrix::Id_to_index_overlay
Overlay for non-basic matrices replacing all input and output MatIdx indices of the original methods ...
Definition Id_to_index_overlay.h:42
Gudhi::persistence_matrix::Id_to_index_overlay::Id_to_index_overlay
Id_to_index_overlay(Column_settings *colSettings)
Constructs an empty matrix.
Definition Id_to_index_overlay.h:634
Gudhi::persistence_matrix::Id_to_index_overlay::is_zero_column
bool is_zero_column(ID_index cellID)
Indicates if the column at given index has value zero.
Definition Id_to_index_overlay.h:933
Gudhi::persistence_matrix::Id_to_index_overlay::update_representative_cycles
void update_representative_cycles()
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Id_to_index_overlay.h:991
Gudhi::persistence_matrix::Id_to_index_overlay::remove_maximal_cell
void remove_maximal_cell(ID_index cellID)
Only available for RU and chain matrices and if PersistenceMatrixOptions::has_removable_columns and P...
Definition Id_to_index_overlay.h:804
Gudhi::persistence_matrix::Id_to_index_overlay::swap
friend void swap(Id_to_index_overlay &matrix1, Id_to_index_overlay &matrix2)
Swap operator.
Definition Id_to_index_overlay.h:524
Gudhi::persistence_matrix::Id_to_index_overlay::operator=
Id_to_index_overlay & operator=(const Id_to_index_overlay &other)
Assign operator.
Definition Id_to_index_overlay.h:965
Gudhi::persistence_matrix::Id_to_index_overlay::get_max_dimension
Dimension get_max_dimension() const
Returns the maximal dimension of a cell stored in the matrix. Only available if PersistenceMatrixOpti...
Definition Id_to_index_overlay.h:874
Gudhi::persistence_matrix::Id_to_index_overlay::add_to
void add_to(ID_index sourceCellID, ID_index targetCellID)
Adds column corresponding to sourceCellID onto the column corresponding to targetCellID.
Definition Id_to_index_overlay.h:894
Gudhi::persistence_matrix::Id_to_index_overlay::get_pivot
ID_index get_pivot(ID_index cellID)
Returns the row index of the pivot of the given column.
Definition Id_to_index_overlay.h:954
Gudhi::persistence_matrix::Id_to_index_overlay::Row
typename Master_matrix::Row Row
Definition Id_to_index_overlay.h:55
Gudhi::persistence_matrix::Id_to_index_overlay::remove_last
void remove_last()
Only available if PersistenceMatrixOptions::has_removable_columns is true. Additionally,...
Definition Id_to_index_overlay.h:849
Gudhi::persistence_matrix::Id_to_index_overlay::multiply_target_and_add_to
void multiply_target_and_add_to(ID_index sourceCellID, const Field_element &coefficient, ID_index targetCellID)
Multiplies the target column with the coefficient and then adds the source column to it....
Definition Id_to_index_overlay.h:900
Gudhi::persistence_matrix::Id_to_index_overlay::reset
void reset(Column_settings *colSettings)
Resets the matrix to an empty matrix.
Definition Id_to_index_overlay.h:510
Gudhi::persistence_matrix::Id_to_index_overlay::zero_column
void zero_column(ID_index cellID)
Zeroes the column at the given index. Not available for chain matrices. In general,...
Definition Id_to_index_overlay.h:920
Gudhi::persistence_matrix::Id_to_index_overlay::Index
typename Master_matrix::Index Index
Definition Id_to_index_overlay.h:44
Gudhi::persistence_matrix::Id_to_index_overlay::multiply_source_and_add_to
void multiply_source_and_add_to(const Field_element &coefficient, ID_index sourceCellID, ID_index targetCellID)
Multiplies the source column with the coefficient before adding it to the target column....
Definition Id_to_index_overlay.h:907
Gudhi::persistence_matrix::Id_to_index_overlay::get_current_barcode
const Barcode & get_current_barcode()
Returns the current barcode of the matrix. Available only if PersistenceMatrixOptions::has_column_pai...
Definition Id_to_index_overlay.h:985
Gudhi::persistence_matrix::Id_to_index_overlay::Column
typename Master_matrix::Column Column
Definition Id_to_index_overlay.h:54
Gudhi::persistence_matrix::Id_to_index_overlay::Bar
typename Master_matrix::Bar Bar
Definition Id_to_index_overlay.h:57
Gudhi::persistence_matrix::Id_to_index_overlay::get_column_with_pivot
ID_index get_column_with_pivot(ID_index cellIndex) const
Returns the IDIdx index of the column which has the given row index as pivot. Assumes that the pivot ...
Definition Id_to_index_overlay.h:940
Gudhi::persistence_matrix::Id_to_index_overlay::insert_boundary
void insert_boundary(const Boundary_range &boundary, Dimension dim=Master_matrix::template get_null_value< Dimension >())
Inserts at the end of the matrix a new ordered column corresponding to the given boundary....
Definition Id_to_index_overlay.h:737
Gudhi::persistence_matrix::Id_to_index_overlay::erase_empty_row
void erase_empty_row(ID_index rowIndex)
The effect varies depending on the matrices and the options:
Definition Id_to_index_overlay.h:798
Gudhi::persistence_matrix::Id_to_index_overlay::get_column
Column & get_column(ID_index cellID)
Returns the column at the given IDIdx index. For RU matrices, the returned column is from ....
Definition Id_to_index_overlay.h:785
Gudhi::persistence_matrix::Id_to_index_overlay::Boundary
typename Master_matrix::Boundary Boundary
Definition Id_to_index_overlay.h:53
Gudhi::persistence_matrix::Id_to_index_overlay::get_row
Row & get_row(ID_index rowIndex)
Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row ...
Definition Id_to_index_overlay.h:792
Gudhi::persistence_matrix::Id_to_index_overlay::vine_swap_with_z_eq_1_case
ID_index vine_swap_with_z_eq_1_case(ID_index cellID1, ID_index cellID2)
Only available if PersistenceMatrixOptions::has_vine_update is true. Does the same than vine_swap,...
Definition Id_to_index_overlay.h:1025
Gudhi::persistence_matrix::Id_to_index_overlay::get_representative_cycle
const Cycle & get_representative_cycle(const Bar &bar)
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Id_to_index_overlay.h:1005
Gudhi::persistence_matrix::Id_to_index_overlay::Cycle
typename Master_matrix::Cycle Cycle
Definition Id_to_index_overlay.h:59
Gudhi::persistence_matrix::Id_to_index_overlay::is_zero_entry
bool is_zero_entry(ID_index cellID, ID_index rowIndex) const
Indicates if the entry at given coordinates has value zero.
Definition Id_to_index_overlay.h:926
Gudhi::persistence_matrix::Id_to_index_overlay::Barcode
typename Master_matrix::Barcode Barcode
Definition Id_to_index_overlay.h:58
Gudhi::persistence_matrix::Id_to_index_overlay::Entry_constructor
typename Master_matrix::Entry_constructor Entry_constructor
Definition Id_to_index_overlay.h:60
Gudhi::persistence_matrix::Id_to_index_overlay::Dimension
typename Master_matrix::Dimension Dimension
Definition Id_to_index_overlay.h:47
Gudhi::persistence_matrix::Id_to_index_overlay::~Id_to_index_overlay
~Id_to_index_overlay()
Destructor.
Definition Id_to_index_overlay.h:728
Gudhi::persistence_matrix::Id_to_index_overlay::swap_columns
void swap_columns(ID_index cellID1, ID_index cellID2)
Only available for simple boundary matrices (only storing ) and if PersistenceMatrixOptions::has_colu...
Definition Id_to_index_overlay.h:1011
Gudhi::persistence_matrix::Id_to_index_overlay::Field_operators
typename Master_matrix::Field_operators Field_operators
Field operators class. Necessary only if PersistenceMatrixOptions::is_z2 is false.
Definition Id_to_index_overlay.h:51
Gudhi::persistence_matrix::Id_to_index_overlay::Column_settings
typename Master_matrix::Column_settings Column_settings
Definition Id_to_index_overlay.h:61
Gudhi::persistence_matrix::Id_to_index_overlay::swap_rows
void swap_rows(Index rowIndex1, Index rowIndex2)
Only available for simple boundary matrices (only storing R) and if PersistenceMatrixOptions::has_col...
Definition Id_to_index_overlay.h:1018
Gudhi::persistence_matrix::Id_to_index_overlay::vine_swap
ID_index vine_swap(ID_index cellID1, ID_index cellID2)
Only available if PersistenceMatrixOptions::has_vine_update is true. Does a vine swap between two cel...
Definition Id_to_index_overlay.h:1051
Gudhi::persistence_matrix::Id_to_index_overlay::Pos_index
typename Master_matrix::Pos_index Pos_index
Definition Id_to_index_overlay.h:46
Gudhi::persistence_matrix::Id_to_index_overlay::zero_entry
void zero_entry(ID_index cellID, ID_index rowIndex)
Zeroes the entry at the given coordinates. Not available for chain matrices. In general,...
Definition Id_to_index_overlay.h:914
Gudhi::persistence_matrix::Id_to_index_overlay::get_number_of_columns
Index get_number_of_columns() const
Returns the current number of columns in the matrix.
Definition Id_to_index_overlay.h:881
Gudhi::persistence_matrix::Id_to_index_overlay::get_representative_cycles
const std::vector< Cycle > & get_representative_cycles()
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Id_to_index_overlay.h:998
Gudhi::persistence_matrix::Id_to_index_overlay::get_column_dimension
Dimension get_column_dimension(ID_index cellID) const
Returns the dimension of the given cell. Only available for non-basic matrices.
Definition Id_to_index_overlay.h:888
Gudhi::persistence_matrix::Id_to_index_overlay::ID_index
typename Master_matrix::ID_index ID_index
Definition Id_to_index_overlay.h:45
Gudhi::persistence_matrix::Id_to_index_overlay::Field_element
typename Master_matrix::Element Field_element
Definition Id_to_index_overlay.h:52
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14