|
DOCI-Exact
1.0
|
#include <SparseMatrix_CRS.h>
Public Member Functions | |
| SparseMatrix_CRS (unsigned int n) | |
| virtual | ~SparseMatrix_CRS ()=default |
| double | operator() (unsigned int i, unsigned int j) const |
| unsigned int | gn () const |
| void | ConvertFromMatrix (const helpers::matrix &dense) |
| void | ConvertToMatrix (helpers::matrix &dense) const |
| void | PrintRaw () const |
| void | PushToRow (unsigned int j, double value) |
| void | PushToRowNext (unsigned int j, double value) |
| void | NewRow () |
| void | mvprod (const double *, double *) const |
| void | mvprod (const double *, double *, double) const |
| void | SetGuess (unsigned int) |
| int | WriteToFile (const char *, const char *, bool=false) const |
| int | ReadFromFile (const char *, const char *) |
| unsigned int | NumOfElInRow (unsigned int idx) const |
| double | GetElementInRow (unsigned int row_index, unsigned int element_index) const |
| unsigned int | GetElementColIndexInRow (unsigned int row_index, unsigned int element_index) const |
| void | AddList (std::vector< std::unique_ptr< SparseMatrix_CRS > > &) |
| SparseMatrix_CRS (unsigned int n) | |
| virtual | ~SparseMatrix_CRS ()=default |
| double | operator() (unsigned int i, unsigned int j) const |
| unsigned int | gn () const |
| void | ConvertFromMatrix (const helpers::matrix &dense) |
| void | ConvertToMatrix (helpers::matrix &dense) const |
| void | PrintRaw () const |
| void | PushToRow (unsigned int j, double value) |
| void | PushToRowNext (unsigned int j, double value) |
| void | NewRow () |
| void | mvprod (const double *, double *) const |
| void | mvprod (const double *, double *, double) const |
| void | SetGuess (unsigned int) |
| int | WriteToFile (const char *, const char *, bool=false) const |
| int | ReadFromFile (const char *, const char *) |
| unsigned int | NumOfElInRow (unsigned int idx) const |
| double | GetElementInRow (unsigned int row_index, unsigned int element_index) const |
| unsigned int | GetElementColIndexInRow (unsigned int row_index, unsigned int element_index) const |
| void | AddList (std::vector< std::unique_ptr< SparseMatrix_CRS > > &) |
Friends | |
| std::ostream & | operator<< (std::ostream &output, helpers::SparseMatrix_CRS &matrix_p) |
| std::ostream & | operator<< (std::ostream &output, helpers::SparseMatrix_CRS &matrix_p) |
Definition at line 22 of file SparseMatrix_CRS.h.
| SparseMatrix_CRS::SparseMatrix_CRS | ( | unsigned int | n | ) |
Construct SparseMatrix_CRS object for n x n matrix
| n | the number of rows/columns |
Definition at line 18 of file SparseMatrix_CRS.cpp.
|
virtualdefault |
| helpers::SparseMatrix_CRS::SparseMatrix_CRS | ( | unsigned int | n | ) |
|
virtualdefault |
| void SparseMatrix_CRS::AddList | ( | std::vector< std::unique_ptr< SparseMatrix_CRS > > & | list | ) |
Add a bunch of non-overlapping, in order, Sparse Matrices together to the current object (overwriting any previous data). This is used if threads each builded a part of the matrix into seperate SparseMatrix_CRS objects. After the parallel part, this method builds the final Sparse Matrix. We also assume that the matrices in the list are in order: the first rows first, etc This method is tuned for the DOCIHamiltonian::Build_iter(), it's not general!
| list | the list of pointer to the Sparse Matrices |
Definition at line 524 of file SparseMatrix_CRS.cpp.
| void helpers::SparseMatrix_CRS::AddList | ( | std::vector< std::unique_ptr< SparseMatrix_CRS > > & | ) |
| void SparseMatrix_CRS::ConvertFromMatrix | ( | const helpers::matrix & | dense | ) |
Convert a dense matrix to CRS format
| dense | the matrix to convert |
Definition at line 53 of file SparseMatrix_CRS.cpp.
Here is the call graph for this function:| void helpers::SparseMatrix_CRS::ConvertFromMatrix | ( | const helpers::matrix & | dense | ) |
| void SparseMatrix_CRS::ConvertToMatrix | ( | helpers::matrix & | dense | ) | const |
Convert this CRS matrix to a dense symmetric matrix (only works for square matrices)
| dense | the matrix to fill |
Definition at line 83 of file SparseMatrix_CRS.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void helpers::SparseMatrix_CRS::ConvertToMatrix | ( | helpers::matrix & | dense | ) | const |
| unsigned int helpers::SparseMatrix_CRS::GetElementColIndexInRow | ( | unsigned int | row_index, |
| unsigned int | element_index | ||
| ) | const |
| unsigned int SparseMatrix_CRS::GetElementColIndexInRow | ( | unsigned int | row_index, |
| unsigned int | element_index | ||
| ) | const |
Get the column number of a element in a row. Used together with GetElementInRow()
| row_index | the index of the row |
| element_index | the index of the element in the row (index of the non-zero elements, not the column index) |
Definition at line 496 of file SparseMatrix_CRS.cpp.
| double helpers::SparseMatrix_CRS::GetElementInRow | ( | unsigned int | row_index, |
| unsigned int | element_index | ||
| ) | const |
| double SparseMatrix_CRS::GetElementInRow | ( | unsigned int | row_index, |
| unsigned int | element_index | ||
| ) | const |
Get a element out of a row
| row_index | the number of the row where to get an element of |
| element_index | the index of the element (index of the non-zero elements, not the column index) |
Definition at line 485 of file SparseMatrix_CRS.cpp.
| unsigned int helpers::SparseMatrix_CRS::gn | ( | ) | const |
| unsigned int SparseMatrix_CRS::gn | ( | ) | const |
Definition at line 44 of file SparseMatrix_CRS.cpp.
Here is the caller graph for this function:| void SparseMatrix_CRS::mvprod | ( | const double * | x, |
| double * | y | ||
| ) | const |
Do the matrix vector product y = A * x
| x | a m component vector |
| y | a n component vector |
Definition at line 219 of file SparseMatrix_CRS.cpp.
Here is the caller graph for this function:| void helpers::SparseMatrix_CRS::mvprod | ( | const double * | , |
| double * | |||
| ) | const |
| void SparseMatrix_CRS::mvprod | ( | const double * | x, |
| double * | y, | ||
| double | beta | ||
| ) | const |
Do the matrix vector product y = A * x + beta * y
| x | a m component vector |
| y | a n component vector |
| beta | the multiply factor for y |
Definition at line 258 of file SparseMatrix_CRS.cpp.
| void helpers::SparseMatrix_CRS::mvprod | ( | const double * | , |
| double * | , | ||
| double | |||
| ) | const |
| void helpers::SparseMatrix_CRS::NewRow | ( | ) |
| void SparseMatrix_CRS::NewRow | ( | ) |
Adds the next row to the sparsematrix
Definition at line 193 of file SparseMatrix_CRS.cpp.
| unsigned int helpers::SparseMatrix_CRS::NumOfElInRow | ( | unsigned int | idx | ) | const |
| unsigned int SparseMatrix_CRS::NumOfElInRow | ( | unsigned int | idx | ) | const |
Get the number of elements in a row
| idx | the row to consider |
Definition at line 474 of file SparseMatrix_CRS.cpp.
| double SparseMatrix_CRS::operator() | ( | unsigned int | i, |
| unsigned int | j | ||
| ) | const |
Read only access operator
| i | the row number |
| j | the column number |
Definition at line 30 of file SparseMatrix_CRS.cpp.
| double helpers::SparseMatrix_CRS::operator() | ( | unsigned int | i, |
| unsigned int | j | ||
| ) | const |
| void SparseMatrix_CRS::PrintRaw | ( | ) | const |
Print the raw CRS data to stdout
Definition at line 96 of file SparseMatrix_CRS.cpp.
| void helpers::SparseMatrix_CRS::PrintRaw | ( | ) | const |
| void SparseMatrix_CRS::PushToRow | ( | unsigned int | j, |
| double | value | ||
| ) |
Adds a new column element to the current row. To use this, first call NewRow() to start a row and then use PushToRow() to add elements to that row. Always end with calling NewRow() again.
| j | column |
| value | the matrix element value |
Definition at line 137 of file SparseMatrix_CRS.cpp.
| void helpers::SparseMatrix_CRS::PushToRow | ( | unsigned int | j, |
| double | value | ||
| ) |
| void helpers::SparseMatrix_CRS::PushToRowNext | ( | unsigned int | j, |
| double | value | ||
| ) |
| void SparseMatrix_CRS::PushToRowNext | ( | unsigned int | j, |
| double | value | ||
| ) |
Adds a new column element to the current row. To use this, first call NewRow() to start a row and then use PushToRowNext() to add elements to that row. Always end with calling NewRow() again.
IMPORTANT: the PushToRow is a general function, you can push values to the row in any order. This method assumes you always add a new element in a column next to the previous one.
| j | column |
| value | the matrix element value |
Definition at line 182 of file SparseMatrix_CRS.cpp.
| int helpers::SparseMatrix_CRS::ReadFromFile | ( | const char * | , |
| const char * | |||
| ) |
| int SparseMatrix_CRS::ReadFromFile | ( | const char * | filename, |
| const char * | name | ||
| ) |
Read a SparseMatrix_CRS from a HDF5 file
| filename | the name of the file to read from |
| name | the name of the group in the HDF5 file |
Definition at line 384 of file SparseMatrix_CRS.cpp.
Here is the caller graph for this function:| void SparseMatrix_CRS::SetGuess | ( | unsigned int | count | ) |
Set a guess for the number of non-zero elements in the matrix. This method will reserve enough memory to store at least count elements
| count | the number of guessed non-zero elements |
Definition at line 508 of file SparseMatrix_CRS.cpp.
| void helpers::SparseMatrix_CRS::SetGuess | ( | unsigned | int | ) |
| int SparseMatrix_CRS::WriteToFile | ( | const char * | filename, |
| const char * | name, | ||
| bool | append = false |
||
| ) | const |
Save a SparseMatrix_CRS to a HDF5 file
| filename | the name of the file to write to |
| name | the name of the group in the HDF5 file |
| append | add or overwrite file |
Definition at line 290 of file SparseMatrix_CRS.cpp.
Here is the caller graph for this function:| int helpers::SparseMatrix_CRS::WriteToFile | ( | const char * | , |
| const char * | , | ||
| bool | = false |
||
| ) | const |
|
friend |
Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:
object << matrix << endl;
For output onto the screen type:
cout << matrix << endl;
| output | The stream to which you are writing (e.g. cout) |
| matrix_p | de SparseMatrix_CRS you want to print |
Print sparse matrix to output
| output | the ostream to print to |
| matrix_p | the matrix to print |
Definition at line 120 of file SparseMatrix_CRS.cpp.
|
friend |
Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:
object << matrix << endl;
For output onto the screen type:
cout << matrix << endl;
| output | The stream to which you are writing (e.g. cout) |
| matrix_p | de SparseMatrix_CRS you want to print |
Print sparse matrix to output
| output | the ostream to print to |
| matrix_p | the matrix to print |
Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:
object << matrix << endl;
For output onto the screen type:
cout << matrix << endl;
| output | The stream to which you are writing (e.g. cout) |
| matrix_p | de SparseMatrix_CRS you want to print |
Print sparse matrix to output
| output | the ostream to print to |
| matrix_p | the matrix to print |
Definition at line 120 of file SparseMatrix_CRS.cpp.