|
ADS
Algorithms and Data Structures
|
A sparse matrix in compressed sparse rows (CSR), beyond the book: the nonzeros of each row, by column, in one vector of values and one of columns, and the place where each row begins in a vector of \( m + 1 \) offsets, \( 12 \, \mathit{nnz} + 8 m \) bytes for doubles, read in order by the product with a vector instead of the walk of the orthogonal lists of SparseMatrix [see SparseMatrix.h], whose nodes are scattered. More...
#include "ADS/Contract.h"#include "ADS/external/MappedFile.h"#include "ADS/numeric/DenseMatrix.h"#include "ADS/numeric/SparseMatrix.h"#include <algorithm>#include <concepts>#include <cstddef>#include <cstdint>#include <limits>#include <numeric>#include <string_view>#include <tuple>#include <type_traits>#include <utility>#include <vector>#include "ADS/numeric/impl/CsrMatrix.tpp"Go to the source code of this file.
Classes | |
| class | ADS::BasicCsrMatrix< T, I, P > |
| a sparse \( m \times n \) matrix of values T in compressed sparse rows, the columns of the type I and the offsets of the rows of the type P More... | |
Namespaces | |
| namespace | ADS |
Typedefs | |
| using | ADS::CsrMatrix = BasicCsrMatrix<> |
| the matrix of doubles of 32-bit columns and std::size_t offsets | |
A sparse matrix in compressed sparse rows (CSR), beyond the book: the nonzeros of each row, by column, in one vector of values and one of columns, and the place where each row begins in a vector of \( m + 1 \) offsets, \( 12 \, \mathit{nnz} + 8 m \) bytes for doubles, read in order by the product with a vector instead of the walk of the orthogonal lists of SparseMatrix [see SparseMatrix.h], whose nodes are scattered.
BasicCsrMatrix< T , I , P > takes the type T of the values, the type I of the columns and the type P of the offsets, and CsrMatrix is BasicCsrMatrix<>: doubles, columns of 32 bits without sign and offsets std::size_t, so that the nonzeros may exceed \( 2^{32} \) while a column takes 4 bytes. Any other I gives offsets of the same type, e.g., BasicCsrMatrix< double , int >, whose three arrays are those of a row-major Eigen::SparseMatrix< double , Eigen::RowMajor , int >, of a compressed matrix of METIS or of the container of GraphBLAS with indices of 32 bits, which the libraries map without a copy; with std::int64_t they are those of the 64-bit indices of GraphBLAS and of MKL. The bytes are \( ( s + i ) \, \mathit{nnz} + p ( m + 1 ) \) for s , i , p the sizes of T , I , P.
The contracts [see Contract.h]: the places of the triplets are in the matrix, the columns fit I and the nonzeros P (the rows fit I too, for transpose()); \( x \) has \( n \) entries; the invariant is that the offsets do not decrease and the columns of a row increase, an audit. The functions are defined in CsrMatrix.tpp.