Loading...
Searching...
No Matches
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 MASTER_MATRIX_H
#define MASTER_MATRIX_H
#include <type_traits>
#include <vector>
#include <unordered_map>
#include <map>
#include <initializer_list>
#include <boost/intrusive/list.hpp>
#include <gudhi/Debug_utils.h>
#include <gudhi/persistence_matrix_options.h>
#include <gudhi/persistence_interval.h>
#include <gudhi/Fields/Z2_field_operators.h>
#include <gudhi/Persistence_matrix/Id_to_index_overlay.h>
#include <gudhi/Persistence_matrix/Position_to_index_overlay.h>
#include <gudhi/Persistence_matrix/matrix_dimension_holders.h>
#include <gudhi/Persistence_matrix/matrix_row_access.h>
#include <gudhi/Persistence_matrix/base_swap.h>
#include <gudhi/Persistence_matrix/base_pairing.h>
#include <gudhi/Persistence_matrix/ru_pairing.h>
#include <gudhi/Persistence_matrix/ru_vine_swap.h>
#include <gudhi/Persistence_matrix/ru_rep_cycles.h>
#include <gudhi/Persistence_matrix/chain_pairing.h>
#include <gudhi/Persistence_matrix/chain_vine_swap.h>
#include <gudhi/Persistence_matrix/chain_rep_cycles.h>
#include <gudhi/Persistence_matrix/Base_matrix.h>
#include <gudhi/Persistence_matrix/Base_matrix_with_column_compression.h>
#include <gudhi/Persistence_matrix/Boundary_matrix.h>
#include <gudhi/Persistence_matrix/RU_matrix.h>
#include <gudhi/Persistence_matrix/Chain_matrix.h>
#include <gudhi/Persistence_matrix/allocators/entry_constructors.h>
#include <gudhi/Persistence_matrix/columns/entry_types.h>
#include <gudhi/Persistence_matrix/columns/row_access.h>
#include <gudhi/Persistence_matrix/columns/column_dimension_holder.h>
#include <gudhi/Persistence_matrix/columns/chain_column_extra_properties.h>
#include <gudhi/Persistence_matrix/columns/intrusive_list_column.h>
#include <gudhi/Persistence_matrix/columns/intrusive_set_column.h>
#include <gudhi/Persistence_matrix/columns/list_column.h>
#include <gudhi/Persistence_matrix/columns/set_column.h>
#include <gudhi/Persistence_matrix/columns/unordered_set_column.h>
#include <gudhi/Persistence_matrix/columns/vector_column.h>
#include <gudhi/Persistence_matrix/columns/naive_vector_column.h>
#include <gudhi/Persistence_matrix/columns/heap_column.h>
namespace Gudhi {
namespace persistence_matrix {
template <class PersistenceMatrixOptions = Default_options<> >
class Matrix {
public:
using Option_list = PersistenceMatrixOptions; //to make it accessible from the other classes
using Index = typename PersistenceMatrixOptions::Index;
using ID_index = typename PersistenceMatrixOptions::Index;
using Pos_index = typename PersistenceMatrixOptions::Index;
using Dimension = typename PersistenceMatrixOptions::Dimension;
using Field_operators =
typename std::conditional<PersistenceMatrixOptions::is_z2,
Gudhi::persistence_fields::Z2_field_operators,
typename PersistenceMatrixOptions::Field_coeff_operators
>::type;
using Element = typename Field_operators::Element;
using Characteristic = typename Field_operators::Characteristic;
template <typename T>
static constexpr const T get_null_value() {
return -1;
}
using Bar = Persistence_interval<Dimension, Pos_index>;
//tags for boost to associate a row and a column to a same entry
struct Matrix_row_tag;
struct Matrix_column_tag;
using Base_hook_matrix_row =
boost::intrusive::list_base_hook<boost::intrusive::tag<Matrix_row_tag>,
boost::intrusive::link_mode<boost::intrusive::auto_unlink> >;
using Base_hook_matrix_list_column =
boost::intrusive::list_base_hook<boost::intrusive::tag<Matrix_column_tag>,
boost::intrusive::link_mode<boost::intrusive::safe_link> >;
using Base_hook_matrix_set_column =
boost::intrusive::set_base_hook<boost::intrusive::tag<Matrix_column_tag>,
boost::intrusive::link_mode<boost::intrusive::safe_link> >;
//Two dummies are necessary to avoid double inheritance as an entry can inherit both a row and a column hook.
struct Dummy_row_hook {};
struct Dummy_column_hook {};
using Row_hook = typename std::conditional<PersistenceMatrixOptions::has_row_access &&
PersistenceMatrixOptions::has_intrusive_rows,
Base_hook_matrix_row,
Dummy_row_hook
>::type;
using Column_hook = typename std::conditional<
PersistenceMatrixOptions::column_type == Column_types::INTRUSIVE_LIST,
Base_hook_matrix_list_column,
typename std::conditional<PersistenceMatrixOptions::column_type == Column_types::INTRUSIVE_SET,
Base_hook_matrix_set_column,
Dummy_column_hook
>::type
>::type;
//Option to store the column index within the entry (additionally to the row index). Necessary only with row access.
using Entry_column_index_option =
typename std::conditional<PersistenceMatrixOptions::has_row_access,
Entry_column_index<Index>,
Dummy_entry_column_index_mixin
>::type;
//Option to store the value of the entry.
//Unnecessary for values in Z_2 as there are always 1 (0-valued entries are never stored).
using Entry_field_element_option =
typename std::conditional<PersistenceMatrixOptions::is_z2,
Dummy_entry_field_element_mixin,
Entry_field_element<Element>
>::type;
using Matrix_entry = Entry<Matrix<PersistenceMatrixOptions> >;
inline static New_entry_constructor<Matrix_entry> defaultEntryConstructor;
using Entry_constructor = Pool_entry_constructor<Matrix_entry>;
using Entry_representative = typename std::conditional<PersistenceMatrixOptions::is_z2,
ID_index,
std::pair<ID_index, Element>
>::type;
struct RowEntryComp {
bool operator()(const Matrix_entry& c1, const Matrix_entry& c2) const {
return c1.get_column_index() < c2.get_column_index();
}
};
using 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;
using Row_container =
typename std::conditional<PersistenceMatrixOptions::has_removable_rows,
std::map<ID_index, Row>,
std::vector<Row>
>::type;
//Row access at column level
using Row_access_option =
typename std::conditional<PersistenceMatrixOptions::has_row_access,
Row_access<Matrix<PersistenceMatrixOptions> >,
Dummy_row_access
>::type;
//Row access at matrix level
using Matrix_row_access_option =
typename std::conditional<PersistenceMatrixOptions::has_row_access,
Matrix_row_access<Row,
Row_container,
PersistenceMatrixOptions::has_removable_rows,
ID_index>,
Dummy_matrix_row_access
>::type;
template <typename value_type>
using Dictionary =
typename std::conditional<PersistenceMatrixOptions::has_map_column_container,
std::unordered_map<unsigned int, value_type>,
std::vector<value_type>
>::type;
static const bool isNonBasic = PersistenceMatrixOptions::has_column_pairings ||
PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::can_retrieve_representative_cycles;
using Column_dimension_option =
typename std::conditional<isNonBasic,
Column_dimension_holder<Matrix<PersistenceMatrixOptions> >,
Dummy_dimension_holder
>::type;
//Extra information needed for a column when the matrix is a @ref chainmatrix "chain matrix".
using Chain_column_option =
typename std::conditional<isNonBasic && !PersistenceMatrixOptions::is_of_boundary_type,
Chain_column_extra_properties<Matrix<PersistenceMatrixOptions> >,
Dummy_chain_properties
>::type;
using Matrix_heap_column = Heap_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_list_column = List_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_vector_column = Vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_naive_vector_column = Naive_std_vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_small_vector_column = Naive_small_vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_set_column = Set_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_unordered_set_column = Unordered_set_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_intrusive_list_column = Intrusive_list_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_intrusive_set_column = Intrusive_set_column<Matrix<PersistenceMatrixOptions> >;
using 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;
struct Column_z2_settings{
Column_z2_settings() : entryConstructor() {}
Column_z2_settings([[maybe_unused]] Characteristic characteristic) : entryConstructor() {}
Column_z2_settings(const Column_z2_settings& toCopy) : entryConstructor() {}
Entry_constructor entryConstructor; //will be replaced by more specific allocators depending on the column type.
};
struct Column_zp_settings {
Column_zp_settings() : operators(), entryConstructor() {}
//purposely triggers operators() instead of operators(characteristic) as the "dummy" values for the different
//operators can be different from -1.
Column_zp_settings(Characteristic characteristic) : operators(), entryConstructor() {
if (characteristic != get_null_value<Characteristic>()) operators.set_characteristic(characteristic);
}
Column_zp_settings(const Column_zp_settings& toCopy)
: operators(toCopy.operators.get_characteristic()), entryConstructor() {}
Field_operators operators;
Entry_constructor entryConstructor; //will be replaced by more specific allocators depending on the column type.
};
// struct Column_z2_with_rows_settings {
// Column_z2_with_rows_settings() : entryConstructor(), rows(nullptr) {}
// Column_z2_with_rows_settings([[maybe_unused]] Characteristic characteristic)
// : entryConstructor(), rows(nullptr) {}
// Entry_constructor entryConstructor;
// Row_container* rows;
// };
// struct Column_zp_with_rows_settings {
// Column_zp_with_rows_settings() : operators(), entryConstructor(), rows(nullptr) {}
// Column_zp_with_rows_settings(Characteristic characteristic)
// : operators(characteristic), entryConstructor(), rows(nullptr) {}
// Field_operators operators;
// Entry_constructor entryConstructor;
// Row_container* rows;
// };
//To prepare a more flexible use of the column types later (custom allocators depending on the column type etc.)
using Column_settings = typename std::conditional<
PersistenceMatrixOptions::is_z2,
Column_z2_settings,
Column_zp_settings
>::type;
// using Column_settings = typename std::conditional<
// PersistenceMatrixOptions::is_z2,
// typename std::conditional<PersistenceMatrixOptions::has_row_access,
// Column_z2_with_rows_settings,
// Column_z2_settings
// >::type,
// typename std::conditional<PersistenceMatrixOptions::has_row_access,
// Column_zp_with_rows_settings,
// Column_zp_settings
// >::type
// >::type;
using Column_container =
typename std::conditional<PersistenceMatrixOptions::has_map_column_container,
std::unordered_map<Index, Column>,
std::vector<Column>
>::type;
static const bool hasFixedBarcode = Option_list::is_of_boundary_type && !PersistenceMatrixOptions::has_vine_update;
using Barcode = typename std::conditional<hasFixedBarcode,
std::vector<Bar>,
typename std::conditional<PersistenceMatrixOptions::has_removable_columns,
std::list<Bar>,
std::vector<Bar>
>::type
>::type;
using Bar_dictionary =
typename std::conditional<hasFixedBarcode,
typename std::conditional<PersistenceMatrixOptions::can_retrieve_representative_cycles,
std::vector<Index>, //RU
std::unordered_map<Pos_index, Index> //boundary
>::type,
typename std::conditional<PersistenceMatrixOptions::has_removable_columns,
std::unordered_map<Pos_index, typename Barcode::iterator>,
std::vector<Index>
>::type
>::type;
//default type for boundaries to permit list initialization directly in function parameters
using Boundary = typename std::conditional<PersistenceMatrixOptions::is_z2,
std::initializer_list<ID_index>,
std::initializer_list<std::pair<ID_index, Element> >
>::type;
//i.e. is simple @ref boundarymatrix "boundary matrix". Also, only needed because of the reduction algorithm.
//TODO: remove the necessity and recalculate when needed or keep it like that?
static const bool maxDimensionIsNeeded =
PersistenceMatrixOptions::has_column_pairings && PersistenceMatrixOptions::is_of_boundary_type &&
!PersistenceMatrixOptions::has_vine_update && !PersistenceMatrixOptions::can_retrieve_representative_cycles;
using Matrix_dimension_option = typename std::conditional<
PersistenceMatrixOptions::has_matrix_maximal_dimension_access || maxDimensionIsNeeded,
typename std::conditional<PersistenceMatrixOptions::has_removable_columns,
Matrix_all_dimension_holder<Dimension>,
Matrix_max_dimension_holder<Dimension>
>::type,
Dummy_matrix_dimension_holder
>::type;
using Master_base_matrix =
typename std::conditional<PersistenceMatrixOptions::has_column_compression,
Base_matrix_with_column_compression<Matrix<PersistenceMatrixOptions> >,
Base_matrix<Matrix<PersistenceMatrixOptions> >
>::type;
using Master_boundary_matrix = Boundary_matrix<Matrix<PersistenceMatrixOptions> >;
using Master_RU_matrix = RU_matrix<Matrix<PersistenceMatrixOptions> >;
using Master_chain_matrix = Chain_matrix<Matrix<PersistenceMatrixOptions> >;
template <class Base>
using Base_swap_option =
typename std::conditional<PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::has_column_and_row_swaps,
Base_swap<Matrix<PersistenceMatrixOptions>, Base>,
Dummy_base_swap
>::type;
using Base_pairing_option =
typename std::conditional<PersistenceMatrixOptions::has_column_pairings &&
!PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::can_retrieve_representative_cycles,
Base_pairing<Matrix<PersistenceMatrixOptions> >,
Dummy_base_pairing
>::type;
using RU_pairing_option =
typename std::conditional<PersistenceMatrixOptions::has_column_pairings &&
!PersistenceMatrixOptions::has_vine_update,
RU_pairing<Matrix<PersistenceMatrixOptions> >,
Dummy_ru_pairing
>::type;
using RU_vine_swap_option =
typename std::conditional<PersistenceMatrixOptions::has_vine_update,
RU_vine_swap<Matrix<PersistenceMatrixOptions> >,
Dummy_ru_vine_swap
>::type;
using RU_representative_cycles_option =
typename std::conditional<PersistenceMatrixOptions::can_retrieve_representative_cycles,
RU_representative_cycles<Matrix<PersistenceMatrixOptions> >,
Dummy_ru_representative_cycles
>::type;
using Chain_pairing_option =
typename std::conditional<PersistenceMatrixOptions::has_column_pairings &&
!PersistenceMatrixOptions::has_vine_update,
Chain_pairing<Matrix<PersistenceMatrixOptions> >,
Dummy_chain_pairing
>::type;
using Chain_vine_swap_option = typename std::conditional<PersistenceMatrixOptions::has_vine_update,
Chain_vine_swap<Matrix<PersistenceMatrixOptions> >,
Dummy_chain_vine_swap
>::type;
using Chain_representative_cycles_option =
typename std::conditional<PersistenceMatrixOptions::can_retrieve_representative_cycles,
Chain_representative_cycles<Matrix<PersistenceMatrixOptions> >,
Dummy_chain_representative_cycles
>::type;
using Cycle = std::vector<ID_index>; //TODO: add coefficients
//Return types to factorize the corresponding methods
//The returned column is `const` if the matrix uses column compression
using Returned_column =
typename std::conditional<!isNonBasic && PersistenceMatrixOptions::has_column_compression,
const Column,
Column
>::type;
//The returned row is `const` if the matrix uses column compression
using Returned_row =
typename std::conditional<!isNonBasic && PersistenceMatrixOptions::has_column_compression,
const Row,
Row
>::type;
//If the matrix is a chain matrix, the insertion method returns the pivots of its unpaired columns used to reduce the
//inserted boundary. Otherwise, void.
using Insertion_return =
typename std::conditional<PersistenceMatrixOptions::is_of_boundary_type || !isNonBasic ||
PersistenceMatrixOptions::column_indexation_type ==
Column_indexation_types::POSITION,
void,
std::vector<Entry_representative>
>::type;
Matrix();
template <class Container = Boundary>
Matrix(const std::vector<Container>& columns, Characteristic characteristic = 11);
Matrix(unsigned int numberOfColumns, Characteristic characteristic = Matrix::get_null_value<Characteristic>());
Matrix(const std::function<bool(Pos_index,Pos_index)>& birthComparator,
const std::function<bool(Pos_index,Pos_index)>& deathComparator);
template <class Boundary_range = Boundary>
Matrix(const std::vector<Boundary_range>& orderedBoundaries,
const std::function<bool(Pos_index,Pos_index)>& birthComparator,
const std::function<bool(Pos_index,Pos_index)>& deathComparator,
Characteristic characteristic = 11);
Matrix(unsigned int numberOfColumns,
const std::function<bool(Pos_index,Pos_index)>& birthComparator,
const std::function<bool(Pos_index,Pos_index)>& deathComparator,
Characteristic characteristic = Matrix::get_null_value<Characteristic>());
Matrix(const Matrix& matrixToCopy);
Matrix(Matrix&& other) noexcept;
~Matrix();
//TODO: compatibility with multi fields:
// - set_characteristic(Characteristic min, Characteristic max)
// - readapt reduction?
void set_characteristic(Characteristic characteristic);
// (TODO: if there is no row access and the column type corresponds to the internal column type of the matrix,
// moving the column instead of copying it should be possible. Is it worth implementing it?)
template <class Container>
void insert_column(const Container& column);
template <class Container>
void insert_column(const Container& column, Index columnIndex);
//TODO: for simple boundary matrices, add an index pointing to the first column inserted after the last call of
//get_current_barcode to enable several calls to get_current_barcode
template <class Boundary_range = Boundary>
Insertion_return insert_boundary(const Boundary_range& boundary, Dimension dim = Matrix::get_null_value<Dimension>());
template <class Boundary_range = Boundary>
Insertion_return insert_boundary(ID_index cellIndex, const Boundary_range& boundary,
Dimension dim = Matrix::get_null_value<Dimension>());
Returned_column& get_column(Index columnIndex);
const Column& get_column(Index columnIndex) const;
//TODO: there is no particular reason that this method is not available for identifier indexing,
// just has to be added to the interface...
const Column& get_column(Index columnIndex, bool inR);
//TODO: update column indices when reordering rows (after lazy swap) such that always MatIdx are returned.
Returned_row& get_row(ID_index rowIndex);
const Row& get_row(ID_index rowIndex) const;
//TODO: there is no particular reason that this method is not available for identifier indexing,
// just has to be added to the interface...
const Row& get_row(ID_index rowIndex, bool inR);
void remove_column(Index columnIndex);
//TODO: rename method to be less confusing.
void erase_empty_row(ID_index rowIndex);
//TODO: for chain matrices, replace IDIdx input with MatIdx input to homogenize.
void remove_maximal_cell(Index columnIndex);
//TODO: See if it would be better to use something more general than a vector for columnsToSwap, such that
// the user do not have to construct the vector from scratch. Like passing iterators instead. But it would be nice,
// to still be able to do (cell, {})...
void remove_maximal_cell(ID_index cellIndex, const std::vector<ID_index>& columnsToSwap);
void remove_last();
Dimension get_max_dimension() const;
Index get_number_of_columns() const;
Dimension get_column_dimension(Index columnIndex) const;
template <typename Integer_index>
std::enable_if_t<std::is_integral_v<Integer_index> > add_to(Integer_index sourceColumnIndex,
Integer_index targetColumnIndex);
template <class Entry_range>
std::enable_if_t<!std::is_integral_v<Entry_range> > add_to(const Entry_range& sourceColumn, Index targetColumnIndex);
template <typename Integer_index>
std::enable_if_t<std::is_integral_v<Integer_index> > multiply_target_and_add_to(Integer_index sourceColumnIndex,
int coefficient,
Integer_index targetColumnIndex);
template <class Entry_range>
std::enable_if_t<!std::is_integral_v<Entry_range> > multiply_target_and_add_to(const Entry_range& sourceColumn,
int coefficient,
Index targetColumnIndex);
template <typename Integer_index>
std::enable_if_t<std::is_integral_v<Integer_index> > multiply_source_and_add_to(int coefficient,
Integer_index sourceColumnIndex,
Integer_index targetColumnIndex);
template <class Entry_range>
std::enable_if_t<!std::is_integral_v<Entry_range> > multiply_source_and_add_to(int coefficient,
const Entry_range& sourceColumn,
Index targetColumnIndex);
void zero_entry(Index columnIndex, ID_index rowIndex);
void zero_entry(Index columnIndex, ID_index rowIndex, bool inR);
void zero_column(Index columnIndex);
void zero_column(Index columnIndex, bool inR);
bool is_zero_entry(Index columnIndex, ID_index rowIndex);
bool is_zero_entry(Index columnIndex, ID_index rowIndex, bool inR) const;
bool is_zero_column(Index columnIndex);
bool is_zero_column(Index columnIndex, bool inR);
Index get_column_with_pivot(ID_index cellIndex) const;
ID_index get_pivot(Index columnIndex);
Matrix& operator=(Matrix other);
friend void swap(Matrix& matrix1, Matrix& matrix2) {
swap(matrix1.matrix_, matrix2.matrix_);
std::swap(matrix1.colSettings_, matrix2.colSettings_);
}
void print(); // for debug
//TODO: change the behaviour for boundary matrices.
const Barcode& get_current_barcode();
const Barcode& get_current_barcode() const;
void swap_columns(Index columnIndex1, Index columnIndex2);
void swap_rows(Index rowIndex1, Index rowIndex2);
//TODO: find better name. And benchmark also to verify if it is really worth it to have this extra version in addition
//to vine_swap.
bool vine_swap_with_z_eq_1_case(Pos_index index);
Index vine_swap_with_z_eq_1_case(Index columnIndex1, Index columnIndex2);
bool vine_swap(Pos_index index);
Index vine_swap(Index columnIndex1, Index columnIndex2);
//TODO: Rethink the interface for representative cycles
void update_representative_cycles();
const std::vector<Cycle>& get_representative_cycles();
const Cycle& get_representative_cycle(const Bar& bar);
private:
using Underlying_matrix =
typename std::conditional<
isNonBasic,
typename std::conditional<
PersistenceMatrixOptions::is_of_boundary_type,
typename std::conditional<
PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::can_retrieve_representative_cycles,
typename std::conditional<
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER ||
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::POSITION,
Master_RU_matrix, Id_to_index_overlay<Master_RU_matrix, Matrix<PersistenceMatrixOptions> >
>::type,
typename std::conditional<
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER ||
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::POSITION,
Master_boundary_matrix,
Id_to_index_overlay<Master_boundary_matrix, Matrix<PersistenceMatrixOptions> >
>::type
>::type,
typename std::conditional<
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER,
Master_chain_matrix,
typename std::conditional<
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::POSITION,
Position_to_index_overlay<Master_chain_matrix, Matrix<PersistenceMatrixOptions> >,
Id_to_index_overlay<Master_chain_matrix, Matrix<PersistenceMatrixOptions> >
>::type
>::type
>::type,
Master_base_matrix
>::type;
// Field_operators* operators_;
// Entry_constructor* entryPool_;
Column_settings* colSettings_; //pointer because the of swap operator on matrix_ which also stores the pointer
Underlying_matrix matrix_;
static constexpr void _assert_options();
};
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix()
: colSettings_(new Column_settings()), matrix_(colSettings_)
{
static_assert(
PersistenceMatrixOptions::is_of_boundary_type || !PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::has_column_pairings,
"When no barcode is recorded with vine swaps, comparison functions for the columns have to be provided.");
_assert_options();
}
template <class PersistenceMatrixOptions>
template <class Container>
inline Matrix<PersistenceMatrixOptions>::Matrix(const std::vector<Container>& columns,
Characteristic characteristic)
: colSettings_(new Column_settings(characteristic)),
matrix_(columns, colSettings_)
{
static_assert(PersistenceMatrixOptions::is_of_boundary_type || !PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::has_column_pairings,
"When no barcode is recorded with vine swaps for chain matrices, comparison functions for the columns "
"have to be provided.");
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix(unsigned int numberOfColumns, Characteristic characteristic)
: colSettings_(new Column_settings(characteristic)),
matrix_(numberOfColumns, colSettings_)
{
static_assert(PersistenceMatrixOptions::is_of_boundary_type || !PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::has_column_pairings,
"When no barcode is recorded with vine swaps for chain matrices, comparison functions for the columns "
"have to be provided.");
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix(const std::function<bool(Pos_index,Pos_index)>& birthComparator,
const std::function<bool(Pos_index,Pos_index)>& deathComparator)
: colSettings_(new Column_settings()),
matrix_(colSettings_, birthComparator, deathComparator)
{
static_assert(
!PersistenceMatrixOptions::is_of_boundary_type && PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::has_column_pairings,
"Constructor only available for chain matrices when vine swaps are enabled, but the barcode is not recorded.");
_assert_options();
}
template <class PersistenceMatrixOptions>
template <class Boundary_range>
inline Matrix<PersistenceMatrixOptions>::Matrix(const std::vector<Boundary_range>& orderedBoundaries,
const std::function<bool(Pos_index, Pos_index)>& birthComparator,
const std::function<bool(Pos_index, Pos_index)>& deathComparator,
Characteristic characteristic)
: colSettings_(new Column_settings(characteristic)),
matrix_(orderedBoundaries, colSettings_, birthComparator, deathComparator)
{
static_assert(
!PersistenceMatrixOptions::is_of_boundary_type && PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::has_column_pairings,
"Constructor only available for chain matrices when vine swaps are enabled, but the barcode is not recorded.");
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix(unsigned int numberOfColumns,
const std::function<bool(Pos_index, Pos_index)>& birthComparator,
const std::function<bool(Pos_index, Pos_index)>& deathComparator,
Characteristic characteristic)
: colSettings_(new Column_settings(characteristic)),
matrix_(numberOfColumns, colSettings_, birthComparator, deathComparator)
{
static_assert(
!PersistenceMatrixOptions::is_of_boundary_type && PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::has_column_pairings,
"Constructor only available for chain matrices when vine swaps are enabled, but the barcode is not recorded.");
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix(const Matrix& matrixToCopy)
: colSettings_(new Column_settings(*matrixToCopy.colSettings_)),
matrix_(matrixToCopy.matrix_, colSettings_)
{
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::Matrix(Matrix&& other) noexcept
: colSettings_(std::exchange(other.colSettings_, nullptr)),
matrix_(std::move(other.matrix_))
{
_assert_options();
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>::~Matrix()
{
matrix_.reset(colSettings_);
delete colSettings_;
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::set_characteristic(Characteristic characteristic)
{
if constexpr (!PersistenceMatrixOptions::is_z2) {
if (colSettings_->operators.get_characteristic() != get_null_value<Characteristic>()) {
std::cerr << "Warning: Characteristic already initialised. Changing it could lead to incoherences in the matrix "
"as the modulo was already applied to values in existing columns.";
}
colSettings_->operators.set_characteristic(characteristic);
}
}
template <class PersistenceMatrixOptions>
template <class Container>
inline void Matrix<PersistenceMatrixOptions>::insert_column(const Container& column)
{
if constexpr (!PersistenceMatrixOptions::is_z2){
GUDHI_CHECK(colSettings_->operators.get_characteristic() != get_null_value<Characteristic>(),
std::logic_error("Matrix::insert_column - Columns cannot be initialized if the coefficient field "
"characteristic is not specified."));
}
static_assert(
!isNonBasic,
"'insert_column' not available for the chosen options. The input has to be in the form of a cell boundary.");
matrix_.insert_column(column);
}
template <class PersistenceMatrixOptions>
template <class Container>
inline void Matrix<PersistenceMatrixOptions>::insert_column(const Container& column, Index columnIndex)
{
if constexpr (!PersistenceMatrixOptions::is_z2){
GUDHI_CHECK(colSettings_->operators.get_characteristic() != get_null_value<Characteristic>(),
std::logic_error("Matrix::insert_column - Columns cannot be initialized if the coefficient field "
"characteristic is not specified."));
}
static_assert(!isNonBasic && !PersistenceMatrixOptions::has_column_compression,
"'insert_column' with those parameters is not available for the chosen options.");
static_assert(!PersistenceMatrixOptions::has_row_access,
"Columns have to be inserted at the end of the matrix when row access is enabled.");
matrix_.insert_column(column, columnIndex);
}
template <class PersistenceMatrixOptions>
template <class Boundary_range>
inline typename Matrix<PersistenceMatrixOptions>::Insertion_return
Matrix<PersistenceMatrixOptions>::insert_boundary(const Boundary_range& boundary, Dimension dim)
{
if constexpr (!PersistenceMatrixOptions::is_z2){
GUDHI_CHECK(colSettings_->operators.get_characteristic() != get_null_value<Characteristic>(),
std::logic_error("Matrix::insert_boundary - Columns cannot be initialized if the coefficient field "
"characteristic is not specified."));
}
if constexpr (isNonBasic && !PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER)
return matrix_.insert_boundary(boundary, dim);
else
matrix_.insert_boundary(boundary, dim);
}
template <class PersistenceMatrixOptions>
template <class Boundary_range>
inline typename Matrix<PersistenceMatrixOptions>::Insertion_return
Matrix<PersistenceMatrixOptions>::insert_boundary(ID_index cellIndex,
const Boundary_range& boundary,
Dimension dim)
{
if constexpr (!PersistenceMatrixOptions::is_z2){
GUDHI_CHECK(colSettings_->operators.get_characteristic() != get_null_value<Characteristic>(),
std::logic_error("Matrix::insert_boundary - Columns cannot be initialized if the coefficient field "
"characteristic is not specified."));
}
static_assert(isNonBasic, "Only enabled for non-basic matrices.");
if constexpr (!PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER)
return matrix_.insert_boundary(cellIndex, boundary, dim);
else
matrix_.insert_boundary(cellIndex, boundary, dim);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Returned_column& Matrix<PersistenceMatrixOptions>::get_column(
Index columnIndex)
{
return matrix_.get_column(columnIndex);
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Column& Matrix<PersistenceMatrixOptions>::get_column(
Index columnIndex) const
{
return matrix_.get_column(columnIndex);
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Column& Matrix<PersistenceMatrixOptions>::get_column(
Index columnIndex, bool inR)
{
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for position indexed RU matrices.");
return matrix_.get_column(columnIndex, inR);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Returned_row& Matrix<PersistenceMatrixOptions>::get_row(
ID_index rowIndex)
{
static_assert(PersistenceMatrixOptions::has_row_access, "'get_row' is not available for the chosen options.");
return matrix_.get_row(rowIndex);
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Row& Matrix<PersistenceMatrixOptions>::get_row(
ID_index rowIndex) const
{
static_assert(PersistenceMatrixOptions::has_row_access, "'get_row' is not available for the chosen options.");
return matrix_.get_row(rowIndex);
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Row& Matrix<PersistenceMatrixOptions>::get_row(
ID_index rowIndex, bool inR)
{
static_assert(PersistenceMatrixOptions::has_row_access, "'get_row' is not available for the chosen options.");
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for position indexed RU matrices.");
return matrix_.get_row(rowIndex, inR);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::remove_column(Index columnIndex)
{
static_assert(PersistenceMatrixOptions::has_map_column_container && !isNonBasic &&
!PersistenceMatrixOptions::has_column_compression,
"'remove_column' is not available for the chosen options.");
matrix_.remove_column(columnIndex);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::erase_empty_row(ID_index rowIndex)
{
static_assert(
!isNonBasic || PersistenceMatrixOptions::is_of_boundary_type || PersistenceMatrixOptions::has_removable_rows,
"'erase_empty_row' is not available for the chosen options.");
matrix_.erase_empty_row(rowIndex);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::remove_maximal_cell(Index columnIndex)
{
static_assert(PersistenceMatrixOptions::has_removable_columns,
"'remove_maximal_cell(ID_index)' is not available for the chosen options.");
static_assert(isNonBasic && PersistenceMatrixOptions::has_vine_update,
"'remove_maximal_cell(ID_index)' is not available for the chosen options.");
static_assert(PersistenceMatrixOptions::is_of_boundary_type || (PersistenceMatrixOptions::has_map_column_container &&
PersistenceMatrixOptions::has_column_pairings),
"'remove_maximal_cell(ID_index)' is not available for the chosen options.");
matrix_.remove_maximal_cell(columnIndex);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::remove_maximal_cell(ID_index cellIndex,
const std::vector<ID_index>& columnsToSwap)
{
static_assert(PersistenceMatrixOptions::has_removable_columns,
"'remove_maximal_cell(ID_index,const std::vector<Index>&)' is not available for the chosen options.");
static_assert(isNonBasic && !PersistenceMatrixOptions::is_of_boundary_type,
"'remove_maximal_cell(ID_index,const std::vector<Index>&)' is not available for the chosen options.");
static_assert(PersistenceMatrixOptions::has_map_column_container && PersistenceMatrixOptions::has_vine_update,
"'remove_maximal_cell(ID_index,const std::vector<Index>&)' is not available for the chosen options.");
matrix_.remove_maximal_cell(cellIndex, columnsToSwap);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::remove_last()
{
static_assert(PersistenceMatrixOptions::has_removable_columns || !isNonBasic,
"'remove_last' is not available for the chosen options.");
static_assert(!PersistenceMatrixOptions::has_column_compression || isNonBasic,
"'remove_last' is not available for the chosen options.");
static_assert(!isNonBasic || PersistenceMatrixOptions::is_of_boundary_type ||
PersistenceMatrixOptions::has_map_column_container || !PersistenceMatrixOptions::has_vine_update,
"'remove_last' is not available for the chosen options.");
matrix_.remove_last();
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Dimension Matrix<PersistenceMatrixOptions>::get_max_dimension()
const
{
static_assert(isNonBasic, "'get_max_dimension' is not available for the chosen options.");
return matrix_.get_max_dimension();
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Index Matrix<PersistenceMatrixOptions>::get_number_of_columns() const
{
return matrix_.get_number_of_columns();
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Dimension Matrix<PersistenceMatrixOptions>::get_column_dimension(
Index columnIndex) const
{
static_assert(isNonBasic, "'get_column_dimension' is not available for the chosen options.");
return matrix_.get_column_dimension(columnIndex);
}
template <class PersistenceMatrixOptions>
template <typename Integer_index>
inline std::enable_if_t<std::is_integral_v<Integer_index> > Matrix<PersistenceMatrixOptions>::add_to(
Integer_index sourceColumnIndex, Integer_index targetColumnIndex)
{
matrix_.add_to(sourceColumnIndex, targetColumnIndex);
}
template <class PersistenceMatrixOptions>
template <class Entry_range>
inline std::enable_if_t<!std::is_integral_v<Entry_range> > Matrix<PersistenceMatrixOptions>::add_to(
const Entry_range& sourceColumn, Index targetColumnIndex)
{
static_assert(!isNonBasic,
"For boundary or chain matrices, only additions with columns inside the matrix is allowed to maintain "
"algebraic consistency.");
matrix_.add_to(sourceColumn, targetColumnIndex);
}
template <class PersistenceMatrixOptions>
template <typename Integer_index>
inline std::enable_if_t<std::is_integral_v<Integer_index> > Matrix<PersistenceMatrixOptions>::multiply_target_and_add_to(
Integer_index sourceColumnIndex, int coefficient, Integer_index targetColumnIndex)
{
if constexpr (PersistenceMatrixOptions::is_z2) {
// coef will be converted to bool, because of Element
matrix_.multiply_target_and_add_to(sourceColumnIndex, coefficient % 2, targetColumnIndex);
} else {
matrix_.multiply_target_and_add_to(sourceColumnIndex, colSettings_->operators.get_value(coefficient), targetColumnIndex);
}
}
template <class PersistenceMatrixOptions>
template <class Entry_range>
inline std::enable_if_t<!std::is_integral_v<Entry_range> > Matrix<PersistenceMatrixOptions>::multiply_target_and_add_to(
const Entry_range& sourceColumn, int coefficient, Index targetColumnIndex)
{
static_assert(!isNonBasic,
"For boundary or chain matrices, only additions with columns inside the matrix is allowed to maintain "
"algebraic consistency.");
if constexpr (PersistenceMatrixOptions::is_z2) {
// coef will be converted to bool, because of Element
matrix_.multiply_target_and_add_to(sourceColumn, coefficient % 2, targetColumnIndex);
} else {
matrix_.multiply_target_and_add_to(sourceColumn, colSettings_->operators.get_value(coefficient), targetColumnIndex);
}
}
template <class PersistenceMatrixOptions>
template <typename Integer_index>
inline std::enable_if_t<std::is_integral_v<Integer_index> > Matrix<PersistenceMatrixOptions>::multiply_source_and_add_to(
int coefficient, Integer_index sourceColumnIndex, Integer_index targetColumnIndex)
{
if constexpr (PersistenceMatrixOptions::is_z2) {
// coef will be converted to bool, because of Element
matrix_.multiply_source_and_add_to(coefficient % 2, sourceColumnIndex, targetColumnIndex);
} else {
matrix_.multiply_source_and_add_to(colSettings_->operators.get_value(coefficient), sourceColumnIndex, targetColumnIndex);
}
}
template <class PersistenceMatrixOptions>
template <class Entry_range>
inline std::enable_if_t<!std::is_integral_v<Entry_range> > Matrix<PersistenceMatrixOptions>::multiply_source_and_add_to(
int coefficient, const Entry_range& sourceColumn, Index targetColumnIndex)
{
static_assert(!isNonBasic,
"For boundary or chain matrices, only additions with columns inside the matrix is allowed to maintain "
"algebraic consistency.");
if constexpr (PersistenceMatrixOptions::is_z2) {
// coef will be converted to bool, because of Element
matrix_.multiply_source_and_add_to(coefficient % 2, sourceColumn, targetColumnIndex);
} else {
matrix_.multiply_source_and_add_to(colSettings_->operators.get_value(coefficient), sourceColumn, targetColumnIndex);
}
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::zero_entry(Index columnIndex, ID_index rowIndex)
{
static_assert(PersistenceMatrixOptions::is_of_boundary_type && !PersistenceMatrixOptions::has_column_compression,
"'zero_entry' is not available for the chosen options.");
return matrix_.zero_entry(columnIndex, rowIndex);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::zero_entry(Index columnIndex, ID_index rowIndex, bool inR)
{
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for RU matrices.");
return matrix_.zero_entry(columnIndex, rowIndex, inR);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::zero_column(Index columnIndex)
{
static_assert(PersistenceMatrixOptions::is_of_boundary_type && !PersistenceMatrixOptions::has_column_compression,
"'zero_column' is not available for the chosen options.");
return matrix_.zero_column(columnIndex);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::zero_column(Index columnIndex, bool inR)
{
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for RU matrices.");
return matrix_.zero_column(columnIndex, inR);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::is_zero_entry(Index columnIndex, ID_index rowIndex)
{
return matrix_.is_zero_entry(columnIndex, rowIndex);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::is_zero_entry(Index columnIndex, ID_index rowIndex, bool inR) const
{
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for RU matrices.");
return matrix_.is_zero_entry(columnIndex, rowIndex, inR);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::is_zero_column(Index columnIndex)
{
return matrix_.is_zero_column(columnIndex);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::is_zero_column(Index columnIndex, bool inR)
{
// TODO: I don't think there is a particular reason why the indexation is forced, should be removed.
static_assert(
isNonBasic && PersistenceMatrixOptions::is_of_boundary_type &&
(PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::can_retrieve_representative_cycles) &&
PersistenceMatrixOptions::column_indexation_type != Column_indexation_types::IDENTIFIER,
"Only enabled for RU matrices.");
return matrix_.is_zero_column(columnIndex, inR);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Index Matrix<PersistenceMatrixOptions>::get_column_with_pivot(
ID_index cellIndex) const
{
static_assert(isNonBasic && (!PersistenceMatrixOptions::is_of_boundary_type ||
(PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::can_retrieve_representative_cycles)),
"'get_column_with_pivot' is not available for the chosen options.");
return matrix_.get_column_with_pivot(cellIndex);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::ID_index Matrix<PersistenceMatrixOptions>::get_pivot(
Index columnIndex)
{
static_assert(isNonBasic, "'get_pivot' is not available for the chosen options.");
return matrix_.get_pivot(columnIndex);
}
template <class PersistenceMatrixOptions>
inline Matrix<PersistenceMatrixOptions>& Matrix<PersistenceMatrixOptions>::operator=(Matrix other)
{
swap(matrix_, other.matrix_);
std::swap(colSettings_, other.colSettings_);
return *this;
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::print()
{
return matrix_.print();
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Barcode&
Matrix<PersistenceMatrixOptions>::get_current_barcode()
{
static_assert(PersistenceMatrixOptions::has_column_pairings, "This method was not enabled.");
return matrix_.get_current_barcode();
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Barcode&
Matrix<PersistenceMatrixOptions>::get_current_barcode() const
{
static_assert(PersistenceMatrixOptions::has_column_pairings, "This method was not enabled.");
static_assert(
!PersistenceMatrixOptions::is_of_boundary_type || PersistenceMatrixOptions::has_vine_update ||
PersistenceMatrixOptions::can_retrieve_representative_cycles,
"'get_current_barcode' is not const for boundary matrices as the barcode is only computed when explicitly "
"asked.");
return matrix_.get_current_barcode();
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::swap_columns(Index columnIndex1, Index columnIndex2)
{
static_assert(
(!isNonBasic && !PersistenceMatrixOptions::has_column_compression) ||
(isNonBasic && PersistenceMatrixOptions::is_of_boundary_type && !PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::can_retrieve_representative_cycles),
"This method was not enabled.");
return matrix_.swap_columns(columnIndex1, columnIndex2);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::swap_rows(Index rowIndex1, Index rowIndex2)
{
static_assert(
(!isNonBasic && !PersistenceMatrixOptions::has_column_compression) ||
(isNonBasic && PersistenceMatrixOptions::is_of_boundary_type && !PersistenceMatrixOptions::has_vine_update &&
!PersistenceMatrixOptions::can_retrieve_representative_cycles),
"This method was not enabled.");
return matrix_.swap_rows(rowIndex1, rowIndex2);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::vine_swap_with_z_eq_1_case(Pos_index index)
{
static_assert(PersistenceMatrixOptions::has_vine_update, "This method was not enabled.");
static_assert(PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::POSITION ||
(PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER),
"This method was not enabled.");
return matrix_.vine_swap_with_z_eq_1_case(index);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Index Matrix<PersistenceMatrixOptions>::vine_swap_with_z_eq_1_case(
Index columnIndex1, Index columnIndex2)
{
static_assert(PersistenceMatrixOptions::has_vine_update, "This method was not enabled.");
static_assert(PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::IDENTIFIER ||
(!PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER),
"This method was not enabled.");
return matrix_.vine_swap_with_z_eq_1_case(columnIndex1, columnIndex2);
}
template <class PersistenceMatrixOptions>
inline bool Matrix<PersistenceMatrixOptions>::vine_swap(Pos_index index)
{
static_assert(PersistenceMatrixOptions::has_vine_update, "This method was not enabled.");
static_assert(PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::POSITION ||
(PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER),
"This method was not enabled.");
return matrix_.vine_swap(index);
}
template <class PersistenceMatrixOptions>
inline typename Matrix<PersistenceMatrixOptions>::Index Matrix<PersistenceMatrixOptions>::vine_swap(
Index columnIndex1, Index columnIndex2)
{
static_assert(PersistenceMatrixOptions::has_vine_update, "This method was not enabled.");
static_assert(PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::IDENTIFIER ||
(!PersistenceMatrixOptions::is_of_boundary_type &&
PersistenceMatrixOptions::column_indexation_type == Column_indexation_types::CONTAINER),
"This method was not enabled.");
return matrix_.vine_swap(columnIndex1, columnIndex2);
}
template <class PersistenceMatrixOptions>
inline void Matrix<PersistenceMatrixOptions>::update_representative_cycles()
{
static_assert(PersistenceMatrixOptions::can_retrieve_representative_cycles, "This method was not enabled.");
matrix_.update_representative_cycles();
}
template <class PersistenceMatrixOptions>
inline const std::vector<typename Matrix<PersistenceMatrixOptions>::Cycle>&
Matrix<PersistenceMatrixOptions>::get_representative_cycles()
{
static_assert(PersistenceMatrixOptions::can_retrieve_representative_cycles, "This method was not enabled.");
return matrix_.get_representative_cycles();
}
template <class PersistenceMatrixOptions>
inline const typename Matrix<PersistenceMatrixOptions>::Cycle&
Matrix<PersistenceMatrixOptions>::get_representative_cycle(const Bar& bar)
{
static_assert(PersistenceMatrixOptions::can_retrieve_representative_cycles, "This method was not enabled.");
return matrix_.get_representative_cycle(bar);
}
template <class PersistenceMatrixOptions>
inline constexpr void Matrix<PersistenceMatrixOptions>::_assert_options()
{
static_assert(
PersistenceMatrixOptions::column_type != Column_types::HEAP || !PersistenceMatrixOptions::has_row_access,
"Row access is not possible for heap columns.");
static_assert(!PersistenceMatrixOptions::has_vine_update || PersistenceMatrixOptions::is_z2,
"Vine update currently works only for Z_2 coefficients.");
// static_assert(!PersistenceMatrixOptions::can_retrieve_representative_cycles || PersistenceMatrixOptions::is_z2,
// "Representative cycles can currently only be computed with Z_2 coefficients.");
static_assert(
PersistenceMatrixOptions::column_type != Column_types::HEAP || !PersistenceMatrixOptions::has_column_compression,
"Column compression not compatible with heap columns.");
// // This should be warnings instead, as PersistenceMatrixOptions::has_column_compression is just ignored in those
// // cases and don't produces errors as long as the corresponding methods are not called.
// static_assert(!PersistenceMatrixOptions::has_column_compression || !PersistenceMatrixOptions::has_column_pairings,
// "Column compression not available to compute persistence homology (it would bring no advantages; "
// "use it for co-homology instead).");
// static_assert(!PersistenceMatrixOptions::has_column_compression || !PersistenceMatrixOptions::has_vine_update,
// "Column compression not available for vineyards.");
// static_assert(!PersistenceMatrixOptions::has_column_compression ||
// !PersistenceMatrixOptions::can_retrieve_representative_cycles,
// "Column compression not available to retrieve representative cycles.");
// // Would column removal while column compression be useful? If yes, should erase() remove a single column or the
// // class of columns identical to the input?
// // For a single column, I have an implementation for union-find (not the current one) which allows deleting a
// // single element in constant time, but find becomes log n in worst case.
// // For a column class, we either just ignore the removed class (constant time), but this results in memory
// // residues, or, we have an erase method which is at least linear in the size of the class.
// static_assert(
// !PersistenceMatrixOptions::has_column_compression || !PersistenceMatrixOptions::has_map_column_container,
// "When column compression is used, the removal of columns is not implemented yet.");
}
} // namespace persistence_matrix
} // namespace Gudhi
#endif // MASTER_MATRIX_H
Base_matrix.h
Contains the Gudhi::persistence_matrix::Base_matrix class.
Base_matrix_with_column_compression.h
Contains the Gudhi::persistence_matrix::Base_matrix_with_column_compression class.
Boundary_matrix.h
Contains the Gudhi::persistence_matrix::Boundary_matrix class.
Chain_matrix.h
Contains the Gudhi::persistence_matrix::Chain_matrix class.
Id_to_index_overlay.h
Contains the Gudhi::persistence_matrix::Id_to_index_overlay class.
Position_to_index_overlay.h
Contains the Gudhi::persistence_matrix::Position_to_index_overlay class.
RU_matrix.h
Contains the Gudhi::persistence_matrix::RU_matrix class.
Z2_field_operators.h
Contains the Gudhi::persistence_fields::Z2_field_operators class.
base_pairing.h
Contains the Gudhi::persistence_matrix::Base_pairing class and Gudhi::persistence_matrix::Dummy_base_...
base_swap.h
Contains the Gudhi::persistence_matrix::Base_swap class and Gudhi::persistence_matrix::Dummy_base_swa...
chain_column_extra_properties.h
Contains the Gudhi::persistence_matrix::Chain_column_extra_properties class and Gudhi::persistence_ma...
chain_pairing.h
Contains the Gudhi::persistence_matrix::Chain_pairing class and Gudhi::persistence_matrix::Dummy_chai...
chain_rep_cycles.h
Contains the Gudhi::persistence_matrix::Chain_representative_cycles class and Gudhi::persistence_matr...
chain_vine_swap.h
Contains the Gudhi::persistence_matrix::Chain_barcode_swap and Gudhi::persistence_matrix::Chain_vine_...
Gudhi::persistence_fields::Z2_field_operators
Class defining operators for the field.
Definition Z2_field_operators.h:32
Gudhi::persistence_matrix::Base_matrix_with_column_compression
A base matrix (also see Base_matrix), but with column compression. That is, all identical columns in ...
Definition Base_matrix_with_column_compression.h:46
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_pairing
Class managing the barcode for Boundary_matrix if the option was enabled.
Definition base_pairing.h:56
Gudhi::persistence_matrix::Base_swap
Class managing the column and row swaps in Base_matrix and Boundary_matrix.
Definition base_swap.h:49
Gudhi::persistence_matrix::Boundary_matrix
Matrix structure to store the ordered boundary matrix of a filtered complex in order to compute its ...
Definition Boundary_matrix.h:44
Gudhi::persistence_matrix::Chain_column_extra_properties
Class managing the pivot and partitioning of columns in Chain_matrix.
Definition chain_column_extra_properties.h:57
Gudhi::persistence_matrix::Chain_matrix
Matrix structure storing a compatible base of a filtered chain complex. See zigzag....
Definition Chain_matrix.h:50
Gudhi::persistence_matrix::Chain_pairing
Class managing the barcode for Chain_matrix if the option was enabled.
Definition chain_pairing.h:48
Gudhi::persistence_matrix::Chain_representative_cycles
Class managing the representative cycles for Chain_matrix if the option was enabled.
Definition chain_rep_cycles.h:52
Gudhi::persistence_matrix::Chain_vine_swap
Class managing the vine swaps for Chain_matrix.
Definition chain_vine_swap.h:240
Gudhi::persistence_matrix::Entry
Matrix entry class. Stores by default only the row index it belongs to, but can also store its column...
Definition entry_types.h:195
Gudhi::persistence_matrix::Heap_column
Column class following the PersistenceMatrixColumn concept. Not compatible with row access.
Definition heap_column.h:51
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::Intrusive_list_column
Column class following the PersistenceMatrixColumn concept.
Definition intrusive_list_column.h:49
Gudhi::persistence_matrix::Intrusive_set_column
Column class following the PersistenceMatrixColumn concept.
Definition intrusive_set_column.h:50
Gudhi::persistence_matrix::List_column
Column class following the PersistenceMatrixColumn concept.
Definition list_column.h:50
Gudhi::persistence_matrix::Matrix_all_dimension_holder
Class managing the maximal dimension of a cell represented in the inheriting matrix,...
Definition matrix_dimension_holders.h:119
Gudhi::persistence_matrix::Matrix_max_dimension_holder
Class managing the maximal dimension of a cell represented in the inheriting matrix,...
Definition matrix_dimension_holders.h:57
Gudhi::persistence_matrix::Matrix_row_access
Class managing the row access for the inheriting matrix.
Definition matrix_row_access.h:54
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Cycle
std::vector< ID_index > Cycle
Definition Matrix.h:541
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::set_characteristic
void set_characteristic(Characteristic characteristic)
Sets the characteristic of the coefficient field if PersistenceMatrixOptions::is_z2 is false,...
Definition Matrix.h:1524
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Bar
Persistence_interval< Dimension, Pos_index > Bar
Definition Matrix.h:177
Gudhi::persistence_matrix::Matrix::get_representative_cycles
const std::vector< Cycle > & get_representative_cycles()
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Matrix.h:2054
Gudhi::persistence_matrix::Matrix::get_column_dimension
Dimension get_column_dimension(Index columnIndex) const
Returns the dimension of the given cell. Only available for non-basic matrices.
Definition Matrix.h:1747
Gudhi::persistence_matrix::Matrix::swap_rows
void swap_rows(Index rowIndex1, Index rowIndex2)
Only available for base matrices without column compression and simple boundary matrices (only storin...
Definition Matrix.h:1988
Gudhi::persistence_matrix::Matrix::get_column_with_pivot
Index get_column_with_pivot(ID_index cellIndex) const
Returns the MatIdx index of the column which has the given row index as pivot. Only available for RU ...
Definition Matrix.h:1918
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< RU_rep_cycles_options >::Field_operators
typename std::conditional< RU_rep_cycles_options::is_z2, Gudhi::persistence_fields::Z2_field_operators, typename RU_rep_cycles_options::Field_coeff_operators >::type Field_operators
Definition Matrix.h:155
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Matrix_entry
Entry< Matrix< RU_rep_cycles_options > > Matrix_entry
Definition Matrix.h:227
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Entry_representative
typename std::conditional< RU_rep_cycles_options::is_z2, ID_index, std::pair< ID_index, Element > >::type Entry_representative
Definition Matrix.h:248
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::multiply_target_and_add_to
std::enable_if_t<!std::is_integral_v< Entry_range > > multiply_target_and_add_to(const Entry_range &sourceColumn, int coefficient, Index targetColumnIndex)
Multiplies the target column with the coefficient and then adds the given range of Entry to it....
Definition Matrix.h:1790
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::Matrix
Matrix(unsigned int numberOfColumns, Characteristic characteristic=Matrix::get_null_value< Characteristic >())
Constructs a new empty matrix and reserves space for the given number of columns.
Definition Matrix.h:1445
Gudhi::persistence_matrix::Matrix::vine_swap
Index vine_swap(Index columnIndex1, Index columnIndex2)
Only available if PersistenceMatrixOptions::has_vine_update is true and if it is either a chain matri...
Definition Matrix.h:2034
Gudhi::persistence_matrix::Matrix::zero_column
void zero_column(Index columnIndex, bool inR)
Only available for RU matrices. Zeroes the column at the given index in if inR is true or in if inR...
Definition Matrix.h:1867
Gudhi::persistence_matrix::Matrix::Matrix
Matrix(const Matrix &matrixToCopy)
Copy constructor.
Definition Matrix.h:1501
Gudhi::persistence_matrix::Matrix::get_current_barcode
const Barcode & get_current_barcode()
Returns the current barcode of the matrix. Available only if PersistenceMatrixOptions::has_column_pai...
Definition Matrix.h:1955
Gudhi::persistence_matrix::Matrix::add_to
std::enable_if_t<!std::is_integral_v< Entry_range > > add_to(const Entry_range &sourceColumn, Index targetColumnIndex)
Adds the given range of Entry onto the column at targetColumnIndex in the matrix. Only available for ...
Definition Matrix.h:1765
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Element
typename Field_operators::Element Element
Definition Matrix.h:163
Gudhi::persistence_matrix::Matrix::multiply_source_and_add_to
std::enable_if_t<!std::is_integral_v< Entry_range > > multiply_source_and_add_to(int coefficient, const Entry_range &sourceColumn, Index targetColumnIndex)
Multiplies the source column with the coefficient before adding it to the target column....
Definition Matrix.h:1820
Gudhi::persistence_matrix::Matrix::get_pivot
ID_index get_pivot(Index columnIndex)
Returns the row index of the pivot of the given column. Only available for non-basic matrices.
Definition Matrix.h:1930
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< RU_rep_cycles_options >::Dimension
typename RU_rep_cycles_options::Dimension Dimension
Definition Matrix.h:150
Gudhi::persistence_matrix::Matrix::get_representative_cycle
const Cycle & get_representative_cycle(const Bar &bar)
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Matrix.h:2062
Gudhi::persistence_matrix::Matrix::swap_columns
void swap_columns(Index columnIndex1, Index columnIndex2)
Only available for base matrices without column compression and simple boundary matrices (only storin...
Definition Matrix.h:1977
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< RU_rep_cycles_options >::Index
typename RU_rep_cycles_options::Index Index
Definition Matrix.h:147
Gudhi::persistence_matrix::Matrix::zero_entry
void zero_entry(Index columnIndex, ID_index rowIndex, bool inR)
Only available for RU matrices. Zeroes the entry at the given coordinates in if inR is true or in i...
Definition Matrix.h:1845
Gudhi::persistence_matrix::Matrix::Matrix
Matrix(const std::function< bool(Pos_index, Pos_index)> &birthComparator, const std::function< bool(Pos_index, Pos_index)> &deathComparator)
Constructs a new empty matrix with the given comparator functions. Only available when those comparat...
Definition Matrix.h:1457
Gudhi::persistence_matrix::Matrix::insert_column
void insert_column(const Container &column, Index columnIndex)
Inserts a new ordered column at the given index by copying the given range of Entry_representative....
Definition Matrix.h:1554
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< 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::Matrix
Matrix(unsigned int numberOfColumns, const std::function< bool(Pos_index, Pos_index)> &birthComparator, const std::function< bool(Pos_index, Pos_index)> &deathComparator, Characteristic characteristic=Matrix::get_null_value< Characteristic >())
Constructs a new empty matrix and reserves space for the given number of columns. Only available when...
Definition Matrix.h:1486
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< RU_rep_cycles_options >::Entry_constructor
Pool_entry_constructor< Matrix_entry > Entry_constructor
Definition Matrix.h:239
Gudhi::persistence_matrix::Matrix::get_column
const Column & get_column(Index columnIndex, bool inR)
Only available for RU matrices without Column_indexation_types::IDENTIFIER indexing....
Definition Matrix.h:1623
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::defaultEntryConstructor
static New_entry_constructor< Matrix_entry > defaultEntryConstructor
Definition Matrix.h:234
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::insert_boundary
Insertion_return insert_boundary(ID_index cellIndex, const Boundary_range &boundary, Dimension dim=Matrix::get_null_value< Dimension >())
Only available for non-basic matrices. It does the same as the other version, but allows the boundary...
Definition Matrix.h:1590
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::get_row
const Row & get_row(ID_index rowIndex, bool inR)
Only available for RU matrices without Column_indexation_types::IDENTIFIER indexing....
Definition Matrix.h:1655
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::Matrix
Matrix(Matrix &&other) noexcept
Move constructor. After the move, the given matrix will be empty.
Definition Matrix.h:1509
Gudhi::persistence_matrix::Matrix::Matrix
Matrix()
Default constructor. Initializes an empty matrix.
Definition Matrix.h:1420
Gudhi::persistence_matrix::Matrix::get_column
const Column & get_column(Index columnIndex) const
Only available for chain matrices. Returns the column at the given MatIdx index. The type of the colu...
Definition Matrix.h:1616
Gudhi::persistence_matrix::Matrix::vine_swap
bool vine_swap(Pos_index index)
Only available if PersistenceMatrixOptions::has_vine_update is true and if it is either a boundary ma...
Definition Matrix.h:2023
Gudhi::persistence_matrix::Matrix::get_row
const Row & get_row(ID_index rowIndex) const
Only available for chain matrices and matrices with column compression. Returns the row at the given ...
Definition Matrix.h:1646
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::vine_swap_with_z_eq_1_case
bool vine_swap_with_z_eq_1_case(Pos_index index)
Only available if PersistenceMatrixOptions::has_vine_update is true and if it is either a boundary ma...
Definition Matrix.h:1999
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::ID_index
typename RU_rep_cycles_options::Index ID_index
Definition Matrix.h:148
Gudhi::persistence_matrix::Matrix::swap
friend void swap(Matrix &matrix1, Matrix &matrix2)
Swap operator for two matrices.
Definition Matrix.h:1232
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::Matrix
Matrix(const std::vector< Container > &columns, Characteristic characteristic=11)
Constructs a new matrix from the given ranges of Entry_representative. Each range corresponds to a co...
Definition Matrix.h:1432
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Pos_index
typename RU_rep_cycles_options::Index Pos_index
Definition Matrix.h:149
Gudhi::persistence_matrix::Matrix::get_max_dimension
Dimension get_max_dimension() const
Returns the maximal dimension of a cell stored in the matrix. Only available for non-basic matrices a...
Definition Matrix.h:1732
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::is_zero_entry
bool is_zero_entry(Index columnIndex, ID_index rowIndex, bool inR) const
Only available for RU matrices. Indicates if the entry at given coordinates has value zero in if inR...
Definition Matrix.h:1886
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::Matrix::remove_maximal_cell
void remove_maximal_cell(ID_index cellIndex, const std::vector< ID_index > &columnsToSwap)
Only available for chain matrices and if PersistenceMatrixOptions::has_removable_columns,...
Definition Matrix.h:1704
Gudhi::persistence_matrix::Matrix< RU_rep_cycles_options >::Barcode
typename std::conditional< hasFixedBarcode, std::vector< Bar >, typename std::conditional< RU_rep_cycles_options::has_removable_columns, std::list< Bar >, std::vector< Bar > >::type >::type Barcode
Definition Matrix.h:441
Gudhi::persistence_matrix::Matrix::get_current_barcode
const Barcode & get_current_barcode() const
Returns the current barcode of the matrix. Available only if PersistenceMatrixOptions::has_column_pai...
Definition Matrix.h:1964
Gudhi::persistence_matrix::Matrix::Matrix
Matrix(const std::vector< Boundary_range > &orderedBoundaries, const std::function< bool(Pos_index, Pos_index)> &birthComparator, const std::function< bool(Pos_index, Pos_index)> &deathComparator, Characteristic characteristic=11)
Constructs a new matrix from the given ranges with the given comparator functions....
Definition Matrix.h:1471
Gudhi::persistence_matrix::Matrix::update_representative_cycles
void update_representative_cycles()
Only available if PersistenceMatrixOptions::can_retrieve_representative_cycles is true....
Definition Matrix.h:2046
Gudhi::persistence_matrix::Matrix::vine_swap_with_z_eq_1_case
Index vine_swap_with_z_eq_1_case(Index columnIndex1, Index columnIndex2)
Only available if PersistenceMatrixOptions::has_vine_update is true and if it is either a chain matri...
Definition Matrix.h:2010
Gudhi::persistence_matrix::Matrix::get_null_value
static constexpr const T get_null_value()
Returns value from a type when not set.
Definition Matrix.h:170
Gudhi::persistence_matrix::Matrix::remove_maximal_cell
void remove_maximal_cell(Index columnIndex)
Only available for RU and chain matrices and if PersistenceMatrixOptions::has_removable_columns and P...
Definition Matrix.h:1690
Gudhi::persistence_matrix::Matrix::is_zero_column
bool is_zero_column(Index columnIndex, bool inR)
Only available for RU matrices. Indicates if the column at given index has value zero in if inR is t...
Definition Matrix.h:1905
Gudhi::persistence_matrix::Position_to_index_overlay
Overlay for chain matrices replacing all input and output MatIdx indices of the original methods with...
Definition Position_to_index_overlay.h:40
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_pairing
Class managing the barcode for RU_matrix if the option was enabled.
Definition ru_pairing.h:54
Gudhi::persistence_matrix::RU_representative_cycles
Class managing the representative cycles for RU_matrix if the option was enabled.
Definition ru_rep_cycles.h:52
Gudhi::persistence_matrix::RU_vine_swap
Class managing the vine swaps for RU_matrix.
Definition ru_vine_swap.h:74
Gudhi::persistence_matrix::Row_access
Class managing the row access for the columns.
Definition row_access.h:51
Gudhi::persistence_matrix::Set_column
Column class following the PersistenceMatrixColumn concept.
Definition set_column.h:50
Gudhi::persistence_matrix::Unordered_set_column
Column class following the PersistenceMatrixColumn concept.
Definition unordered_set_column.h:67
Gudhi::persistence_matrix::Vector_column
Column class following the PersistenceMatrixColumn concept.
Definition vector_column.h:52
column_dimension_holder.h
Contains the Gudhi::persistence_matrix::Column_dimension_holder class and Gudhi::persistence_matrix::...
entry_constructors.h
Contains different versions of Gudhi::persistence_matrix::Entry factories.
entry_types.h
Contains the Gudhi::persistence_matrix::Entry, Gudhi::persistence_matrix::Entry_column_index and Gudh...
Gudhi::persistence_matrix::Column_indexation_types::IDENTIFIER
@ IDENTIFIER
Definition persistence_matrix_options.h:54
Gudhi::persistence_matrix::Column_indexation_types::POSITION
@ POSITION
Definition persistence_matrix_options.h:53
Gudhi::persistence_matrix::Column_indexation_types::CONTAINER
@ CONTAINER
Definition persistence_matrix_options.h:52
Gudhi::persistence_matrix::Column_types::LIST
@ LIST
Definition persistence_matrix_options.h:31
Gudhi::persistence_matrix::Column_types::INTRUSIVE_SET
@ INTRUSIVE_SET
Definition persistence_matrix_options.h:42
Gudhi::persistence_matrix::Column_types::INTRUSIVE_LIST
@ INTRUSIVE_LIST
Definition persistence_matrix_options.h:41
Gudhi::persistence_matrix::Column_types::UNORDERED_SET
@ UNORDERED_SET
Definition persistence_matrix_options.h:40
Gudhi::persistence_matrix::Column_types::VECTOR
@ VECTOR
Definition persistence_matrix_options.h:35
Gudhi::persistence_matrix::Column_types::SET
@ SET
Definition persistence_matrix_options.h:32
Gudhi::persistence_matrix::Column_types::SMALL_VECTOR
@ SMALL_VECTOR
Definition persistence_matrix_options.h:38
Gudhi::persistence_matrix::Column_types::NAIVE_VECTOR
@ NAIVE_VECTOR
Definition persistence_matrix_options.h:37
Gudhi::persistence_matrix::Column_types::HEAP
@ HEAP
Definition persistence_matrix_options.h:33
heap_column.h
Contains the Gudhi::persistence_matrix::Heap_column class. Also defines the std::hash method for Gudh...
intrusive_list_column.h
Contains the Gudhi::persistence_matrix::Intrusive_list_column class. Also defines the std::hash metho...
intrusive_set_column.h
Contains the Gudhi::persistence_matrix::Intrusive_set_column class. Also defines the std::hash method...
list_column.h
Contains the Gudhi::persistence_matrix::List_column class. Also defines the std::hash method for Gudh...
matrix_dimension_holders.h
Contains the Gudhi::persistence_matrix::Matrix_max_dimension_holder Gudhi::persistence_matrix::Matrix...
matrix_row_access.h
Contains the Gudhi::persistence_matrix::Matrix_row_access class and Gudhi::persistence_matrix::Dummy_...
naive_vector_column.h
Contains the Gudhi::persistence_matrix::Naive_vector_column class. Also defines the std::hash method ...
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14
persistence_interval.h
Contains Gudhi::persistence_matrix::Persistence_interval class.
persistence_matrix_options.h
Contains the options for the matrix template.
row_access.h
Contains the Gudhi::persistence_matrix::Row_access class and Gudhi::persistence_matrix::Dummy_row_acc...
ru_pairing.h
Contains the Gudhi::persistence_matrix::RU_pairing class and Gudhi::persistence_matrix::Dummy_ru_pair...
ru_rep_cycles.h
Contains the Gudhi::persistence_matrix::RU_representative_cycles class and Gudhi::persistence_matrix:...
ru_vine_swap.h
Contains the Gudhi::persistence_matrix::RU_vine_swap class, as well as the Gudhi::persistence_matrix:...
set_column.h
Contains the Gudhi::persistence_matrix::Set_column class. Also defines the std::hash method for Gudhi...
Gudhi::persistence_matrix::Column_dimension_holder
Class managing the dimension access of a column.
Definition column_dimension_holder.h:51
Gudhi::persistence_matrix::Dummy_base_pairing
Empty structure. Inherited instead of Base_pairing, when the computation of the barcode was not enabl...
Definition base_pairing.h:38
Gudhi::persistence_matrix::Dummy_base_swap
Empty structure. Inherited instead of Base_swap, when the column and row swaps are not enabled.
Definition base_swap.h:33
Gudhi::persistence_matrix::Dummy_chain_pairing
Empty structure. Inherited instead of Chain_pairing, when the computation of the barcode was not enab...
Definition chain_pairing.h:34
Gudhi::persistence_matrix::Dummy_chain_properties
Empty structure. Inherited instead of Chain_column_extra_properties, when the columns are not meant f...
Definition chain_column_extra_properties.h:34
Gudhi::persistence_matrix::Dummy_chain_representative_cycles
Empty structure. Inherited instead of Chain_representative_cycles, when the computation of the repres...
Definition chain_rep_cycles.h:36
Gudhi::persistence_matrix::Dummy_chain_vine_swap
Empty structure. Inherited instead of Chain_vine_swap, when vine swaps are not enabled.
Definition chain_vine_swap.h:56
Gudhi::persistence_matrix::Dummy_dimension_holder
Empty structure. Inherited instead of Column_dimension_holder, when the columns are not storing a dim...
Definition column_dimension_holder.h:33
Gudhi::persistence_matrix::Dummy_matrix_dimension_holder
Empty structure. Inherited instead of Matrix_max_dimension_holder or Matrix_all_dimension_holder,...
Definition matrix_dimension_holders.h:36
Gudhi::persistence_matrix::Dummy_matrix_row_access
Empty structure. Inherited instead of Matrix_row_access, when the the row access is not enabled.
Definition matrix_row_access.h:33
Gudhi::persistence_matrix::Dummy_row_access
Empty structure. Inherited instead of Row_access, if the row access is not enabled.
Definition row_access.h:33
Gudhi::persistence_matrix::Dummy_ru_pairing
Empty structure. Inherited instead of RU_pairing, when the computation of the barcode was not enabled...
Definition ru_pairing.h:36
Gudhi::persistence_matrix::Dummy_ru_representative_cycles
Empty structure. Inherited instead of RU_representative_cycles, when the computation of the represent...
Definition ru_rep_cycles.h:36
Gudhi::persistence_matrix::Dummy_ru_vine_swap
Empty structure. Inherited instead of RU_vine_swap, when vine swaps are not enabled.
Definition ru_vine_swap.h:40
Gudhi::persistence_matrix::Matrix::RowEntryComp
Compares two entries by their position in the row. They are assume to be in the same row.
Definition Matrix.h:256
Gudhi::persistence_matrix::Persistence_interval
Type for an interval in a persistent diagram or barcode. Stores the birth, death and dimension of the...
Definition persistence_interval.h:40
Gudhi::persistence_matrix::PersistenceMatrixOptions
Concept of the template parameter for the class Matrix.
Definition PersistenceMatrixOptions.h:32
Gudhi::persistence_matrix::PersistenceMatrixOptions::column_indexation_type
static const Column_indexation_types column_indexation_type
Specifies the desired indexation scheme to access the methods of the matrix. See matrix description a...
Definition PersistenceMatrixOptions.h:66
Gudhi::persistence_matrix::PersistenceMatrixOptions::column_type
static const Column_types column_type
Specifies the desired column type. All possible column types are described in Column_types.
Definition PersistenceMatrixOptions.h:60
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_matrix_maximal_dimension_access
static const bool has_matrix_maximal_dimension_access
Only enabled for boundary and chain matrices, i.e., when at least one of the following is true: has_c...
Definition PersistenceMatrixOptions.h:142
Gudhi::persistence_matrix::PersistenceMatrixOptions::Dimension
unspecified Dimension
Type for the dimension. Has to be an integer type. If unsigned, the maximal value of the type should ...
Definition PersistenceMatrixOptions.h:42
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_map_column_container
static const bool has_map_column_container
If set to true, the underlying container containing the matrix columns is an std::unordered_map....
Definition PersistenceMatrixOptions.h:101
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_column_compression
static const bool has_column_compression
Only enabled for base matrices (i.e., none of the following is true: has_column_pairings,...
Definition PersistenceMatrixOptions.h:83
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_row_access
static const bool has_row_access
If set to true, enables the method Matrix::get_row.
Definition PersistenceMatrixOptions.h:111
Gudhi::persistence_matrix::PersistenceMatrixOptions::can_retrieve_representative_cycles
static const bool can_retrieve_representative_cycles
If set to true, enables the methods Matrix::update_representative_cycles and Matrix::get_representati...
Definition PersistenceMatrixOptions.h:161
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_removable_rows
static const bool has_removable_rows
Only enabled if has_row_access is true, ignored otherwise. If set to true, the underlying container c...
Definition PersistenceMatrixOptions.h:124
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_column_and_row_swaps
static const bool has_column_and_row_swaps
Only enabled for base matrices or simple boundary matrices, i.e., when both has_vine_update and can_r...
Definition PersistenceMatrixOptions.h:89
Gudhi::persistence_matrix::PersistenceMatrixOptions::is_z2
static const bool is_z2
If true, indicates that the values contained in the matrix are in and can therefore be treated like ...
Definition PersistenceMatrixOptions.h:56
Gudhi::persistence_matrix::PersistenceMatrixOptions::Index
unspecified Index
Type for the different indexation types and should be able to contain the maximal number of columns o...
Definition PersistenceMatrixOptions.h:48
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_column_pairings
static const bool has_column_pairings
If set to true, enables the method Matrix::get_current_barcode. The matrix will then either be a boun...
Definition PersistenceMatrixOptions.h:148
Gudhi::persistence_matrix::PersistenceMatrixOptions::Field_coeff_operators
unspecified Field_coeff_operators
Field operators. Has to follow the FieldOperators concept. The type will not be used if is_z2 is set ...
Definition PersistenceMatrixOptions.h:37
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_vine_update
static const bool has_vine_update
If set to true, enables the methods Matrix::vine_swap and Matrix::vine_swap_with_z_eq_1_case....
Definition PersistenceMatrixOptions.h:154
Gudhi::persistence_matrix::PersistenceMatrixOptions::is_of_boundary_type
static const bool is_of_boundary_type
Only used, when at least one of the following is true: has_column_pairings, has_vine_update or can_re...
Definition PersistenceMatrixOptions.h:132
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_removable_columns
static const bool has_removable_columns
If set to true, enables the methods Matrix::remove_maximal_cell and Matrix::remove_last,...
Definition PersistenceMatrixOptions.h:106
Gudhi::persistence_matrix::PersistenceMatrixOptions::has_intrusive_rows
static const bool has_intrusive_rows
Only enabled if has_row_access is true, ignored otherwise. If set to true, the underlying container r...
Definition PersistenceMatrixOptions.h:117
unordered_set_column.h
Contains the Gudhi::persistence_matrix::Unordered_set_column class. Also defines the std::hash method...
vector_column.h
Contains the Gudhi::persistence_matrix::Vector_column class. Also defines the std::hash method for Gu...