CGAL 6.1 - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag > Class Template Reference

#include <CGAL/HDVF/Sub_sparse_matrix.h>

Inherits from

CGAL::OSM::Sparse_matrix< CoefficientType, ChainTypeFlag >.

Definition

template<typename CoefficientType, int ChainTypeFlag>
class CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >

The class Sub_sparse_matrix is a technical class implementing the concept SparseMatrix together with a system of masks to partially screen matrices (and restrict computations to a subset of indices along their major direction).

This class is used to compute reduced homology (and thus to compute persistent homology and Alexander duality).

Sub_sparse_matrix inherits Sparse_matrix structure and basically adds two bitboards:

  • one describing indices of cells belonging to the subset of indices considered (let us denote it by \(A\))
  • the second providing indices of non-empty chains in \(A\)

The class does not modify linear algebra operators, but focuses on adapted iterators, output operators and methods to adjust the "mask".

Is model of
SparseMatrix
Template Parameters
CoefficientTypea model of the Ring concept, providing the ring used to compute homology.
ChainTypeFlagan integer constant encoding the type of matrices (OSM::COLUMN or OSM::ROW).

Public Member Functions

 Sub_sparse_matrix (size_t rowCount=0, size_t columnCount=0)
 Default constructor of a new Sub_sparse_matrix (with given rows/columns sizes and mask set to full).
 
 Sub_sparse_matrix (size_t rowCount, size_t columnCount, const Bitboard &subChain)
 Constructor with given rows/columns sizes and a mask.
 
 Sub_sparse_matrix (const Sub_sparse_matrix &otherToCopy)
 Copy constructor from another Sub_sparse_matrix.
 
 Sub_sparse_matrix (const Sparse_matrix< CoefficientType, ChainTypeFlag > &otherToCopy)
 Copy constructor from Sparse_matrix.
 
Bitboard::iterator begin () const noexcept
 Iterator to the beginning of the indices of non empty chains inside the mask.
 
Bitboard::iterator end () const noexcept
 Iterator to the end of the of the indices of non empty chains inside the mask.
 
void set_sub (const Bitboard &new_subChains)
 Changes the indices subset mask.
 
void set_bit_on (size_t index)
 Adds an index to the mask.
 
void set_bit_off (size_t index)
 Removes an index from the mask.
 
void complement ()
 Changes the mask to its complement.
 
Sub_sparse_matrixoperator= (const Sub_sparse_matrix &otherToCopy)
 Assigns to other Sub_sparse_matrix.
 
- Public Member Functions inherited from CGAL::OSM::Sparse_matrix< CoefficientType, ChainTypeFlag >
 Sparse_matrix ()
 Default constructor (empty new Sparse_matrix object).
 
 Sparse_matrix (const size_t rowCount, const size_t columnCount)
 Constructor with given rows/columns sizes.
 
template<int CTF>
 Sparse_matrix (const Sparse_matrix< CoefficientType, CTF > &otherToCopy)
 Copy constructor.
 
Sparse_matrixoperator= (const Sparse_matrix &otherToCopy)
 Assigns to other matrix.
 
void nullify ()
 Cleans a SparseMatrix (set all coefficients to zero).
 
bool is_null ()
 Tests if a SparseMatrix is null.
 
Sparse_matrixoperator+= (const Sparse_matrix &other)
 Matrices sum and assign: COLUMN += COLUMN or ROW += ROW.
 
Sparse_matrixoperator-= (const Sparse_matrix &other)
 Matrices subtraction and assign: COLUMN -= COLUMN or ROW -= ROW.
 
Sparse_matrixoperator*= (const CoefficientType &lambda)
 Applies factor on each coefficients and assign.
 
MatrixChain operator[] (size_t index) const
 Gets the value of a chain from a const matrix.
 
Sparse_matrixoperator/= (const std::vector< size_t > &indexes)
 Removes a set of chains from a matrix.
 
Sparse_matrixoperator/= (const size_t index)
 Removes the chain at a given index from a matrix.
 
Bitboard::iterator begin () const noexcept
 Iterator to the index of the first non null chain.
 
Bitboard::iterator end () const noexcept
 Iterator to the ending of chains indices.
 
Bitboard::reverse_iterator reverse_begin () noexcept
 Reverse iterator to the index of the last non null chain.
 
Bitboard::reverse_iterator reverse_begin (size_t index) noexcept
 
Bitboard::reverse_iterator reverse_end () noexcept
 Reverse iterator to the ending of chains indices.
 
Sparse_matrix< CoefficientType, COLUMN+ROW - ChainTypeFlag > transpose ()
 Transposes a matrix.
 
std::pair< size_t, size_t > dimensions () const
 Gets the matrix sizes.
 

Protected Attributes

Bitboard _subChains
 A bitboard describing subchains restriction.
 
Bitboard _subChainsStates
 A bitboard containing state of each chain (restricted to subchains).
 
- Protected Attributes inherited from CGAL::OSM::Sparse_matrix< CoefficientType, ChainTypeFlag >
std::vector< Sparse_chain< CoefficientType, ChainTypeFlag > > _chains
 
Bitboard _chainsStates
 
std::pair< size_t, size_t > _size
 

Friends

std::ostream & operator<< (std::ostream &stream, const Sub_sparse_matrix &matrix)
 Displays a Sub_sparse_matrix in the output stream.
 

Additional Inherited Members

- Public Types inherited from CGAL::OSM::Sparse_matrix< CoefficientType, ChainTypeFlag >
typedef Sparse_chain< CoefficientType, ChainTypeFlag > MatrixChain
 Type of chains associated to the matrix.
 
- Protected Member Functions inherited from CGAL::OSM::Sparse_matrix< CoefficientType, ChainTypeFlag >
MatrixChainoperator[] (const size_t _index)
 
void set_coef (const size_t i, const size_t j, const CoefficientType d)
 
CoefficientType get_coef (const size_t i, const size_t j) const
 
Sparse_matrixdel_column (size_t index)
 
Sparse_matrixdel_row (size_t index)
 
Sparse_matrixdel_coef (size_t i, size_t j)
 

Constructor & Destructor Documentation

◆ Sub_sparse_matrix() [1/4]

template<typename CoefficientType , int ChainTypeFlag>
CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::Sub_sparse_matrix ( size_t  rowCount = 0,
size_t  columnCount = 0 
)

Default constructor of a new Sub_sparse_matrix (with given rows/columns sizes and mask set to full).

Default constructor. Constructor with sizes, initialize an empty Sub_sparse_matrix of type ChainTypeFlag with coefficients of type CoefficientType, a given size along rows/columns. The constructor sets the mask to full.

Parameters
[in]rowCountThe number of rows to preallocate (default 0).
[in]columnCountThe number of columns to preallocate (default 0).

◆ Sub_sparse_matrix() [2/4]

template<typename CoefficientType , int ChainTypeFlag>
CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::Sub_sparse_matrix ( size_t  rowCount,
size_t  columnCount,
const Bitboard subChain 
)

Constructor with given rows/columns sizes and a mask.

Create a new empty Sub_sparse_matrix of type ChainTypeFlag with coefficients of type CoefficientType, a given size along rows/columns and a given mask.

Parameters
[in]rowCountThe number of rows to preallocate.
[in]columnCountThe number of columns to preallocate.
[in]subChainBitboard describing the subset of indices considered as a mask.

◆ Sub_sparse_matrix() [3/4]

template<typename CoefficientType , int ChainTypeFlag>
CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::Sub_sparse_matrix ( const Sub_sparse_matrix< CoefficientType, ChainTypeFlag > &  otherToCopy)

Copy constructor from another Sub_sparse_matrix.

Create a new empty Sub_sparse_matrix from another of type ChainTypeFlag with coefficients of type CoefficientType, a given size along rows/columns and a given mask.

Parameters
[in]otherToCopySub_sparse_matrix copied into this.

◆ Sub_sparse_matrix() [4/4]

template<typename CoefficientType , int ChainTypeFlag>
CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::Sub_sparse_matrix ( const Sparse_matrix< CoefficientType, ChainTypeFlag > &  otherToCopy)

Copy constructor from Sparse_matrix.

Create a new Sub_sparse_matrix from a Sparse_matrix object (with the same ChainTypeFlag). Create a "full" mask.

Parameters
[in]otherToCopyThe matrix copied.

Member Function Documentation

◆ operator=()

template<typename CoefficientType , int ChainTypeFlag>
Sub_sparse_matrix & CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::operator= ( const Sub_sparse_matrix< CoefficientType, ChainTypeFlag > &  otherToCopy)

Assigns to other Sub_sparse_matrix.

Assign to other matrix coefficient-wise, and copy the bitboard.

Precondition
The matrices must have the same type.
Parameters
[in]otherToCopyThe matrix we want to copy.
Returns
The reference to the modified matrix.

◆ set_bit_off()

template<typename CoefficientType , int ChainTypeFlag>
void CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::set_bit_off ( size_t  index)

Removes an index from the mask.

Set the bit encoding a given index to 0 (ie. remove the index from the mask).

Parameters
[in]indexIndex to turn off in the mask.

◆ set_bit_on()

template<typename CoefficientType , int ChainTypeFlag>
void CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::set_bit_on ( size_t  index)

Adds an index to the mask.

Set the bit encoding a given index to 1 (ie. add the index in the mask).

Parameters
[in]indexIndex to turn on in the mask.

◆ set_sub()

template<typename CoefficientType , int ChainTypeFlag>
void CGAL::OSM::Sub_sparse_matrix< CoefficientType, ChainTypeFlag >::set_sub ( const Bitboard new_subChains)

Changes the indices subset mask.

Set a new mask encoding a new subset of indices along the major dimension.

Friends And Related Function Documentation

◆ operator<<

template<typename CoefficientType , int ChainTypeFlag>
std::ostream & operator<< ( std::ostream &  stream,
const Sub_sparse_matrix< CoefficientType, ChainTypeFlag > &  matrix 
)
friend

Displays a Sub_sparse_matrix in the output stream.

Displays the sparse matrix as well as its mask.

Parameters
[in]streamThe output stream.
[in]matrixThe matrix to display.
Returns
A reference to the modified stream.