A struct which stores a sparse matrix in CSR format. More...
#include <MatrixCSR.hpp>
Public Member Functions | |
MatrixCSR (S nnz_in, S nrows_in) | |
A constructor of `MatrixCSR`. The three arrays MatrixCSR::rows, MatrixCSR::cols and MatrixCSR::vals are allocated, without further filling in. More... | |
MatrixCSR (std::vector< S > rowoffs, std::vector< S > colidxs, std::vector< T > values) | |
A constructor of `MatrixCSR`. The three arrays MatrixCSR::rows, MatrixCSR::cols and MatrixCSR::vals are filled with user-provided arrays. More... | |
~MatrixCSR () | |
This a destructor of MatrixCSR. | |
T | GetValue (S row, S col) |
Get the value of position `(row, col)` from sparse matrix. More... | |
void | SetValue (S row, S col, T val) |
Overwrite the value of entry of position `(row, col)` in sparse matrix by `val`. More... | |
void | InsertValue (S row, S col, T val) |
Insert a value `val` in the position `(row, col)` in sparse matrix. More... | |
void | show () |
Print the sparse matrix in COO format. More... | |
Public Attributes | |
S | nrows |
number of rows of a sparse matrix More... | |
S | nnz |
number of non-zero entries of a sparse matrix More... | |
S | ncols |
dimension of the array MatrixCSR::cols More... | |
std::vector< S > | rows |
An array points to row starts in indices and data. More... | |
std::vector< S > | cols |
An array stores the column indices of non-zero elements. More... | |
std::vector< T > | vals |
An array stores the values of non-zero elements. More... | |
A struct which stores a sparse matrix in CSR format.
This struct defines a CSR format to store a sparse matrix. This format stores a sparse matrix with three arrays
T | describes the scalar types of the entries of a sparse matrix. |
S | type of integer to describes the dimension of matrices to be generated. |
A constructor of `MatrixCSR`. The three arrays MatrixCSR::rows, MatrixCSR::cols and MatrixCSR::vals are allocated, without further filling in.
[in] | nnz_in | number of non-zero elements in the sparse matrix to be allocated |
[in] | nrows_in | number of rows of the sparse matrix to be allocated |
|
inline |
A constructor of `MatrixCSR`. The three arrays MatrixCSR::rows, MatrixCSR::cols and MatrixCSR::vals are filled with user-provided arrays.
[in] | rowoffs | user-provided array stored in a `std::vector` for MatrixCSR::rows |
[in] | colidxs | user-provided array stored in a `std::vector` for MatrixCSR::cols |
[in] | values | user-provided array stored in a `std::vector` for MatrixCSR::vals |
|
inline |
Get the value of position `(row, col)` from sparse matrix.
[in] | row | index of row of the poisition in sparse matrix |
[in] | col | index of column of the poisition in sparse matrix |
|
inline |
Insert a value `val` in the position `(row, col)` in sparse matrix.
[in] | row | index of row of the poisition in sparse matrix |
[in] | col | index of column of the poisition in sparse matrix |
[in] | val | the value should be set on the position `(row, col)` of sparse matrix |
|
inline |
Overwrite the value of entry of position `(row, col)` in sparse matrix by `val`.
[in] | row | index of row of the poisition in sparse matrix |
[in] | col | index of column of the poisition in sparse matrix |
[in] | val | the value should be set on the position `(row, col)` of sparse matrix |
|
inline |
Print the sparse matrix in COO format.
Print the sparse matrix in COO format
std::vector<S> MatrixCSR< T, S >::cols |
An array stores the column indices of non-zero elements.
Its size is `nnz`
S MatrixCSR< T, S >::ncols |
dimension of the array MatrixCSR::cols
dimension of the array MatrixCSR::cols, which stores the column indices of all non-zero entries.
S MatrixCSR< T, S >::nnz |
number of non-zero entries of a sparse matrix
number of non-zero entries of a sparse matrix
S MatrixCSR< T, S >::nrows |
number of rows of a sparse matrix
number of rows of a sparse matrix
std::vector<S> MatrixCSR< T, S >::rows |
An array points to row starts in indices and data.
Its size is `nrows+1`
std::vector<T> MatrixCSR< T, S >::vals |
An array stores the values of non-zero elements.
Its size is `nnz`