ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ModuleIO::SparseMatrix< T > Class Template Reference

Sparse matrix class designed mainly for csr format input and output. More...

#include <sparse_matrix.h>

Collaboration diagram for ModuleIO::SparseMatrix< T >:

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 >, Telements
 
double _sparse_threshold = 1.0e-10
 

Detailed Description

template<typename T>
class ModuleIO::SparseMatrix< T >

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.

Template Parameters
Tdata type, it can be double or std::complex<double>

Constructor & Destructor Documentation

◆ SparseMatrix() [1/2]

template<typename T >
ModuleIO::SparseMatrix< T >::SparseMatrix ( )
inline

◆ SparseMatrix() [2/2]

template<typename T >
ModuleIO::SparseMatrix< T >::SparseMatrix ( int  rows,
int  cols 
)
inline

Member Function Documentation

◆ getCols()

template<typename T >
int ModuleIO::SparseMatrix< T >::getCols ( ) const
inline

◆ getElements()

template<typename T >
const std::map< std::pair< int, int >, T > & ModuleIO::SparseMatrix< T >::getElements ( ) const
inline
Here is the caller graph for this function:

◆ getNNZ()

template<typename T >
int ModuleIO::SparseMatrix< T >::getNNZ ( ) const
inline
Here is the caller graph for this function:

◆ getRows()

template<typename T >
int ModuleIO::SparseMatrix< T >::getRows ( ) const
inline

◆ getSparseThreshold()

template<typename T >
double ModuleIO::SparseMatrix< T >::getSparseThreshold ( ) const
inline
Here is the caller graph for this function:

◆ insert()

template<typename T >
void ModuleIO::SparseMatrix< T >::insert ( int  row,
int  col,
T  value 
)

Add value to the matrix with row and column indices.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()()

template<typename T >
T ModuleIO::SparseMatrix< T >::operator() ( int  row,
int  col 
) const
Here is the call graph for this function:

◆ printToCSR()

template<typename T >
void ModuleIO::SparseMatrix< T >::printToCSR ( std::ostream &  ofs,
int  precision = 8 
)

Print to CSR format.

Here is the caller graph for this function:

◆ readCSR()

template<typename T >
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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCols()

template<typename T >
void ModuleIO::SparseMatrix< T >::setCols ( int  cols)
inline
Here is the caller graph for this function:

◆ setRows()

template<typename T >
void ModuleIO::SparseMatrix< T >::setRows ( int  rows)
inline
Here is the caller graph for this function:

◆ setSparseThreshold()

template<typename T >
void ModuleIO::SparseMatrix< T >::setSparseThreshold ( double  sparse_threshold)
inline
Here is the caller graph for this function:

Member Data Documentation

◆ _cols

template<typename T >
int ModuleIO::SparseMatrix< T >::_cols
private

◆ _rows

template<typename T >
int ModuleIO::SparseMatrix< T >::_rows
private

◆ _sparse_threshold

template<typename T >
double ModuleIO::SparseMatrix< T >::_sparse_threshold = 1.0e-10
private

◆ elements

template<typename T >
std::map<std::pair<int, int>, T> ModuleIO::SparseMatrix< T >::elements
private

The documentation for this class was generated from the following files: