|
CGAL 6.2 - Homological Discrete Vector Fields
|
#include <CGAL/OSM/Sparse_matrix.h>
Inherited by CGAL::OSM::Sub_sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >.
The class Sparse_matrix_core 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_core class are either column of row major (the StorageFormat parameter determines this storage format). A column-major (resp. row-major) Sparse_matrix_core 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_core () | |
| Default constructor. | |
| Sparse_matrix_core (const size_t rowCount, const size_t columnCount) | |
| Constructor with given rows/columns sizes. | |
| Sparse_matrix_core (const std::pair< size_t, size_t > dimensions) | |
| Constructor with given pair of rows/columns sizes. | |
| Sparse_matrix_core (const Sparse_matrix_core &otherToCopy)=default | |
| template<int CTF> | |
| Sparse_matrix_core (const Sparse_matrix_core< CoefficientRing, CTF, SparseChainType > &otherToCopy) | |
| Copy constructor. | |
| void | eye (size_t nrows, size_t ncols) |
| Sets an identity matrix. | |
| void | eye (std::pair< size_t, size_t > dimensions) |
| Sets an identity matrix. | |
| Sparse_matrix_core & | operator= (const Sparse_matrix_core &otherToCopy)=default |
| Assignment. | |
| void | nullify () |
| Cleans a SparseMatrix (set all coefficients to zero). | |
| bool | is_null () |
Tests if a Sparse_matrix_core is null. | |
| bool | is_empty () |
Tests if a Sparse_matrix_core is empty. | |
| int | storage_format () const |
| Returns the storage format of the matrix. | |
| template<int _CTF> | |
| Sparse_matrix_core | operator+ (const Sparse_matrix_core< CoefficientRing, _CTF > &other) |
| Adds two matrices into a new matrix. | |
| template<int _CTF> | |
| Sparse_matrix_core | operator- (const Sparse_matrix_core< CoefficientRing, _CTF > &other) |
| Subtracts two matrices into a new matrix. | |
| Sparse_matrix_core | operator* (const CoefficientRing &lambda) |
| Applies factor on each coefficients into a new matrix. | |
| Sparse_matrix_core & | operator*= (const CoefficientRing &lambda) |
| Applies factor on each coefficients and assign. | |
| Sparse_matrix_core | 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. | |
| Matrix_chain | chain (size_t index) const |
| Gets the value of a chain from a const matrix. | |
| Sparse_matrix_core | operator/ (const std::vector< size_t > &_indices) |
| Removes a set of chains from a copy of the matrix. | |
| Sparse_matrix_core | operator/ (size_t index) |
Removes the chain at a given index from a copy of the matrix. | |
| Sparse_matrix_core & | operator/= (const std::vector< size_t > &indices) |
| Removes a set of chains from a matrix. | |
| Sparse_matrix_core & | 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_core< Coefficient_ring,(COLUMN|ROW)&(~StorageFormat), SparseChainType > | transpose () const |
| Transposes a matrix. | |
| std::pair< size_t, size_t > | dimensions () const |
| Gets the matrix sizes. | |
Protected Member Functions | |
| 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_core & | remove_column (size_t index) |
| Sparse_matrix_core & | remove_row (size_t index) |
| Sparse_matrix_core & | swap_rows (size_t i, size_t j) |
| Sparse_matrix_core & | swap_columns (size_t i, size_t j) |
| Sparse_matrix_core & | remove_coefficient (size_t i, size_t j) |
Protected Attributes | |
| std::vector< Sparse_chain_type< CoefficientRing, StorageFormat > > | _chains |
| Bitboard | _chainsStates |
| std::pair< size_t, size_t > | _size |
Friends | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| class | Sparse_matrix_core |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename _CT , template< typename, int > typename SCT> | |
| bool | operator== (const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &other) |
| Comparison of two COLUMN matrices. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| bool | operator== (const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, OSM::ROW, SCT > &other) |
| Comparison of a COLUMN and a ROW matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| bool | operator== (const Sparse_matrix_core< _CT, OSM::ROW, SCT > &matrix, const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &other) |
| Comparison of a ROW and a COLUMN matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| bool | operator== (const Sparse_matrix_core< _CT, OSM::ROW, SCT > &matrix, const Sparse_matrix_core< _CT, OSM::ROW, SCT > &other) |
| Comparison of two ROW matrices. | |
| std::ostream & | operator<< (std::ostream &stream, const Sparse_matrix_core &matrix) |
| Writes a sparse matrix in the output stream. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| std::ostream & | write_matrix (const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &M, std::ostream &out) |
| Writes a sparse COLUMN matrix to a stream. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| std::ostream & | write_matrix (const Sparse_matrix_core< _CT, OSM::ROW, SCT > &M, std::ostream &out) |
| Writes a sparse ROW matrix to a stream. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | write_matrix (const Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &M, std::string filename) |
| Writes a sparse COLUMN matrix to a file. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | write_matrix (const Sparse_matrix_core< _CT, OSM::ROW, SCT > &M, std::string filename) |
| Writes a sparse ROW matrix to a file. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| std::istream & | read_matrix (Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &M, std::istream &in) |
| Reads a sparse COLUMN matrix from a stream. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| std::istream & | read_matrix (Sparse_matrix_core< _CT, OSM::ROW, SCT > &M, std::istream &in) |
| Reads a sparse ROW matrix from a stream. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | read_matrix (Sparse_matrix_core< _CT, OSM::COLUMN, SCT > &M, std::string filename) |
| Reads a sparse COLUMN matrix from a file. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | read_matrix (Sparse_matrix_core< _CT, OSM::ROW, SCT > &M, std::string filename) |
| Reads a sparse ROW matrix from a file. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core | operator* (const _CT &lambda, const Sparse_matrix_core< _CT, _CTF, SCT > &matrix) |
| Applies factor on each coefficients into a new matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > | operator* (const Sparse_matrix_core< _CT, COLUMN, SCT > &first, const Sparse_matrix_core< _CT, COLUMN, SCT > &second) |
| Matrix multiplication: COLUMN x COLUMN -> COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > | operator* (const Sparse_matrix_core< _CT, ROW, SCT > &first, const Sparse_matrix_core< _CT, COLUMN, SCT > &second) |
| Matrix multiplication: ROW x COLUMN -> COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > | operator* (const Sparse_matrix_core< _CT, COLUMN, SCT > &first, const Sparse_matrix_core< _CT, ROW, SCT > &second) |
| Matrix multiplication: COLUMN x ROW -> COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > | operator* (const Sparse_matrix_core< _CT, ROW, SCT > &first, const Sparse_matrix_core< _CT, ROW, SCT > &second) |
| Matrix multiplication: ROW x ROW -> COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, COLUMN > | operator* (const Sparse_matrix_core< _CT, COLUMN, SCT > &_matrix, const SCT< _CT, COLUMN > &_column) |
| Matrix/column chain multiplication: COLUMN matrix x COLUMN chain -> COLUMN chain. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, COLUMN > | operator* (const Sparse_matrix_core< _CT, ROW, SCT > &_matrix, const SCT< _CT, COLUMN > &_column) |
| Matrix/column chain multiplication: ROW matrix x COLUMN chain -> COLUMN chain. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, ROW > | operator* (const SCT< _CT, ROW > &_row, const Sparse_matrix_core< _CT, ROW, SCT > &_matrix) |
| Row chain/matrix multiplication: ROW chain x COLUMN matrix -> ROW chain. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, ROW > | operator* (const SCT< _CT, ROW > &_row, const Sparse_matrix_core< _CT, COLUMN, SCT > &_matrix) |
| Row chain/matrix multiplication: ROW chain x ROW matrix -> ROW chain. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > | operator% (const Sparse_matrix_core< _CT, COLUMN, SCT > &_first, const Sparse_matrix_core< _CT, COLUMN, SCT > &_second) |
| matrix multiplication: COLUMN x COLUMN -> ROW | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > | operator% (const Sparse_matrix_core< _CT, ROW, SCT > &_first, const Sparse_matrix_core< _CT, COLUMN, SCT > &_second) |
| matrix multiplication: ROW x COLUMN -> ROW | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > | operator% (const Sparse_matrix_core< _CT, COLUMN, SCT > &_first, const Sparse_matrix_core< _CT, ROW, SCT > &_second) |
| matrix multiplication: COLUMN x ROW -> ROW | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > | operator% (const Sparse_matrix_core< _CT, ROW, SCT > &_first, const Sparse_matrix_core< _CT, ROW, SCT > &_second) |
| matrix multiplication: ROW x ROW -> ROW | |
| Sparse_matrix_core & | operator+= (const Sparse_matrix_core &other) |
| Matrices sum and assign: COLUMN += COLUMN or ROW += ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > & | operator+= (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, ROW, SCT > &other) |
| Matrices sum and assign: COLUMN += ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > & | operator+= (Sparse_matrix_core< _CT, ROW, SCT > &matrix, const Sparse_matrix_core< _CT, COLUMN, SCT > &other) |
| Matrices sum and assign: ROW += COLUMN. | |
| Sparse_matrix_core & | operator-= (const Sparse_matrix_core &other) |
| Matrices subtraction and assign: COLUMN -= COLUMN or ROW -= ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > & | operator-= (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, ROW, SCT > &other) |
| Matrices subtraction and assign: COLUMN -= ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > & | operator-= (Sparse_matrix_core< _CT, ROW, SCT > &matrix, const Sparse_matrix_core< _CT, COLUMN, SCT > &other) |
| Matrices subtraction and assign: ROW -= COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > & | operator*= (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, COLUMN, SCT > &other) |
| Matrix multiplication and assign: COLUMN *= COLUMN. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > & | operator*= (Sparse_matrix_core< _CT, ROW, SCT > &matrix, const Sparse_matrix_core< _CT, ROW, SCT > &other) |
| Matrix multiplication and assign: ROW *= ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, COLUMN, SCT > & | operator*= (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, const Sparse_matrix_core< _CT, ROW, SCT > &other) |
| Matrix multiplication and assign: COLUMN *= ROW. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, ROW, SCT > & | operator*= (Sparse_matrix_core< _CT, ROW, SCT > &matrix, const Sparse_matrix_core< _CT, COLUMN, SCT > &other) |
| Matrix multiplication and assign: ROW *= COLUMN. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| void | set_coefficient (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t i, size_t j, const _CT d) |
Sets a given coefficient in matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| _CT | get_coefficient (const Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t i, size_t j) |
| Gets a given coefficient. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, COLUMN > | get_column (const Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, size_t index) |
| Gets a column from a COLUMN matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, COLUMN > | get_column (const Sparse_matrix_core< _CT, ROW, SCT > &matrix, size_t index) |
| Gets a column from a ROW matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, ROW > | get_row (const Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, size_t index) |
| Gets a row from a COLUMN matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| SCT< _CT, ROW > | get_row (const Sparse_matrix_core< _CT, ROW, SCT > &matrix, size_t index) |
| Gets a row from a ROW matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| const SCT< _CT, COLUMN > & | cget_column (const Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, size_t index) |
| Gets a const reference over a column from a column matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| const SCT< _CT, ROW > & | cget_row (const Sparse_matrix_core< _CT, ROW, SCT > &matrix, const size_t index) |
| Gets a constant reference over a row from a row matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | set_column (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, size_t index, const SCT< _CT, COLUMN > &column) |
| Sets a column in a COLUMN matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | set_column (Sparse_matrix_core< _CT, ROW, SCT > &matrix, size_t index, const SCT< _CT, COLUMN > &column) |
| Sets a column in a ROW matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | set_row (Sparse_matrix_core< _CT, COLUMN, SCT > &matrix, size_t index, const SCT< _CT, ROW > &row) |
| Sets a row in a COLUMN matrix. | |
| template<typename _CT , template< typename, int > typename SCT> | |
| void | set_row (Sparse_matrix_core< _CT, ROW, SCT > &matrix, size_t index, const SCT< _CT, ROW > &row) |
| Sets a row in a ROW matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, _CTF, SCT > & | remove_column (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t index) |
| Removes a column from the matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, _CTF, SCT > & | remove_row (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t index) |
| Removes a row from the matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, _CTF, SCT > & | swap_rows (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t i, size_t j) |
| Swaps rows in a matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, _CTF, SCT > & | swap_columns (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t i, size_t j) |
| Swaps columns in a matrix. | |
| template<typename _CT , int _CTF, template< typename, int > typename SCT> | |
| Sparse_matrix_core< _CT, _CTF, SCT > & | remove_coefficient (Sparse_matrix_core< _CT, _CTF, SCT > &matrix, size_t i, size_t j) |
| Removes a coefficient from the matrix. | |
| CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix_core | ( | ) |
Default constructor.
Create an empty matrix of type StorageFormat with coefficients of type CoefficientRing. The default matrix size is 0x0.
| CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix_core | ( | const size_t | rowCount, |
| const size_t | columnCount | ||
| ) |
Constructor with given rows/columns sizes.
Create a new empty Sparse_matrix_core 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_core< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix_core | ( | const std::pair< size_t, size_t > | dimensions | ) |
Constructor with given pair of rows/columns sizes.
Create a new empty Sparse_matrix_core 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. |
| CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::Sparse_matrix_core | ( | const Sparse_matrix_core< CoefficientRing, CTF, SparseChainType > & | otherToCopy | ) |
Copy constructor.
Create a new SparseMatrix from another SparseMatrix object (with possibly a different StorageFormat). Initialize a SparseMatrix of same sizes, containing the same coefficients (but not necessarly of the same StorageFormat). If types are different, the constructor performs conversion.
| otherToCopy | The matrix copied. |
|
noexcept |
Iterator to the index of the first non null chain.
Return an iterator to the index of the first non null chain (the iterator visits indices of non null chains along the major dimension of the matrix).
| Matrix_chain CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::chain | ( | size_t | index | ) | const |
Gets the value of a chain from a const matrix.
| index | The chain index. |
| std::pair< size_t, size_t > CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::dimensions | ( | ) | const |
Gets the matrix sizes.
|
noexcept |
Iterator past-the-end of chain indices.
| void CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::eye | ( | size_t | nrows, |
| size_t | ncols | ||
| ) |
Sets an identity matrix.
| nrows | Number of rows of the matrix. |
| ncols | Number of columns of the matrix. |
| void CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::eye | ( | std::pair< size_t, size_t > | dimensions | ) |
Sets an identity matrix.
| dimensions | Pair containing the number of rows and number of columns of the matrix. |
| bool CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::is_empty | ( | ) |
Tests if a Sparse_matrix_core is empty.
The function return true is the Sparse_matrix_core is empty (that is, if the number of columns or rows is null) and false otherwise.
| bool CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::is_null | ( | ) |
Tests if a Sparse_matrix_core is null.
The function return true is the Sparse_matrix_core is null (that is, empty) and false otherwise.
| void CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::nullify | ( | ) |
Cleans a SparseMatrix (set all coefficients to zero).
Empty all structures of the sparse matrix.
| Sparse_matrix_core CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator* | ( | const CoefficientRing & | lambda | ) |
Applies factor on each coefficients into a new matrix.
This method creates a new matrix obtained by multiplying the matrix by a scalar factor lambda.
If lambda is zero, the function comes to nullify the matrix (when possible, prefer *= for efficiency).
| lambda | The factor to apply. |
| Sparse_matrix_core & CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator*= | ( | const CoefficientRing & | lambda | ) |
Applies factor on each coefficients and assign.
If lambda is 0, this comes to nullify the matrix.
| lambda | The factor to apply. |
| Sparse_matrix_core CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator+ | ( | const Sparse_matrix_core< CoefficientRing, _CTF > & | other | ) |
Adds two matrices into a new matrix.
Adds each coefficient of the matrices and returns a new matrix (of the same type as this) representing the result (when possible, prefer += for efficiency).
CoefficientRing but can have different StorageFormat.CoefficientRing.| other | The second matrix. |
| Sparse_matrix_core CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator- | ( | ) |
Computes the negative of a matrix (unary operator).
| Sparse_matrix_core CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator- | ( | const Sparse_matrix_core< CoefficientRing, _CTF > & | other | ) |
Subtracts two matrices into a new matrix.
Subtracts each coefficient of the matrix other and returns a new matrix (of the same type as this) representing the result (when possible, prefer -= for efficiency).
CoefficientRing but can have different StorageFormat.CoefficientRing.| other | The second matrix. |
|
default |
Assignment.
Assign to other matrix coefficient-wise, equivalent to copying it.
| Matrix_chain CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::operator[] | ( | size_t | index | ) | const |
Gets the value of a chain from a const matrix.
| index | The chain index. |
|
noexcept |
Reverse iterator to the index of the last non null chain.
Return a reverse iiterator to the index of the last non null chain (the iterator visits indices of non null chains, in decreading order, along the major dimension of the matrix).
|
noexcept |
Reverse iterator past-the-end of chain indices.
| Sparse_matrix_core< Coefficient_ring,(COLUMN|ROW)&(~StorageFormat), SparseChainType > CGAL::OSM::Sparse_matrix_core< CoefficientRing, StorageFormat, SparseChainType >::transpose | ( | ) | const |
Transposes a matrix.
StorageFormat has been swapped between COLUMN and ROW and data chains have been transposed.
|
friend |
Gets a const reference over a column from a column matrix.
Constant time get.
| matrix | The matrix considered. |
| index | The column index. |
|
friend |
Gets a constant reference over a row from a row matrix.
Constant time get.
| matrix | The matrix considered. |
| index | The row index. |
|
friend |
Gets a given coefficient.
Returns the coefficient on row i and column j of the matrix.
| matrix | Constant reference on the matrix. |
| i | The row index. |
| j | The column index. |
|
friend |
Applies factor on each coefficients into a new matrix.
This method creates a new matrix obtained by multiplying the matrix by a scalar factor lambda.
If lambda is zero, the function comes to nullify the matrix (when possible, prefer *= for efficiency).
| lambda | The factor to apply. |
| matrix | The matrix. |
|
friend |
Writes a sparse matrix in the output stream.
| stream | The output stream. |
| matrix | The matrix to display. |
|
friend |
|
friend |
Removes a column from the matrix.
Removes column of index index whatever the StorageFormat of the matrix. For column matrices, it just comes to the \= operator and for row matrices, it entails a traversal of the matrix.
| matrix | Reference on the matrix to modify. |
| index | The index to remove. |
|
friend |
Removes a row from the matrix.
Removes row of index index whatever the StorageFormat of the matrix. For row matrices, it just comes to the \= operator and for column matrices, it entails a traversal of the matrix.
| matrix | Reference on the matrix to modify. |
| index | The index to remove. |
|
friend |
Sets a given coefficient in matrix.
Assign the scalar d to the coefficient on row i and column j.
| matrix | Reference on the matrix to modify. |
| i | The row index. |
| j | The column index. |
| d | The value. |
|
friend |
Swaps columns in a matrix.
Swaps columns at indices i and j whatever the StorageFormat of the matrix. For column matrices, the operation runs in constant time, while it entails a traversal of the matrix for row matrices.
| matrix | Reference on the matrix to modify. |
| i | Index of the first column. |
| j | Index of the second column. |
|
friend |
Swaps rows in a matrix.
Swaps rows at indices i and j whatever the StorageFormat of the matrix. For row matrices, the operation runs in constant time, while it entails a traversal of the matrix for column matrices.
| matrix | Reference on the matrix to modify. |
| i | Index of the first row. |
| j | Index of the second row. |