template<typename CoefficientRing, int StorageFormat>
class CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat >
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.
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 Sparse_chain 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):

- Is model of
SparseMatrix
- Template Parameters
-
- Examples
- HDVF/matrix_chain.cpp.
|
(Note that these are not member functions.)
|
|
template<typename _CT > |
| bool | operator== (const Sparse_matrix< _CT, OSM::COLUMN > &matrix, const Sparse_matrix< _CT, OSM::COLUMN > &other) |
| | Comparison of two COLUMN matrices.
|
| |
|
template<typename _CT > |
| bool | operator== (const Sparse_matrix< _CT, OSM::COLUMN > &matrix, const Sparse_matrix< _CT, OSM::ROW > &other) |
| | Comparison of a COLUMN and a ROW matrix.
|
| |
|
template<typename _CT > |
| bool | operator== (const Sparse_matrix< _CT, OSM::ROW > &matrix, const Sparse_matrix< _CT, OSM::COLUMN > &other) |
| | Comparison of a ROW and a COLUMN matrix.
|
| |
|
template<typename _CT > |
| bool | operator== (const Sparse_matrix< _CT, OSM::ROW > &matrix, const Sparse_matrix< _CT, OSM::ROW > &other) |
| | Comparison of two ROW matrices.
|
| |
| std::ostream & | operator<< (std::ostream &stream, const Sparse_matrix &matrix) |
| | Writes a sparse matrix in the output stream.
|
| |
|
template<typename _CT > |
| std::ostream & | write_matrix (const Sparse_matrix< _CT, OSM::COLUMN > &M, std::ostream &out) |
| | Writes a sparse COLUMN matrix to a stream.
|
| |
|
template<typename _CT > |
| std::ostream & | write_matrix (const Sparse_matrix< _CT, OSM::ROW > &M, std::ostream &out) |
| | Writes a sparse ROW matrix to a stream.
|
| |
|
template<typename _CT > |
| void | write_matrix (const Sparse_matrix< _CT, OSM::COLUMN > &M, std::string filename) |
| | Writes a sparse COLUMN matrix to a file.
|
| |
|
template<typename _CT > |
| void | write_matrix (const Sparse_matrix< _CT, OSM::ROW > &M, std::string filename) |
| | Writes a sparse ROW matrix to a file.
|
| |
|
template<typename _CT > |
| std::istream & | read_matrix (Sparse_matrix< _CT, OSM::COLUMN > &M, std::istream &in) |
| | Reads a sparse COLUMN matrix from a stream.
|
| |
|
template<typename _CT > |
| std::istream & | read_matrix (Sparse_matrix< _CT, OSM::ROW > &M, std::istream &in) |
| | Reads a sparse ROW matrix from a stream.
|
| |
|
template<typename _CT > |
| void | read_matrix (Sparse_matrix< _CT, OSM::COLUMN > &M, std::string filename) |
| | Reads a sparse COLUMN matrix from a file.
|
| |
|
template<typename _CT > |
| void | read_matrix (Sparse_matrix< _CT, OSM::ROW > &M, std::string filename) |
| | Reads a sparse ROW matrix from a file.
|
| |
| template<typename _CT , int _CTF> |
| Sparse_matrix | operator* (const _CT &lambda, const Sparse_matrix< _CT, _CTF > &matrix) |
| | Applies factor on each coefficients into a new matrix.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, COLUMN > &first, const Sparse_matrix< _CT, COLUMN > &second) |
| | Matrix multiplication: COLUMN x COLUMN -> COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, ROW > &first, const Sparse_matrix< _CT, COLUMN > &second) |
| | Matrix multiplication: ROW x COLUMN -> COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, COLUMN > &first, const Sparse_matrix< _CT, ROW > &second) |
| | Matrix multiplication: COLUMN x ROW -> COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, ROW > &first, const Sparse_matrix< _CT, ROW > &second) |
| | Matrix multiplication: ROW x ROW -> COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, COLUMN > &_matrix, const Sparse_chain< _CT, COLUMN > &_column) |
| | Matrix/column chain multiplication: COLUMN matrix x COLUMN chain -> COLUMN chain.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, COLUMN > | operator* (const Sparse_matrix< _CT, ROW > &_matrix, const Sparse_chain< _CT, COLUMN > &_column) |
| | Matrix/column chain multiplication: ROW matrix x COLUMN chain -> COLUMN chain.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, ROW > | operator* (const Sparse_chain< _CT, ROW > &_row, const Sparse_matrix< _CT, ROW > &_matrix) |
| | Row chain/matrix multiplication: ROW chain x COLUMN matrix -> ROW chain.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, ROW > | operator* (const Sparse_chain< _CT, ROW > &_row, const Sparse_matrix< _CT, COLUMN > &_matrix) |
| | Row chain/matrix multiplication: ROW chain x ROW matrix -> ROW chain.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > | operator% (const Sparse_matrix< _CT, COLUMN > &_first, const Sparse_matrix< _CT, COLUMN > &_second) |
| | matrix multiplication: COLUMN x COLUMN -> ROW
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > | operator% (const Sparse_matrix< _CT, ROW > &_first, const Sparse_matrix< _CT, COLUMN > &_second) |
| | matrix multiplication: ROW x COLUMN -> ROW
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > | operator% (const Sparse_matrix< _CT, COLUMN > &_first, const Sparse_matrix< _CT, ROW > &_second) |
| | matrix multiplication: COLUMN x ROW -> ROW
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > | operator% (const Sparse_matrix< _CT, ROW > &_first, const Sparse_matrix< _CT, ROW > &_second) |
| | matrix multiplication: ROW x ROW -> ROW
|
| |
|
Sparse_matrix & | operator+= (const Sparse_matrix &other) |
| | Matrices sum and assign: COLUMN += COLUMN or ROW += ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > & | operator+= (Sparse_matrix< _CT, COLUMN > &matrix, const Sparse_matrix< _CT, ROW > &other) |
| | Matrices sum and assign: COLUMN += ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > & | operator+= (Sparse_matrix< _CT, ROW > &matrix, const Sparse_matrix< _CT, COLUMN > &other) |
| | Matrices sum and assign: ROW += COLUMN.
|
| |
|
Sparse_matrix & | operator-= (const Sparse_matrix &other) |
| | Matrices subtraction and assign: COLUMN -= COLUMN or ROW -= ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > & | operator-= (Sparse_matrix< _CT, COLUMN > &matrix, const Sparse_matrix< _CT, ROW > &other) |
| | Matrices subtraction and assign: COLUMN -= ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > & | operator-= (Sparse_matrix< _CT, ROW > &matrix, const Sparse_matrix< _CT, COLUMN > &other) |
| | Matrices subtraction and assign: ROW -= COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > & | operator*= (Sparse_matrix< _CT, COLUMN > &matrix, const Sparse_matrix< _CT, COLUMN > &other) |
| | Matrix multiplication and assign: COLUMN *= COLUMN.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > & | operator*= (Sparse_matrix< _CT, ROW > &matrix, const Sparse_matrix< _CT, ROW > &other) |
| | Matrix multiplication and assign: ROW *= ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, COLUMN > & | operator*= (Sparse_matrix< _CT, COLUMN > &matrix, const Sparse_matrix< _CT, ROW > &other) |
| | Matrix multiplication and assign: COLUMN *= ROW.
|
| |
|
template<typename _CT > |
| Sparse_matrix< _CT, ROW > & | operator*= (Sparse_matrix< _CT, ROW > &matrix, const Sparse_matrix< _CT, COLUMN > &other) |
| | Matrix multiplication and assign: ROW *= COLUMN.
|
| |
| template<typename _CT , int _CTF> |
| void | set_coefficient (Sparse_matrix< _CT, _CTF > &matrix, size_t i, size_t j, const _CT d) |
| | Sets a given coefficient in matrix.
|
| |
| template<typename _CT , int _CTF> |
| _CT | get_coefficient (const Sparse_matrix< _CT, _CTF > &matrix, size_t i, size_t j) |
| | Gets a given coefficient.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, COLUMN > | get_column (const Sparse_matrix< _CT, COLUMN > &matrix, size_t index) |
| | Gets a column from a COLUMN matrix.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, COLUMN > | get_column (const Sparse_matrix< _CT, ROW > &matrix, size_t index) |
| | Gets a column from a ROW matrix.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, ROW > | get_row (const Sparse_matrix< _CT, COLUMN > &matrix, size_t index) |
| | Gets a row from a COLUMN matrix.
|
| |
|
template<typename _CT > |
| Sparse_chain< _CT, ROW > | get_row (const Sparse_matrix< _CT, ROW > &matrix, size_t index) |
| | Gets a row from a ROW matrix.
|
| |
| template<typename _CT > |
| const Sparse_chain< _CT, COLUMN > & | cget_column (const Sparse_matrix< _CT, COLUMN > &matrix, size_t index) |
| | Gets a const reference over a column from a column matrix.
|
| |
| template<typename _CT > |
| const Sparse_chain< _CT, ROW > & | cget_row (const Sparse_matrix< _CT, ROW > &matrix, const size_t index) |
| | Gets a constant reference over a row from a row matrix.
|
| |
|
template<typename _CT > |
| void | set_column (Sparse_matrix< _CT, COLUMN > &matrix, size_t index, const Sparse_chain< _CT, COLUMN > &column) |
| | Sets a column in a COLUMN matrix.
|
| |
|
template<typename _CT > |
| void | set_column (Sparse_matrix< _CT, ROW > &matrix, size_t index, const Sparse_chain< _CT, COLUMN > &column) |
| | Sets a column in a ROW matrix.
|
| |
|
template<typename _CT > |
| void | set_row (Sparse_matrix< _CT, COLUMN > &matrix, size_t index, const Sparse_chain< _CT, ROW > &row) |
| | Sets a row in a COLUMN matrix.
|
| |
|
template<typename _CT > |
| void | set_row (Sparse_matrix< _CT, ROW > &matrix, size_t index, const Sparse_chain< _CT, ROW > &row) |
| | Sets a row in a ROW matrix.
|
| |
| template<typename _CT , int _CTF> |
| Sparse_matrix< _CT, _CTF > & | remove_column (Sparse_matrix< _CT, _CTF > &matrix, size_t index) |
| | Removes a column from the matrix.
|
| |
| template<typename _CT , int _CTF> |
| Sparse_matrix< _CT, _CTF > & | remove_row (Sparse_matrix< _CT, _CTF > &matrix, size_t index) |
| | Removes a row from the matrix.
|
| |
| template<typename _CT , int _CTF> |
| Sparse_matrix< _CT, _CTF > & | remove_coefficient (Sparse_matrix< _CT, _CTF > &matrix, size_t i, size_t j) |
| | Removes a coefficient from the matrix.
|
| |