ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SellMatrix.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*---------------------------- File SellMatrix.h ---------------------------*/
3/*--------------------------------------------------------------------------*/
51/*--------------------------------------------------------------------------*/
52/*----------------------------- DEFINITIONS --------------------------------*/
53/*--------------------------------------------------------------------------*/
54
55#ifndef __ADS_SellMatrix
56 #define __ADS_SellMatrix
57/* self-identification: #endif constant */
58
59/*--------------------------------------------------------------------------*/
60/*------------------------------ INCLUDES ----------------------------------*/
61/*--------------------------------------------------------------------------*/
62
63#include "ADS/Contract.h"
65
66#include <algorithm>
67#include <cstddef>
68#include <cstdint>
69#include <numeric>
70#include <vector>
71
72/*--------------------------------------------------------------------------*/
73/*--------------------------- NAMESPACE ------------------------------------*/
74/*--------------------------------------------------------------------------*/
75
76namespace ADS
77{
78
79/*--------------------------------------------------------------------------*/
80/*---------------------------- CLASS SellMatrix ----------------------------*/
81/*--------------------------------------------------------------------------*/
82
86template< std::size_t C = 4 >
88{
89 static_assert( ( C >= 1 ) && ( ( C & ( C - 1 ) ) == 0 ) ,
90 "the rows of a chunk are a power of 2" );
91
92 public:
117 explicit SellMatrix( const CsrMatrix & A , std::size_t sigma = 256 );
118
120 [[nodiscard]] std::size_t rows( void ) const { return( f_m ); }
122 [[nodiscard]] std::size_t cols( void ) const { return( f_n ); }
123
125 [[nodiscard]] std::size_t nonzeros( void ) const { return( f_nnz ); }
127 [[nodiscard]] std::size_t places( void ) const { return( f_val.size() ); }
128
133 void multiply( const double * x , double * y ) const;
134
159 void multiply( const double * x , double * y , std::size_t first ,
160 std::size_t last ) const;
161
163 [[nodiscard]] std::size_t chunks( void ) const {
164 return( f_start.size() - 1 );
165 }
166
168 [[nodiscard]] std::size_t chunkStart( std::size_t c ) const {
169 return( f_start[ c ] );
170 }
171
174 [[nodiscard]] std::vector< double >
175 multiply( const std::vector< double > & x ) const;
176
177 private:
178 std::size_t f_m ,
179 f_n ,
180 f_nnz;
182 std::vector< std::size_t > f_start;
183 std::vector< std::uint32_t > f_perm;
184 std::vector< std::uint32_t > f_col;
185 std::vector< double > f_val;
186 }; // end( class SellMatrix )
187
188/*--------------------------------------------------------------------------*/
189
190} // end( namespace ADS )
191
192/*--------------------------------------------------------------------------*/
193/*-------------------------- IMPLEMENTATION --------------------------------*/
194/*--------------------------------------------------------------------------*/
195
196#include "ADS/numeric/impl/SellMatrix.tpp"
197
198/*--------------------------------------------------------------------------*/
199
200#endif /* SellMatrix.h included */
201
202/*--------------------------------------------------------------------------*/
203/*------------------------- End File SellMatrix.h --------------------------*/
204/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
A sparse matrix in compressed sparse rows (CSR), beyond the book: the nonzeros of each row,...
std::size_t rows(void) const
the number of rows
Definition SellMatrix.h:120
std::vector< double > multiply(const std::vector< double > &x) const
the product , a new vector
std::size_t chunks(void) const
the number of chunks
Definition SellMatrix.h:163
void multiply(const double *x, double *y, std::size_t first, std::size_t last) const
the entries of of the rows of the chunks of rows (by the permutation), so that the chunks may be s...
SellMatrix(const CsrMatrix &A, std::size_t sigma=256)
the matrix , its rows sorted by length within windows of rows
std::size_t places(void) const
the places kept, and the padding
Definition SellMatrix.h:127
std::size_t chunkStart(std::size_t c) const
the place where the chunk starts, chunks() for the end
Definition SellMatrix.h:168
std::size_t nonzeros(void) const
the number of the nonzeros of
Definition SellMatrix.h:125
std::size_t cols(void) const
the number of columns
Definition SellMatrix.h:122
void multiply(const double *x, double *y) const
the product into , which must have entries, as the chunks from 0 to chunks()
BasicCsrMatrix<> CsrMatrix
the matrix of doubles of 32-bit columns and std::size_t offsets
Definition CsrMatrix.h:277
Definition ADT.h:96