CGAL 6.2 - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType > Class Template Reference

#include <CGAL/HDVF/Sub_sparse_matrix.h>

Inherits from

CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >.

Definition

template<typename CoefficientRing, int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
class CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >

The class Sub_sparse_matrix_core 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_core inherits Sparse_matrix_core 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
CoefficientRinga model of the IntegralDomainWithoutDivision concept, providing the ring used to compute homology.
StorageFormatan integer constant encoding the storage format of matrices (OSM::COLUMN or OSM::ROW).
SparseChainTypea model of SparseChain used to store chains of the sparse matrix (default: OSM::Sparse_chain).

Public Member Functions

 Sub_sparse_matrix_core (size_t rowCount=0, size_t columnCount=0)
 Constructor with given rows/columns sizes and mask set to full.
 
 Sub_sparse_matrix_core (size_t rowCount, size_t columnCount, const Bitboard &subChain)
 Constructor with given rows/columns sizes and a mask.
 
 Sub_sparse_matrix_core (const Sub_sparse_matrix_core &otherToCopy)
 Copy constructor.
 
 Sub_sparse_matrix_core (const Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType > &otherToCopy)
 Copy constructor.
 
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 past-the-end 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_matrix_coreoperator= (const Sub_sparse_matrix_core &otherToCopy)
 Assignment.
 
bool is_null () const
 Tests if a Sub_sparse_matrix_core is null.
 
bool is_null (const Bitboard &b) const
 Tests if a Sub_sparse_matrix_core with chains restricted to a Bitboard is null.
 
- Public Member Functions inherited from CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >
 Sparse_matrix_core ()
 Default constructor.
 
 Sparse_matrix_core (const size_t rowCount, const size_t columnCount)
 Constructor with given rows/columns sizes.
 
 Sparse_matrix_core (const std::pair< size_t, size_t > dimensions)
 Constructor with given pair of rows/columns sizes.
 
 Sparse_matrix_core (const Sparse_matrix_core &otherToCopy)=default
 
template<int CTF>
 Sparse_matrix_core (const Sparse_matrix_core< CoefficientRing, CTF, SparseChainType > &otherToCopy)
 Copy constructor.
 
void eye (size_t nrows, size_t ncols)
 Sets an identity matrix.
 
void eye (std::pair< size_t, size_t > dimensions)
 Sets an identity matrix.
 
Sparse_matrix_coreoperator= (const Sparse_matrix_core &otherToCopy)=default
 Assignment.
 
void nullify ()
 Cleans a SparseMatrix (set all coefficients to zero).
 
bool is_null ()
 Tests if a Sparse_matrix_core is null.
 
bool is_empty ()
 Tests if a Sparse_matrix_core is empty.
 
int storage_format () const
 Returns the storage format of the matrix.
 
template<int _CTF>
Sparse_matrix_core operator+ (const Sparse_matrix_core< CoefficientRing, _CTF > &other)
 Adds two matrices into a new matrix.
 
template<int _CTF>
Sparse_matrix_core operator- (const Sparse_matrix_core< CoefficientRing, _CTF > &other)
 Subtracts two matrices into a new matrix.
 
Sparse_matrix_core operator* (const CoefficientRing &lambda)
 Applies factor on each coefficients into a new matrix.
 
Sparse_matrix_coreoperator*= (const CoefficientRing &lambda)
 Applies factor on each coefficients and assign.
 
Sparse_matrix_core operator- ()
 Computes the negative of a matrix (unary operator).
 
Matrix_chain operator[] (size_t index) const
 Gets the value of a chain from a const matrix.
 
Matrix_chain chain (size_t index) const
 Gets the value of a chain from a const matrix.
 
Sparse_matrix_core operator/ (const std::vector< size_t > &_indices)
 Removes a set of chains from a copy of the matrix.
 
Sparse_matrix_core operator/ (size_t index)
 Removes the chain at a given index from a copy of the matrix.
 
Sparse_matrix_coreoperator/= (const std::vector< size_t > &indices)
 Removes a set of chains from a matrix.
 
Sparse_matrix_coreoperator/= (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 past-the-end of chain 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 past-the-end of chain indices.
 
Sparse_matrix_core< Coefficient_ring,(COLUMN|ROW)&(~StorageFormat), SparseChainType > transpose () const
 Transposes a matrix.
 
std::pair< size_t, size_t > dimensions () const
 Gets the matrix sizes.
 

Protected Attributes

Bitboard _subChains
 
Bitboard _subChainsStates
 
- Protected Attributes inherited from CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >
std::vector< Sparse_chain_type< CoefficientRing, StorageFormat > > _chains
 
Bitboard _chainsStates
 
std::pair< size_t, size_t > _size
 

Friends

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

Additional Inherited Members

- Public Types inherited from CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >
typedef CoefficientRing Coefficient_ring
 Type of coefficient ring.
 
template<typename _CT , int _SF>
using Sparse_chain_type = SparseChainType< _CT, _SF >
 Type of sparse chains used in the matrix.
 
typedef Sparse_chain_type< CoefficientRing, StorageFormat > Matrix_chain
 Type of chains associated to the matrix.
 
- Protected Member Functions inherited from CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >
Matrix_chainoperator[] (const size_t _index)
 
void set_coefficient (const size_t i, const size_t j, const Coefficient_ring d)
 
Coefficient_ring get_coefficient (const size_t i, const size_t j) const
 
Sparse_matrix_coreremove_column (size_t index)
 
Sparse_matrix_coreremove_row (size_t index)
 
Sparse_matrix_coreswap_rows (size_t i, size_t j)
 
Sparse_matrix_coreswap_columns (size_t i, size_t j)
 
Sparse_matrix_coreremove_coefficient (size_t i, size_t j)
 

Constructor & Destructor Documentation

◆ Sub_sparse_matrix_core() [1/2]

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::Sub_sparse_matrix_core ( size_t  rowCount = 0,
size_t  columnCount = 0 
)

Constructor with given rows/columns sizes and mask set to full.

Constructor with sizes, initializes an empty Sub_sparse_matrix_core of a given size along rows/columns. The constructor sets the mask to full.

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

◆ Sub_sparse_matrix_core() [2/2]

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::Sub_sparse_matrix_core ( 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_core of given size along rows/columns and a given mask.

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

Member Function Documentation

◆ is_null() [1/2]

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
bool CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::is_null ( ) const

Tests if a Sub_sparse_matrix_core is null.

The function return true is the Sub_sparse_matrix_core is null (that is, all the chains in the mask are empty) and false otherwise.

◆ is_null() [2/2]

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
bool CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::is_null ( const Bitboard b) const

Tests if a Sub_sparse_matrix_core with chains restricted to a Bitboard is null.

The function return true is the restricted Sub_sparse_matrix_core is null (that is, all the chains in the mask, restricted to the Bitboard b are null) and false otherwise.

◆ set_bit_off()

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
void CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::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
indexIndex to turn off in the mask.

◆ set_bit_on()

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
void CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::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
indexIndex to turn on in the mask.

◆ set_sub()

template<typename CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
void CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::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 CoefficientRing , int StorageFormat, template< typename, int > typename SparseChainType = OSM::Sparse_chain>
std::ostream & operator<< ( std::ostream &  stream,
const Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType > &  matrix 
)
friend

Displays a Sub_sparse_matrix_core in the output stream.

Displays the sparse matrix as well as its mask.

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