|
CGAL 6.2 - Homological Discrete Vector Fields
|
#include <CGAL/HDVF/Sub_sparse_matrix.h>
CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat >.
The class Sub_sparse_matrix 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 inherits Sparse_matrix structure and basically adds two bitboards:
The class does not modify linear algebra operators, but focuses on adapted iterators, output operators and methods to adjust the "mask".
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). |
Public Member Functions | |
| Sub_sparse_matrix (size_t rowCount=0, size_t columnCount=0) | |
Default constructor of a new Sub_sparse_matrix (with given rows/columns sizes and mask set to full). | |
| Sub_sparse_matrix (size_t rowCount, size_t columnCount, const Bitboard &subChain) | |
| Constructor with given rows/columns sizes and a mask. | |
| Sub_sparse_matrix (const Sub_sparse_matrix &otherToCopy) | |
Copy constructor from another Sub_sparse_matrix. | |
| Sub_sparse_matrix (const Sparse_matrix< CoefficientRing, StorageFormat > &otherToCopy) | |
Copy constructor from Sparse_matrix. | |
| 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 & | operator= (const Sub_sparse_matrix &otherToCopy) |
Assigns to other Sub_sparse_matrix. | |
Public Member Functions inherited from CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat > | |
| Sparse_matrix () | |
Default constructor (empty new Sparse_matrix object). | |
| Sparse_matrix (const size_t rowCount, const size_t columnCount) | |
| Constructor with given rows/columns sizes. | |
| template<int CTF> | |
| Sparse_matrix (const Sparse_matrix< CoefficientRing, CTF > &otherToCopy) | |
| Copy constructor. | |
| Sparse_matrix & | operator= (const Sparse_matrix &otherToCopy) |
| Assigns to other matrix. | |
| void | nullify () |
| Cleans a SparseMatrix (set all coefficients to zero). | |
| bool | is_null () |
| Tests if a SparseMatrix is null. | |
| template<int _CTF> | |
| Sparse_matrix | operator+ (const Sparse_matrix< CoefficientRing, _CTF > &other) |
| Adds two matrices into a new matrix. | |
| template<int _CTF> | |
| Sparse_matrix | operator- (const Sparse_matrix< CoefficientRing, _CTF > &other) |
| Subtracts two matrices into a new matrix. | |
| Sparse_matrix | operator* (const CoefficientRing &lambda) |
| Applies factor on each coefficients into a new matrix. | |
| Sparse_matrix & | operator*= (const CoefficientRing &lambda) |
| Applies factor on each coefficients and assign. | |
| Sparse_matrix | 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. | |
| Sparse_matrix | operator/ (const std::vector< size_t > &_indices) |
| Removes a set of chains from a copy of the matrix. | |
| Sparse_matrix | operator/ (size_t index) |
Removes the chain at a given index from a copy of the matrix. | |
| Sparse_matrix & | operator/= (const std::vector< size_t > &indices) |
| Removes a set of chains from a matrix. | |
| Sparse_matrix & | operator/= (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< CoefficientRing, COLUMN+ROW - StorageFormat > | transpose () |
| Transposes a matrix. | |
| std::pair< size_t, size_t > | dimensions () const |
| Gets the matrix sizes. | |
Protected Attributes | |
| Bitboard | _subChains |
| A bitboard describing subchains restriction. | |
| Bitboard | _subChainsStates |
| A bitboard containing state of each chain (restricted to subchains). | |
Protected Attributes inherited from CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat > | |
| std::vector< Sparse_chain< CoefficientRing, StorageFormat > > | _chains |
| Bitboard | _chainsStates |
| std::pair< size_t, size_t > | _size |
Friends | |
| std::ostream & | operator<< (std::ostream &stream, const Sub_sparse_matrix &matrix) |
Displays a Sub_sparse_matrix in the output stream. | |
Additional Inherited Members | |
Public Types inherited from CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat > | |
| typedef CoefficientRing | Coefficient_ring |
| Type of coefficient ring. | |
| typedef Sparse_chain< CoefficientRing, StorageFormat > | Matrix_chain |
| Type of chains associated to the matrix. | |
Protected Member Functions inherited from CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat > | |
| Matrix_chain & | operator[] (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 & | remove_column (size_t index) |
| Sparse_matrix & | remove_row (size_t index) |
| Sparse_matrix & | remove_coefficient (size_t i, size_t j) |
Related Functions inherited from CGAL::OSM::Sparse_matrix< CoefficientRing, StorageFormat > | |
| 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. | |
| CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::Sub_sparse_matrix | ( | size_t | rowCount = 0, |
| size_t | columnCount = 0 |
||
| ) |
Default constructor of a new Sub_sparse_matrix (with given rows/columns sizes and mask set to full).
Default constructor. Constructor with sizes, initialize an empty Sub_sparse_matrix of type StorageFormat with coefficients of type CoefficientRing, a given size along rows/columns. The constructor sets the mask to full.
| rowCount | The number of rows to preallocate (default 0). |
| columnCount | The number of columns to preallocate (default 0). |
| CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::Sub_sparse_matrix | ( | 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 of type StorageFormat with coefficients of type CoefficientRing, a given size along rows/columns and a given mask.
| rowCount | The number of rows to preallocate. |
| columnCount | The number of columns to preallocate. |
| subChain | Bitboard describing the subset of indices considered as a mask. |
| CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::Sub_sparse_matrix | ( | const Sub_sparse_matrix< CoefficientRing, StorageFormat > & | otherToCopy | ) |
Copy constructor from another Sub_sparse_matrix.
Create a new empty Sub_sparse_matrix from another of type StorageFormat with coefficients of type CoefficientRing, a given size along rows/columns and a given mask.
| otherToCopy | Sub_sparse_matrix copied into this. |
| CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::Sub_sparse_matrix | ( | const Sparse_matrix< CoefficientRing, StorageFormat > & | otherToCopy | ) |
Copy constructor from Sparse_matrix.
Create a new Sub_sparse_matrix from a Sparse_matrix object (with the same StorageFormat). Create a "full" mask.
| otherToCopy | The matrix copied. |
| Sub_sparse_matrix & CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::operator= | ( | const Sub_sparse_matrix< CoefficientRing, StorageFormat > & | otherToCopy | ) |
Assigns to other Sub_sparse_matrix.
Assign to other matrix coefficient-wise, and copy the bitboard.
| otherToCopy | The matrix we want to copy. |
| void CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::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).
| index | Index to turn off in the mask. |
| void CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::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).
| index | Index to turn on in the mask. |
| void CGAL::OSM::Sub_sparse_matrix< CoefficientRing, StorageFormat >::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.
|
friend |
Displays a Sub_sparse_matrix in the output stream.
Displays the sparse matrix as well as its mask.
| stream | The output stream. |
| matrix | The matrix to display. |