INMOST
A toolkit for distributed mathematical modeling
INMOST::Sparse::Matrix Class Reference

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)
 
Matrixoperator= (Matrix const &other)
 
Rowoperator[] (INMOST_DATA_ENUM_TYPE i)
 Return reference to i-th Row of the matrix.
 
const Rowoperator[] (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.
 

Detailed Description

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).

See also
http://netlib.org/linalg/html_templates/node91.html

Definition at line 474 of file inmost_sparse.h.

Constructor & Destructor Documentation

◆ Matrix()

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.

Parameters
_nameName of the matrix, empty string by default.
startStart of the local data interval.
endEnd of the local data interval.
_commCommunicator for parallel data exchanges, MPI_COMM_WORLD by default.

Member Function Documentation

◆ Load()

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).

◆ MatVec()

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.

Parameters
yInput/output vector.

◆ MatVecTranspose()

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.

Parameters
yInput/output vector.

◆ Residual()

INMOST_DATA_REAL_TYPE INMOST::Sparse::Matrix::Residual ( Sparse::Vector RHS,
Sparse::Vector SOL 
)

Calculate the real residual.

Parameters
RHSThe right-hand side Vector b.
SOLThe initial guess to the solution on input and the solution Vector x on return.
Returns
||A*x-b||

It is assumed that the coefficient matrix A have been set and the preconditioner have been already constructed.

◆ Save()

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.

See also
http://math.nist.gov/MatrixMarket/formats.html

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