CGAL 6.1 - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType > Class Template Reference

#include <CGAL/HDVF/Sub_chain_complex_mask.h>

Definition

template<typename CoefficientType, typename ComplexType>
class CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >

The class Sub_chain_complex_mask is a technical class implementing a sub chain complex.

A sub chain complex \(A\) of a chain complex \(K\) is a subset \(A\subseteq K\) such that the restricted boundary operator \(\partial_A = \partial_K|_A\) still satisfies \(\partial_A^2 = 0\).

The Sub_chain_complex_mask class is used to compute reduced homology. This class is based on a set of bitboard masks (one in each dimension) used to define sub chain complexes and their associated reduction encoded in sub-sparse matrices (OSM::Sub_sparse_matrix class). Technically, Sub_chain_complex_mask are used to partially screen chain complexes and chains in associated boundary matrices, and hence compute homology "locally".

Warning
For efficiency reasons, when a Sub_chain_complex_mask is used to screen sparse matrices (with the screen_matrices method), screening is only performed on the major direction of matrices (thus column-major matrices are restricted over columns and row-major matrices are restricted over rows). Iterators are restricted accordingly. But chains themselves are not restricted.
However, if A is a proper sub-complex of K (that is, closed with respect to faces), chains automatically comply with the screening. Indeed, for any \(q\)-cell \(\sigma\in A\) (thus the corresponding bit is on in the mask), all the faces of \(\sigma\) also belong to \(A\). Thus for any \(q-1\)-cell \(\tau\) in the boundary of \(\sigma\) (that is, such that \(\langle\partial_k(\sigma),\tau\rangle\neq 0\)), \(\tau\) belongs to \(A\) (and thus the corresponding bit in the mask is also on).
Template Parameters
CoefficientTypea model of the Ring concept.
ComplexTypea model of the AbstractChainComplex concept (type of the chain complex screened by Sub_chain_complex_mask).
Examples
HDVF/main_dual_hdvf.cpp.

Public Member Functions

 Sub_chain_complex_mask (const ComplexType &K, bool full=true)
 Constructor from a complex.
 
 Sub_chain_complex_mask (const ComplexType &K, const std::vector< std::vector< int > > &cells, bool close=true)
 Constructor from an enumeration of cells.
 
 Sub_chain_complex_mask (const Sub_chain_complex_mask &otherToCopy)
 Constructor by copy.
 
Sub_chain_complex_maskoperator= (const Sub_chain_complex_mask &otherToCopy)
 Assignment operator.
 
Sub_chain_complex_mask complement ()
 Returns the complement of the mask.
 
bool get_bit (int q, int i) const
 Gets a bit of the mask (bit i in dimension q).
 
void set_bit_on (int q, int i)
 Sets a bit to 1 (bit i in dimension q).
 
void set_bit_off (int q, int i)
 Sets a bit to 0 (bit i in dimension q).
 
const std::vector< OSM::Bitboard > & get_bitboard () const
 Gets the bitboards of the sub chain complex.
 
const OSM::Bitboardget_bitboard (int q) const
 Gets the bitboard of the sub chain complex in dimension q.
 
template<typename CT , int CTF>
void screen_matrices (std::vector< OSM::Sub_sparse_matrix< CT, CTF > > &matrices)
 Screens a sequence of Sub_sparse_matrix (in each dimension).
 
template<typename CT , int CTF>
void screen_chain (OSM::Sparse_chain< CT, CTF > &chain, int q)
 Restricts a chain in a given dimension to the sub chain complex maks.
 

Protected Attributes

int _dim
 Dimension of the underlying complex.
 
std::vector< OSM::Bitboard_sub
 Vector of bitboards coding masks in each dimension.
 
std::vector< int > _nb_cells
 Number of cells in the mask in each dimension.
 
const ComplexType & _K
 Constant reference to the underlying complex.
 
bool _full
 Is full sub_complex.
 

Friends

std::ostream & operator<< (std::ostream &out, const Sub_chain_complex_mask &sub)
 Overload of the <<operator for Sub_chain_complex_mask.
 

Constructor & Destructor Documentation

◆ Sub_chain_complex_mask() [1/3]

template<typename CoefficientType , typename ComplexType >
CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::Sub_chain_complex_mask ( const ComplexType &  K,
bool  full = true 
)

Constructor from a complex.

Build a Sub_chain_complex_mask associated to K with all bits set to 1 in the masks if full is true, and all bits set to 0 otherwise.

Parameters
[in]KA constant reference to the underlying complex.
[in]fullBuild full / empty masks (default: full).

◆ Sub_chain_complex_mask() [2/3]

template<typename CoefficientType , typename ComplexType >
CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::Sub_chain_complex_mask ( const ComplexType &  K,
const std::vector< std::vector< int > > &  cells,
bool  close = true 
)

Constructor from an enumeration of cells.

Build masks associated to the underlying complex K with all bits corresponding to cells (and their faces if close is true) set to 1.

Parameters
[in]KA constant reference to the underlying complex.
[in]cellsA vector containing, in each dimension, a vector of cells indexes.
[in]closeIf this boolean is true, the faces of cells are also set to 1.

◆ Sub_chain_complex_mask() [3/3]

template<typename CoefficientType , typename ComplexType >
CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::Sub_chain_complex_mask ( const Sub_chain_complex_mask< CoefficientType, ComplexType > &  otherToCopy)

Constructor by copy.

Builds a Sub_chain_complex_mask by copy from another.

Parameters
[in]otherToCopyAn initial Sub_chain_complex_mask.

Member Function Documentation

◆ complement()

template<typename CoefficientType , typename ComplexType >
Sub_chain_complex_mask CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::complement ( )

Returns the complement of the mask.

The method return a new Sub_chain_complex_mask containing the complement of the current mask (0 and 1 bits in the mask are exchanged).

◆ get_bitboard()

template<typename CoefficientType , typename ComplexType >
const std::vector< OSM::Bitboard > & CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::get_bitboard ( ) const

Gets the bitboards of the sub chain complex.

Returns a constant reference to the vector of bitboards in each dimension.

◆ operator=()

template<typename CoefficientType , typename ComplexType >
Sub_chain_complex_mask & CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::operator= ( const Sub_chain_complex_mask< CoefficientType, ComplexType > &  otherToCopy)

Assignment operator.

Warning
The operator argument must provide a sub chain complex mask over the same underlying chain complex. It not so, the assignment will throw an exception.
Parameters
[in]otherToCopyA Sub_chain_complex_mask copied into this (otherToCopy and this must have the same underlying chain complex).

◆ screen_chain()

template<typename CoefficientType , typename ComplexType >
template<typename CT , int CTF>
void CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::screen_chain ( OSM::Sparse_chain< CT, CTF > &  chain,
int  q 
)

Restricts a chain in a given dimension to the sub chain complex maks.

Nullify all coefficients out of the mask.

Parameters
[in]chainThe chain restricted.
[in]qDimension of the chain.

◆ screen_matrices()

template<typename CoefficientType , typename ComplexType >
template<typename CT , int CTF>
void CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::screen_matrices ( std::vector< OSM::Sub_sparse_matrix< CT, CTF > > &  matrices)

Screens a sequence of Sub_sparse_matrix (in each dimension).

Given a sequence of matrices (vector of Sub_sparse_matrices) sets the masks of Sub_sparse_matrices in each dimension to the current Sub_chain_complex_mask.

Warning
For efficiency, screening is performed on the major direction of matrices (so along columns for column-major matrices and along row for row-major matrices).
Parameters
[in]matricesA vector of Sub_sparse_matrix (in each dimension).

Member Data Documentation

◆ _full

template<typename CoefficientType , typename ComplexType >
bool CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::_full
protected

Is full sub_complex.

This boolean flag is true is all bits in the bitboards are on.