ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Sparse matrix class designed mainly for csr format input and output. More...
#include <sparse_matrix.h>
Public Member Functions | |
SparseMatrix () | |
SparseMatrix (int rows, int cols) | |
void | insert (int row, int col, T value) |
Add value to the matrix with row and column indices. | |
void | printToCSR (std::ostream &ofs, int precision=8) |
Print to CSR format. | |
void | readCSR (const std::vector< T > &values, const std::vector< int > &col_ind, const std::vector< int > &row_ptr) |
Read CSR data from arrays. | |
void | setRows (int rows) |
void | setCols (int cols) |
int | getRows () const |
int | getCols () const |
T | operator() (int row, int col) const |
void | setSparseThreshold (double sparse_threshold) |
double | getSparseThreshold () const |
int | getNNZ () const |
const std::map< std::pair< int, int >, T > & | getElements () const |
Private Attributes | |
int | _rows |
int | _cols |
std::map< std::pair< int, int >, T > | elements |
double | _sparse_threshold = 1.0e-10 |
Sparse matrix class designed mainly for csr format input and output.
The sparse matrix is stored in a map. The map key is a pair of row and column indices. The map value is the matrix element. The matrix element is stored only if its absolute value is greater than the threshold. The threshold is set to 1.0e-10 by default.
T | data type, it can be double or std::complex<double> |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void ModuleIO::SparseMatrix< T >::insert | ( | int | row, |
int | col, | ||
T | value | ||
) |
Add value to the matrix with row and column indices.
T ModuleIO::SparseMatrix< T >::operator() | ( | int | row, |
int | col | ||
) | const |
void ModuleIO::SparseMatrix< T >::printToCSR | ( | std::ostream & | ofs, |
int | precision = 8 |
||
) |
Print to CSR format.
void ModuleIO::SparseMatrix< T >::readCSR | ( | const std::vector< T > & | values, |
const std::vector< int > & | col_ind, | ||
const std::vector< int > & | row_ptr | ||
) |
Read CSR data from arrays.
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |