CGAL 6.2 - Homological Discrete Vector Fields
Loading...
Searching...
No Matches
HDVF/matrix_chain.cpp
#include <iostream>
#include <fstream>
#include <CGAL/OSM/OSM.h>
int main ()
{
// Create a column-major sparse matrix
Column_matrix M(5,4) ;
// Fill coefficients
// Iterate over non empty columns
for(CGAL::OSM::Bitboard::iterator it_col = M.begin(); it_col != M.end(); ++it_col)
{
std::cout << "col: " << *it_col << std::endl ;
// Get a constant reference over the column (complexity O(1))
const Column_chain& col(CGAL::OSM::cget_column(M, *it_col));
// Iterate over the column
for (Column_chain::const_iterator it = col.begin(); it != col.end(); ++it)
{
std::cout << "row: " << it->first << " - coef: " << it->second << std::endl ;
}
}
// Direct output of the matrix with << operator
std::cout << "M: " << M << std::endl;
return 0 ;
}
The class Sparse_chain implements the concept SparseChain, that is, sparse vectors (encoding homologi...
Definition: Sparse_chain.h:52
iterator end() noexcept
Iterator to the end of the chain.
Definition: Sparse_chain.h:573
iterator begin() noexcept
Iterator to the beginning of the chain.
Definition: Sparse_chain.h:540
std::unordered_map< size_t, CoefficientRing >::const_iterator const_iterator
Type of chains constant iterators.
Definition: Sparse_chain.h:66
The class Sparse_matrix implements the concept SparseMatrix, that is, sparse matrices optimized for t...
Definition: Sparse_matrix.h:68
Bitboard::iterator begin() const noexcept
Iterator to the index of the first non null chain.
Definition: Sparse_matrix.h:1274
Bitboard::iterator end() const noexcept
Iterator past-the-end of chain indices.
Definition: Sparse_matrix.h:1281
void set_coefficient(Sparse_matrix< _CT, _CTF > &matrix, size_t i, size_t j, const _CT d)
Definition: Sparse_matrix.h:1830
const Sparse_chain< _CT, COLUMN > & cget_column(const Sparse_matrix< _CT, COLUMN > &matrix, size_t index)
Definition: Sparse_matrix.h:1749
Definition: Bitboard.h:97