Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
Public Member Functions | List of all members
TDenseMatrixMPI< MT > Class Template Reference

Distributed dense matrix class. More...

#include <dnsmatrix_mpi.h>

Inheritance diagram for TDenseMatrixMPI< MT >:
TMatrix< MT >

Public Member Functions

 TDenseMatrixMPI ()
 Defines a matrix of size 0 x 0.
 
 TDenseMatrixMPI (int r, int c)
 Defines a matrix of size r x c, and allocates space for a sub-set of rows. More...
 
 ~TDenseMatrixMPI ()
 
MatrixStorage StorageType () const
 Matrix storage class. More...
 
void New (int r, int c)
 Resize matrix to new dimensions. More...
 
void MPIRange (int *_r0, int *_r1) const
 Returns the row range of the current process. More...
 
MT Get (int r, int c) const
 Retrieve a matrix element. More...
 
MT & operator() (int r, int c)
 
TVector< MT > Row (int r) const
 Returns a row of the matrix. More...
 
TVector< MT > Col (int c) const
 Returns a vector containing a copy of column 'c'. More...
 
int SparseRow (int r, int *ci, MT *rv) const
 Returns a row of the matrix in sparse format. More...
 
void SetRow (int r, const TVector< MT > &rval)
 Replace entries in row r with the values provided in rval. More...
 
void ColScale (const TVector< MT > &scale)
 
void RowScale (const TVector< MT > &scale)
 
TVector< MT > RowSum () const
 Returns a vector of row sums. More...
 
TVector< MT > RowSumSq () const
 Returns a vector of sum of squares for each row. More...
 
TVector< MT > ColSum () const
 Returns a vector of column sums. More...
 
TVector< MT > ColSumSq () const
 Returns a vector of sum of squares for each column. More...
 
void Ax (const TVector< MT > &x, TVector< MT > &b) const
 Matrix x vector product. More...
 
void ATx (const TVector< MT > &x, TVector< MT > &b) const
 Matrix-transpose x vector product. More...
 
MPI_Datatype MPIType () const
 Returns MPI type compatible with template type.
 
- Public Member Functions inherited from TMatrix< MT >
 TMatrix ()
 Create a matrix of size 0 x 0.
 
 TMatrix (int nrows, int ncols)
 Create a matrix of logical size nrows x ncols. More...
 
 TMatrix (const TMatrix< MT > &m)
 Create a matrix as a copy of another matrix. More...
 
virtual ~TMatrix ()
 Destroy the matrix. More...
 
int Dim (RC rc) const
 Return a matrix dimension. More...
 
int nRows () const
 Return number of rows of the matrix. More...
 
int nCols () const
 Return number of columns of the matrix. More...
 
bool isSparse () const
 Return sparse storage flag. More...
 
bool isFull () const
 Return dense storage flag. More...
 
MT operator() (int r, int c) const
 Matrix element access (read only) More...
 
virtual TVector< MT > Diag () const
 Returns the matrix diagonal as a vector. More...
 
virtual TVector< MT > ColNorm () const
 Returns vector of column norms. More...
 
TVector< MT > operator* (const TVector< MT > &x) const
 
TVector< MT > ATx (const TVector< MT > &x) const
 
virtual void Transpone ()
 
virtual MT RowMult (int r, MT *x) const
 
void Export (std::ostream &os) const
 Write matrix to ASCII stream. More...
 
void Print (std::ostream &os=std::cout, int n=80) const
 
void PrintNzeroGraph (char *fname)
 
virtual int pcg (const TVector< MT > &b, TVector< MT > &x, double &tol, TPreconditioner< MT > *precon=0, int maxit=0) const
 
virtual void pcg (const TVector< MT > *b, TVector< MT > *x, int nrhs, double tol, int maxit=0, TPreconditioner< MT > *precon=0, IterativeSolverResult *res=0) const
 
virtual int bicgstab (const TVector< MT > &b, TVector< MT > &x, double &tol, TPreconditioner< MT > *precon=0, int maxit=0) const
 
virtual void bicgstab (const TVector< MT > *b, TVector< MT > *x, int nrhs, double tol, int maxit=0, TPreconditioner< MT > *precon=0, IterativeSolverResult *res=0) const
 
template<>
int pcg (const FVector &b, FVector &x, double &tol, TPreconditioner< float > *precon, int maxit) const
 
template<>
void pcg (const FVector *b, FVector *x, int nrhs, double tol, int maxit, TPreconditioner< float > *precon, IterativeSolverResult *res) const
 
template<>
int bicgstab (const FVector &b, FVector &x, double &tol, TPreconditioner< float > *precon, int maxit) const
 
template<>
void bicgstab (const FVector *b, FVector *x, int nrhs, double tol, int maxit, TPreconditioner< float > *precon, IterativeSolverResult *res) const
 

Additional Inherited Members

- Public Types inherited from TMatrix< MT >
enum  RC { ROW, COL }
 
- Protected Attributes inherited from TMatrix< MT >
int rows
 
int cols
 

Detailed Description

template<class MT>
class TDenseMatrixMPI< MT >

Distributed dense matrix class.

A dense matrix type that distributes itself across the available processes, by assigning blocks of rows of equal size to each process.

Each process only allocates the memory required to store the associated sub-block. Methods such as matrix x vector (Ax) and transpose(matrix) x vector (ATx) are automaticall performed in parallel, without the need for any special code by the application developer.

Constructor & Destructor Documentation

template<class MT >
TDenseMatrixMPI< MT >::TDenseMatrixMPI ( int  r,
int  c 
)

Defines a matrix of size r x c, and allocates space for a sub-set of rows.

Parameters
rnumber of rows
cnumber of columns
Note
This constructor automatically subdivides the matrix according to the process rank and MPI size.
template<class MT >
TDenseMatrixMPI< MT >::~TDenseMatrixMPI ( )

.

Member Function Documentation

template<class MT >
void TDenseMatrixMPI< MT >::ATx ( const TVector< MT > &  x,
TVector< MT > &  b 
) const
virtual

Matrix-transpose x vector product.

Parameters
[in]xRight-hand operand.
[out]bResult vector
Note
The size of x must equal the number of rows of the matrix
The size of b must equal the number of columns of the matrix
This is a synchronising method: The result b is collected from all contributions, and re-distributed to all processes.
See Also
Ax

Reimplemented from TMatrix< MT >.

template<class MT >
void TDenseMatrixMPI< MT >::Ax ( const TVector< MT > &  x,
TVector< MT > &  b 
) const
virtual

Matrix x vector product.

Parameters
[in]xRight-hand operand.
[out]bResult vector
Note
The size of x must equal the number of columns of the matrix.
The size of b must equal the number of rows of the matrix.
This is a synchronising method: The result b is collected from all contributions, and re-distributed to all processes.
See Also
ATx

Reimplemented from TMatrix< MT >.

template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::Col ( int  c) const
virtual

Returns a vector containing a copy of column 'c'.

Parameters
ccolumn index (>= 0)
Returns
vector containing column c
Note
Sparse matrix types expand to a dense column, with missing entries filled with zeros, so this can be used as a "scatter" operation.
See Also
Row

Implements TMatrix< MT >.

template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::ColSum ( ) const

Returns a vector of column sums.

Returns
Column sum vector.
Note
The size of the returned vector equals the number of columns of the matrix. Each entry j contains the sum of elements of column j.
See Also
RowSum, RowSumSq, ColSumSq
template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::ColSumSq ( ) const

Returns a vector of sum of squares for each column.

Returns
Vector of sum of squares.
Note
The size of the returned vector equals the number of columns of the matrix. Each entry j contains the sum of the squares of elements of column j.
See Also
ColSum, RowSum, RowSumSq
template<class MT >
MT TDenseMatrixMPI< MT >::Get ( int  r,
int  c 
) const
virtual

Retrieve a matrix element.

Parameters
rmatrix row (0 <= r < nRows())
cmatrix column (0 <= c < nCols())
Returns
matrix element (*this)r,c
Note
This is a read operation and returns the element value. For writing operations, use Put() or operator().
See Also
operator()

Implements TMatrix< MT >.

template<class MT >
void TDenseMatrixMPI< MT >::MPIRange ( int *  _r0,
int *  _r1 
) const
inline

Returns the row range of the current process.

Parameters
[out]_r0low row index (>= 0)
[out]_r1high row index+1
Note
This method returns the range of rows the current process is operating on.
template<class MT >
void TDenseMatrixMPI< MT >::New ( int  r,
int  c 
)
virtual

Resize matrix to new dimensions.

Parameters
rnew row dimension
cnew column dimension
Note
All matrix entries are reset to zero by this method.
This is a blocking function: it must be called for all processes.

Reimplemented from TMatrix< MT >.

template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::Row ( int  r) const
virtual

Returns a row of the matrix.

Parameters
rrow index (>= 0)
Returns
Row vector. The size of the returned vector equals the number of columns of the matrix.
Note
This is a blocking method. The process responsible for row r broadcasts its value to all other processes. Each process then returns the same row vector.

Implements TMatrix< MT >.

template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::RowSum ( ) const

Returns a vector of row sums.

Returns
Row sum vector.
Note
The size of the returned vector equals the number of rows of the matrix. Each entry i contains the sum of elements of row i.
See Also
RowSumSq, ColSum, ColSumSq
template<class MT >
TVector<MT> TDenseMatrixMPI< MT >::RowSumSq ( ) const

Returns a vector of sum of squares for each row.

Returns
Vector of sum of squares.
Note
The size of the returned vector equals the number of rows of the matrix. Each entry i contains the sum of the squares of elements of row i.
See Also
RowSum, ColSum, ColSumSq
template<class MT >
void TDenseMatrixMPI< MT >::SetRow ( int  r,
const TVector< MT > &  rval 
)
virtual

Replace entries in row r with the values provided in rval.

Parameters
rrow number (>= 0)
rvalreplacement row
Note
The length of rval must be equal to the number of columns in the matrix.
This method can be called for all processes, but it affects only the process responsible for row r.

Reimplemented from TMatrix< MT >.

template<class MT >
int TDenseMatrixMPI< MT >::SparseRow ( int  r,
int *  colidx,
MT *  val 
) const
virtual

Returns a row of the matrix in sparse format.

Returns a list of column indices and values for all allocated entries of row r. This is only really useful for sparse matrix types. For dense matrices this simply returns the complete row, with indices 0, 1, 2, ... n-1

Parameters
rrow index (>= 0)
colidxpointer to array of column indices
valpointer to array of element values
Returns
Actual number of allocated matrix entries in the row.
Note
The arrays must be allocated by the caller and be of sufficient size.
See Also
Row, SetRow

Implements TMatrix< MT >.

template<class MT >
MatrixStorage TDenseMatrixMPI< MT >::StorageType ( ) const
inlinevirtual

Matrix storage class.

Returns
storage class identifier

Implements TMatrix< MT >.

References MATRIX_DENSE.


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