LAMA
|
The class Matrix is a abstract type that represents a distributed 2D real or complex matrix. More...
#include <Matrix.hpp>
Public Types | |
enum | SyncKind { ASYNCHRONOUS, SYNCHRONOUS } |
SyncKind describes if the communication and computation should be done synchronously or asynchronously. More... | |
enum | MatrixKind { DENSE, SPARSE } |
MatrixKind describes if a matrix is dense or sparse. More... | |
typedef const Matrix & | ExpressionMemberType |
ExpressionMemberType is the type that is used the template Expression to store a Vector. | |
Public Member Functions | |
Matrix (DistributionPtr rowDistribution, DistributionPtr colDistribution) | |
Construct a matrix by corresponding distributions. | |
Matrix (const IndexType numRows, const IndexType numColumns) | |
Construct a matrix of a given size replicated on each partition. | |
Matrix (DistributionPtr distribution) | |
Construct a square matrix with the given size and the specified distribution. | |
Matrix (const IndexType size) | |
Construct a square matrix with a replicated distribution. | |
Matrix () | |
Default constructor creates a replicated matrix of size 0 x 0. | |
Matrix (const Matrix &other, DistributionPtr rowDistribution, DistributionPtr colDistribution) | |
Redistribute the given matrix with the specified distributions. | |
Matrix (const Matrix &other) | |
Copy a matrix to a new matrix with the same distribution. | |
virtual | ~Matrix () |
Releases all allocated resources. | |
virtual const char * | getTypeName () const =0 |
Virtual method that delivers the class name to which a matrix belongs. | |
std::auto_ptr< _LAMAArray > | createArray () const |
This routine creates a LAMA array with the same value type as the matrix. | |
virtual void | clear ()=0 |
Clear the full matrix, resets global and local sizes to 0. | |
virtual void | allocate (const IndexType numRows, const IndexType numColumns)=0 |
Reallocate this matrix to a replicated zero-matrix of the given shape. | |
virtual void | allocate (DistributionPtr rowDistribution, DistributionPtr colDistribution)=0 |
Reallocate this matrix to a distributed zero-matrix by the given distributions. | |
virtual void | setIdentity ()=0 |
Operator that sets the matrix to the identity matrix. | |
virtual void | assign (const Matrix &other)=0 |
This method assigns a matrix to this matrix with automatic conversion to the matrix type and the current row / column distribution of *this. | |
virtual void | assign (const _MatrixStorage &other)=0 |
This method assigns replicated/global matrix storage data to this matrix. | |
virtual void | assign (const _MatrixStorage &storage, DistributionPtr rowDist, DistributionPtr colDist)=0 |
Assign local storage for a distributed matrix. | |
virtual void | buildLocalStorage (_MatrixStorage &storage) const =0 |
Get the local part (no splitted columns) of a matrix as if colDist is replicated. | |
virtual void | redistribute (DistributionPtr rowDistribution, DistributionPtr colDistribution)=0 |
This method allows any arbitrary redistribution of the matrix. | |
virtual void | getRow (Vector &row, const IndexType globalRowIndex) const =0 |
This method returns one row of the matrix. | |
virtual void | getDiagonal (Vector &diagonal) const =0 |
This method returns the diagonal. | |
virtual void | setDiagonal (const Vector &diagonal)=0 |
This method replaces the diagonal. | |
virtual void | setDiagonal (const Scalar scalar)=0 |
This method replaces the diagonal by a diagonal value. | |
virtual void | scale (const Vector &scaling)=0 |
This method scales all values with a vector. | |
virtual void | scale (const Scalar scaling)=0 |
This method scales all matrix values with a scalar. | |
Scalar | operator() (IndexType i, IndexType j) const |
returns a copy of the value at the passed global indexes. | |
virtual Scalar | getValue (IndexType i, IndexType j) const =0 |
returns a copy of the value at the passed global indexes. | |
virtual void | writeAt (std::ostream &stream) const |
Write some information about this to the passed stream. | |
IndexType | getNumRows () const |
Returns the number of global rows. | |
IndexType | getNumColumns () const |
Returns the number of columns. | |
virtual IndexType | getNumValues () const =0 |
Get the total number of non-zero values in the matrix. | |
double | getSparsityRate () const |
virtual void | matrixTimesVector (Vector &result, const Scalar alpha, const Vector &x, const Scalar beta, const Vector &y) const =0 |
matrixTimesVector computes result = alpha * this * x + beta * y | |
virtual void | matrixTimesScalar (const Matrix &other, const Scalar alpha)=0 |
matrixTimesScalar computes this = alpha * other | |
virtual void | matrixTimesMatrix (Matrix &result, const Scalar alpha, const Matrix &B, const Scalar beta, const Matrix &C) const =0 |
matrixTimesMatrix computes result = alpha * this * B + beta * C | |
virtual void | matrix2CSRGraph (IndexType *xadj, IndexType *adjncy, IndexType *vwgt, CommunicatorPtr comm, const IndexType *globalRowIndices=NULL, IndexType *vtxdist=NULL) const |
transformation from matrix type to a csr graph | |
virtual IndexType | getLocalNumValues () const =0 |
Getter routine for the local number of stored values. | |
virtual IndexType | getLocalNumRows () const =0 |
Getter routine for the local number of rows. | |
virtual IndexType | getLocalNumColumns () const =0 |
Getter routine for the local number of rows and columns. | |
const Distribution & | getColDistribution () const |
gets a constant reference to the column distribution. | |
DistributionPtr | getColDistributionPtr () const |
gets a pointer to the column distribution. | |
virtual void | setContext (const ContextPtr context)=0 |
specifies on which compute back end the matrix operations should take place. | |
virtual void | setContext (const ContextPtr localContext, const ContextPtr haloContext) |
Only sparse matrices will override this method, others will ignore second argument. | |
virtual ContextPtr | getContextPtr () const =0 |
Getter routine for the context. | |
const Context & | getContext () const |
virtual MatrixKind | getMatrixKind () const =0 |
Each derived matrix must give info about its kind (DENSE or SPARSE). | |
SyncKind | getCommunicationKind () const |
get the communication kind. | |
SyncKind | getComputeKind () const |
get the compute kind. | |
void | setCommunicationKind (SyncKind communicationKind) |
set the communication kind. | |
virtual void | setComputeKind (SyncKind computeKind) |
set the compute kind. | |
void | inheritAttributes (const Matrix &other) |
Inherit context and kind arguments from another matrix. | |
virtual void | prefetch () const =0 |
Prefetch matrix data to its 'preferred' context location. | |
virtual void | wait () const =0 |
wait for a possibly running prefetch. | |
Matrix & | operator= (const Matrix &other) |
the assignment operator for matrix. | |
Matrix & | operator= (Expression< Scalar, Matrix, Times > exp) |
the assignment operator for a scalar matrix multiplication. | |
Matrix & | operator= (Expression< Matrix, Matrix, Times > exp) |
the assignment operator for a matrix matrix multiplication. | |
Matrix & | operator= (Expression< Scalar, Expression< Matrix, Matrix, Times >, Times > exp) |
the assignment operator for a scalar matrix matrix multiplication. | |
Matrix & | operator= (Expression< Expression< Scalar, Expression< Matrix, Matrix, Times >, Times >, Expression< Scalar, Matrix, Times >, Plus > exp) |
the assignment operator for a GEMM expression. | |
virtual void | invert (const Matrix &other)=0 |
Compute the inverse of a matrix. | |
virtual Scalar | maxDiffNorm (const Matrix &other) const =0 |
returns the max norm of ( this - other ) | |
virtual std::auto_ptr< Matrix > | create () const =0 |
Constructor function which creates a 'zero' matrix of same type as a given matrix. | |
std::auto_ptr< Matrix > | create (const IndexType numRows, const IndexType numColumns) const |
Constructor creates a replicated matrix of same type as a given matrix. | |
std::auto_ptr< Matrix > | create (const IndexType size) const |
Constructor creates a distributed zero matrix of same type as a given matrix. | |
std::auto_ptr< Matrix > | create (DistributionPtr rowDistribution, DistributionPtr colDistribution) const |
Constructor creates a distributed zero matrix of same type as a given matrix. | |
std::auto_ptr< Matrix > | create (DistributionPtr distribution) const |
Constructor creates a distributed zero matrix of same type as a given matrix. | |
VectorPtr | createDenseVector (DistributionPtr distribution, const Scalar value) const |
Constructor creates a distributed dense vector of same type as a given matrix. | |
virtual std::auto_ptr< Matrix > | copy () const =0 |
Constructor function which creates a copy of this matrix. | |
virtual Scalar::ScalarType | getValueType () const =0 |
Query the value type of the matrix elements, e.g. | |
virtual bool | hasDiagonalProperty () const =0 |
hasDiagonalProperty returns the diagonalProperty of the local storage. | |
virtual void | resetDiagonalProperty ()=0 |
resetDiagonalProperty rechecks the storages for their diagonal property | |
virtual size_t | getMemoryUsage () const =0 |
getMemoryUsage returns the global memory that is allocated to hold this matrix. | |
const Distribution & | getDistribution () const |
DistributionPtr | getDistributionPtr () const |
Protected Member Functions | |
void | setReplicatedMatrix (const IndexType numRows, const IndexType numColumns) |
Set the global/local size of replicated matrix. | |
void | setDistributedMatrix (DistributionPtr distribution, DistributionPtr colDistribution) |
Set the global and local size of distributed matrix. | |
void | checkSettings () |
void | swapMatrix (Matrix &other) |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
void | swap (Distributed &other) |
void | setDistributionPtr (DistributionPtr distributionPtr) |
Protected Attributes | |
DistributionPtr | mColDistribution |
IndexType | mNumRows |
IndexType | mNumColumns |
Private Member Functions | |
void | setDefaultKind () |
Private Attributes | |
SyncKind | mCommunicationKind |
SyncKind | mComputeKind |
The class Matrix is a abstract type that represents a distributed 2D real or complex matrix.
Matrix is one of the LAMA Base Types and should be used in all situations where it is not necessary to access a single element or to create a new Matrix.
typedef const Matrix& lama::Matrix::ExpressionMemberType |
ExpressionMemberType is the type that is used the template Expression to store a Vector.
lama::Matrix::Matrix | ( | DistributionPtr | rowDistribution, |
DistributionPtr | colDistribution | ||
) |
Construct a matrix by corresponding distributions.
[in] | rowDistribution | specifies number of rows and how the rows of the matrix are distributed among the available partitions. |
[in] | colDistribution | specifies number of columns and the distribution of a vector when matrix is applied to a matrix-vector multiplication. |
The colDstribution is used to setup a communication pattern (e.g. halo) that can be reused for multiple matrix-vector operations. It might also be used to split the matrix data on one partition into a local and non-local part.
The number of rows and columns is given implicitly by the global sizes of the distributions.
References checkSettings(), lama::Distributed::getDistribution(), mNumColumns, mNumRows, setDefaultKind(), and setDistributedMatrix().
lama::Matrix::Matrix | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) |
Construct a matrix of a given size replicated on each partition.
[in] | numRows | is the number of rows |
[in] | numColumns | is the number of columns |
Same as Matrix( NoDistribution(numRows), NoDistribution(numColumns) )
References mNumColumns, and mNumRows.
lama::Matrix::Matrix | ( | DistributionPtr | distribution | ) |
Construct a square matrix with the given size and the specified distribution.
[in] | distribution | specifies how the rows of the matrix are distributed among the available partitions. |
Same as Matrix( distribution, distribution ); column distribution will be same as that of rows.
References checkSettings(), lama::Distributed::getDistribution(), mNumColumns, mNumRows, and setDistributedMatrix().
lama::Matrix::Matrix | ( | const IndexType | size | ) | [explicit] |
Construct a square matrix with a replicated distribution.
[in] | size | is the number of rows |
Same as Matrix(size, size ).
Default constructor creates a replicated matrix of size 0 x 0.
lama::Matrix::Matrix | ( | const Matrix & | other, |
DistributionPtr | rowDistribution, | ||
DistributionPtr | colDistribution | ||
) |
Redistribute the given matrix with the specified distributions.
[in] | other | the matrix to redistribute |
[in] | rowDistribution | specifies how the rows of the matrix are distributed among the available partitions. |
[in] | colDistribution | specifies the distribution of a vector when matrix is applied to a matrix-vector multiplication. |
The following relations must hold:
References checkSettings(), getColDistribution(), and lama::Distributed::getDistribution().
lama::Matrix::Matrix | ( | const Matrix & | other | ) |
Copy a matrix to a new matrix with the same distribution.
[in] | other | the matrix to take a copy from |
lama::Matrix::~Matrix | ( | ) | [virtual] |
Releases all allocated resources.
virtual void lama::Matrix::allocate | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) | [pure virtual] |
Reallocate this matrix to a replicated zero-matrix of the given shape.
[in] | numRows | number of rows |
[in] | numColumns | number of columns |
Implemented in lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::allocate | ( | DistributionPtr | rowDistribution, |
DistributionPtr | colDistribution | ||
) | [pure virtual] |
Reallocate this matrix to a distributed zero-matrix by the given distributions.
[in] | distribution | is row distribution, number of rows given by getGlobalSize() |
[in] | colDistribution | is col distribution, number of columns given by getGlobalSize() |
The distributions specify the new global and the new local sizes for a distributed matrix.
Implemented in lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::assign | ( | const Matrix & | other | ) | [pure virtual] |
This method assigns a matrix to this matrix with automatic conversion to the matrix type and the current row / column distribution of *this.
Note: other.getNumRows() == getNumRows(), other.getNumColumns() == getNumColumns() is mandatory
Implemented in lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by lama::MatrixCreator< T >::fillRandom(), and operator=().
virtual void lama::Matrix::assign | ( | const _MatrixStorage & | other | ) | [pure virtual] |
This method assigns replicated/global matrix storage data to this matrix.
Note: the current matrix data will be overridden.
Implemented in lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::assign | ( | const _MatrixStorage & | storage, |
DistributionPtr | rowDist, | ||
DistributionPtr | colDist | ||
) | [pure virtual] |
Assign local storage for a distributed matrix.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::buildLocalStorage | ( | _MatrixStorage & | storage | ) | const [pure virtual] |
Get the local part (no splitted columns) of a matrix as if colDist is replicated.
[out] | storage | will contain the local part of the matrix with all columns. |
As splitting of columns is differently handled for sparse and dense matrices, this method is useful for conversion between them. An alternative solution of copying the whole matrix and replication of columns might be too expensive.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by lama::SparseMatrix< T >::assign().
void lama::Matrix::checkSettings | ( | ) | [protected] |
Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.
References getColDistribution(), lama::Distributed::getDistribution(), LAMA_THROWEXCEPTION, mColDistribution, mNumColumns, and mNumRows.
Referenced by Matrix().
virtual void lama::Matrix::clear | ( | ) | [pure virtual] |
Clear the full matrix, resets global and local sizes to 0.
CSRSparseMatrix<double> a ( ... ); a = CSRSparseMatrix<double> (); \\ will free all arrays a.clear(); \\ same functionality, clears involved arrays
Implemented in lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual std::auto_ptr<Matrix> lama::Matrix::copy | ( | ) | const [pure virtual] |
Constructor function which creates a copy of this matrix.
std::auto_ptr<Matrix> newMatrix = matrix.copy();
// More convenient to use, but exactly same as follows:
std::auto_ptr<Matrix> newMatrix = matrix.create(); *newMatrix = matrix;
This method is a workaround to call the copy constructor of a derived matrix class where the derived class is not known at compile time.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
Referenced by lama::DefaultJacobi::initialize().
virtual std::auto_ptr<Matrix> lama::Matrix::create | ( | ) | const [pure virtual] |
Constructor function which creates a 'zero' matrix of same type as a given matrix.
void sub( ..., const Matrix& matrix, ...) { ... // Create a copy of the input matrix std::auto_ptr<Matrix> newMatrix = matrix.create(); *newMatrix = matrix; // Create a unity matrix of same type and same row distribution as matrix std::auto_ptr<Matrix> newMatrix = matrix.create(); newMatrix->allocate( matrix.getRowDistributionPtr(), matrix.getRowDistributionPtr() ); newMatrix->setIdentity(); ... }
This method is a workaround to call the constructor of a derived matrix class where the derived class is not known at compile time.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::DenseMatrix< T >, and lama::SimpleStorageStrategy< ValueType >.
Referenced by create(), createArray(), lama::SingleGridSetup::initialize(), lama::DefaultJacobi::initialize(), and lama::InverseSolver::initialize().
std::auto_ptr< Matrix > lama::Matrix::create | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) | const |
Constructor creates a replicated matrix of same type as a given matrix.
References create().
std::auto_ptr< Matrix > lama::Matrix::create | ( | const IndexType | size | ) | const |
Constructor creates a distributed zero matrix of same type as a given matrix.
References create().
std::auto_ptr< Matrix > lama::Matrix::create | ( | DistributionPtr | rowDistribution, |
DistributionPtr | colDistribution | ||
) | const |
Constructor creates a distributed zero matrix of same type as a given matrix.
References create().
std::auto_ptr< Matrix > lama::Matrix::create | ( | DistributionPtr | distribution | ) | const |
Constructor creates a distributed zero matrix of same type as a given matrix.
References create().
std::auto_ptr< _LAMAArray > lama::Matrix::createArray | ( | ) | const |
This routine creates a LAMA array with the same value type as the matrix.
: returns an auto pointer to the LAMA array.
Same as _LAMAArray::create( this.getValueType() )
Value type is known only at runtime, so pointer to the base class is returned. Auto pointer indicates that calling routine takes ownership of the allocated array.
References create(), and getValueType().
VectorPtr lama::Matrix::createDenseVector | ( | DistributionPtr | distribution, |
const Scalar | value | ||
) | const |
Constructor creates a distributed dense vector of same type as a given matrix.
References lama::Scalar::DOUBLE, lama::Scalar::FLOAT, lama::Scalar::getValue(), getValueType(), and LAMA_THROWEXCEPTION.
const Distribution & lama::Matrix::getColDistribution | ( | ) | const [inline] |
gets a constant reference to the column distribution.
References LAMA_ASSERT_ERROR, and mColDistribution.
Referenced by lama::DenseMatrix< T >::assignSparse(), checkSettings(), lama::LUSolver::computeLUFactorization(), lama::InverseSolver::decompose(), lama::DenseMatrix< T >::DenseMatrix(), lama::DenseMatrixOps::invert(), lama::InverseSolver::invert(), lama::DenseMatrixOps::invertReplicated(), lama::SpecializedJacobi::iterateTyped(), Matrix(), lama::DenseMatrix< T >::matrixTimesMatrix(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), lama::CRTPMatrix< DenseMatrix< T >, T >::matrixTimesVector(), lama::SparseMatrix< T >::matrixTimesVectorNImpl(), lama::DenseMatrix< T >::maxDiffNorm(), lama::SparseMatrix< T >::maxDiffNorm(), lama::DenseMatrix< T >::maxDiffNormImpl(), lama::SparseMatrix< T >::maxDiffNormImpl(), operator=(), lama::LUSolver::solve(), and lama::Solver::solveInit().
DistributionPtr lama::Matrix::getColDistributionPtr | ( | ) | const [inline] |
gets a pointer to the column distribution.
References LAMA_ASSERT_ERROR, and mColDistribution.
Referenced by lama::SparseMatrix< T >::assign(), lama::DenseMatrix< T >::assign(), lama::DenseMatrix< T >::assignSparse(), lama::SparseMatrix< T >::assignTransposeImpl(), lama::DenseMatrix< T >::copyDenseMatrix(), lama::MatrixCreator< T >::fillRandom(), lama::DenseMatrixOps::invert(), lama::DenseMatrix< T >::invert(), lama::DenseMatrix< T >::matrixTimesMatrix(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), and lama::SparseMatrix< T >::matrixTimesVectorNImpl().
Matrix::SyncKind lama::Matrix::getCommunicationKind | ( | ) | const [inline] |
get the communication kind.
References mCommunicationKind.
Referenced by inheritAttributes(), lama::SpecializedJacobi::iterateTyped(), and lama::DenseMatrix< T >::matrixTimesVectorImpl().
Matrix::SyncKind lama::Matrix::getComputeKind | ( | ) | const [inline] |
get the compute kind.
References mComputeKind.
Referenced by inheritAttributes().
const Context& lama::Matrix::getContext | ( | ) | const [inline] |
Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.
virtual ContextPtr lama::Matrix::getContextPtr | ( | ) | const [pure virtual] |
Getter routine for the context.
Note: Only for SparseMatrix the context of the halo can be queried.
Implemented in lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, and lama::DenseMatrix< T >.
Referenced by lama::SparseMatrix< T >::assign(), inheritAttributes(), lama::CG::initialize(), lama::DefaultJacobi::initialize(), lama::GMRES::initialize(), lama::InverseSolver::initialize(), lama::InverseSolver::invert(), and lama::LUSolver::piamax_own().
virtual void lama::Matrix::getDiagonal | ( | Vector & | diagonal | ) | const [pure virtual] |
This method returns the diagonal.
[out] | diagonal | is the destination array |
Calculations are dependent to the diagonal property.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by lama::DefaultJacobi::initialize().
const Distribution & lama::Distributed::getDistribution | ( | ) | const [inline, inherited] |
References lama::Distributed::mDistribution.
Referenced by lama::SparseMatrix< T >::assignTransposeImpl(), checkSettings(), lama::LUSolver::computeLUFactorization(), lama::InverseSolver::decompose(), lama::DenseMatrix< T >::DenseMatrix(), lama::DenseVector< T >::DenseVector(), lama::DenseVector< T >::dotProduct(), lama::MatrixCreator< T >::fillRandom(), lama::SparseMatrix< T >::getLocalRow(), lama::SparseMatrix< T >::getRow(), lama::DenseMatrix< T >::getRow(), lama::DenseMatrixOps::invert(), lama::InverseSolver::invert(), lama::DenseMatrixOps::invertCyclic(), lama::DenseMatrixOps::invertReplicated(), Matrix(), lama::DenseMatrix< T >::matrixTimesMatrix(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), lama::CRTPMatrix< DenseMatrix< T >, T >::matrixTimesVector(), lama::SparseMatrix< T >::matrixTimesVector(), lama::SparseMatrix< T >::matrixTimesVectorNImpl(), lama::DenseMatrix< T >::maxDiffNorm(), lama::SparseMatrix< T >::maxDiffNorm(), lama::DenseMatrix< T >::maxDiffNormImpl(), lama::SparseMatrix< T >::maxDiffNormImpl(), operator=(), lama::SparseMatrix< T >::scale(), lama::SparseMatrix< T >::setDiagonal(), lama::LUSolver::solve(), lama::Solver::solveInit(), lama::Vector::Vector(), and lama::Vector::~Vector().
DistributionPtr lama::Distributed::getDistributionPtr | ( | ) | const [inline, inherited] |
References lama::Distributed::mDistribution.
Referenced by lama::SparseMatrix< T >::assign(), lama::DenseMatrix< T >::assign(), lama::DenseVector< T >::assign(), lama::DenseMatrix< T >::assignSparse(), lama::SparseMatrix< T >::assignTransposeImpl(), lama::DenseMatrix< T >::copyDenseMatrix(), lama::DenseVector< T >::DenseVector(), lama::MatrixCreator< T >::fillRandom(), lama::SingleGridSetup::initialize(), lama::CG::initialize(), lama::DefaultJacobi::initialize(), lama::GMRES::initialize(), lama::DenseMatrixOps::invert(), lama::DenseMatrix< T >::invert(), lama::DenseMatrixOps::invertCyclic(), lama::GMRES::iterate(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), lama::CRTPMatrix< DenseMatrix< T >, T >::matrixTimesVector(), lama::Vector::operator=(), lama::Vector::size(), and lama::Vector::writeAt().
virtual IndexType lama::Matrix::getLocalNumColumns | ( | ) | const [pure virtual] |
Getter routine for the local number of rows and columns.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual IndexType lama::Matrix::getLocalNumRows | ( | ) | const [pure virtual] |
Getter routine for the local number of rows.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual IndexType lama::Matrix::getLocalNumValues | ( | ) | const [pure virtual] |
Getter routine for the local number of stored values.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual MatrixKind lama::Matrix::getMatrixKind | ( | ) | const [pure virtual] |
Each derived matrix must give info about its kind (DENSE or SPARSE).
Implemented in lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::DenseMatrix< T >, and lama::_SparseMatrix.
Referenced by lama::DenseMatrix< T >::assign(), and lama::SparseMatrix< T >::matrixTimesMatrix().
virtual size_t lama::Matrix::getMemoryUsage | ( | ) | const [pure virtual] |
getMemoryUsage returns the global memory that is allocated to hold this matrix.
getMemoryUsage returns the global memory that is allocated to hold this matrix. For a distributed matrix all partitions are summed together.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
IndexType lama::Matrix::getNumColumns | ( | ) | const [inline] |
Returns the number of columns.
References mNumColumns.
Referenced by lama::DenseMatrix< T >::assignSparse(), lama::LUSolver::computeLUFactorization(), lama::InverseSolver::decompose(), lama::DenseMatrix< T >::DenseMatrix(), lama::MatrixCreator< T >::fillRandom(), lama::SparseMatrix< T >::getLocalNumColumns(), lama::InverseSolver::invert(), lama::DenseMatrix< T >::invert(), lama::DenseMatrixOps::invertCyclic(), lama::MatrixConfigGrammar::MatrixConfigGrammar(), operator=(), lama::LUSolver::solve(), and lama::Solver::solveInit().
IndexType lama::Matrix::getNumRows | ( | ) | const [inline] |
Returns the number of global rows.
References mNumRows.
Referenced by lama::InverseSolver::computeInverse(), lama::LUSolver::computeLUFactorization(), lama::InverseSolver::decompose(), lama::SparseMatrix< T >::getLocalNumRows(), lama::LUSolver::initialize(), lama::DenseMatrixOps::invert(), lama::InverseSolver::invert(), lama::DenseMatrix< T >::invert(), lama::DenseMatrixOps::invertCyclic(), lama::SpecializedJacobi::iterateTyped(), lama::MatrixConfigGrammar::MatrixConfigGrammar(), operator=(), lama::LUSolver::solve(), and lama::Solver::solveInit().
virtual IndexType lama::Matrix::getNumValues | ( | ) | const [pure virtual] |
Get the total number of non-zero values in the matrix.
An element is considered to be non-zero if its absolute value is greater equal than mEpsilon. Zero diagonal elements are also counted if this->hasDiagonalProperty() is given.
This routine does not count zero elements even if they are stored (e.g. for dense or dia storage data).
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by getSparsityRate().
virtual void lama::Matrix::getRow | ( | Vector & | row, |
const IndexType | globalRowIndex | ||
) | const [pure virtual] |
This method returns one row of the matrix.
[out] | row | is a replicated vector with all values of the row |
Note: the value type of the vector should be the same type as the matrix (otherwise conversion) and it should be a replicated vector (otherwise reallocation)
Unclear: should the distribution always be unchanged ?
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
double lama::Matrix::getSparsityRate | ( | ) | const |
References getNumValues(), mNumColumns, and mNumRows.
virtual const char* lama::Matrix::getTypeName | ( | ) | const [pure virtual] |
Virtual method that delivers the class name to which a matrix belongs.
Implemented in lama::COOSparseMatrix< T >, lama::CSRSparseMatrix< T >, lama::DIASparseMatrix< T >, lama::ELLSparseMatrix< T >, lama::JDSSparseMatrix< T >, lama::XXXSparseMatrix< T >, lama::DenseMatrix< T >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual Scalar lama::Matrix::getValue | ( | IndexType | i, |
IndexType | j | ||
) | const [pure virtual] |
returns a copy of the value at the passed global indexes.
[in] | i | the global row index |
[in] | j | the global column index |
As this operation requires communication ins SPMD mode it can be very inefficient in some situations.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by operator()().
virtual Scalar::ScalarType lama::Matrix::getValueType | ( | ) | const [pure virtual] |
Query the value type of the matrix elements, e.g.
DOUBLE or FLOAT.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
Referenced by lama::DenseMatrix< T >::assign(), createArray(), createDenseVector(), lama::SingleGridSetup::initialize(), lama::SOR::initialize(), lama::CG::initialize(), lama::DefaultJacobi::initialize(), lama::GMRES::initialize(), lama::GMRES::iterate(), lama::DenseMatrix< T >::maxDiffNorm(), and lama::SparseMatrix< T >::maxDiffNorm().
virtual bool lama::Matrix::hasDiagonalProperty | ( | ) | const [pure virtual] |
hasDiagonalProperty returns the diagonalProperty of the local storage.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
Referenced by lama::SpecializedJacobi::initialize(), and lama::DefaultJacobi::initialize().
void lama::Matrix::inheritAttributes | ( | const Matrix & | other | ) |
Inherit context and kind arguments from another matrix.
This routine will also be used by copy constructors in base classes.
References getCommunicationKind(), getComputeKind(), getContextPtr(), setCommunicationKind(), setComputeKind(), and setContext().
virtual void lama::Matrix::invert | ( | const Matrix & | other | ) | [pure virtual] |
Compute the inverse of a matrix.
Implemented in lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::DenseMatrix< T >, lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.
lama::Matrix::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected] |
Reimplemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::COOSparseMatrix< T >, lama::CSRSparseMatrix< T >, lama::DIASparseMatrix< T >, lama::ELLSparseMatrix< T >, lama::JDSSparseMatrix< T >, and lama::XXXSparseMatrix< T >.
void lama::Matrix::matrix2CSRGraph | ( | IndexType * | xadj, |
IndexType * | adjncy, | ||
IndexType * | vwgt, | ||
CommunicatorPtr | comm, | ||
const IndexType * | globalRowIndices = NULL , |
||
IndexType * | vtxdist = NULL |
||
) | const [virtual] |
transformation from matrix type to a csr graph
transformation from matrix type to a csr graph, so that it (Par)Metis can work with it.
[out] | xadj | the ia array of the csr graph |
[out] | adjncy | the ja array of the csr graph |
References LAMA_THROWEXCEPTION.
virtual void lama::Matrix::matrixTimesMatrix | ( | Matrix & | result, |
const Scalar | alpha, | ||
const Matrix & | B, | ||
const Scalar | beta, | ||
const Matrix & | C | ||
) | const [pure virtual] |
matrixTimesMatrix computes result = alpha * this * B + beta * C
[out] | result | the Matrix to store the result to |
[in] | alpha | the Scalar alpha of the expression |
[in] | B | the Matrix B of the expression |
[in] | beta | the Scalar beta of the expression |
[in] | C | the Matrix C of the expression |
matrixTimesMatrix computes result = alpha * this * x + beta * y.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by operator=().
virtual void lama::Matrix::matrixTimesScalar | ( | const Matrix & | other, |
const Scalar | alpha | ||
) | [pure virtual] |
matrixTimesScalar computes this = alpha * other
matrixTimesScalar computes this = alpha * other.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by operator=().
virtual void lama::Matrix::matrixTimesVector | ( | Vector & | result, |
const Scalar | alpha, | ||
const Vector & | x, | ||
const Scalar | beta, | ||
const Vector & | y | ||
) | const [pure virtual] |
matrixTimesVector computes result = alpha * this * x + beta * y
[out] | result | the Vector to store the result to |
[in] | alpha | the Scalar alpha of the expression |
[in] | x | the Vector x of the expression |
[in] | beta | the Scalar beta of the expression |
[in] | y | the Vector y of the expression |
matrixTimesVector computes result = alpha * this * x + beta * y. If result == x or result == y new storage is allocated to store the result.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::CRTPMatrix< Derived, ValueType >, and lama::CRTPMatrix< DenseMatrix< T >, T >.
Referenced by lama::Vector::operator=().
virtual Scalar lama::Matrix::maxDiffNorm | ( | const Matrix & | other | ) | const [pure virtual] |
returns the max norm of ( this - other )
[in] | other | another matrix with the same shape as this matrix |
The maximal value is given by the largest difference between two elements at the same position of the matrices.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
returns a copy of the value at the passed global indexes.
[in] | i | the global row index |
[in] | j | the global column index |
As this operator requires communication ins SPMD mode it can be very inefficient in some situations.
References getValue().
the assignment operator for matrix.
[in] | other | is the input matrix. |
The assignment operator will make a deep copy of the input matrix. Size and distributions are inherited, but there might be implicit conversions regarding storage format and/or value type of the matrix elements.
Reimplemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, and lama::DenseMatrix< T >.
References assign().
Referenced by lama::DenseMatrix< T >::DenseMatrix(), and lama::DenseMatrix< T >::operator=().
Matrix & lama::Matrix::operator= | ( | Expression< Scalar, Matrix, Times > | exp | ) |
the assignment operator for a scalar matrix multiplication.
Reimplemented in lama::DenseMatrix< T >.
References lama::Expression< T1, T2, type >::getArg1(), lama::Expression< T1, T2, type >::getArg2(), and matrixTimesScalar().
Matrix & lama::Matrix::operator= | ( | Expression< Matrix, Matrix, Times > | exp | ) |
the assignment operator for a matrix matrix multiplication.
Reimplemented in lama::DenseMatrix< T >.
References lama::Expression< T1, T2, type >::getArg1(), lama::Plus, lama::Times, and lama::zero.
Matrix & lama::Matrix::operator= | ( | Expression< Scalar, Expression< Matrix, Matrix, Times >, Times > | exp | ) |
the assignment operator for a scalar matrix matrix multiplication.
the assignment operator for a matrix matrix multiplication.
Reimplemented in lama::DenseMatrix< T >.
References lama::Plus, lama::Times, and lama::zero.
Matrix & lama::Matrix::operator= | ( | Expression< Expression< Scalar, Expression< Matrix, Matrix, Times >, Times >, Expression< Scalar, Matrix, Times >, Plus > | exp | ) |
the assignment operator for a GEMM expression.
Reimplemented in lama::DenseMatrix< T >.
References getColDistribution(), lama::Distributed::getDistribution(), getNumColumns(), getNumRows(), LAMA_THROWEXCEPTION, matrixTimesMatrix(), and lama::zero.
virtual void lama::Matrix::prefetch | ( | ) | const [pure virtual] |
Prefetch matrix data to its 'preferred' context location.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::DenseMatrix< T >, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::redistribute | ( | DistributionPtr | rowDistribution, |
DistributionPtr | colDistribution | ||
) | [pure virtual] |
This method allows any arbitrary redistribution of the matrix.
[in] | rowDistribution | is new distribution of rows, global size must be mNumRows |
[in] | colDistribution | is new distribution of columns, global size must be mNumColumns |
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar().
virtual void lama::Matrix::resetDiagonalProperty | ( | ) | [pure virtual] |
resetDiagonalProperty rechecks the storages for their diagonal property
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.
virtual void lama::Matrix::scale | ( | const Vector & | scaling | ) | [pure virtual] |
This method scales all values with a vector.
[in] | values | is the source array |
row wise calculations
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::scale | ( | const Scalar | scaling | ) | [pure virtual] |
This method scales all matrix values with a scalar.
[in] | value | is the source value |
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
void lama::Matrix::setCommunicationKind | ( | SyncKind | communicationKind | ) |
set the communication kind.
[in] | communicationKind | the communication kind. |
References mCommunicationKind.
Referenced by inheritAttributes().
void lama::Matrix::setComputeKind | ( | SyncKind | computeKind | ) | [virtual] |
set the compute kind.
[in] | computeKind | the compute kind. |
Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.
References mComputeKind.
Referenced by inheritAttributes().
virtual void lama::Matrix::setContext | ( | const ContextPtr | context | ) | [pure virtual] |
specifies on which compute back end the matrix operations should take place.
[in] | context | the compute back to use for calculations with matrix |
Note: Only for sparse matrices it is possible to specify separate locations for local and halo computations.
Implemented in lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, and lama::DenseMatrix< T >.
Referenced by inheritAttributes(), lama::MatrixConfigGrammar::MatrixConfigGrammar(), and setContext().
void lama::Matrix::setContext | ( | const ContextPtr | localContext, |
const ContextPtr | haloContext | ||
) | [virtual] |
Only sparse matrices will override this method, others will ignore second argument.
Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.
References setContext().
void lama::Matrix::setDefaultKind | ( | ) | [private] |
References mCommunicationKind, mComputeKind, and SYNCHRONOUS.
Referenced by Matrix().
virtual void lama::Matrix::setDiagonal | ( | const Vector & | diagonal | ) | [pure virtual] |
This method replaces the diagonal.
[in] | diagonal | is the source array |
Calculations are dependent to the diagonal property
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
virtual void lama::Matrix::setDiagonal | ( | const Scalar | scalar | ) | [pure virtual] |
This method replaces the diagonal by a diagonal value.
[in] | scalar | is the source value |
Calculations are dependent to the diagonal property
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
void lama::Matrix::setDistributedMatrix | ( | DistributionPtr | distribution, |
DistributionPtr | colDistribution | ||
) | [protected] |
Set the global and local size of distributed matrix.
[in] | distribution | is distribution for rows |
[in] | colDistribution | is distribution for columns |
Global and local size is given implicitly by the distributions itself.
References LAMA_ASSERT_ERROR, mColDistribution, mNumColumns, mNumRows, and lama::Distributed::setDistributionPtr().
Referenced by lama::DenseMatrix< T >::allocate(), lama::SimpleStorageStrategy< ValueType >::applyStrategy(), lama::DenseMatrix< T >::assign(), lama::DenseMatrix< T >::assignSparse(), lama::COOSparseMatrix< T >::COOSparseMatrix(), lama::DenseMatrix< T >::copyDenseMatrix(), lama::CSRSparseMatrix< T >::CSRSparseMatrix(), lama::DIASparseMatrix< T >::DIASparseMatrix(), lama::ELLSparseMatrix< T >::ELLSparseMatrix(), lama::JDSSparseMatrix< T >::JDSSparseMatrix(), Matrix(), setReplicatedMatrix(), lama::DenseMatrix< T >::splitColumns(), and lama::XXXSparseMatrix< T >::XXXSparseMatrix().
void lama::Distributed::setDistributionPtr | ( | DistributionPtr | distributionPtr | ) | [protected, inherited] |
References lama::Distributed::mDistribution.
Referenced by lama::Vector::resize(), and setDistributedMatrix().
virtual void lama::Matrix::setIdentity | ( | ) | [pure virtual] |
Operator that sets the matrix to the identity matrix.
void sub( ..., Matrix& a, ... ) ... LAMA_ASSERT_EQUAL_DEBUG( a.getNumRows(), a.getNumColumns() ); A.setIdentity();
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.
void lama::Matrix::setReplicatedMatrix | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) | [protected] |
Set the global/local size of replicated matrix.
[in] | numRows | number of rows, must be non-negative. |
[in] | numColumns | number of columns, must be non-negative. |
References setDistributedMatrix().
Referenced by lama::DenseMatrix< T >::allocate(), lama::DenseMatrix< T >::assign(), lama::DenseMatrix< T >::clear(), and lama::DenseMatrix< T >::DenseMatrix().
void lama::Distributed::swap | ( | Distributed & | other | ) | [protected, inherited] |
References lama::Distributed::mDistribution.
Referenced by swapMatrix().
void lama::Matrix::swapMatrix | ( | Matrix & | other | ) | [protected] |
References mColDistribution, mNumColumns, mNumRows, and lama::Distributed::swap().
Referenced by lama::DenseMatrix< T >::swap().
virtual void lama::Matrix::wait | ( | ) | const [pure virtual] |
wait for a possibly running prefetch.
Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::DenseMatrix< T >, and lama::SimpleStorageStrategy< ValueType >.
void lama::Matrix::writeAt | ( | std::ostream & | stream | ) | const [virtual] |
Write some information about this to the passed stream.
[out] | stream | the stream to write to. |
Reimplemented from Printable.
Reimplemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, and lama::DenseMatrix< T >.
References mNumColumns, and mNumRows.
DistributionPtr lama::Matrix::mColDistribution [protected] |
SyncKind lama::Matrix::mCommunicationKind [private] |
Referenced by getCommunicationKind(), setCommunicationKind(), and setDefaultKind().
SyncKind lama::Matrix::mComputeKind [private] |
Referenced by getComputeKind(), setComputeKind(), and setDefaultKind().
IndexType lama::Matrix::mNumColumns [protected] |
IndexType lama::Matrix::mNumRows [protected] |
Referenced by checkSettings(), lama::DenseMatrix< T >::DenseMatrix(), getNumRows(), getSparsityRate(), Matrix(), setDistributedMatrix(), swapMatrix(), and writeAt().