LAMA
lama::CRTPMatrix< Derived, ValueType > Class Template Reference

This template class supports static polymorphism to define common routines for base classes SparseMatrix<T> and DenseMatrix<T>. More...

#include <CRTPMatrix.hpp>

Inheritance diagram for lama::CRTPMatrix< Derived, ValueType >:

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 MatrixExpressionMemberType
 ExpressionMemberType is the type that is used the template Expression to store a Vector.

Public Member Functions

 CRTPMatrix ()
 Default constructor.
 CRTPMatrix (const IndexType numRows, const IndexType numColumns)
 Constructor for a replicated zero-matrix of a given shape.
 CRTPMatrix (DistributionPtr rowDistribution, DistributionPtr colDistribution)
 Constructor for a distributed matrix.
void matrixTimesVector (Vector &result, const Scalar alpha, const Vector &x, const Scalar beta, const Vector &y) const
 matrixTimesVector computes result = alpha * this * x + beta * y
virtual const char * getTypeName () const =0
 Virtual method that delivers the class name to which a matrix belongs.
std::auto_ptr< _LAMAArraycreateArray () 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 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 DistributiongetColDistribution () 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 ContextgetContext () 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.
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< Matrixcreate () const =0
 Constructor function which creates a 'zero' matrix of same type as a given matrix.
std::auto_ptr< Matrixcreate (const IndexType numRows, const IndexType numColumns) const
 Constructor creates a replicated matrix of same type as a given matrix.
std::auto_ptr< Matrixcreate (const IndexType size) const
 Constructor creates a distributed zero matrix of same type as a given matrix.
std::auto_ptr< Matrixcreate (DistributionPtr rowDistribution, DistributionPtr colDistribution) const
 Constructor creates a distributed zero matrix of same type as a given matrix.
std::auto_ptr< Matrixcreate (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< Matrixcopy () 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 DistributiongetDistribution () 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

Detailed Description

template<class Derived, typename ValueType>
class lama::CRTPMatrix< Derived, ValueType >

This template class supports static polymorphism to define common routines for base classes SparseMatrix<T> and DenseMatrix<T>.

Therefore it uses the Curiously Recurring Template Pattern (CRTP) as a C++ idiom where a class X derived from this template is itself a template argument.

Template Parameters:
Derivedis the derived class of Matrix
ValueTypespecifies the type of the matrix valuess
Todo:
: create, copy should also be defined here

Member Typedef Documentation

typedef const Matrix& lama::Matrix::ExpressionMemberType [inherited]

ExpressionMemberType is the type that is used the template Expression to store a Vector.


Member Enumeration Documentation

enum lama::Matrix::MatrixKind [inherited]

MatrixKind describes if a matrix is dense or sparse.

Enumerator:
DENSE 

matrix kind for a dense matrix

SPARSE 

matrix kind for a sparse matrix

enum lama::Matrix::SyncKind [inherited]

SyncKind describes if the communication and computation should be done synchronously or asynchronously.

Enumerator:
ASYNCHRONOUS 
SYNCHRONOUS 

Constructor & Destructor Documentation

template<class Derived, typename ValueType>
lama::CRTPMatrix< Derived, ValueType >::CRTPMatrix ( ) [inline]

Default constructor.

template<class Derived, typename ValueType>
lama::CRTPMatrix< Derived, ValueType >::CRTPMatrix ( const IndexType  numRows,
const IndexType  numColumns 
) [inline]

Constructor for a replicated zero-matrix of a given shape.

template<class Derived, typename ValueType>
lama::CRTPMatrix< Derived, ValueType >::CRTPMatrix ( DistributionPtr  rowDistribution,
DistributionPtr  colDistribution 
) [inline]

Constructor for a distributed matrix.


Member Function Documentation

virtual void lama::Matrix::allocate ( const IndexType  numRows,
const IndexType  numColumns 
) [pure virtual, inherited]

Reallocate this matrix to a replicated zero-matrix of the given shape.

Parameters:
[in]numRowsnumber of rows
[in]numColumnsnumber of columns
Remarks:
The call allocate( 0, 0 ) implies a clear on all arrays used internally for the presentation of the matrix data.

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, inherited]

Reallocate this matrix to a distributed zero-matrix by the given distributions.

Parameters:
[in]distributionis row distribution, number of rows given by getGlobalSize()
[in]colDistributionis 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, inherited]

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 lama::Matrix::operator=().

virtual void lama::Matrix::assign ( const _MatrixStorage other) [pure virtual, inherited]

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, inherited]
virtual void lama::Matrix::buildLocalStorage ( _MatrixStorage storage) const [pure virtual, inherited]

Get the local part (no splitted columns) of a matrix as if colDist is replicated.

Parameters:
[out]storagewill 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().

virtual void lama::Matrix::clear ( ) [pure virtual, inherited]

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, inherited]

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, inherited]

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 lama::Matrix::create(), lama::Matrix::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 [inherited]

Constructor creates a replicated matrix of same type as a given matrix.

References lama::Matrix::create().

std::auto_ptr< Matrix > lama::Matrix::create ( const IndexType  size) const [inherited]

Constructor creates a distributed zero matrix of same type as a given matrix.

References lama::Matrix::create().

std::auto_ptr< Matrix > lama::Matrix::create ( DistributionPtr  rowDistribution,
DistributionPtr  colDistribution 
) const [inherited]

Constructor creates a distributed zero matrix of same type as a given matrix.

References lama::Matrix::create().

std::auto_ptr< Matrix > lama::Matrix::create ( DistributionPtr  distribution) const [inherited]

Constructor creates a distributed zero matrix of same type as a given matrix.

References lama::Matrix::create().

std::auto_ptr< _LAMAArray > lama::Matrix::createArray ( ) const [inherited]

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 lama::Matrix::create(), and lama::Matrix::getValueType().

VectorPtr lama::Matrix::createDenseVector ( DistributionPtr  distribution,
const Scalar  value 
) const [inherited]

Constructor creates a distributed dense vector of same type as a given matrix.

References lama::Scalar::DOUBLE, lama::Scalar::FLOAT, lama::Scalar::getValue(), lama::Matrix::getValueType(), and LAMA_THROWEXCEPTION.

Matrix::SyncKind lama::Matrix::getComputeKind ( ) const [inline, inherited]

get the compute kind.

Returns:
the compute kind.

References lama::Matrix::mComputeKind.

Referenced by lama::Matrix::inheritAttributes().

const Context& lama::Matrix::getContext ( ) const [inline, inherited]
virtual void lama::Matrix::getDiagonal ( Vector diagonal) const [pure virtual, inherited]

This method returns the diagonal.

Parameters:
[out]diagonalis 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().

virtual IndexType lama::Matrix::getLocalNumColumns ( ) const [pure virtual, inherited]
virtual IndexType lama::Matrix::getLocalNumRows ( ) const [pure virtual, inherited]
virtual IndexType lama::Matrix::getLocalNumValues ( ) const [pure virtual, inherited]
virtual MatrixKind lama::Matrix::getMatrixKind ( ) const [pure virtual, inherited]

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, inherited]

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.

Returns:
the memory consumption of this matrix.

Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::MetaMatrix, lama::SimpleStorageStrategy< ValueType >, and lama::DenseMatrix< T >.

virtual IndexType lama::Matrix::getNumValues ( ) const [pure virtual, inherited]

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

Returns:
the number of non-zero values in this matrix.

Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.

Referenced by lama::Matrix::getSparsityRate().

virtual void lama::Matrix::getRow ( Vector row,
const IndexType  globalRowIndex 
) const [pure virtual, inherited]

This method returns one row of the matrix.

Parameters:
[out]rowis 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 >.

virtual Scalar lama::Matrix::getValue ( IndexType  i,
IndexType  j 
) const [pure virtual, inherited]

returns a copy of the value at the passed global indexes.

Parameters:
[in]ithe global row index
[in]jthe global column index
Returns:
a copy of the value at the passed global position.

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 lama::Matrix::operator()().

virtual bool lama::Matrix::hasDiagonalProperty ( ) const [pure virtual, inherited]

hasDiagonalProperty returns the diagonalProperty of the local storage.

Returns:
if the diagonal property is full filled.

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) [inherited]

Inherit context and kind arguments from another matrix.

This routine will also be used by copy constructors in base classes.

References lama::Matrix::getCommunicationKind(), lama::Matrix::getComputeKind(), lama::Matrix::getContextPtr(), lama::Matrix::setCommunicationKind(), lama::Matrix::setComputeKind(), and lama::Matrix::setContext().

virtual void lama::Matrix::invert ( const Matrix other) [pure virtual, inherited]
void lama::Matrix::matrix2CSRGraph ( IndexType xadj,
IndexType adjncy,
IndexType vwgt,
CommunicatorPtr  comm,
const IndexType globalRowIndices = NULL,
IndexType vtxdist = NULL 
) const [virtual, inherited]

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.

Parameters:
[out]xadjthe ia array of the csr graph
[out]adjncythe 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, inherited]

matrixTimesMatrix computes result = alpha * this * B + beta * C

Parameters:
[out]resultthe Matrix to store the result to
[in]alphathe Scalar alpha of the expression
[in]Bthe Matrix B of the expression
[in]betathe Scalar beta of the expression
[in]Cthe 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 lama::Matrix::operator=().

virtual void lama::Matrix::matrixTimesScalar ( const Matrix other,
const Scalar  alpha 
) [pure virtual, inherited]

matrixTimesScalar computes this = alpha * other

Parameters:
[out]otherthe Matrix to mutliply
[in]alphathe Scalar of the expression

matrixTimesScalar computes this = alpha * other.

Implemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, lama::DenseMatrix< T >, lama::MetaMatrix, and lama::SimpleStorageStrategy< ValueType >.

Referenced by lama::Matrix::operator=().

template<class Derived, typename ValueType>
void lama::CRTPMatrix< Derived, ValueType >::matrixTimesVector ( Vector result,
const Scalar  alpha,
const Vector x,
const Scalar  beta,
const Vector y 
) const [inline, virtual]

matrixTimesVector computes result = alpha * this * x + beta * y

Parameters:
[out]resultthe Vector to store the result to
[in]alphathe Scalar alpha of the expression
[in]xthe Vector x of the expression
[in]betathe Scalar beta of the expression
[in]ythe 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.

Implements lama::Matrix.

virtual Scalar lama::Matrix::maxDiffNorm ( const Matrix other) const [pure virtual, inherited]

returns the max norm of ( this - other )

Parameters:
[in]otheranother matrix with the same shape as this matrix
Returns:
the max norm of ( this - other )

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

Scalar lama::Matrix::operator() ( IndexType  i,
IndexType  j 
) const [inherited]

returns a copy of the value at the passed global indexes.

Parameters:
[in]ithe global row index
[in]jthe global column index
Returns:
a copy of the value at the passed global position.

As this operator requires communication ins SPMD mode it can be very inefficient in some situations.

References lama::Matrix::getValue().

virtual void lama::Matrix::prefetch ( ) const [pure virtual, inherited]

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, inherited]

This method allows any arbitrary redistribution of the matrix.

Parameters:
[in]rowDistributionis new distribution of rows, global size must be mNumRows
[in]colDistributionis 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, inherited]

resetDiagonalProperty rechecks the storages for their diagonal property

Returns:
if the diagonal property is full filled.

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, inherited]

This method scales all values with a vector.

Parameters:
[in]valuesis 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, inherited]

This method scales all matrix values with a scalar.

Parameters:
[in]valueis 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) [inherited]

set the communication kind.

Parameters:
[in]communicationKindthe communication kind.

References lama::Matrix::mCommunicationKind.

Referenced by lama::Matrix::inheritAttributes().

void lama::Matrix::setComputeKind ( SyncKind  computeKind) [virtual, inherited]

set the compute kind.

Parameters:
[in]computeKindthe compute kind.

Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.

References lama::Matrix::mComputeKind.

Referenced by lama::Matrix::inheritAttributes().

virtual void lama::Matrix::setContext ( const ContextPtr  context) [pure virtual, inherited]

specifies on which compute back end the matrix operations should take place.

Parameters:
[in]contextthe 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 lama::Matrix::inheritAttributes(), lama::MatrixConfigGrammar::MatrixConfigGrammar(), and lama::Matrix::setContext().

void lama::Matrix::setContext ( const ContextPtr  localContext,
const ContextPtr  haloContext 
) [virtual, inherited]

Only sparse matrices will override this method, others will ignore second argument.

Reimplemented in lama::SparseMatrix< T >, and lama::SparseMatrix< ValueType >.

References lama::Matrix::setContext().

virtual void lama::Matrix::setDiagonal ( const Vector diagonal) [pure virtual, inherited]

This method replaces the diagonal.

Parameters:
[in]diagonalis 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, inherited]

This method replaces the diagonal by a diagonal value.

Parameters:
[in]scalaris 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 >.

virtual void lama::Matrix::setIdentity ( ) [pure virtual, inherited]

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, inherited]

Set the global/local size of replicated matrix.

Parameters:
[in]numRowsnumber of rows, must be non-negative.
[in]numColumnsnumber of columns, must be non-negative.

References lama::Matrix::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]
virtual void lama::Matrix::wait ( ) const [pure virtual, inherited]
void lama::Matrix::writeAt ( std::ostream &  stream) const [virtual, inherited]

Write some information about this to the passed stream.

Parameters:
[out]streamthe stream to write to.

Reimplemented from Printable.

Reimplemented in lama::SparseMatrix< T >, lama::SparseMatrix< ValueType >, and lama::DenseMatrix< T >.

References lama::Matrix::mNumColumns, and lama::Matrix::mNumRows.


Field Documentation


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