|
CGAL 6.3-dev - Homological Discrete Vector Fields
|
#include <CGAL/OSM/Sparse_matrix.h>
Inherited by CGAL::OSM::Sub_sparse_matrix< CT, SF, SparseChainType >.
The class Sparse_matrix implements the concept SparseMatrix, that is, sparse matrices optimized for topological computations.
It provides standard linear algebra operators and fast iterators and block operations (set, get and nullify) which are required to implement efficiently HDVFs.
Given a SparseChain model, users should normally define a Sparse_matrix_structure structure (which provides both corresponding Sparse_chain_type and Spare_matrix_type templates).
The implementation is based on mapped sparse matrices. Hence matrices of the Sparse_matrix class are either column of row major (the StorageFormat parameter determines this storage format). A column-major (resp. row-major) Sparse_matrix is a vector of SparseChainType (a model of SparseChain) which encode columns (res. rows). Moreover, in order to efficiently iterate over non empty columns (resp. rows) the Bitboard data structure implements the concept SparseMatrix::NonZeroChainIndices. A bitboard is basically a bucket of bits recording the indices of non empty chains. However, this data structure has been designed in order to efficiently remove or add indices, as well as provide efficient iterators to visit non empty chains.
For instance, let us consider the \(5\times 4\) matrix:
\[A = \left(\begin{array}{cccc} 1 & \cdot & \cdot & \cdot \\ -1 & \cdot & 2 & \cdot\\ \cdot & \cdot & 1 & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \cdot & \cdot & \cdot & \cdot \\ \end{array}\right) \]
where \(\cdot\) means \(0\).
Figures below shows the data structures are created according to the chosen representation (left: column-major, right: row-major):
SparseMatrix | CoefficientRing | a model of the IntegralDomainWithoutDivision concept, providing the ring used to compute homology. |
| StorageFormat | an integer constant encoding the storage format of matrices (OSM::COLUMN or OSM::ROW). |
| SparseChainType | a model of SparseChain used to store chains of the sparse matrix (default: OSM::Sparse_chain). |
Public Types | |
| 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. | |
Public Member Functions | |
| Sparse_matrix () | |
| Default constructor. | |
| Sparse_matrix (const size_t rowCount, const size_t columnCount) | |
| Constructor with given rows/columns sizes. | |
| Sparse_matrix (const std::pair< size_t, size_t > dimensions) | |
| Constructor with given pair of rows/columns sizes. | |
Public Attributes | |
| int | Storage_format = StorageFormat |
| Storage format of the matrix. | |
| CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix | ( | ) |
Default constructor.
Create an empty matrix of type StorageFormat with coefficients of type CoefficientRing. The default matrix size is 0x0.
| CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix | ( | const size_t | rowCount, |
| const size_t | columnCount ) |
Constructor with given rows/columns sizes.
Create a new empty Sparse_matrix object of type StorageFormat with coefficients of type CoefficientRing and a given size along rows/columns.
| rowCount | The number of rows to preallocate. |
| columnCount | The number of columns to preallocate. |
| CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix | ( | const std::pair< size_t, size_t > | dimensions | ) |
Constructor with given pair of rows/columns sizes.
Create a new empty Sparse_matrix object of type StorageFormat with coefficients of type CoefficientRing and a given size along rows/columns.
| dimensions | A pair containing the number of rows and columns to preallocate. |