INMOST
A toolkit for distributed mathematical modeling
|
Class to store the distributed sparse matrix by compressed rows. More...
#include <inmost_sparse.h>
Public Types | |
typedef Rows::iterator | iterator |
typedef Rows::const_iterator | const_iterator |
Public Member Functions | |
Matrix (std::string _name="", INMOST_DATA_ENUM_TYPE start=0, INMOST_DATA_ENUM_TYPE end=0, INMOST_MPI_Comm _comm=INMOST_MPI_COMM_WORLD) | |
Main constructor of the Matrix class. More... | |
Matrix (const Matrix &other) | |
Matrix & | operator= (Matrix const &other) |
Row & | operator[] (INMOST_DATA_ENUM_TYPE i) |
Return reference to i-th Row of the matrix. | |
const Row & | operator[] (INMOST_DATA_ENUM_TYPE i) const |
Return reference to i-th Row of the matrix. | |
INMOST_DATA_ENUM_TYPE | Size () const |
Return the total number of rows in the matrix. | |
bool | Empty () const |
iterator | Begin () |
iterator | End () |
const_iterator | Begin () const |
const_iterator | End () const |
void | SetInterval (INMOST_DATA_ENUM_TYPE start, INMOST_DATA_ENUM_TYPE end) |
Set the start and the end row numbers of the distributed matrix interval. | |
void | GetInterval (INMOST_DATA_ENUM_TYPE &start, INMOST_DATA_ENUM_TYPE &end) const |
Get the start and the end row numbers of the distributed matrix interval. | |
void | ShiftInterval (INMOST_DATA_ENUM_TYPE shift) |
INMOST_DATA_ENUM_TYPE | GetFirstIndex () const |
Get the first row index of the distributed matrix interval. | |
INMOST_DATA_ENUM_TYPE | GetLastIndex () const |
Get the last row index of the distributed matrix interval. | |
INMOST_MPI_Comm | GetCommunicator () const |
Get the communicator which the matrix is associated with. | |
void | MoveRows (INMOST_DATA_ENUM_TYPE from, INMOST_DATA_ENUM_TYPE to, INMOST_DATA_ENUM_TYPE size) |
void | Swap (Matrix &other) |
void | MatVec (INMOST_DATA_REAL_TYPE alpha, Vector &x, INMOST_DATA_REAL_TYPE beta, Vector &y) const |
Matrix-vector product of the form: y = alpha*A*x + beta * y. More... | |
void | MatVecTranspose (INMOST_DATA_REAL_TYPE alpha, Vector &x, INMOST_DATA_REAL_TYPE beta, Vector &y) const |
Matrix-vector product with transposed matrix of the form: y = alpha*A^T*x + beta * y. More... | |
void | Clear () |
Clear all data of the matrix. | |
INMOST_DATA_ENUM_TYPE | Nonzeros () |
Count number of nonzeros in matrix. | |
void | Load (std::string file, INMOST_DATA_ENUM_TYPE beg=ENUMUNDEF, INMOST_DATA_ENUM_TYPE end=ENUMUNDEF, std::string file_ord="") |
Load the matrix from a single data file in MTX format using the specified interval. More... | |
void | Save (std::string file, const AnnotationService *annotation=NULL) |
Save the distributed matrix to a single data file in MTX format using parallel MPI I/O. More... | |
bool & | isParallel () |
Check that matrix is in parallel state. | |
const bool & | isParallel () const |
std::string | GetName () const |
Get the matrix name specified in the main constructor. | |
void | Sort () |
Sort rows. | |
INMOST_DATA_REAL_TYPE | Residual (Sparse::Vector &RHS, Sparse::Vector &SOL) |
Calculate the real residual. More... | |
Static Public Member Functions | |
static void | ZAXPBY (INMOST_DATA_REAL_TYPE alpha, const Sparse::Matrix &X, INMOST_DATA_REAL_TYPE beta, const Sparse::Matrix &Y, Sparse::Matrix &Z) |
ZAXPBY operation for sparse matrices Z = alpha * X + beta * Y. | |
Class to store the distributed sparse matrix by compressed rows.
The format used to store sparse matrix is analogous to Compressed Row Storage format (CRS).
Definition at line 474 of file inmost_sparse.h.
INMOST::Sparse::Matrix::Matrix | ( | std::string | _name = "" , |
INMOST_DATA_ENUM_TYPE | start = 0 , |
||
INMOST_DATA_ENUM_TYPE | end = 0 , |
||
INMOST_MPI_Comm | _comm = INMOST_MPI_COMM_WORLD |
||
) |
Main constructor of the Matrix class.
_name | Name of the matrix, empty string by default. |
start | Start of the local data interval. |
end | End of the local data interval. |
_comm | Communicator for parallel data exchanges, MPI_COMM_WORLD by default. |
void INMOST::Sparse::Matrix::Load | ( | std::string | file, |
INMOST_DATA_ENUM_TYPE | beg = ENUMUNDEF , |
||
INMOST_DATA_ENUM_TYPE | end = ENUMUNDEF , |
||
std::string | file_ord = "" |
||
) |
Load the matrix from a single data file in MTX format using the specified interval.
If interval is not specified, then it will be automatically constructed, with the about equal block size (the last block may has larger dimension).
void INMOST::Sparse::Matrix::MatVec | ( | INMOST_DATA_REAL_TYPE | alpha, |
Vector & | x, | ||
INMOST_DATA_REAL_TYPE | beta, | ||
Vector & | y | ||
) | const |
Matrix-vector product of the form: y = alpha*A*x + beta * y.
y | Input/output vector. |
void INMOST::Sparse::Matrix::MatVecTranspose | ( | INMOST_DATA_REAL_TYPE | alpha, |
Vector & | x, | ||
INMOST_DATA_REAL_TYPE | beta, | ||
Vector & | y | ||
) | const |
Matrix-vector product with transposed matrix of the form: y = alpha*A^T*x + beta * y.
y | Input/output vector. |
INMOST_DATA_REAL_TYPE INMOST::Sparse::Matrix::Residual | ( | Sparse::Vector & | RHS, |
Sparse::Vector & | SOL | ||
) |
void INMOST::Sparse::Matrix::Save | ( | std::string | file, |
const AnnotationService * | annotation = NULL |
||
) |
Save the distributed matrix to a single data file in MTX format using parallel MPI I/O.