Loading...
Searching...
No Matches
Base_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_BASE_MATRIX_H
#define PM_BASE_MATRIX_H
#include <iostream> //print() only
#include <vector>
#include <utility> //std::swap, std::move & std::exchange
namespace Gudhi {
namespace persistence_matrix {
template <class Master_matrix>
class Base_matrix : public Master_matrix::template Base_swap_option<Base_matrix<Master_matrix> >,
protected Master_matrix::Matrix_row_access_option
{
public:
using Index = typename Master_matrix::Index;
using Dimension = typename Master_matrix::Dimension;
using Field_operators = typename Master_matrix::Field_operators;
using Field_element = typename Master_matrix::Element;
using Column = typename Master_matrix::Column;
using Boundary = typename Master_matrix::Boundary;
using Row = typename Master_matrix::Row;
using Entry_constructor = typename Master_matrix::Entry_constructor;
using Column_settings = typename Master_matrix::Column_settings;
Base_matrix(Column_settings* colSettings);
template <class Container = Boundary>
Base_matrix(const std::vector<Container>& columns,
Column_settings* colSettings);
Base_matrix(unsigned int numberOfColumns, Column_settings* colSettings);
Base_matrix(const Base_matrix& matrixToCopy,
Column_settings* colSettings = nullptr);
Base_matrix(Base_matrix&& other) noexcept;
template <class Container = Boundary>
void insert_column(const Container& column);
template <class Container = Boundary>
void insert_column(const Container& column, Index columnIndex);
template <class Boundary_range>
void insert_boundary(const Boundary_range& boundary,
Dimension dim = Master_matrix::template get_null_value<Dimension>());
Column& get_column(Index columnIndex);
Row& get_row(Index rowIndex);
void remove_column(Index columnIndex);
void remove_last();
void erase_empty_row(Index rowIndex);
Index get_number_of_columns() const;
template <class Entry_range_or_column_index>
void add_to(const Entry_range_or_column_index& sourceColumn, Index targetColumnIndex);
template <class Entry_range_or_column_index>
void multiply_target_and_add_to(const Entry_range_or_column_index& sourceColumn,
const Field_element& coefficient,
Index targetColumnIndex);
template <class Entry_range_or_column_index>
void multiply_source_and_add_to(const Field_element& coefficient,
const Entry_range_or_column_index& sourceColumn,
Index targetColumnIndex);
void zero_entry(Index columnIndex, Index rowIndex);
void zero_column(Index columnIndex);
bool is_zero_entry(Index columnIndex, Index rowIndex) const;
bool is_zero_column(Index columnIndex);
void reset(Column_settings* colSettings) {
matrix_.clear();
nextInsertIndex_ = 0;
colSettings_ = colSettings;
}
Base_matrix& operator=(const Base_matrix& other);
friend void swap(Base_matrix& matrix1, Base_matrix& matrix2) {
swap(static_cast<typename Master_matrix::template Base_swap_option<Base_matrix<Master_matrix> >&>(matrix1),
static_cast<typename Master_matrix::template Base_swap_option<Base_matrix<Master_matrix> >&>(matrix2));
matrix1.matrix_.swap(matrix2.matrix_);
std::swap(matrix1.nextInsertIndex_, matrix2.nextInsertIndex_);
std::swap(matrix1.colSettings_, matrix2.colSettings_);
if constexpr (Master_matrix::Option_list::has_row_access) {
swap(static_cast<typename Master_matrix::Matrix_row_access_option&>(matrix1),
static_cast<typename Master_matrix::Matrix_row_access_option&>(matrix2));
}
}
void print(); // for debug
private:
using Swap_opt = typename Master_matrix::template Base_swap_option<Base_matrix<Master_matrix> >;
using RA_opt = typename Master_matrix::Matrix_row_access_option;
using Column_container = typename Master_matrix::Column_container;
using Entry_representative =
typename std::conditional<Master_matrix::Option_list::is_z2,
Index,
std::pair<Index, Field_element>
>::type;
friend Swap_opt; // direct access to matrix_ to avoid row reorder.
Column_container matrix_;
Index nextInsertIndex_;
Column_settings* colSettings_;
template <class Container = Boundary>
void _insert(const Container& column, Index columnIndex, Dimension dim);
void _orderRowsIfNecessary();
const Column& _get_column(Index columnIndex) const;
Column& _get_column(Index columnIndex);
Index _get_real_row_index(Index rowIndex) const;
template <class Container>
void _container_insert(const Container& column, Index pos, Dimension dim);
void _container_insert(const Column& column, [[maybe_unused]] Index pos = 0);
};
template <class Master_matrix>
inline Base_matrix<Master_matrix>::Base_matrix(Column_settings* colSettings)
: Swap_opt(), RA_opt(), nextInsertIndex_(0), colSettings_(colSettings)
{}
template <class Master_matrix>
template <class Container>
inline Base_matrix<Master_matrix>::Base_matrix(const std::vector<Container>& columns,
Column_settings* colSettings)
: Swap_opt(columns.size()),
// not ideal if max row index is much smaller than max column index, does that happen often?
RA_opt(columns.size()),
matrix_(!Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_row_access
? 0
: columns.size()),
nextInsertIndex_(columns.size()),
colSettings_(colSettings)
{
if constexpr (!Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_row_access)
matrix_.reserve(columns.size());
for (Index i = 0; i < columns.size(); i++) {
_container_insert(columns[i], i, columns[i].size() == 0 ? 0 : columns[i].size() - 1);
}
}
template <class Master_matrix>
inline Base_matrix<Master_matrix>::Base_matrix(unsigned int numberOfColumns,
Column_settings* colSettings)
: Swap_opt(numberOfColumns),
RA_opt(numberOfColumns),
matrix_(!Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_row_access
? 0
: numberOfColumns),
nextInsertIndex_(0),
colSettings_(colSettings)
{
if constexpr (!Master_matrix::Option_list::has_map_column_container && Master_matrix::Option_list::has_row_access)
matrix_.reserve(numberOfColumns);
}
template <class Master_matrix>
inline Base_matrix<Master_matrix>::Base_matrix(const Base_matrix& matrixToCopy,
Column_settings* colSettings)
: Swap_opt(static_cast<const Swap_opt&>(matrixToCopy)),
RA_opt(static_cast<const RA_opt&>(matrixToCopy)),
nextInsertIndex_(matrixToCopy.nextInsertIndex_),
colSettings_(colSettings == nullptr ? matrixToCopy.colSettings_ : colSettings)
{
matrix_.reserve(matrixToCopy.matrix_.size());
for (const auto& cont : matrixToCopy.matrix_){
if constexpr (Master_matrix::Option_list::has_map_column_container){
_container_insert(cont.second, cont.first);
} else {
_container_insert(cont);
}
}
}
template <class Master_matrix>
inline Base_matrix<Master_matrix>::Base_matrix(Base_matrix&& other) noexcept
: Swap_opt(std::move(static_cast<Swap_opt&>(other))),
RA_opt(std::move(static_cast<RA_opt&>(other))),
matrix_(std::move(other.matrix_)),
nextInsertIndex_(std::exchange(other.nextInsertIndex_, 0)),
colSettings_(std::exchange(other.colSettings_, nullptr))
{}
template <class Master_matrix>
template <class Container>
inline void Base_matrix<Master_matrix>::insert_column(const Container& column)
{
//TODO: dim not actually stored right now, so either get rid of it or store it again
_insert(column, nextInsertIndex_, column.size() == 0 ? 0 : column.size() - 1);
++nextInsertIndex_;
}
template <class Master_matrix>
template <class Container>
inline void Base_matrix<Master_matrix>::insert_column(const Container& column, Index columnIndex)
{
static_assert(!Master_matrix::Option_list::has_row_access,
"Columns have to be inserted at the end of the matrix when row access is enabled.");
if (columnIndex >= nextInsertIndex_) nextInsertIndex_ = columnIndex + 1;
//TODO: dim not actually stored right now, so either get rid of it or store it again
_insert(column, columnIndex, column.size() == 0 ? 0 : column.size() - 1);
}
template <class Master_matrix>
template <class Boundary_range>
inline void Base_matrix<Master_matrix>::insert_boundary(const Boundary_range& boundary, Dimension dim)
{
if (dim == Master_matrix::template get_null_value<Dimension>()) dim = boundary.size() == 0 ? 0 : boundary.size() - 1;
//TODO: dim not actually stored right now, so either get rid of it or store it again
_insert(boundary, nextInsertIndex_++, dim);
}
template <class Master_matrix>
inline typename Base_matrix<Master_matrix>::Column& Base_matrix<Master_matrix>::get_column(Index columnIndex)
{
_orderRowsIfNecessary();
return _get_column(columnIndex);
}
template <class Master_matrix>
inline typename Base_matrix<Master_matrix>::Row& Base_matrix<Master_matrix>::get_row(Index rowIndex)
{
static_assert(Master_matrix::Option_list::has_row_access, "Row access has to be enabled for this method.");
_orderRowsIfNecessary();
return RA_opt::get_row(rowIndex);
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::remove_column(Index columnIndex)
{
static_assert(Master_matrix::Option_list::has_map_column_container,
"'remove_column' is not implemented for the chosen options.");
// assumes that eventual "holes" left at unused indices are considered as empty columns.
if (columnIndex == nextInsertIndex_ - 1) --nextInsertIndex_;
matrix_.erase(columnIndex);
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::remove_last()
{
if (nextInsertIndex_ == 0) return; //empty matrix
--nextInsertIndex_; // assumes that eventual "holes" left at unused indices are considered as empty columns.
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.erase(nextInsertIndex_);
} else {
if constexpr (Master_matrix::Option_list::has_row_access) {
GUDHI_CHECK(nextInsertIndex_ == matrix_.size() - 1,
std::logic_error("Base_matrix::remove_last - Indexation problem."));
matrix_.pop_back();
} else {
matrix_[nextInsertIndex_].clear();
}
}
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::erase_empty_row(Index rowIndex)
{
if constexpr (Master_matrix::Option_list::has_row_access && Master_matrix::Option_list::has_removable_rows) {
RA_opt::erase_empty_row(_get_real_row_index(rowIndex));
}
if constexpr ((Master_matrix::Option_list::has_column_and_row_swaps || Master_matrix::Option_list::has_vine_update) &&
Master_matrix::Option_list::has_map_column_container) {
auto it = Swap_opt::indexToRow_.find(rowIndex);
Swap_opt::rowToIndex_.erase(it->second);
Swap_opt::indexToRow_.erase(it);
}
}
template <class Master_matrix>
inline typename Base_matrix<Master_matrix>::Index Base_matrix<Master_matrix>::get_number_of_columns() const
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return matrix_.size();
} else {
return nextInsertIndex_; // matrix could have been resized much bigger while insert
}
}
template <class Master_matrix>
template <class Entry_range_or_column_index>
inline void Base_matrix<Master_matrix>::add_to(const Entry_range_or_column_index& sourceColumn,
Index targetColumnIndex)
{
if constexpr (std::is_integral_v<Entry_range_or_column_index>) {
_get_column(targetColumnIndex) += _get_column(sourceColumn);
} else {
_get_column(targetColumnIndex) += sourceColumn;
}
}
template <class Master_matrix>
template <class Entry_range_or_column_index>
inline void Base_matrix<Master_matrix>::multiply_target_and_add_to(const Entry_range_or_column_index& sourceColumn,
const Field_element& coefficient,
Index targetColumnIndex)
{
if constexpr (std::is_integral_v<Entry_range_or_column_index>) {
_get_column(targetColumnIndex).multiply_target_and_add(coefficient, _get_column(sourceColumn));
} else {
_get_column(targetColumnIndex).multiply_target_and_add(coefficient, sourceColumn);
}
}
template <class Master_matrix>
template <class Entry_range_or_column_index>
inline void Base_matrix<Master_matrix>::multiply_source_and_add_to(const Field_element& coefficient,
const Entry_range_or_column_index& sourceColumn,
Index targetColumnIndex)
{
if constexpr (std::is_integral_v<Entry_range_or_column_index>) {
_get_column(targetColumnIndex).multiply_source_and_add(_get_column(sourceColumn), coefficient);
} else {
_get_column(targetColumnIndex).multiply_source_and_add(sourceColumn, coefficient);
}
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::zero_entry(Index columnIndex, Index rowIndex)
{
_get_column(columnIndex).clear(_get_real_row_index(rowIndex));
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::zero_column(Index columnIndex) {
_get_column(columnIndex).clear();
}
template <class Master_matrix>
inline bool Base_matrix<Master_matrix>::is_zero_entry(Index columnIndex, Index rowIndex) const
{
return !(_get_column(columnIndex).is_non_zero(_get_real_row_index(rowIndex)));
}
template <class Master_matrix>
inline bool Base_matrix<Master_matrix>::is_zero_column(Index columnIndex)
{
return _get_column(columnIndex).is_empty();
}
template <class Master_matrix>
inline Base_matrix<Master_matrix>& Base_matrix<Master_matrix>::operator=(const Base_matrix& other)
{
Swap_opt::operator=(other);
RA_opt::operator=(other);
matrix_.clear();
nextInsertIndex_ = other.nextInsertIndex_;
colSettings_ = other.colSettings_;
matrix_.reserve(other.matrix_.size());
for (const auto& cont : other.matrix_){
if constexpr (Master_matrix::Option_list::has_map_column_container){
_container_insert(cont.second, cont.first);
} else {
_container_insert(cont);
}
}
return *this;
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::print()
{
_orderRowsIfNecessary();
std::cout << "Base_matrix:\n";
for (Index i = 0; i < nextInsertIndex_; ++i) {
const Column& col = matrix_[i];
for (const auto& e : col.get_content(nextInsertIndex_)) {
if (e == 0u)
std::cout << "- ";
else
std::cout << e << " ";
}
std::cout << "\n";
}
std::cout << "\n";
if constexpr (Master_matrix::Option_list::has_row_access) {
std::cout << "Row Matrix:\n";
for (Index i = 0; i < nextInsertIndex_; ++i) {
const auto& row = (*RA_opt::rows_)[i];
for (const auto& entry : row) {
std::cout << entry.get_column_index() << " ";
}
std::cout << "(" << i << ")\n";
}
std::cout << "\n";
}
}
template <class Master_matrix>
template <class Container>
inline void Base_matrix<Master_matrix>::_insert(const Container& column, Index columnIndex, Dimension dim)
{
_orderRowsIfNecessary();
//resize of containers when necessary:
Index pivot = 0;
if (column.begin() != column.end()) {
//first, compute pivot of `column`
if constexpr (Master_matrix::Option_list::is_z2) {
pivot = *std::prev(column.end());
} else {
pivot = std::prev(column.end())->first;
}
//row container
if constexpr (Master_matrix::Option_list::has_row_access && !Master_matrix::Option_list::has_removable_rows)
if (RA_opt::rows_->size() <= pivot) RA_opt::rows_->resize(pivot + 1);
}
//row swap map containers
if constexpr (Master_matrix::Option_list::has_map_column_container) {
if constexpr (Master_matrix::Option_list::has_column_and_row_swaps || Master_matrix::Option_list::has_vine_update) {
for (auto id : column) {
Index idx;
if constexpr (Master_matrix::Option_list::is_z2) {
idx = id;
} else {
idx = id.first;
}
Swap_opt::indexToRow_[idx] = idx;
Swap_opt::rowToIndex_[idx] = idx;
}
}
} else {
if constexpr (Master_matrix::Option_list::has_column_and_row_swaps || Master_matrix::Option_list::has_vine_update) {
Index size = Swap_opt::indexToRow_.size();
if (size <= pivot) {
for (Index i = size; i <= pivot; i++) {
Swap_opt::indexToRow_.push_back(i);
Swap_opt::rowToIndex_.push_back(i);
}
}
}
//column container
if constexpr (!Master_matrix::Option_list::has_row_access) {
if (matrix_.size() <= columnIndex) {
matrix_.resize(columnIndex + 1);
}
}
}
_container_insert(column, columnIndex, dim);
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::_orderRowsIfNecessary()
{
if constexpr (Master_matrix::Option_list::has_column_and_row_swaps || Master_matrix::Option_list::has_vine_update) {
if (Swap_opt::rowSwapped_) Swap_opt::_orderRows();
}
}
template <class Master_matrix>
inline const typename Base_matrix<Master_matrix>::Column& Base_matrix<Master_matrix>::_get_column(
Index columnIndex) const
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return matrix_.at(columnIndex);
} else {
return matrix_[columnIndex];
}
}
template <class Master_matrix>
inline typename Base_matrix<Master_matrix>::Column& Base_matrix<Master_matrix>::_get_column(Index columnIndex)
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return matrix_.at(columnIndex);
} else {
return matrix_[columnIndex];
}
}
template <class Master_matrix>
inline typename Base_matrix<Master_matrix>::Index Base_matrix<Master_matrix>::_get_real_row_index(Index rowIndex) const
{
if constexpr (Master_matrix::Option_list::has_column_and_row_swaps || Master_matrix::Option_list::has_vine_update) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
return Swap_opt::indexToRow_.at(rowIndex);
} else {
return Swap_opt::indexToRow_[rowIndex];
}
} else {
return rowIndex;
}
}
template <class Master_matrix>
template <class Container>
inline void Base_matrix<Master_matrix>::_container_insert(const Container& column, Index pos, Dimension dim){
if constexpr (Master_matrix::Option_list::has_map_column_container) {
if constexpr (Master_matrix::Option_list::has_row_access) {
matrix_.try_emplace(pos, Column(pos, column, dim, RA_opt::rows_, colSettings_));
} else {
matrix_.try_emplace(pos, Column(column, dim, colSettings_));
}
} else {
if constexpr (Master_matrix::Option_list::has_row_access) {
matrix_.emplace_back(pos, column, dim, RA_opt::rows_, colSettings_);
} else {
matrix_[pos] = Column(column, dim, colSettings_);
}
}
}
template <class Master_matrix>
inline void Base_matrix<Master_matrix>::_container_insert(const Column& column, [[maybe_unused]] Index pos){
if constexpr (Master_matrix::Option_list::has_map_column_container) {
if constexpr (Master_matrix::Option_list::has_row_access) {
matrix_.try_emplace(pos, Column(column, column.get_column_index(), RA_opt::rows_, colSettings_));
} else {
matrix_.try_emplace(pos, Column(column, colSettings_));
}
} else {
if constexpr (Master_matrix::Option_list::has_row_access) {
matrix_.emplace_back(column, column.get_column_index(), RA_opt::rows_, colSettings_);
} else {
matrix_.emplace_back(column, colSettings_);
}
}
}
} // namespace persistence_matrix
} // namespace Gudhi
#endif // PM_BASE_MATRIX_H
Gudhi::persistence_matrix::Base_matrix
A basic matrix structure allowing to easily manipulate and access entire columns and rows,...
Definition Base_matrix.h:39
Gudhi::persistence_matrix::Base_matrix::get_column
Column & get_column(Index columnIndex)
Returns the column at the given MatIdx index. The type of the column depends on the chosen options,...
Definition Base_matrix.h:448
Gudhi::persistence_matrix::Base_matrix::is_zero_entry
bool is_zero_entry(Index columnIndex, Index rowIndex) const
Indicates if the entry at given coordinates has value zero.
Definition Base_matrix.h:568
Gudhi::persistence_matrix::Base_matrix::add_to
void add_to(const Entry_range_or_column_index &sourceColumn, Index targetColumnIndex)
Adds column represented by sourceColumn onto the column at targetColumnIndex in the matrix.
Definition Base_matrix.h:520
Gudhi::persistence_matrix::Base_matrix::swap
friend void swap(Base_matrix &matrix1, Base_matrix &matrix2)
Swap operator.
Definition Base_matrix.h:307
Gudhi::persistence_matrix::Base_matrix::Row
typename Master_matrix::Row Row
Definition Base_matrix.h:50
Gudhi::persistence_matrix::Base_matrix::get_number_of_columns
Index get_number_of_columns() const
Returns the current number of columns in the matrix.
Definition Base_matrix.h:509
Gudhi::persistence_matrix::Base_matrix::zero_column
void zero_column(Index columnIndex)
Zeroes the column at the given index.
Definition Base_matrix.h:563
Gudhi::persistence_matrix::Base_matrix::is_zero_column
bool is_zero_column(Index columnIndex)
Indicates if the column at given index has value zero.
Definition Base_matrix.h:574
Gudhi::persistence_matrix::Base_matrix::Field_element
typename Master_matrix::Element Field_element
Definition Base_matrix.h:47
Gudhi::persistence_matrix::Base_matrix::get_row
Row & get_row(Index rowIndex)
Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row ...
Definition Base_matrix.h:455
Gudhi::persistence_matrix::Base_matrix::insert_boundary
void insert_boundary(const Boundary_range &boundary, Dimension dim=Master_matrix::template get_null_value< Dimension >())
Same as insert_column, only for interface purposes. The given dimension is ignored and not stored.
Definition Base_matrix.h:440
Gudhi::persistence_matrix::Base_matrix::reset
void reset(Column_settings *colSettings)
Resets the matrix to an empty matrix.
Definition Base_matrix.h:294
Gudhi::persistence_matrix::Base_matrix::operator=
Base_matrix & operator=(const Base_matrix &other)
Assign operator.
Definition Base_matrix.h:580
Gudhi::persistence_matrix::Base_matrix::Field_operators
typename Master_matrix::Field_operators Field_operators
Field operators class. Necessary only if PersistenceMatrixOptions::is_z2 is false.
Definition Base_matrix.h:46
Gudhi::persistence_matrix::Base_matrix::Column
typename Master_matrix::Column Column
Definition Base_matrix.h:48
Gudhi::persistence_matrix::Base_matrix::remove_last
void remove_last()
Removes the last column from the matrix. The last column is at index , where:
Definition Base_matrix.h:476
Gudhi::persistence_matrix::Base_matrix::Column_settings
typename Master_matrix::Column_settings Column_settings
Definition Base_matrix.h:53
Gudhi::persistence_matrix::Base_matrix::Dimension
typename Master_matrix::Dimension Dimension
Definition Base_matrix.h:42
Gudhi::persistence_matrix::Base_matrix::Index
typename Master_matrix::Index Index
Definition Base_matrix.h:41
Gudhi::persistence_matrix::Base_matrix::Base_matrix
Base_matrix(Column_settings *colSettings)
Constructs an empty matrix.
Definition Base_matrix.h:350
Gudhi::persistence_matrix::Base_matrix::Entry_constructor
typename Master_matrix::Entry_constructor Entry_constructor
Definition Base_matrix.h:52
Gudhi::persistence_matrix::Base_matrix::remove_column
void remove_column(Index columnIndex)
Only available if PersistenceMatrixOptions::has_map_column_container is true. Otherwise,...
Definition Base_matrix.h:464
Gudhi::persistence_matrix::Base_matrix::Boundary
typename Master_matrix::Boundary Boundary
Definition Base_matrix.h:49
Gudhi::persistence_matrix::Base_matrix::multiply_source_and_add_to
void multiply_source_and_add_to(const Field_element &coefficient, const Entry_range_or_column_index &sourceColumn, Index targetColumnIndex)
Multiplies the source column with the coefficient before adding it to the target column....
Definition Base_matrix.h:545
Gudhi::persistence_matrix::Base_matrix::zero_entry
void zero_entry(Index columnIndex, Index rowIndex)
Zeroes the entry at the given coordinates.
Definition Base_matrix.h:557
Gudhi::persistence_matrix::Base_matrix::insert_column
void insert_column(const Container &column)
Inserts a new ordered column at the end of the matrix by copying the given range of Matrix::Entry_rep...
Definition Base_matrix.h:419
Gudhi::persistence_matrix::Base_matrix::erase_empty_row
void erase_empty_row(Index rowIndex)
If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true...
Definition Base_matrix.h:495
Gudhi::persistence_matrix::Base_matrix::multiply_target_and_add_to
void multiply_target_and_add_to(const Entry_range_or_column_index &sourceColumn, const Field_element &coefficient, Index targetColumnIndex)
Multiplies the target column with the coefficient and then adds the source column to it....
Definition Base_matrix.h:532
Gudhi::persistence_matrix::Matrix::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)
Multiplies the target column with the coefficient and then adds the source column to it....
Definition Matrix.h:1777
Gudhi::persistence_matrix::Matrix::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)
Multiplies the source column with the coefficient before adding it to the target column....
Definition Matrix.h:1807
Gudhi::persistence_matrix::Matrix::Row
typename std::conditional< PersistenceMatrixOptions::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
Type of the rows stored in the matrix. Is either an intrusive list of Matrix_entry (not ordered) if P...
Definition Matrix.h:267
Gudhi::persistence_matrix::Matrix::zero_column
void zero_column(Index columnIndex)
Zeroes the column at the given index. Not available for chain matrices and for base matrices with col...
Definition Matrix.h:1858
Gudhi::persistence_matrix::Matrix::get_column
Returned_column & get_column(Index columnIndex)
Returns the column at the given MatIdx index. For RU matrices, is equivalent to get_column(columnInde...
Definition Matrix.h:1609
Gudhi::persistence_matrix::Matrix::is_zero_entry
bool is_zero_entry(Index columnIndex, ID_index rowIndex)
Indicates if the entry at given coordinates has value zero.
Definition Matrix.h:1880
Gudhi::persistence_matrix::Matrix::Index
typename PersistenceMatrixOptions::Index Index
Definition Matrix.h:147
Gudhi::persistence_matrix::Matrix::zero_entry
void zero_entry(Index columnIndex, ID_index rowIndex)
Zeroes the entry at the given coordinates. Not available for chain matrices and for base matrices wit...
Definition Matrix.h:1836
Gudhi::persistence_matrix::Matrix::Column
typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::HEAP, Matrix_heap_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::LIST, Matrix_list_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::SET, Matrix_set_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::UNORDERED_SET, Matrix_unordered_set_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::VECTOR, Matrix_vector_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::INTRUSIVE_LIST, Matrix_intrusive_list_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::NAIVE_VECTOR, Matrix_naive_vector_column, typename std::conditional< PersistenceMatrixOptions::column_type==Column_types::SMALL_VECTOR, Matrix_small_vector_column, Matrix_intrusive_set_column >::type >::type >::type >::type >::type >::type >::type >::type Column
Type of the columns stored in the matrix. The type depends on the value of PersistenceMatrixOptions::...
Definition Matrix.h:336
Gudhi::persistence_matrix::Matrix::insert_boundary
Insertion_return insert_boundary(const Boundary_range &boundary, Dimension dim=Matrix::get_null_value< Dimension >())
Inserts at the end of the matrix a new ordered column corresponding to the given boundary....
Definition Matrix.h:1572
Gudhi::persistence_matrix::Matrix::get_row
Returned_row & get_row(ID_index rowIndex)
Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row ...
Definition Matrix.h:1637
Gudhi::persistence_matrix::Matrix::remove_last
void remove_last()
Removes the last inserted column/cell from the matrix. If the matrix is non basic,...
Definition Matrix.h:1718
Gudhi::persistence_matrix::Matrix::is_zero_column
bool is_zero_column(Index columnIndex)
Indicates if the column at given index has value zero.
Definition Matrix.h:1899
Gudhi::persistence_matrix::Matrix::erase_empty_row
void erase_empty_row(ID_index rowIndex)
The effect varies depending on the matrices and the options:
Definition Matrix.h:1680
Gudhi::persistence_matrix::Matrix::remove_column
void remove_column(Index columnIndex)
Only available for base matrices without column compression and if PersistenceMatrixOptions::has_map_...
Definition Matrix.h:1670
Gudhi::persistence_matrix::Matrix::operator=
Matrix & operator=(Matrix other)
Assign operator.
Definition Matrix.h:1939
Gudhi::persistence_matrix::Matrix::get_number_of_columns
Index get_number_of_columns() const
Returns the current number of columns in the matrix.
Definition Matrix.h:1741
Gudhi::persistence_matrix::Matrix::insert_column
void insert_column(const Container &column)
Inserts a new ordered column at the end of the matrix by copying the given range of Entry_representat...
Definition Matrix.h:1538
Gudhi::persistence_matrix::Matrix::add_to
std::enable_if_t< std::is_integral_v< Integer_index > > add_to(Integer_index sourceColumnIndex, Integer_index targetColumnIndex)
Adds column at sourceColumnIndex onto the column at targetColumnIndex in the matrix....
Definition Matrix.h:1757
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14