Loading...
Searching...
No Matches
Gudhi::persistence_matrix::Base_matrix< Master_matrix > Class Template Reference
Persistence Matrix

A basic matrix structure allowing to easily manipulate and access entire columns and rows, but not individual entries. More...

`#include <gudhi/Persistence_matrix/Base_matrix.h>`

## Public Types

using | Index = typename Master_matrix::Index
using | Dimension = typename Master_matrix::Dimension
using | Field_operators = typename Master_matrix::Field_operators
| Field operators class. Necessary only if PersistenceMatrixOptions::is_z2 is false.
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

## Public Member Functions

| Base_matrix (Column_settings *colSettings)
| Constructs an empty matrix.
template<class Container = Boundary>
| Base_matrix (const std::vector< Container > &columns, Column_settings *colSettings)
| Constructs a matrix from the given ordered columns. The columns are inserted in the given order.
| Base_matrix (unsigned int numberOfColumns, Column_settings *colSettings)
| Constructs a new empty matrix and reserves space for the given number of columns.
| Base_matrix (const Base_matrix &matrixToCopy, Column_settings *colSettings=nullptr)
| Copy constructor. If `colSettings` is not a null pointer, its value is kept instead of the one in the copied matrix.
| Base_matrix (Base_matrix &&other) noexcept
| Move constructor.
template<class Container = Boundary>
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_representative. The content of the range is assumed to be sorted by increasing ID value.
template<class Container = Boundary>
void | insert_column (const Container &column, Index columnIndex)
| Inserts a new ordered column at the given index by copying the given range of Matrix::Entry_representative. There should not be any other column inserted at that index which was not explicitly removed before. The content of the range is assumed to be sorted by increasing ID value. Not available when row access is enabled.
template<class Boundary_range>
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.
Column & | get_column (Index columnIndex)
| Returns the column at the given MatIdx index. The type of the column depends on the chosen options, see PersistenceMatrixOptions::column_type.
Row & | get_row (Index rowIndex)
| Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row index of the matrix. The type of the row depends on the chosen options, see PersistenceMatrixOptions::has_intrusive_rows.
void | remove_column (Index columnIndex)

Only available if PersistenceMatrixOptions::has_map_column_container is true. Otherwise, see remove_last. Erases the given column from the matrix. If the given column index corresponded to the last used column index, the "new last column index" will be columnIndex - 1, even if a column was never explicitly inserted at this index (possible when insert_column(column, columnIndex) was used). If the column didn't existed, it will simply be considered as an empty column.

void | remove_last ()
| Removes the last column from the matrix. The last column is at index \( max(ins1, ins2, rem - 1) \), where:
void | erase_empty_row (Index rowIndex)
| If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true: assumes that the row is empty and removes it. If PersistenceMatrixOptions::has_map_column_container and PersistenceMatrixOptions::has_column_and_row_swaps are true: cleans up maps used for the lazy row swaps. Otherwise, does nothing.
Index | get_number_of_columns () const
| Returns the current number of columns in the matrix.
template<class Entry_range_or_column_index>
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.
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)
| Multiplies the target column with the coefficient and then adds the source column to it. That is: targetColumn = (targetColumn * coefficient) + sourceColumn.
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)
| Multiplies the source column with the coefficient before adding it to the target column. That is: targetColumn += (coefficient * sourceColumn). The source column will not be modified.
void | zero_entry (Index columnIndex, Index rowIndex)
| Zeroes the entry at the given coordinates.
void | zero_column (Index columnIndex)
| Zeroes the column at the given index.
bool | is_zero_entry (Index columnIndex, Index rowIndex) const
| Indicates if the entry at given coordinates has value zero.
bool | is_zero_column (Index columnIndex)
| Indicates if the column at given index has value zero.
void | reset (Column_settings *colSettings)
| Resets the matrix to an empty matrix.
Base_matrix & | operator= (const Base_matrix &other)
| Assign operator.

## Friends

void | swap (Base_matrix &matrix1, Base_matrix &matrix2)
| Swap operator.

## Detailed Description

template<class Master_matrix>
class Gudhi::persistence_matrix::Base_matrix< Master_matrix >

A basic matrix structure allowing to easily manipulate and access entire columns and rows, but not individual entries.

Template Parameters

  Master_matrix | An instantiation of Matrix from which all types and options are deduced.

## Member Typedef Documentation

## Boundary

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Boundary = typename Master_matrix::Boundary

Type of the column container.

## Column

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Column = typename Master_matrix::Column

Column type.

## Column_settings

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Column_settings = typename Master_matrix::Column_settings

Structure giving access to the columns to necessary external classes.

## Dimension

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Dimension = typename Master_matrix::Dimension

Dimension value type.

## Entry_constructor

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Entry_constructor = typename Master_matrix::Entry_constructor

Factory of Entry classes.

## Field_element

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Field_element = typename Master_matrix::Element

Type of a field element.

## Index

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Index = typename Master_matrix::Index

Container index type.

## Row

template<class Master_matrix>

using Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Row = typename Master_matrix::Row

Row type, only necessary with row access option.

## Constructor & Destructor Documentation

## Base_matrix() [1/5]

template<class Master_matrix>

Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Base_matrix | ( | Column_settings * | colSettings | ) |

inline

Constructs an empty matrix.

Parameters

  colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the chosen column type, such as custom allocators.

## Base_matrix() [2/5]

template<class Master_matrix>
template<class Container>

Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Base_matrix | ( | const std::vector< Container > & | columns,
|  | Column_settings * | colSettings )

inline

Constructs a matrix from the given ordered columns. The columns are inserted in the given order.

Template Parameters

  Container | Range type for Matrix::Entry_representative ranges. Assumed to have a begin(), end() and size() method.

Parameters

  columns | A vector of Matrix::Entry_representative ranges to construct the columns from. The content of the ranges are assumed to be sorted by increasing ID value.
  colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the chosen column type, such as custom allocators.

## Base_matrix() [3/5]

template<class Master_matrix>

Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Base_matrix | ( | unsigned int | numberOfColumns,
|  | Column_settings * | colSettings )

inline

Constructs a new empty matrix and reserves space for the given number of columns.

Parameters

  numberOfColumns | Number of columns to reserve space for.
  colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the chosen column type, such as custom allocators.

## Base_matrix() [4/5]

template<class Master_matrix>

Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Base_matrix | ( | const Base_matrix< Master_matrix > & | matrixToCopy,
|  | Column_settings * | colSettings = nullptr )

inline

Copy constructor. If `colSettings` is not a null pointer, its value is kept instead of the one in the copied matrix.

Parameters

  matrixToCopy | Matrix to copy.
  colSettings | Either a pointer to an existing setting structure for the columns or a null pointer. The structure should contain all the necessary external classes specifically necessary for the chosen column type, such as custom allocators. If null pointer, the pointer stored in `matrixToCopy` is used instead.

## Base_matrix() [5/5]

template<class Master_matrix>

Gudhi::persistence_matrix::Base_matrix< Master_matrix >::Base_matrix | ( | Base_matrix< Master_matrix > && | other | ) |

inline noexcept

Move constructor.

Parameters

  other | Matrix to move.

## Member Function Documentation

## add_to()

template<class Master_matrix>
template<class Entry_range_or_column_index>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::add_to | ( | const Entry_range_or_column_index & | sourceColumn,
|  | Index | targetColumnIndex )

inline

Adds column represented by `sourceColumn` onto the column at `targetColumnIndex` in the matrix.

Template Parameters

  Entry_range_or_column_index | Either a range of Entry with a begin() and end() method, or any integer type.

Parameters

  sourceColumn | Either an entry range or the MatIdx index of the column to add.
  targetColumnIndex | MatIdx index of the target column.

## erase_empty_row()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::erase_empty_row | ( | Index | rowIndex | ) |

inline

If PersistenceMatrixOptions::has_row_access and PersistenceMatrixOptions::has_removable_rows are true: assumes that the row is empty and removes it. If PersistenceMatrixOptions::has_map_column_container and PersistenceMatrixOptions::has_column_and_row_swaps are true: cleans up maps used for the lazy row swaps. Otherwise, does nothing.

Warning
  The removed rows are always assumed to be empty. If it is not the case, the deleted row entries are not removed from their columns. And in the case of intrusive rows, this will generate a segmentation fault when the column entries are destroyed later. The row access is just meant as a "read only" access to the rows and the erase_empty_row method just as a way to specify that a row is empty and can therefore be removed from dictionaries. This allows to avoid testing the emptiness of a row at each column entry removal, what can be quite frequent.

Parameters

  rowIndex | Row index of the empty row.

## get_column()

template<class Master_matrix>

Base_matrix< Master_matrix >::Column & Gudhi::persistence_matrix::Base_matrix< Master_matrix >::get_column | ( | Index | columnIndex | ) |

inline

Returns the column at the given MatIdx index. The type of the column depends on the chosen options, see PersistenceMatrixOptions::column_type.

Note that before returning the column, all column entries can eventually be reordered, if lazy swaps occurred. It is therefore recommended to avoid calling get_column between column or row swaps, otherwise the benefits of the the laziness is lost.

Parameters

  columnIndex | MatIdx index of the column to return.

Returns
  Reference to the column.

## get_number_of_columns()

template<class Master_matrix>

Base_matrix< Master_matrix >::Index Gudhi::persistence_matrix::Base_matrix< Master_matrix >::get_number_of_columns | ( |  | ) | const

inline

Returns the current number of columns in the matrix.

Returns
  The number of columns.

## get_row()

template<class Master_matrix>

Base_matrix< Master_matrix >::Row & Gudhi::persistence_matrix::Base_matrix< Master_matrix >::get_row | ( | Index | rowIndex | ) |

inline

Only available if PersistenceMatrixOptions::has_row_access is true. Returns the row at the given row index of the matrix. The type of the row depends on the chosen options, see PersistenceMatrixOptions::has_intrusive_rows.

Note that before returning the row, all column entries can eventually be reordered, if lazy swaps occurred. It is therefore recommended to avoid calling get_row between column or row swaps, otherwise the benefits of the the laziness is lost.

Parameters

  rowIndex | Row index of the row to return.

Returns
  Reference to the row.

## insert_boundary()

template<class Master_matrix>
template<class Boundary_range>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::insert_boundary | ( | const Boundary_range & | boundary,
|  | Dimension | dim = Master_matrix::template get_null_value<Dimension>() )

inline

Same as insert_column, only for interface purposes. The given dimension is ignored and not stored.

Template Parameters

  Boundary_range | Range of Matrix::Entry_representative. Assumed to have a begin(), end() and size() method.

Parameters

  boundary | Range of Matrix::Entry_representative from which the column has to be constructed. Assumed to be ordered by increasing ID value.
  dim | Ignored.

## insert_column() [1/2]

template<class Master_matrix>
template<class Container>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::insert_column | ( | const Container & | column | ) |

inline

Inserts a new ordered column at the end of the matrix by copying the given range of Matrix::Entry_representative. The content of the range is assumed to be sorted by increasing ID value.

Template Parameters

  Container | Range of Matrix::Entry_representative. Assumed to have a begin(), end() and size() method.

Parameters

  column | Range of Matrix::Entry_representative from which the column has to be constructed. Assumed to be ordered by increasing ID value.

## insert_column() [2/2]

template<class Master_matrix>
template<class Container>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::insert_column | ( | const Container & | column,
|  | Index | columnIndex )

inline

Inserts a new ordered column at the given index by copying the given range of Matrix::Entry_representative. There should not be any other column inserted at that index which was not explicitly removed before. The content of the range is assumed to be sorted by increasing ID value. Not available when row access is enabled.

Template Parameters

  Container | Range of Matrix::Entry_representative. Assumed to have a begin(), end() and size() method.

Parameters

  column | Range of Matrix::Entry_representative from which the column has to be constructed. Assumed to be ordered by increasing ID value.
  columnIndex | MatIdx index to which the column has to be inserted.

## is_zero_column()

template<class Master_matrix>

bool Gudhi::persistence_matrix::Base_matrix< Master_matrix >::is_zero_column | ( | Index | columnIndex | ) |

inline

Indicates if the column at given index has value zero.

Parameters

  columnIndex | MatIdx index of the column.

Returns
  true If the column has value zero.
  false Otherwise.

## is_zero_entry()

template<class Master_matrix>

bool Gudhi::persistence_matrix::Base_matrix< Master_matrix >::is_zero_entry | ( | Index | columnIndex,
|  | Index | rowIndex ) const

inline

Indicates if the entry at given coordinates has value zero.

Parameters

  columnIndex | MatIdx index of the column of the entry.
  rowIndex | Row index of the row of the entry.

Returns
  true If the entry has value zero.
  false Otherwise.

## multiply_source_and_add_to()

template<class Master_matrix>
template<class Entry_range_or_column_index>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::multiply_source_and_add_to | ( | const Field_element & | coefficient,
|  | const Entry_range_or_column_index & | sourceColumn,
|  | Index | targetColumnIndex )

inline

Multiplies the source column with the coefficient before adding it to the target column. That is: targetColumn += (coefficient * sourceColumn). The source column will not be modified.

Template Parameters

  Entry_range_or_column_index | Either a range of Entry with a begin() and end() method, or any integer type.

Parameters

  coefficient | Value to multiply.
  sourceColumn | Either an entry range or the MatIdx index of the column to add.
  targetColumnIndex | MatIdx index of the target column.

## multiply_target_and_add_to()

template<class Master_matrix>
template<class Entry_range_or_column_index>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::multiply_target_and_add_to | ( | const Entry_range_or_column_index & | sourceColumn,
|  | const Field_element & | coefficient,
|  | Index | targetColumnIndex )

inline

Multiplies the target column with the coefficient and then adds the source column to it. That is: targetColumn = (targetColumn * coefficient) + sourceColumn.

Template Parameters

  Entry_range_or_column_index | Either a range of Entry with a begin() and end() method, or any integer type.

Parameters

  sourceColumn | Either an entry range or the MatIdx index of the column to add.
  coefficient | Value to multiply.
  targetColumnIndex | MatIdx index of the target column.

## remove_column()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::remove_column | ( | Index | columnIndex | ) |

inline

Only available if PersistenceMatrixOptions::has_map_column_container is true. Otherwise, see remove_last. Erases the given column from the matrix. If the given column index corresponded to the last used column index, the "new last column index" will be columnIndex - 1, even if a column was never explicitly inserted at this index (possible when insert_column(column, columnIndex) was used). If the column didn't existed, it will simply be considered as an empty column.

If PersistenceMatrixOptions::has_row_access is also true, the deleted column entries are also automatically removed from their respective rows.

Parameters

  columnIndex | MatIdx index of the column to remove.

## remove_last()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::remove_last | ( |  | ) |

inline

Removes the last column from the matrix. The last column is at index \( max(ins1, ins2, rem - 1) \), where:

- \( ins1 \) is the index of the last column inserted by insert_column(column),
- \( ins2 \) is largest index used with insert_column(column, columnIndex),
- \( rem \) is the last index just before the last call of remove_column or remove_last.

If \( max(ins1, ins2, rem - 1) = rem - 1 \) but no column was explicitly inserted at that index (possible by the use of insert_column(column, columnIndex)), the column is assumed to be an empty column.

See also remove_column.

## reset()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::reset | ( | Column_settings * | colSettings | ) |

inline

Resets the matrix to an empty matrix.

Parameters

  colSettings | Pointer to an existing setting structure for the columns. The structure should contain all the necessary external classes specifically necessary for the chosen column type, such as custom allocators.

## zero_column()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::zero_column | ( | Index | columnIndex | ) |

inline

Zeroes the column at the given index.

Parameters

  columnIndex | MatIdx index of the column to zero.

## zero_entry()

template<class Master_matrix>

void Gudhi::persistence_matrix::Base_matrix< Master_matrix >::zero_entry | ( | Index | columnIndex,
|  | Index | rowIndex )

inline

Zeroes the entry at the given coordinates.

Parameters

  columnIndex | MatIdx index of the column of the entry.
  rowIndex | Row index of the row of the entry.

The documentation for this class was generated from the following file:

- include/gudhi/Persistence_matrix/Base_matrix.h