|
CGAL 6.1 - Homological Discrete Vector Fields
|
#include <CGAL/HDVF/Sub_chain_complex_mask.h>
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".
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.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).| CoefficientType | a model of the Ring concept. |
| ComplexType | a model of the AbstractChainComplex concept (type of the chain complex screened by Sub_chain_complex_mask). |
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_mask & | operator= (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::Bitboard & | get_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. | |
| 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.
| [in] | K | A constant reference to the underlying complex. |
| [in] | full | Build full / empty masks (default: full). |
| 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.
| [in] | K | A constant reference to the underlying complex. |
| [in] | cells | A vector containing, in each dimension, a vector of cells indexes. |
| [in] | close | If this boolean is true, the faces of cells are also set to 1. |
| 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.
| [in] | otherToCopy | An initial Sub_chain_complex_mask. |
| 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).
| 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.
| Sub_chain_complex_mask & CGAL::HDVF::Sub_chain_complex_mask< CoefficientType, ComplexType >::operator= | ( | const Sub_chain_complex_mask< CoefficientType, ComplexType > & | otherToCopy | ) |
Assignment operator.
| [in] | otherToCopy | A Sub_chain_complex_mask copied into this (otherToCopy and this must have the same underlying chain complex). |
| 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.
| [in] | chain | The chain restricted. |
| [in] | q | Dimension of the chain. |
| 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.
| [in] | matrices | A vector of Sub_sparse_matrix (in each dimension). |
|
protected |
Is full sub_complex.
This boolean flag is true is all bits in the bitboards are on.