Hex
1.0
Hydrogen-electron collision solver
|
Complex CSR matrix. More...
#include <matrix.h>
Data Structures | |
class | LUft |
LU factorization object. More... | |
class | PngGenerator |
Public Member Functions | |
CsrMatrix () | |
CsrMatrix (size_t m, size_t n) | |
CsrMatrix (CsrMatrix const &A) | |
CsrMatrix (size_t m, size_t n, lArrayView const &p, lArrayView const &i, cArrayView const &x) | |
~CsrMatrix () | |
void | drop () |
Clear data. More... | |
cArray | dot (cArrayView const &b) const |
size_t | size () const |
size_t | rows () const |
size_t | cols () const |
lArray const & | p () const |
lArray const & | i () const |
cArray const & | x () const |
double | norm () const |
void | write (const char *filename) const |
void | plot (const char *filename, double threshold=0.) const |
LUft | factorize (double droptol=0) const |
Compute (incomplete) LU factorization. More... | |
cArray | solve (const cArrayView b, size_t eqs=1) const |
Solve the Ax = b problem, where "b" can be a matrix. More... | |
void | link (std::string name) |
Link to a disk file. More... | |
Complex | operator() (unsigned i, unsigned j) const |
CsrMatrix & | operator*= (Complex r) |
CsrMatrix & | operator&= (CsrMatrix const &B) |
CsrMatrix & | operator^= (CsrMatrix const &B) |
CsrMatrix | sparse_like (CsrMatrix const &B) const |
cArray | diag () const |
CooMatrix | tocoo () const |
RowMatrix< Complex > | torow () const |
cArray | upperSolve (cArrayView const &b) const |
cArray | lowerSolve (cArrayView const &b) const |
template<class Functor > | |
CsrMatrix | nzTransform (Functor f) const |
bool | hdfsave () const |
bool | hdfsave (std::string name) const |
bool | hdfload () |
bool | hdfload (std::string name) |
Complex compressed-storage-row-major-ordered sparse matrix. The data are stored in four arrays,
Here, Ap
is an array of N+1 elements, where N is the number of rows. It contains indices of beginnings of single rows in all remaining arrays. The last element contains one-past-end pointer, i.e. it should be aqual to the element count of the matrix (zero and nonzero). The array Ai
holds column indices of elements, which are stored in Ax
and Az
, real ang imaginary part being separated.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
cArray CsrMatrix::diag | ( | ) | const |
Return dense array with diagonal elements of the matrix.
cArray CsrMatrix::dot | ( | cArrayView const & | b | ) | const |
Ordinary matrix-vector product, \( A\cdot b \).
b | Vector to multiply with. |
|
inline |
CsrMatrix::LUft CsrMatrix::factorize | ( | double | droptol = 0 | ) | const |
This function computes the LU factorization of the matrix. It uses the free UMFPACK library.
droptol | Drop tolerance. If an element of the factorization matrices should be in absolute value smaller than "droptol" the library will omit it completely effectively making the result more sparse. |
|
inline |
Load matrix from HDF file.
bool CsrMatrix::hdfload | ( | std::string | name | ) |
|
inline |
Save matrix to HDF file.
bool CsrMatrix::hdfsave | ( | std::string | name | ) | const |
|
inline |
void CsrMatrix::link | ( | std::string | name | ) |
cArray CsrMatrix::lowerSolve | ( | cArrayView const & | b | ) | const |
Solves lower triangular system of equations using backsubstitution. The matrix needs not be triangular, but elements above the diagonal won't be used or changed.
b | Right-hand side. |
double CsrMatrix::norm | ( | ) | const |
|
inline |
Addition of another CSR matrix. The matrices MUST HAVE THE SAME SPARSE STRUCTURE, as no indices are checked.
Complex CsrMatrix::operator() | ( | unsigned | i, |
unsigned | j | ||
) | const |
Element-wise access (const). If a non-existing element is referenced, zero is returned.
Subtraction of another CSR matrix. The matrices MUST HAVE THE SAME SPARSE STRUCTURE, as no indices are checked.
|
inline |
void CsrMatrix::plot | ( | const char * | filename, |
double | threshold = 0. |
||
) | const |
Save matrix structure as a black-and-white image.
filename | File name. |
threshold | Largest absolute value represented by white colour. |
|
inline |
|
inline |
cArray CsrMatrix::solve | ( | const cArrayView | b, |
size_t | eqs = 1 |
||
) | const |
Uses UMFPACK through the LUft::solve function.
b | Complex vector containing column-major ordered data; it may be a flattened matrix. |
eqs | Number of columns. |
Sets fill-in elements so that the storage structure of this matrix will be identical to that of the other CSR matrix. We can the use “fast” arithmetic operators & and ^.
CooMatrix CsrMatrix::tocoo | ( | ) | const |
Convert to COO format.
cArray CsrMatrix::upperSolve | ( | cArrayView const & | b | ) | const |
Solves upper triangular system of equations using backsubstitution. The matrix needs not be triangular, but elements under the diagonal won't be used or changed.
b | Right-hand side. |
void CsrMatrix::write | ( | const char * | filename | ) | const |
Write the matrix data to a file.
filename | Filename. |
Format of the fields i,j,x,z is:
|
inline |