Loading...
Searching...
No Matches
RU_matrix.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_RU_MATRIX_H
#define PM_RU_MATRIX_H
#include <vector>
#include <utility> //std::swap, std::move & std::exchange
#include <iostream> //print() only
namespace Gudhi {
namespace persistence_matrix {
template <class Master_matrix>
class RU_matrix : public Master_matrix::RU_pairing_option,
public Master_matrix::RU_vine_swap_option,
public Master_matrix::RU_representative_cycles_option
{
public:
using Field_operators = typename Master_matrix::Field_operators;
using Field_element = typename Master_matrix::Element;
using Column = typename Master_matrix::Column;
using Row = typename Master_matrix::Row;
using Entry_constructor = typename Master_matrix::Entry_constructor;
using Column_settings = typename Master_matrix::Column_settings;
using Boundary = typename Master_matrix::Boundary;
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;
RU_matrix(Column_settings* colSettings);
template <class Boundary_range = Boundary>
RU_matrix(const std::vector<Boundary_range>& orderedBoundaries, Column_settings* colSettings);
RU_matrix(unsigned int numberOfColumns, Column_settings* colSettings);
RU_matrix(const RU_matrix& matrixToCopy, Column_settings* colSettings = nullptr);
RU_matrix(RU_matrix&& other) noexcept;
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(Index columnIndex, bool inR = true);
Row& get_row(Index rowIndex, bool inR = true);
void erase_empty_row(Index rowIndex);
void remove_maximal_cell(Index columnIndex);
void remove_last();
Dimension get_max_dimension() const;
Index get_number_of_columns() const;
Dimension get_column_dimension(Index columnIndex) const;
void add_to(Index sourceColumnIndex, Index targetColumnIndex);
void multiply_target_and_add_to(Index sourceColumnIndex, const Field_element& coefficient, Index targetColumnIndex);
void multiply_source_and_add_to(const Field_element& coefficient, Index sourceColumnIndex, Index targetColumnIndex);
void zero_entry(Index columnIndex, Index rowIndex, bool inR = true);
void zero_column(Index columnIndex, bool inR = true);
bool is_zero_entry(Index columnIndex, Index rowIndex, bool inR = true) const;
bool is_zero_column(Index columnIndex, bool inR = true);
Index get_column_with_pivot(Index cellIndex) const;
Index get_pivot(Index columnIndex);
void reset(Column_settings* colSettings) {
reducedMatrixR_.reset(colSettings);
mirrorMatrixU_.reset(colSettings);
pivotToColumnIndex_.clear();
nextEventIndex_ = 0;
if constexpr (!Master_matrix::Option_list::is_z2) {
operators_ = &(colSettings->operators);
}
}
RU_matrix& operator=(const RU_matrix& other);
friend void swap(RU_matrix& matrix1, RU_matrix& matrix2) {
swap(static_cast<typename Master_matrix::RU_pairing_option&>(matrix1),
static_cast<typename Master_matrix::RU_pairing_option&>(matrix2));
swap(static_cast<typename Master_matrix::RU_vine_swap_option&>(matrix1),
static_cast<typename Master_matrix::RU_vine_swap_option&>(matrix2));
swap(static_cast<typename Master_matrix::RU_representative_cycles_option&>(matrix1),
static_cast<typename Master_matrix::RU_representative_cycles_option&>(matrix2));
swap(matrix1.reducedMatrixR_, matrix2.reducedMatrixR_);
swap(matrix1.mirrorMatrixU_, matrix2.mirrorMatrixU_);
matrix1.pivotToColumnIndex_.swap(matrix2.pivotToColumnIndex_);
std::swap(matrix1.nextEventIndex_, matrix2.nextEventIndex_);
std::swap(matrix1.operators_, matrix2.operators_);
}
void print(); // for debug
private:
using Swap_opt = typename Master_matrix::RU_vine_swap_option;
using Pair_opt = typename Master_matrix::RU_pairing_option;
using Rep_opt = typename Master_matrix::RU_representative_cycles_option;
using Dictionary = typename Master_matrix::template Dictionary<Index>;
using Barcode = typename Master_matrix::Barcode;
using Bar_dictionary = typename Master_matrix::Bar_dictionary;
using R_matrix = typename Master_matrix::Master_boundary_matrix;
using U_matrix = typename Master_matrix::Master_base_matrix;
friend Rep_opt; // direct access to the two matrices
friend Swap_opt; // direct access to the two matrices
R_matrix reducedMatrixR_;
// TODO: make U not accessible by default and add option to enable access? Inaccessible, it
// needs less options and we could avoid some ifs.
U_matrix mirrorMatrixU_;
Dictionary pivotToColumnIndex_;
Pos_index nextEventIndex_;
Field_operators* operators_;
void _insert_boundary(Index currentIndex);
void _initialize_U();
void _reduce();
void _reduce_last_column(Index lastIndex);
void _reduce_column(Index target, Index eventIndex);
void _reduce_column_by(Index target, Index source);
void _update_barcode(ID_index birthPivot, Pos_index death);
void _add_bar(Dimension dim, Pos_index birth);
void _remove_last_in_barcode(Pos_index eventIndex);
constexpr Bar_dictionary& _indexToBar();
};
template <class Master_matrix>
inline RU_matrix<Master_matrix>::RU_matrix(Column_settings* colSettings)
: Pair_opt(),
Swap_opt(),
Rep_opt(),
reducedMatrixR_(colSettings),
mirrorMatrixU_(colSettings),
nextEventIndex_(0),
operators_(nullptr)
{
if constexpr (!Master_matrix::Option_list::is_z2) {
operators_ = &(colSettings->operators);
}
}
template <class Master_matrix>
template <class Boundary_range>
inline RU_matrix<Master_matrix>::RU_matrix(const std::vector<Boundary_range>& orderedBoundaries,
Column_settings* colSettings)
: Pair_opt(),
Swap_opt(),
Rep_opt(),
reducedMatrixR_(orderedBoundaries, colSettings),
mirrorMatrixU_(orderedBoundaries.size(), colSettings),
nextEventIndex_(orderedBoundaries.size()),
operators_(nullptr)
{
if constexpr (!Master_matrix::Option_list::is_z2) {
operators_ = &(colSettings->operators);
}
if constexpr (Master_matrix::Option_list::has_map_column_container) {
pivotToColumnIndex_.reserve(orderedBoundaries.size());
} else {
pivotToColumnIndex_.resize(orderedBoundaries.size(), Master_matrix::template get_null_value<Index>());
}
_initialize_U();
_reduce();
}
template <class Master_matrix>
inline RU_matrix<Master_matrix>::RU_matrix(unsigned int numberOfColumns, Column_settings* colSettings)
: Pair_opt(),
Swap_opt(),
Rep_opt(),
reducedMatrixR_(numberOfColumns, colSettings),
mirrorMatrixU_(numberOfColumns, colSettings),
nextEventIndex_(0),
operators_(nullptr)
{
if constexpr (!Master_matrix::Option_list::is_z2) {
operators_ = &(colSettings->operators);
}
if constexpr (Master_matrix::Option_list::has_map_column_container) {
pivotToColumnIndex_.reserve(numberOfColumns);
} else {
pivotToColumnIndex_.resize(numberOfColumns, Master_matrix::template get_null_value<Index>());
}
if constexpr (Master_matrix::Option_list::has_column_pairings) {
_indexToBar().reserve(numberOfColumns);
}
if constexpr (Master_matrix::Option_list::has_vine_update) {
Swap_opt::_positionToRowIdx().reserve(numberOfColumns);
}
}
template <class Master_matrix>
inline RU_matrix<Master_matrix>::RU_matrix(const RU_matrix& matrixToCopy, Column_settings* colSettings)
: Pair_opt(static_cast<const Pair_opt&>(matrixToCopy)),
Swap_opt(static_cast<const Swap_opt&>(matrixToCopy)),
Rep_opt(static_cast<const Rep_opt&>(matrixToCopy)),
reducedMatrixR_(matrixToCopy.reducedMatrixR_, colSettings),
mirrorMatrixU_(matrixToCopy.mirrorMatrixU_, colSettings),
pivotToColumnIndex_(matrixToCopy.pivotToColumnIndex_),
nextEventIndex_(matrixToCopy.nextEventIndex_),
operators_(colSettings == nullptr ? matrixToCopy.operators_ : nullptr)
{
if constexpr (!Master_matrix::Option_list::is_z2) {
if (colSettings != nullptr) operators_ = &(colSettings->operators);
}
}
template <class Master_matrix>
inline RU_matrix<Master_matrix>::RU_matrix(RU_matrix&& other) noexcept
: Pair_opt(std::move(static_cast<Pair_opt&>(other))),
Swap_opt(std::move(static_cast<Swap_opt&>(other))),
Rep_opt(std::move(static_cast<Rep_opt&>(other))),
reducedMatrixR_(std::move(other.reducedMatrixR_)),
mirrorMatrixU_(std::move(other.mirrorMatrixU_)),
pivotToColumnIndex_(std::move(other.pivotToColumnIndex_)),
nextEventIndex_(std::exchange(other.nextEventIndex_, 0)),
operators_(std::exchange(other.operators_, nullptr))
{}
template <class Master_matrix>
template <class Boundary_range>
inline void RU_matrix<Master_matrix>::insert_boundary(const Boundary_range& boundary, Dimension dim)
{
_insert_boundary(reducedMatrixR_.insert_boundary(boundary, dim));
}
template <class Master_matrix>
template <class Boundary_range>
inline void RU_matrix<Master_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 (cellIndex != nextEventIndex_) {
Pair_opt::idToPosition_.emplace(cellIndex, nextEventIndex_);
if constexpr (Master_matrix::Option_list::has_removable_columns) {
Pair_opt::PIDM::map_.emplace(nextEventIndex_, cellIndex);
}
}
}
if constexpr (Master_matrix::Option_list::has_vine_update) {
if (cellIndex != nextEventIndex_) {
Swap_opt::_positionToRowIdx().emplace(nextEventIndex_, cellIndex);
if constexpr (Master_matrix::Option_list::has_column_pairings) {
Swap_opt::template RU_pairing<Master_matrix>::idToPosition_.emplace(cellIndex, nextEventIndex_);
}
}
}
_insert_boundary(reducedMatrixR_.insert_boundary(cellIndex, boundary, dim));
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Column& RU_matrix<Master_matrix>::get_column(Index columnIndex, bool inR)
{
if (inR) {
return reducedMatrixR_.get_column(columnIndex);
}
return mirrorMatrixU_.get_column(columnIndex);
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Row& RU_matrix<Master_matrix>::get_row(Index rowIndex, bool inR)
{
static_assert(Master_matrix::Option_list::has_row_access, "'get_row' is not implemented for the chosen options.");
if (inR) {
return reducedMatrixR_.get_row(rowIndex);
}
return mirrorMatrixU_.get_row(rowIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::erase_empty_row(Index rowIndex)
{
reducedMatrixR_.erase_empty_row(rowIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::remove_maximal_cell(Index columnIndex)
{
static_assert(Master_matrix::Option_list::has_removable_columns && Master_matrix::Option_list::has_vine_update,
"'remove_maximal_cell' is not implemented for the chosen options.");
// TODO: is there an easy test to verify maximality even without row access?
for (Index curr = columnIndex; curr < nextEventIndex_ - 1; ++curr) {
Swap_opt::vine_swap(curr);
}
remove_last();
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::remove_last()
{
static_assert(Master_matrix::Option_list::has_removable_columns,
"'remove_last' is not implemented for the chosen options.");
if (nextEventIndex_ == 0) return; // empty matrix
--nextEventIndex_;
// assumes PosIdx == MatIdx for boundary matrices.
_remove_last_in_barcode(nextEventIndex_);
mirrorMatrixU_.remove_last();
if constexpr (Master_matrix::Option_list::has_map_column_container) {
pivotToColumnIndex_.erase(reducedMatrixR_.remove_last());
} else {
ID_index lastPivot = reducedMatrixR_.remove_last();
if (lastPivot != Master_matrix::template get_null_value<ID_index>())
pivotToColumnIndex_[lastPivot] = Master_matrix::template get_null_value<Index>();
}
// if has_vine_update and has_column_pairings are both true,
// then the element is already removed in _remove_last_in_barcode
if constexpr (Master_matrix::Option_list::has_vine_update && !Master_matrix::Option_list::has_column_pairings) {
Swap_opt::_positionToRowIdx().erase(nextEventIndex_);
}
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Dimension RU_matrix<Master_matrix>::get_max_dimension() const
{
return reducedMatrixR_.get_max_dimension();
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Index RU_matrix<Master_matrix>::get_number_of_columns() const
{
return reducedMatrixR_.get_number_of_columns();
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Dimension RU_matrix<Master_matrix>::get_column_dimension(
Index columnIndex) const
{
return reducedMatrixR_.get_column_dimension(columnIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::add_to(Index sourceColumnIndex, Index targetColumnIndex)
{
reducedMatrixR_.add_to(sourceColumnIndex, targetColumnIndex);
// U transposed to avoid row operations
if constexpr (Master_matrix::Option_list::is_z2)
mirrorMatrixU_.add_to(targetColumnIndex, sourceColumnIndex);
else
mirrorMatrixU_.add_to(sourceColumnIndex, targetColumnIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::multiply_target_and_add_to(Index sourceColumnIndex,
const Field_element& coefficient,
Index targetColumnIndex)
{
static_assert(!Master_matrix::Option_list::is_z2,
"Multiplication with something else than the identity is not allowed with Z2 coefficients.");
reducedMatrixR_.multiply_target_and_add_to(sourceColumnIndex, coefficient, targetColumnIndex);
mirrorMatrixU_.multiply_target_and_add_to(sourceColumnIndex, coefficient, targetColumnIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::multiply_source_and_add_to(const Field_element& coefficient,
Index sourceColumnIndex,
Index targetColumnIndex)
{
static_assert(!Master_matrix::Option_list::is_z2,
"Multiplication with something else than the identity is not allowed with Z2 coefficients.");
reducedMatrixR_.multiply_source_and_add_to(coefficient, sourceColumnIndex, targetColumnIndex);
mirrorMatrixU_.multiply_source_and_add_to(coefficient, sourceColumnIndex, targetColumnIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::zero_entry(Index columnIndex, Index rowIndex, bool inR)
{
if (inR) {
return reducedMatrixR_.zero_entry(columnIndex, rowIndex);
}
return mirrorMatrixU_.zero_entry(columnIndex, rowIndex);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::zero_column(Index columnIndex, bool inR)
{
if (inR) {
return reducedMatrixR_.zero_column(columnIndex);
}
return mirrorMatrixU_.zero_column(columnIndex);
}
template <class Master_matrix>
inline bool RU_matrix<Master_matrix>::is_zero_entry(Index columnIndex, Index rowIndex, bool inR) const
{
if (inR) {
return reducedMatrixR_.is_zero_entry(columnIndex, rowIndex);
}
return mirrorMatrixU_.is_zero_entry(columnIndex, rowIndex);
}
template <class Master_matrix>
inline bool RU_matrix<Master_matrix>::is_zero_column(Index columnIndex, bool inR)
{
if (inR) {
return reducedMatrixR_.is_zero_column(columnIndex);
}
return mirrorMatrixU_.is_zero_column(columnIndex);
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Index RU_matrix<Master_matrix>::get_column_with_pivot(Index cellIndex) const
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return pivotToColumnIndex_.at(cellIndex);
} else {
return pivotToColumnIndex_[cellIndex];
}
}
template <class Master_matrix>
inline typename RU_matrix<Master_matrix>::Index RU_matrix<Master_matrix>::get_pivot(Index columnIndex)
{
return reducedMatrixR_.get_column(columnIndex).get_pivot();
}
template <class Master_matrix>
inline RU_matrix<Master_matrix>& RU_matrix<Master_matrix>::operator=(const RU_matrix& other)
{
Swap_opt::operator=(other);
Pair_opt::operator=(other);
Rep_opt::operator=(other);
reducedMatrixR_ = other.reducedMatrixR_;
mirrorMatrixU_ = other.mirrorMatrixU_;
pivotToColumnIndex_ = other.pivotToColumnIndex_;
nextEventIndex_ = other.nextEventIndex_;
operators_ = other.operators_;
return *this;
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::print()
{
std::cout << "R_matrix:\n";
reducedMatrixR_.print();
std::cout << "U_matrix:\n";
mirrorMatrixU_.print();
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_insert_boundary(Index currentIndex)
{
if constexpr (Master_matrix::Option_list::is_z2) {
mirrorMatrixU_.insert_column({currentIndex});
} else {
mirrorMatrixU_.insert_column({{currentIndex, 1}});
}
if constexpr (!Master_matrix::Option_list::has_map_column_container) {
ID_index pivot = reducedMatrixR_.get_column(currentIndex).get_pivot();
if (pivot != Master_matrix::template get_null_value<ID_index>() && pivotToColumnIndex_.size() <= pivot)
pivotToColumnIndex_.resize((pivot + 1) * 2, Master_matrix::template get_null_value<Index>());
}
_reduce_last_column(currentIndex);
++nextEventIndex_;
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_initialize_U()
{
typename std::conditional<Master_matrix::Option_list::is_z2, Index, std::pair<Index, Field_element> >::type id;
if constexpr (!Master_matrix::Option_list::is_z2) id.second = 1;
for (ID_index i = 0; i < reducedMatrixR_.get_number_of_columns(); i++) {
if constexpr (Master_matrix::Option_list::is_z2)
id = i;
else
id.first = i;
mirrorMatrixU_.insert_column({id});
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_reduce()
{
if constexpr (Master_matrix::Option_list::has_column_pairings) {
_indexToBar().reserve(reducedMatrixR_.get_number_of_columns());
}
for (Index i = 0; i < reducedMatrixR_.get_number_of_columns(); i++) {
if (!(reducedMatrixR_.is_zero_column(i))) {
_reduce_column(i, i);
} else {
_add_bar(get_column_dimension(i), i);
}
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_reduce_last_column(Index lastIndex)
{
if (reducedMatrixR_.get_column(lastIndex).is_empty()) {
_add_bar(get_column_dimension(lastIndex), nextEventIndex_);
return;
}
_reduce_column(lastIndex, nextEventIndex_);
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_reduce_column(Index target, Index eventIndex)
{
auto get_column_with_pivot_ = [&](ID_index pivot) -> Index {
if (pivot == Master_matrix::template get_null_value<ID_index>())
return Master_matrix::template get_null_value<Index>();
if constexpr (Master_matrix::Option_list::has_map_column_container) {
auto it = pivotToColumnIndex_.find(pivot);
if (it == pivotToColumnIndex_.end())
return Master_matrix::template get_null_value<Index>();
else
return it->second;
} else {
return pivotToColumnIndex_[pivot];
}
};
Column& curr = reducedMatrixR_.get_column(target);
ID_index pivot = curr.get_pivot();
Index currIndex = get_column_with_pivot_(pivot);
while (pivot != Master_matrix::template get_null_value<ID_index>() &&
currIndex != Master_matrix::template get_null_value<Index>()) {
_reduce_column_by(target, currIndex);
pivot = curr.get_pivot();
currIndex = get_column_with_pivot_(pivot);
}
if (pivot != Master_matrix::template get_null_value<ID_index>()) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
pivotToColumnIndex_.try_emplace(pivot, target);
} else {
pivotToColumnIndex_[pivot] = target;
}
_update_barcode(pivot, eventIndex);
} else {
_add_bar(get_column_dimension(target), eventIndex);
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_reduce_column_by(Index target, Index source)
{
Column& curr = reducedMatrixR_.get_column(target);
if constexpr (Master_matrix::Option_list::is_z2) {
curr += reducedMatrixR_.get_column(source);
// to avoid having to do line operations during vineyards, U is transposed
// TODO: explain this somewhere in the documentation...
mirrorMatrixU_.get_column(source).push_back(*mirrorMatrixU_.get_column(target).begin());
} else {
Column& toadd = reducedMatrixR_.get_column(source);
Field_element coef = toadd.get_pivot_value();
coef = operators_->get_inverse(coef);
operators_->multiply_inplace(coef, operators_->get_characteristic() - curr.get_pivot_value());
curr.multiply_source_and_add(toadd, coef);
// but no transposition for Zp, careful if there will be vineyard or rep cycles in Zp one day
// TODO: explain this somewhere in the documentation...
mirrorMatrixU_.multiply_source_and_add_to(coef, source, target);
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_update_barcode(ID_index birthPivot, Pos_index death)
{
if constexpr (Master_matrix::Option_list::has_column_pairings) {
if constexpr (Master_matrix::Option_list::has_vine_update)
Swap_opt::template RU_pairing<Master_matrix>::_update_barcode(birthPivot, death);
else
Pair_opt::_update_barcode(birthPivot, death);
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_add_bar(Dimension dim, Pos_index birth)
{
if constexpr (Master_matrix::Option_list::has_column_pairings) {
if constexpr (Master_matrix::Option_list::has_vine_update)
Swap_opt::template RU_pairing<Master_matrix>::_add_bar(dim, birth);
else
Pair_opt::_add_bar(dim, birth);
}
}
template <class Master_matrix>
inline void RU_matrix<Master_matrix>::_remove_last_in_barcode(Pos_index eventIndex)
{
if constexpr (Master_matrix::Option_list::has_column_pairings) {
if constexpr (Master_matrix::Option_list::has_vine_update)
Swap_opt::template RU_pairing<Master_matrix>::_remove_last(eventIndex);
else
Pair_opt::_remove_last(eventIndex);
}
}
template <class Master_matrix>
inline constexpr typename RU_matrix<Master_matrix>::Bar_dictionary& RU_matrix<Master_matrix>::_indexToBar()
{
if constexpr (Master_matrix::Option_list::has_vine_update)
return Swap_opt::template RU_pairing<Master_matrix>::indexToBar_;
else
return Pair_opt::indexToBar_;
}
} // namespace persistence_matrix
} // namespace Gudhi
#endif // PM_RU_MATRIX_H
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::multiply_target_and_add_to
std::enable_if_t< std::is_integral_v< Integer_index > > multiply_target_and_add_to(Integer_index sourceColumnIndex, int coefficient, Integer_index targetColumnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_column_dimension
Dimension get_column_dimension(Index columnIndex) const
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_column_with_pivot
Index get_column_with_pivot(ID_index cellIndex) const
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::multiply_source_and_add_to
std::enable_if_t< std::is_integral_v< Integer_index > > multiply_source_and_add_to(int coefficient, Integer_index sourceColumnIndex, Integer_index targetColumnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Row
typename std::conditional< RU_rep_cycles_options::has_intrusive_rows, boost::intrusive::list< Matrix_entry, boost::intrusive::constant_time_size< false >, boost::intrusive::base_hook< Base_hook_matrix_row > >, std::set< Matrix_entry, RowEntryComp > >::type Row
Definition Matrix.h:267
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::zero_column
void zero_column(Index columnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_pivot
ID_index get_pivot(Index columnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_column
Returned_column & get_column(Index columnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Dimension
typename RU_rep_cycles_options::Dimension Dimension
Definition Matrix.h:150
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::is_zero_entry
bool is_zero_entry(Index columnIndex, ID_index rowIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Index
typename RU_rep_cycles_options::Index Index
Definition Matrix.h:147
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::zero_entry
void zero_entry(Index columnIndex, ID_index rowIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Column
typename std::conditional< RU_rep_cycles_options::column_type==Column_types::HEAP, Matrix_heap_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::LIST, Matrix_list_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::SET, Matrix_set_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::UNORDERED_SET, Matrix_unordered_set_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::VECTOR, Matrix_vector_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::INTRUSIVE_LIST, Matrix_intrusive_list_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::NAIVE_VECTOR, Matrix_naive_vector_column, typename std::conditional< RU_rep_cycles_options::column_type==Column_types::SMALL_VECTOR, Matrix_small_vector_column, Matrix_intrusive_set_column >::type >::type >::type >::type >::type >::type >::type >::type Column
Definition Matrix.h:336
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::insert_boundary
Insertion_return insert_boundary(const Boundary_range &boundary, Dimension dim=Matrix::get_null_value< Dimension >())
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_row
Returned_row & get_row(ID_index rowIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::remove_last
void remove_last()
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::is_zero_column
bool is_zero_column(Index columnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::erase_empty_row
void erase_empty_row(ID_index rowIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::operator=
Matrix & operator=(Matrix other)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_number_of_columns
Index get_number_of_columns() const
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::get_max_dimension
Dimension get_max_dimension() const
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::add_to
std::enable_if_t< std::is_integral_v< Integer_index > > add_to(Integer_index sourceColumnIndex, Integer_index targetColumnIndex)
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::remove_maximal_cell
void remove_maximal_cell(Index columnIndex)
Gudhi::persistence_matrix::RU_matrix
Matrix structure to store the ordered boundary matrix of a filtered complex in order to compute its ...
Definition RU_matrix.h:42
Gudhi::persistence_matrix::RU_matrix::RU_matrix
RU_matrix(const std::vector< Boundary_range > &orderedBoundaries, Column_settings *colSettings)
Constructs a new matrix from the given ranges of Matrix::Entry_representative. Each range corresponds...
Definition RU_matrix.h:439
Gudhi::persistence_matrix::RU_matrix::remove_maximal_cell
void remove_maximal_cell(Index columnIndex)
Only available if PersistenceMatrixOptions::has_removable_columns and PersistenceMatrixOptions::has_v...
Definition RU_matrix.h:578
Gudhi::persistence_matrix::RU_matrix::is_zero_column
bool is_zero_column(Index columnIndex, bool inR=true)
Indicates if the column at given index has value zero in if inR is true or in if inR is false.
Definition RU_matrix.h:700
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::ID_index
typename Matrix< PersistenceMatrixOptions >::ID_index ID_index
Definition RU_matrix.h:57
Gudhi::persistence_matrix::RU_matrix::add_to
void add_to(Index sourceColumnIndex, Index targetColumnIndex)
Adds column at sourceColumnIndex onto the column at targetColumnIndex in the matrix.
Definition RU_matrix.h:640
Gudhi::persistence_matrix::RU_matrix::is_zero_entry
bool is_zero_entry(Index columnIndex, Index rowIndex, bool inR=true) const
Indicates if the entry at given coordinates has value zero in if inR is true or in if inR is false.
Definition RU_matrix.h:691
Gudhi::persistence_matrix::RU_matrix::remove_last
void remove_last()
Only available if PersistenceMatrixOptions::has_removable_columns is true. Removes the last cell in t...
Definition RU_matrix.h:593
Gudhi::persistence_matrix::RU_matrix::insert_boundary
void insert_boundary(ID_index cellIndex, const Boundary_range &boundary, Dimension dim=Master_matrix::template get_null_value< Dimension >())
It does the same as the other version, but allows the boundary cells to be identified without restric...
Definition RU_matrix.h:527
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Field_element
typename Matrix< PersistenceMatrixOptions >::Element Field_element
Definition RU_matrix.h:48
Gudhi::persistence_matrix::RU_matrix::get_column_with_pivot
Index get_column_with_pivot(Index cellIndex) const
Returns the MatIdx index of the column which has the given row index as pivot in ....
Definition RU_matrix.h:709
Gudhi::persistence_matrix::RU_matrix::RU_matrix
RU_matrix(RU_matrix &&other) noexcept
Move constructor.
Definition RU_matrix.h:507
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Pos_index
typename Matrix< PersistenceMatrixOptions >::Pos_index Pos_index
Definition RU_matrix.h:58
Gudhi::persistence_matrix::RU_matrix::multiply_source_and_add_to
void multiply_source_and_add_to(const Field_element &coefficient, Index sourceColumnIndex, Index targetColumnIndex)
Multiplies the source column with the coefficient before adding it to the target column....
Definition RU_matrix.h:662
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Entry_constructor
typename Matrix< PersistenceMatrixOptions >::Entry_constructor Entry_constructor
Definition RU_matrix.h:52
Gudhi::persistence_matrix::RU_matrix::RU_matrix
RU_matrix(Column_settings *colSettings)
Constructs an empty matrix.
Definition RU_matrix.h:423
Gudhi::persistence_matrix::RU_matrix::erase_empty_row
void erase_empty_row(Index rowIndex)
If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true...
Definition RU_matrix.h:572
Gudhi::persistence_matrix::RU_matrix::zero_column
void zero_column(Index columnIndex, bool inR=true)
Zeroes the column at the given index in if inR is true or in if inR is false. Should be used with c...
Definition RU_matrix.h:682
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Row
typename Matrix< PersistenceMatrixOptions >::Row Row
Definition RU_matrix.h:50
Gudhi::persistence_matrix::RU_matrix::swap
friend void swap(RU_matrix &matrix1, RU_matrix &matrix2)
Swap operator.
Definition RU_matrix.h:371
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Field_operators
typename Matrix< PersistenceMatrixOptions >::Field_operators Field_operators
Definition RU_matrix.h:47
Gudhi::persistence_matrix::RU_matrix::get_max_dimension
Dimension get_max_dimension() const
Returns the maximal dimension of a cell stored in the matrix. Only available if PersistenceMatrixOpti...
Definition RU_matrix.h:621
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Column
typename Matrix< PersistenceMatrixOptions >::Column Column
Definition RU_matrix.h:49
Gudhi::persistence_matrix::RU_matrix::zero_entry
void zero_entry(Index columnIndex, Index rowIndex, bool inR=true)
Zeroes the entry at the given coordinates in if inR is true or in if inR is false....
Definition RU_matrix.h:673
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Index
typename Matrix< PersistenceMatrixOptions >::Index Index
Definition RU_matrix.h:56
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Boundary
typename Matrix< PersistenceMatrixOptions >::Boundary Boundary
Definition RU_matrix.h:55
Gudhi::persistence_matrix::RU_matrix::get_pivot
Index get_pivot(Index columnIndex)
Returns the row index of the pivot of the given column in .
Definition RU_matrix.h:719
Gudhi::persistence_matrix::RU_matrix::RU_matrix
RU_matrix(unsigned int numberOfColumns, Column_settings *colSettings)
Constructs a new empty matrix and reserves space for the given number of columns.
Definition RU_matrix.h:464
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Dimension
typename Matrix< PersistenceMatrixOptions >::Dimension Dimension
Definition RU_matrix.h:59
Gudhi::persistence_matrix::RU_matrix::RU_matrix
RU_matrix(const RU_matrix &matrixToCopy, Column_settings *colSettings=nullptr)
Copy constructor. If colSettings is not a null pointer, its value is kept instead of the one in the c...
Definition RU_matrix.h:491
Gudhi::persistence_matrix::RU_matrix::reset
void reset(Column_settings *colSettings)
Resets the matrix to an empty matrix.
Definition RU_matrix.h:354
Gudhi::persistence_matrix::RU_matrix::get_column_dimension
Dimension get_column_dimension(Index columnIndex) const
Returns the dimension of the given column.
Definition RU_matrix.h:633
Gudhi::persistence_matrix::RU_matrix::get_number_of_columns
Index get_number_of_columns() const
Returns the current number of columns in the matrix.
Definition RU_matrix.h:627
Gudhi::persistence_matrix::RU_matrix::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 RU_matrix.h:520
Gudhi::persistence_matrix::RU_matrix::get_column
Column & get_column(Index columnIndex, bool inR=true)
Returns the column at the given MatIdx index in if inR is true and in if inR is false....
Definition RU_matrix.h:552
Gudhi::persistence_matrix::RU_matrix::multiply_target_and_add_to
void multiply_target_and_add_to(Index sourceColumnIndex, const Field_element &coefficient, Index targetColumnIndex)
Multiplies the target column with the coefficient and then adds the source column to it....
Definition RU_matrix.h:651
Gudhi::persistence_matrix::RU_matrix::operator=
RU_matrix & operator=(const RU_matrix &other)
Assign operator.
Definition RU_matrix.h:725
Gudhi::persistence_matrix::RU_matrix< Matrix< PersistenceMatrixOptions > >::Column_settings
typename Matrix< PersistenceMatrixOptions >::Column_settings Column_settings
Definition RU_matrix.h:53
Gudhi::persistence_matrix::RU_matrix::get_row
Row & get_row(Index rowIndex, bool inR=true)
Returns the row at the given row index in if inR is true and in if inR is false....
Definition RU_matrix.h:561
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14