|
CGAL 6.3-dev - Homological Discrete Vector Fields
|
The concept SparseChain describes the requirements for sparse vectors (called sparse chains in homology) optimized for topological computations. More precisely, SparseChain provides all the operations on chains required by the SparseMatrix concept.
SparseChain encodes non zero coefficients of a sparse vector.
SparseChain can be either row or column vectors. The following integer constants, called Storage_format, encode the direction of sparse chains (and sparse matrices).
Types | |
| typedef unspecified_type | Coefficient_ring |
| Type of coefficients stored in the matrix (a model of IntegralDomainWithoutDivision). | |
| template<typename CR, int SF> | |
| using | Sparse_matrix_derived = OSM::Sparse_matrix_structure<OSM::Sparse_chain>::Sparse_matrix_type<CR, SF> |
| Type of derived sparse matrices. | |
| typedef unspecified_type | iterator |
| Sparse chain iterator type. | |
| typedef unspecified_type | const_iterator |
| Sparse chain constant iterator type. | |
Member data | |
| int | Storage_format |
| Chain storage format (either CGAL::OSM::ROW or CGAL::OSM::COLUMN). | |
Creation, filling | |
| SparseChain () | |
| Creates new empty sparse chain. | |
| SparseChain (size_t chainSize) | |
| Creates new empty sparse chain (ie. zero-chain) of given size. | |
| Sparse_chain & | operator= (const Sparse_chain &other) |
| Assignment. | |
Matrix informations and iterators | |
| size_t | dimension () const |
| Size of the chain. | |
| iterator | begin () noexcept |
| Iterator to the beginning of the chain. | |
| const_iterator | begin () const noexcept |
| Constant iterator to the beginning of the chain. | |
| const_iterator | cbegin () const noexcept |
| Constant iterator to the beginning of the chain. | |
| iterator | end () noexcept |
| Iterator to the end of the chain. | |
| const_iterator | end () const noexcept |
| Constant iterator to the end of the chain. | |
| const_iterator | cend () const noexcept |
| Constant iterator to the end of the chain. | |
Linear algebra operators | |
| Sparse_chain | operator+ (const Sparse_chain &other) |
| Adds two chains. | |
| Sparse_chain | operator- (const Sparse_chain &other) |
| Subtracts a chain from current chain. | |
| Sparse_chain | operator* (const Coefficient_ring &lambda) |
| Multiplies each coefficient of chain by lambda. | |
| SparseChain & | operator+= (const SparseChain &other) |
| Adds a chain to this. | |
| SparseChain & | operator-= (const SparseChain &other) |
| Sustracts a chain to this. | |
| SparseChain & | operator*= (const Coefficient_ring &lambda) |
| Multiplies each coefficient of this by lambda. | |
| SparseChain | transpose () |
| Transposes a sparse chain. | |
| SparseChain | operator* (const Coefficient_ring &lambda, const SparseChain &chain) |
| Multiplies each coefficient of chain by lambda. | |
| Sparse_matrix_derived< Coefficient_ring, COLUMN > | operator* (const SparseChain &column, const SparseChain &row) |
| Performs matrix multiplication between two chains (COLUMN x ROW) and return a COLUMN matrix. | |
| SparseMatrix | operator% (const Sparse_chain &column, const Sparse_chain &row) |
| Performs matrix multiplication between two chains (COLUMN x ROW) and return a ROW matrix. | |
| Coefficient_ring | operator* (const Sparse_chain &row, const Sparse_chain &column) |
| Performs dot product between two chains (ROW x COLUMN). | |
Test, access and modifications | |
| bool | is_column () const |
| Checks if chain is a column. | |
| bool | is_row () const |
| Checks if chain is a row. | |
| bool | is_null (size_t index) const |
| Checks if a coefficient is null (that is, not store in the sparse chain). | |
| bool | is_null () const |
| Checks if the chain is null. | |
| Coefficient_ring | get_coefficient (size_t index) const |
| Gets the value of a coefficient index of the chain. | |
| void | set_coefficient (size_t index, Coefficient_ring d) |
| Sets coefficient index of the chain to value d. | |
| SparseChain & | operator/= (const std::vector< size_t > &indices) |
| Restricts the chain to a sub-chain by removing indices. | |
| SparseChain & | operator/= (size_t index) |
| Restricts the chain to a sub-chain by removing a given index. | |
| void | nullify () |
| Removes all coefficients from the chain. | |
| bool | operator== (const Sparse_chain &chain, const Sparse_chain &other) |
| Tests if two chains are equal. | |
| SparseChain | operator/ (const SparseChain &chain, const std::vector< size_t > &indices) |
| Gets a subchain from the chain. | |
| SparseChain | operator/ (const SparseChain &chain, size_t index) |
| Gets a subchain from the chain. | |
Output | |
| std::ostream & | operator<< (std::ostream &stream, const SparseChain &chain) |
| Inserts chain in the output stream with a compact "user friendly" format. | |
| template<typename _CT, int _SF> | |
| std::ostream & | write_chain (const Sparse_chain< _CT, _SF > &chain, std::ostream &out) |
| Write a sparse chain to an output stream using the .osm file format. | |
| template<typename _CT, int _SF> | |
| void | write_chain (const Sparse_chain< _CT, _SF > &chain, std::string filename) |
| Write a sparse chain to a file using the .osm file format. | |
| template<typename _CT, int _SF> | |
| std::istream & | read_chain (Sparse_chain< _CT, _SF > &chain, std::istream &in) |
| Reads a sparse chain from an input stream using the .osm file format. | |
| template<typename _CT, int _SF> | |
| void | read_chain (Sparse_chain< _CT, _SF > &chain, std::string filename) |
| Reads a sparse chain from a file using the .osm file format. | |
| SparseChain::SparseChain | ( | ) |
Creates new empty sparse chain.
Creates a sparse chain encoding an empty linear combination of cells.
| SparseChain::SparseChain | ( | size_t | chainSize | ) |
Creates new empty sparse chain (ie. zero-chain) of given size.
Constructor with size, initializes an empty sparse chain encoding a linear combination of cells with all coefficients null.
|
noexcept |
Constant iterator to the beginning of the chain.
|
noexcept |
Iterator to the beginning of the chain.
|
noexcept |
Constant iterator to the beginning of the chain.
|
noexcept |
Constant iterator to the end of the chain.
| size_t SparseChain::dimension | ( | ) | const |
Size of the chain.
|
noexcept |
Constant iterator to the end of the chain.
|
noexcept |
Iterator to the end of the chain.
| Coefficient_ring SparseChain::get_coefficient | ( | size_t | index | ) | const |
Gets the value of a coefficient index of the chain.
| index | The coefficient index. |
| bool SparseChain::is_null | ( | ) | const |
Checks if the chain is null.
| bool SparseChain::is_null | ( | size_t | index | ) | const |
Checks if a coefficient is null (that is, not store in the sparse chain).
| index | The index to check. |
| void SparseChain::nullify | ( | ) |
Removes all coefficients from the chain.
The function comes to set all coefficients to zero.
| Sparse_chain SparseChain::operator* | ( | const Coefficient_ring & | lambda | ) |
Multiplies each coefficient of chain by lambda.
| lambda | The factor to apply. |
| SparseChain & SparseChain::operator*= | ( | const Coefficient_ring & | lambda | ) |
Multiplies each coefficient of this by lambda.
If lambda is null, this function comes to nullify the chain.
| lambda | The factor to apply. |
| Sparse_chain SparseChain::operator+ | ( | const Sparse_chain & | other | ) |
Adds two chains.
Adds other chain to current chain and returns the result in a new matrix.
| other | The other chain. |
| SparseChain & SparseChain::operator+= | ( | const SparseChain & | other | ) |
Adds a chain to this.
Add a chain to this.
| other | The other chain. |
| Sparse_chain SparseChain::operator- | ( | const Sparse_chain & | other | ) |
Subtracts a chain from current chain.
Subtracts other chain from current chain and returns the result in a new matrix.
| other | The other chain. |
| SparseChain & SparseChain::operator-= | ( | const SparseChain & | other | ) |
Sustracts a chain to this.
Subtract a chain to this.
| other | The other chain. |
| SparseChain & SparseChain::operator/= | ( | const std::vector< size_t > & | indices | ) |
Restricts the chain to a sub-chain by removing indices.
Removes all indices provided in the vector from the chain. Returns a reference to the modified chain.
| indices | The indices to remove. |
| SparseChain & SparseChain::operator/= | ( | size_t | index | ) |
Restricts the chain to a sub-chain by removing a given index.
Removes the index provided from the chain.
| index | The index to remove. |
| Sparse_chain & SparseChain::operator= | ( | const Sparse_chain & | other | ) |
Assignment.
The assignment operator converts the storage format if needed (complexity \(\mathscr O(k)\) with \(k\) the number of non zero coefficients of other).
| other | Chain to copy into this. |
| void SparseChain::set_coefficient | ( | size_t | index, |
| Coefficient_ring | d ) |
Sets coefficient index of the chain to value d.
Sets the value of the coefficient in the chain at index.
| index | The coefficient index. |
| d | Value of the coefficient. |
| SparseChain SparseChain::transpose | ( | ) |
Transposes a sparse chain.
The result is a chain with Storage_format switched between COLUMN and ROW.
|
friend |
Performs matrix multiplication between two chains (COLUMN x ROW) and return a ROW matrix.
Generate a row-based matrix from the matrix multiplication and return it.
| column | The column chain. |
| row | The row chain. |
|
friend |
Multiplies each coefficient of chain by lambda.
| lambda | The factor to apply. |
| chain | The chain. |
|
friend |
Performs dot product between two chains (ROW x COLUMN).
| row | The row chain. |
| column | The column chain. |
|
friend |
Performs matrix multiplication between two chains (COLUMN x ROW) and return a COLUMN matrix.
Generate a column-based matrix from the matrix multiplication and return it.
| column | The column chain. |
| row | The row chain. |
|
friend |
Gets a subchain from the chain.
Returns a copy of chain where all coefficients of indices provided in the vector are removed.
| indices | The indices to remove. |
|
friend |
Gets a subchain from the chain.
Returns a copy of chain where the coefficient at a given index is removed.
| index | The index to remove. |
|
friend |
Inserts chain in the output stream with a compact "user friendly" format.
| stream | The output stream. |
| chain | The chain to display. |
|
friend |
Tests if two chains are equal.
If the storage formats of chains differ, return false, otherwise, tests if all coefficients are equal.
| chain | First chain to compare. |
| other | Second chain to compare. |
|
friend |
Reads a sparse chain from an input stream using the .osm file format.
Loads a sparse chain (the chain can be exported using write_chain), see OSM file format documentation.
|
friend |
Reads a sparse chain from a file using the .osm file format.
Loads a sparse chain (the chain can be exported using write_chain), see OSM file format documentation.
|
friend |
Write a sparse chain to an output stream using the .osm file format.
Outputs a sparse chain (the chain can be reloaded using read_chain), see OSM file format documentation.
|
friend |
Write a sparse chain to a file using the .osm file format.
Outputs a sparse chain (the chain can be reloaded using read_chain), see OSM file format documentation.