A class which defines a sparse matrix distributed across 1D MPI grid. More...
#include <parMatrixSparse.hpp>
Public Member Functions | |
parMatrixSparse (parVector< T, S > vec) | |
A constructor of `parMatrixSparse`. More... | |
parMatrixSparse (parVectorMap< S > map) | |
A constructor of `parMatrixSparse`. More... | |
S | GetNRows () |
Return the number of rows of local matrix on each MPI proc. | |
S | GetNCols () |
Return the number of columns of local matrix on each MPI proc. | |
S | GetNNzLoc () |
Return the number of non-zeros entries of local matrix on each MPI proc. | |
parVectorMap< S > | GetMap () |
Return the parVectorMap object used to distribute sparse Matrix. | |
S | GetLowerBound () |
Return parMatrixSparse::lower_b. | |
S | GetUpperBound () |
Return parMatrixSparse::upper_b. | |
MPI_Comm | GetComm () |
Return parMatrixSparse::comm. | |
int | GetProcId () |
Return parMatrixSparse::ProcID. | |
int | GetNProcs () |
Return parMatrixSparse::nProcs. | |
std::map< S, T > * | GetDynMatLoc () |
Return parMatrixSparse::dynmat_loc. | |
void | SetValueLocal (S row, S col, T value) |
Set a value to a distributed sparse matrix with a given local index on each MPI proc. More... | |
void | SetValuesLocal (S nindex, S *rows, S *cols, T *values) |
Set multiple values to a distributed sparse matrix with given multiple local indices on each MPI proc. More... | |
void | SetValue (S row, S col, T value) |
Set a value to a distributed sparse matrix with a given global index on each MPI proc. More... | |
void | SetDiagonal (parVector< T, S > diag) |
Set the diagonal of a distributed sparse matrix with a given parVector object. More... | |
void | AddValueLocal (S row, S col, T value) |
Add a value to an entry of a distributed sparse matrix with a given local index on each MPI proc. More... | |
void | AddValue (S row, S col, T value) |
Add a value to an entry of a distributed sparse matrix with a given global index on each MPI proc. More... | |
T | GetValueLocal (S row, S col) |
Return a value of an entry of a distributed sparse matrix with a given local index on each MPI proc. More... | |
T | GetValue (S row, S col) |
Return a value to an entry of a distributed sparse matrix with a given global index on each MPI proc. More... | |
void | MatScale (T scale) |
Perform an operation `A = scale * A`, in which `scale` is a scalar. More... | |
void | MatAXPY (parMatrixSparse< T, S > X, T scale) |
Perform `A = A + scale * X`. More... | |
void | MatAYPX (parMatrixSparse< T, S > X, T scale) |
Perform `A = scale * A + X`. More... | |
void | initMat (S diag_l, S diag_u, Base< T > scale, T shift, Base< T > sparsity) |
filling the lower part of matrix between diagonal of offset `diag_l` and diagonal of offset `diag_u` with random values `scale * rnd + shift` where `rnd` is a randomly generated value between `0` and `1` More... | |
void | initMat (S diag_l, S diag_u) |
filling the lower part of matrix between diagonal of offset `diag_l` and diagonal of offset `diag_u` with random values `rnd`, which is a randomly generated value between `0` and `1` More... | |
void | setSpecNonHerm (parVector< T, S > spectrum) |
Set a given spectrum onto a parMatrixSparse object for constructing a non-Hermitian matrix. More... | |
void | setSpecNonSymm (parVector< T, S > spectrum) |
Set a given spectrum (all eigenvalues are in real scalars) onto a parMatrixSparse object for constructing a non-Symmetric matrix. More... | |
void | setSpecNonSymmCmplx (parVector< std::complex< Base< T >>, S > spectrum) |
Set a given spectrum (all eigenvalues can be in real scalars or appear as pairs of conjugate complex scalars) onto a parMatrixSparse object for constructing a non-Symmetric matrix. More... | |
void | updateNnz () |
Explicitly re-compute the number of nnz on each MPI proc. More... | |
void | copy (parMatrixSparse< T, S > X) |
Duplicate from another parMatrixSparse object. More... | |
void | rmZeros () |
Explicitly remove all the zeros of parMatrixSparse object. More... | |
parMatrixSparse< T, S > | MA (Nilpotent< S > nilp) |
Perform `M*A`, in which `A` is a nilpotent matrix. More... | |
parMatrixSparse< T, S > | AM (Nilpotent< S > nilp) |
Perform `A*M`, in which `A` is a nilpotent matrix. More... | |
void | ZeroEntries () |
Make all the entries a sparse matrix to be zeros, but keep the sparsity structure as it is. | |
MatrixCSR< T, S > | ConvertToCSR () |
Convert a parMatrixSparse with dynamic memory into a distributed CSR matrix. More... | |
void | show () |
Display multiple information of a parMatrixSparse object. More... | |
void | MatView () |
Print a parMatrixSparse object in a distributed COO format. More... | |
void | MatView (std::string matName) |
Print a parMatrixSparse object in a distributed COO format with matrix name indicated at the starting point of each line. More... | |
void | writeToMatrixMarket (std::string file_name) |
A parallel IO to write a parMatrixSparse object into a file of MatrixMarket format. More... | |
void | writeToMatrixMarketCmplx (std::string file_name) |
A parallel IO to write a parMatrixSparse object with complex scalar into a file of MatrixMarket format. More... | |
Private Attributes | |
std::map< S, T > * | dynmat_loc |
An array of `std::map` in which each map stores the column index and related non-zero entry value of each row. | |
S | ncols |
number of columns of local matrix on each MPI proc | |
S | nrows |
number of rows of local matrix on each MPI proc | |
S | nnz_loc |
number of non-zero entries of local matrix on each MPI proc | |
parVectorMap< S > | index_map |
the parVectorMap object used to distribute the global matrix across 1D MPI grid | |
S | lower_b |
the smallest index of row of a distributed matrix on each MPI proc | |
S | upper_b |
upper_b-1 = the largest index of row of a distributed matrix on each MPI proc | |
MPI_Comm | comm |
the working MPI communicator | |
int | ProcID |
rank of each MPI procs within the working MPI communicator | |
int | nProcs |
number of MPI procs within the working MPI communicator | |
A class which defines a sparse matrix distributed across 1D MPI grid.
T | describes the scalar types of the entries of a sparse matrix. |
S | type of integer to describes the dimension of vector to be generated. |
parMatrixSparse< T, S >::parMatrixSparse | ( | parVector< T, S > | vec | ) |
A constructor of `parMatrixSparse`.
[in] | vec | a given parVector, a parMatrixSparse object is constructed with the same distribution scheme of `vec` |
parMatrixSparse< T, S >::parMatrixSparse | ( | parVectorMap< S > | map | ) |
A constructor of `parMatrixSparse`.
[in] | map | the distribution scheme determined by this object of type parVectorMap |
void parMatrixSparse< T, S >::AddValue | ( | S | row, |
S | col, | ||
T | value | ||
) |
Add a value to an entry of a distributed sparse matrix with a given global index on each MPI proc.
[in] | row | the global index of row |
[in] | col | the global index of column |
[in] | value | the scalar to be added |
void parMatrixSparse< T, S >::AddValueLocal | ( | S | row, |
S | col, | ||
T | value | ||
) |
Add a value to an entry of a distributed sparse matrix with a given local index on each MPI proc.
[in] | row | the local index of row |
[in] | col | the local index of column |
[in] | value | the scalar to be added |
parMatrixSparse< T, S > parMatrixSparse< T, S >::AM | ( | Nilpotent< S > | nilp | ) |
Perform `A*M`, in which `A` is a nilpotent matrix.
[in] | nilp | a Nilpotent |
MatrixCSR< T, S > parMatrixSparse< T, S >::ConvertToCSR |
Convert a parMatrixSparse with dynamic memory into a distributed CSR matrix.
void parMatrixSparse< T, S >::copy | ( | parMatrixSparse< T, S > | X | ) |
Duplicate from another parMatrixSparse object.
[in] | X | another parMatrixSparse object to be duplicated with a same distribution scheme |
T parMatrixSparse< T, S >::GetValue | ( | S | row, |
S | col | ||
) |
Return a value to an entry of a distributed sparse matrix with a given global index on each MPI proc.
[in] | row | the global index of row |
[in] | col | the global index of column |
T parMatrixSparse< T, S >::GetValueLocal | ( | S | row, |
S | col | ||
) |
Return a value of an entry of a distributed sparse matrix with a given local index on each MPI proc.
[in] | row | the local index of row |
[in] | col | the local index of column |
void parMatrixSparse< T, S >::initMat | ( | S | diag_l, |
S | diag_u | ||
) |
filling the lower part of matrix between diagonal of offset `diag_l` and diagonal of offset `diag_u` with random values `rnd`, which is a randomly generated value between `0` and `1`
[in] | diag_l | the offset of lower diagonal |
[in] | diag_u | the offset of lower diagonal |
void parMatrixSparse< T, S >::initMat | ( | S | diag_l, |
S | diag_u, | ||
Base< T > | scale, | ||
T | shift, | ||
Base< T > | sparsity | ||
) |
filling the lower part of matrix between diagonal of offset `diag_l` and diagonal of offset `diag_u` with random values `scale * rnd + shift` where `rnd` is a randomly generated value between `0` and `1`
[in] | diag_l | the offset of lower diagonal |
[in] | diag_u | the offset of lower diagonal |
[in] | scale | a scalar to be multiplied on the randomly generated value |
[in] | shift | a scalar to be added on the randomly generated value |
[in] | sparsity | the probability that a entry in the range set to be zero |
parMatrixSparse< T, S > parMatrixSparse< T, S >::MA | ( | Nilpotent< S > | nilp | ) |
Perform `M*A`, in which `A` is a nilpotent matrix.
[in] | nilp | a Nilpotent |
void parMatrixSparse< T, S >::MatAXPY | ( | parMatrixSparse< T, S > | X, |
T | scale | ||
) |
Perform `A = A + scale * X`.
[in] | X | another parMatrixSparse object with a same distribution scheme |
[in] | scale | the scalar to be multiplied on `X` |
void parMatrixSparse< T, S >::MatAYPX | ( | parMatrixSparse< T, S > | X, |
T | scale | ||
) |
Perform `A = scale * A + X`.
[in] | X | another parMatrixSparse object with a same distribution scheme |
[in] | scale | the scalar to be multiplied on `A` |
void parMatrixSparse< T, S >::MatScale | ( | T | scale | ) |
Perform an operation `A = scale * A`, in which `scale` is a scalar.
[in] | scale | the scalar to be multiplied on the distributed sparse matrix |
void parMatrixSparse< T, S >::MatView |
Print a parMatrixSparse object in a distributed COO format.
void parMatrixSparse< T, S >::MatView | ( | std::string | matName | ) |
Print a parMatrixSparse object in a distributed COO format with matrix name indicated at the starting point of each line.
void parMatrixSparse< T, S >::rmZeros |
Explicitly remove all the zeros of parMatrixSparse object.
void parMatrixSparse< T, S >::SetDiagonal | ( | parVector< T, S > | diag | ) |
void parMatrixSparse< T, S >::setSpecNonHerm | ( | parVector< T, S > | spectrum | ) |
Set a given spectrum onto a parMatrixSparse object for constructing a non-Hermitian matrix.
[in] | spectrum | a parVector object which stores the given spectrum in complex scalars |
void parMatrixSparse< T, S >::setSpecNonSymm | ( | parVector< T, S > | spectrum | ) |
Set a given spectrum (all eigenvalues are in real scalars) onto a parMatrixSparse object for constructing a non-Symmetric matrix.
[in] | spectrum | a parVector object which stores the given spectrum in real scalars |
void parMatrixSparse< T, S >::setSpecNonSymmCmplx | ( | parVector< std::complex< Base< T >>, S > | spectrum | ) |
Set a given spectrum (all eigenvalues can be in real scalars or appear as pairs of conjugate complex scalars) onto a parMatrixSparse object for constructing a non-Symmetric matrix.
[in] | spectrum | a parVector object which stores the given spectrum with conjugate eigenvalues |
void parMatrixSparse< T, S >::SetValue | ( | S | row, |
S | col, | ||
T | value | ||
) |
Set a value to a distributed sparse matrix with a given global index on each MPI proc.
[in] | row | the global index of row |
[in] | col | the global index of column |
[in] | value | the scalar to be set |
void parMatrixSparse< T, S >::SetValueLocal | ( | S | row, |
S | col, | ||
T | value | ||
) |
Set a value to a distributed sparse matrix with a given local index on each MPI proc.
[in] | row | the local index of row |
[in] | col | the local index of column |
[in] | value | the scalar to be set |
void parMatrixSparse< T, S >::SetValuesLocal | ( | S | nindex, |
S * | rows, | ||
S * | cols, | ||
T * | values | ||
) |
Set multiple values to a distributed sparse matrix with given multiple local indices on each MPI proc.
[in] | nindex | number of values to be set |
[in] | rows | an array storing multiple local indices of row |
[in] | cols | an array storing multiple local indices of column |
[in] | values | an array storing multiple scalars to be set |
void parMatrixSparse< T, S >::show |
Display multiple information of a parMatrixSparse object.
void parMatrixSparse< T, S >::updateNnz |
Explicitly re-compute the number of nnz on each MPI proc.
void parMatrixSparse< T, S >::writeToMatrixMarket | ( | std::string | file_name | ) |
A parallel IO to write a parMatrixSparse object into a file of MatrixMarket format.
[in] | file_name | the path and file name to write into |
void parMatrixSparse< T, S >::writeToMatrixMarketCmplx | ( | std::string | file_name | ) |
A parallel IO to write a parMatrixSparse object with complex scalar into a file of MatrixMarket format.
[in] | file_name | the path and file name to write into |