LAMA
|
The class _MatrixStorage is the base class for all matrix storage classes supported by LAMA. More...
#include <MatrixStorage.hpp>
Public Member Functions | |
_MatrixStorage (const IndexType numRows, const IndexType numColumns) | |
Constructor for storage of a matrix of size numRows x numColumns. | |
_MatrixStorage () | |
Default constructor. | |
virtual | ~_MatrixStorage () |
virtual const char * | getTypeName () const =0 |
This method returns the type name of a matrix storage, e.g. | |
void | init (const IndexType numRows, const IndexType numColumns) |
Initialization of base class due to a resize. | |
virtual Scalar::ScalarType | getValueType () const =0 |
Objects of this class should give info about their value type. | |
virtual void | clear ()=0 |
Clear the matrix storage, resets size to 0 x 0. | |
virtual void | purge ()=0 |
Purge clears the matrix and even frees the allocated memory. | |
virtual void | allocate (const IndexType numRows, const IndexType numColumns)=0 |
This method allocates new matrix storage for the matrix. | |
void | setContext (ContextPtr context) |
Set the preferred context for the matrix storage. | |
ContextPtr | getContextPtr () const |
Getter for the preferred context of the storage data, returns pointer. | |
const Context & | getContext () const |
Getter for the preferred context of the storage data. | |
virtual void | prefetch (const ContextPtr context) const =0 |
Pure method that prefetches storage data into a given context. | |
void | prefetch () const |
Method that prefetches storage data to its preferred location. | |
virtual void | wait () const =0 |
Will wait for all outstanding asynchronous data transfers. | |
void | setCompressThreshold (float ratio) |
Allow for additional row compression. | |
IndexType | getNumRows () const |
IndexType | getNumColumns () const |
virtual void | writeAt (std::ostream &stream) const |
Writes some Information about this to the passed stream. | |
void | resetDiagonalProperty () |
bool | hasDiagonalProperty () const |
virtual MatrixStorageFormat | getFormat () const =0 |
virtual void | setIdentity (const IndexType n)=0 |
This method sets storage for the identity matrix. | |
virtual void | getRow (_LAMAArray &row, const IndexType i) const =0 |
This method returns the i-th row of the matrix. | |
virtual void | getDiagonal (_LAMAArray &diagonal) const =0 |
This method returns the diagonal of the matrix. | |
virtual void | setDiagonal (const _LAMAArray &diagonal)=0 |
This method sets the diagonal of a matrix storage. | |
virtual void | setDiagonal (const Scalar value)=0 |
virtual void | scale (const Scalar value)=0 |
This method scales all matrix values with a scalar. | |
virtual void | scale (const _LAMAArray &values)=0 |
This method scales each row of a matrix with a separate value. | |
virtual void | localize (const _MatrixStorage &global, const Distribution &rowDist) |
This operation localizes the matrix storage of a full matrix to the part that is owned by this processor. | |
virtual IndexType | getNumValues () const |
Get the total number of non-zero values in the matrix. | |
const LAMAArray< IndexType > & | getRowIndexes () const |
virtual void | buildCSRSizes (LAMAArray< IndexType > &csrIA) const =0 |
Get the number of entries in each row. | |
virtual void | buildCSRData (LAMAArray< IndexType > &csrIA, LAMAArray< IndexType > &csrJA, _LAMAArray &csrValues) const =0 |
Get the matrix data of the storage in CSR format. | |
virtual void | setCSRData (const IndexType numRows, const IndexType numColumns, const IndexType numValues, const LAMAArray< IndexType > &csrIA, const LAMAArray< IndexType > &csrJA, const _LAMAArray &csrValues)=0 |
Each storage class must provide a routine to set CSR storage data. | |
virtual void | assign (const _MatrixStorage &other)=0 |
Assign of matrix storage with any format or value type. | |
virtual void | copyTo (_MatrixStorage &other) const =0 |
The opposite routine to assign, for convenience as the other way around is sometimes more efficient. | |
_MatrixStorage & | operator= (const _MatrixStorage &other) |
Override default assignment operator. | |
size_t | getMemoryUsage () const |
Returns the number of bytes needed for the current matrix. | |
virtual void | check (const char *msg) const =0 |
virtual _MatrixStorage * | create () const =0 |
Each matrix storage must provide a routine that creates a new object of the same matrix type (same format and same value type). | |
virtual _MatrixStorage * | copy () const =0 |
Each matrix storage must provide a routine that makes a new copy of the input matrix (same format and same value type). | |
Static Public Member Functions | |
static void | offsets2sizes (LAMAArray< IndexType > &offsets) |
Help routines to convert arrays with sizes to offsets and vice versa. | |
static void | offsets2sizes (LAMAArray< IndexType > &sizes, const LAMAArray< IndexType > &offsets) |
static IndexType | sizes2offsets (LAMAArray< IndexType > &sizes) |
Utitily to compute the offset array from a sizes array. | |
Protected Member Functions | |
void | swap (_MatrixStorage &other) |
Swaps this with other. | |
virtual void | _assignTranspose (const _MatrixStorage &other) |
virtual void | _assign (const _MatrixStorage &other) |
virtual size_t | getMemoryUsageImpl () const =0 |
Returns the number of bytes needed for the current matrix. | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
logger for this matrix format | |
Protected Attributes | |
IndexType | mNumRows |
IndexType | mNumColumns |
LAMAArray< IndexType > | mRowIndexes |
used in case of sparse representation of ia | |
float | mCompressThreshold |
ratio at which compression is done, 0 for never, 1 for always | |
bool | mDiagonalProperty |
if true, diagonal elements are always stored at first position in each row | |
ContextPtr | mContext |
preferred context for the storage | |
Private Member Functions | |
virtual bool | checkDiagonalProperty () const =0 |
checkDiagonalProperty checks if the diagonal property of this is full filled. |
The class _MatrixStorage is the base class for all matrix storage classes supported by LAMA.
In contratry to a matrix a matrix storage is never distributed. It contains local parts of a distributed matrix that are typically submatrices.
This base class is also common for all supported value types for matrix elements.
Note: Default copy constructor and assignment operator can be used.
Each matrix storage has a context that will be taken as the preferred location where the matrix data resides and where operations on the matrix storage should take place.
lama::_MatrixStorage::_MatrixStorage | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) |
Constructor for storage of a matrix of size numRows x numColumns.
References init(), mNumColumns, and mNumRows.
Default constructor.
References init().
lama::_MatrixStorage::~_MatrixStorage | ( | ) | [virtual] |
void lama::_MatrixStorage::_assign | ( | const _MatrixStorage & | other | ) | [protected, virtual] |
void lama::_MatrixStorage::_assignTranspose | ( | const _MatrixStorage & | other | ) | [protected, virtual] |
References lama::LAMAArray< T >::clear(), mCompressThreshold, mDiagonalProperty, mNumColumns, mNumRows, and mRowIndexes.
Referenced by lama::CSRStorage< T >::assignTranspose().
virtual void lama::_MatrixStorage::allocate | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) | [pure virtual] |
This method allocates new matrix storage for the matrix.
The matrix contains only zero elements.
Note: This method contains an implicit clear, but not a purge. So allocation of a much smaller matrix compared to the existing one might result in some waste of memory.
Implemented in lama::CSRStorage< T >, lama::DenseStorageView< T >, lama::JDSStorage< T >, lama::DIAStorage< T >, lama::COOStorage< T >, lama::ELLStorage< T >, and lama::SparseAssemblyStorage< T >.
Referenced by lama::MatrixStorage< T >::splitHalo().
virtual void lama::_MatrixStorage::assign | ( | const _MatrixStorage & | other | ) | [pure virtual] |
Assign of matrix storage with any format or value type.
Format conversion and type conversion is done implicitly. Derived clauses might override this method with more efficient solutions.
[in] | other | is the matrix storage to be assigned |
Implemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, lama::CSRStorage< T >, and lama::DenseStorageView< T >.
Referenced by operator=().
virtual void lama::_MatrixStorage::buildCSRData | ( | LAMAArray< IndexType > & | csrIA, |
LAMAArray< IndexType > & | csrJA, | ||
_LAMAArray & | csrValues | ||
) | const [pure virtual] |
Get the matrix data of the storage in CSR format.
[out] | csrIA | offset array for rows, csrIA.size() == numRows + 1 |
[out] | csrJA | column indexes, csrJA.size() == csrIA[ csrIA.size() ] |
[out] | csrValues | are the non-zero matrix values, csrJA.size() == csrValues.size() |
The csr data will have the diagonal property if this->hasDiagonalProperty() is true.
Note: This routine supports also type conversion between different value types.
DenseStorage<double> dense( ... ) LAMAArray<IndexType> ia, ja; LAMAArray<float> values; // get non-zero values of dense matrix as float values dense.buildCSRData( ia, ja, values );
This routine must be provided by each matrix storage format.
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
Referenced by lama::CSRStorage< T >::assign(), lama::MatrixStorage< T >::assign(), lama::DenseMatrix< T >::assignLocal(), lama::MatrixStorage< T >::exchangeHalo(), lama::MatrixStorage< T >::joinHalo(), lama::MatrixStorage< T >::localize(), and lama::MatrixStorage< T >::redistribute().
virtual void lama::_MatrixStorage::buildCSRSizes | ( | LAMAArray< IndexType > & | csrIA | ) | const [pure virtual] |
Get the number of entries in each row.
[out] | csrIA | size array for rows, csrIA.size() == numRows |
If this->hasDiagonalProperty() is true, diagonal elements are also counted.
DenseStorage<double> dense( ... ) LAMAArray<IndexType> ia; dense.buildCSRSizes( ia );
This routine must be provided by each matrix storage format.
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
Referenced by getNumValues().
virtual void lama::_MatrixStorage::check | ( | const char * | msg | ) | const [pure virtual] |
virtual bool lama::_MatrixStorage::checkDiagonalProperty | ( | ) | const [private, pure virtual] |
checkDiagonalProperty checks if the diagonal property of this is full filled.
Implemented in lama::CSRStorage< T >, lama::SparseAssemblyStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, lama::JDSStorage< T >, lama::COOStorage< T >, and lama::DenseStorageView< T >.
Referenced by resetDiagonalProperty().
virtual void lama::_MatrixStorage::clear | ( | ) | [pure virtual] |
Clear the matrix storage, resets size to 0 x 0.
Clearing of matrix storage will not free allocated data, so resize to the original size is a cheap operation.
Implemented in lama::DenseStorageView< T >, lama::JDSStorage< T >, lama::ELLStorage< T >, lama::CSRStorage< T >, lama::SparseAssemblyStorage< T >, lama::DIAStorage< T >, and lama::COOStorage< T >.
virtual _MatrixStorage* lama::_MatrixStorage::copy | ( | ) | const [pure virtual] |
Each matrix storage must provide a routine that makes a new copy of the input matrix (same format and same value type).
The implementations in derived classes should use covariant return types to allow polymorphic creation of objects.
Note: as shared_ptr cannot be used for for covariant return types this routine returns directly a new created object that should be wrapped as a shared pointer at calling site.
Implemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, lama::SparseAssemblyStorage< T >, lama::COOStorage< T >, lama::CSRStorage< T >, lama::JDSStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, and lama::DenseStorageView< T >.
virtual void lama::_MatrixStorage::copyTo | ( | _MatrixStorage & | other | ) | const [pure virtual] |
The opposite routine to assign, for convenience as the other way around is sometimes more efficient.
Implemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, and lama::CSRStorage< T >.
Referenced by lama::MatrixStorage< T >::assign().
virtual _MatrixStorage* lama::_MatrixStorage::create | ( | ) | const [pure virtual] |
Each matrix storage must provide a routine that creates a new object of the same matrix type (same format and same value type).
The implementations in derived classes should use covariant return types to allow polymorphic creation of objects.
Note: as shared_ptr cannot be used for for covariant return types this routine returns directly a new created object that should be wrapped as a shared pointer at calling site.
Implemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, lama::SparseAssemblyStorage< T >, lama::COOStorage< T >, lama::CSRStorage< T >, lama::JDSStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, and lama::DenseStorageView< T >.
const Context& lama::_MatrixStorage::getContext | ( | ) | const [inline] |
Getter for the preferred context of the storage data.
Referenced by lama::ELLStorage< T >::ELLStorage().
ContextPtr lama::_MatrixStorage::getContextPtr | ( | ) | const [inline] |
Getter for the preferred context of the storage data, returns pointer.
Referenced by lama::SpecializedJacobi::iterateTyped(), and lama::JDSStorage< T >::JDSStorage().
virtual void lama::_MatrixStorage::getDiagonal | ( | _LAMAArray & | diagonal | ) | const [pure virtual] |
This method returns the diagonal of the matrix.
[out] | diagonal | is the destination array |
The values will be stored in diagonal that can be of any type for which implicit conversion is available.
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
Referenced by lama::JDSStorage< T >::jacobiIterateHalo(), and lama::ELLStorage< T >::jacobiIterateHalo().
virtual MatrixStorageFormat lama::_MatrixStorage::getFormat | ( | ) | const [pure virtual] |
Implemented in lama::SparseAssemblyStorage< T >, lama::CSRStorage< T >, lama::JDSStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, lama::COOStorage< T >, and lama::DenseStorageView< T >.
Referenced by lama::DenseStorageView< T >::assign(), lama::DenseMatrix< T >::assign(), lama::MatrixStorage< T >::assign(), lama::SOR::initialize(), lama::DenseStorageView< T >::invert(), lama::ELLStorage< T >::jacobiIterateHalo(), lama::CSRStorage< T >::jacobiIterateHalo(), lama::DenseStorageView< T >::matrixTimesMatrix(), lama::ELLStorage< T >::matrixTimesMatrix(), lama::CSRStorage< T >::matrixTimesMatrix(), lama::DenseStorageView< T >::maxDiffNorm(), and lama::CSRStorage< T >::maxDiffNorm().
size_t lama::_MatrixStorage::getMemoryUsage | ( | ) | const |
Returns the number of bytes needed for the current matrix.
Note: This routine does not tell how many memory is really allocated. Storage data might be allocated on more than one device. Furthermore, it is possible that arrays have more memory reserved than needed for its current size.
References getMemoryUsageImpl(), mRowIndexes, and lama::_LAMAArray::size().
virtual size_t lama::_MatrixStorage::getMemoryUsageImpl | ( | ) | const [protected, pure virtual] |
Returns the number of bytes needed for the current matrix.
This pure function must be implemented by each derived class. Relevant for the number of bytes is the current size of the used (LAMA) arrays.
Note: This routine does not tell how many memory is really allocated. Storage data might be allocated on more than one device. Furthermore, it is possible that arrays have more memory reserved than needed for its current size.
Implemented in lama::CSRStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, lama::COOStorage< T >, lama::JDSStorage< T >, lama::DenseStorageView< T >, and lama::SparseAssemblyStorage< T >.
Referenced by getMemoryUsage().
IndexType lama::_MatrixStorage::getNumColumns | ( | ) | const [inline] |
References mNumColumns.
Referenced by lama::SparseMatrix< T >::assign(), lama::DenseMatrix< T >::assign(), lama::MatrixStorage< T >::assign(), lama::MatrixStorage< T >::assignTranspose(), lama::SparseMatrix< T >::assignTransposeImpl(), lama::InverseSolver::decompose(), lama::MatrixStorage< T >::exchangeHalo(), lama::InverseSolver::invert(), lama::JDSStorage< T >::jacobiIterateHalo(), lama::ELLStorage< T >::jacobiIterateHalo(), lama::CSRStorage< T >::jacobiIterateHalo(), lama::DenseMatrix< T >::joinColumnData(), lama::MatrixStorage< T >::joinHalo(), localize(), lama::DenseMatrix< T >::localize(), lama::MatrixStorage< T >::localize(), lama::CSRStorage< T >::matrixAddMatrixCSR(), lama::ELLStorage< T >::matrixAddMatrixELL(), lama::CSRStorage< T >::matrixTimesMatrixCSR(), lama::DenseStorageView< T >::matrixTimesMatrixDense(), lama::ELLStorage< T >::matrixTimesMatrixELL(), lama::DenseStorageView< T >::maxDiffNorm(), lama::CSRStorage< T >::maxDiffNorm(), lama::MatrixStorage< T >::maxDiffNorm(), lama::MatrixStorage< T >::redistribute(), lama::DenseMatrix< T >::redistributeRows(), lama::MatrixStorage< T >::replicate(), lama::replicate(), lama::SparseMatrix< T >::set(), lama::DenseMatrix< T >::splitColumnData(), lama::JDSSparseMatrix< T >::swapLocalStorage(), lama::COOSparseMatrix< T >::swapLocalStorage(), lama::DIASparseMatrix< T >::swapLocalStorage(), lama::CSRSparseMatrix< T >::swapLocalStorage(), and lama::ELLSparseMatrix< T >::swapLocalStorage().
IndexType lama::_MatrixStorage::getNumRows | ( | ) | const [inline] |
References mNumRows.
Referenced by lama::SparseMatrix< T >::assign(), lama::DenseMatrix< T >::assign(), lama::MatrixStorage< T >::assign(), lama::MatrixStorage< T >::assignTranspose(), lama::InverseSolver::decompose(), lama::InverseSolver::invert(), lama::DenseMatrix< T >::invertCyclic(), lama::SOR::iterateImpl(), lama::JDSStorage< T >::jacobiIterateHalo(), lama::ELLStorage< T >::jacobiIterateHalo(), lama::CSRStorage< T >::jacobiIterateHalo(), lama::DenseMatrix< T >::joinColumnData(), lama::MatrixStorage< T >::joinHalo(), localize(), lama::DenseMatrix< T >::localize(), lama::MatrixStorage< T >::localize(), lama::CSRStorage< T >::matrixAddMatrixCSR(), lama::ELLStorage< T >::matrixAddMatrixELL(), lama::CSRStorage< T >::matrixTimesMatrixCSR(), lama::DenseStorageView< T >::matrixTimesMatrixDense(), lama::ELLStorage< T >::matrixTimesMatrixELL(), lama::DenseStorageView< T >::maxDiffNorm(), lama::CSRStorage< T >::maxDiffNorm(), lama::MatrixStorage< T >::maxDiffNorm(), lama::MatrixStorage< T >::redistribute(), lama::MatrixStorage< T >::replicate(), lama::replicate(), lama::SparseMatrix< T >::set(), lama::DenseMatrix< T >::splitColumnData(), lama::COOSparseMatrix< T >::swapLocalStorage(), lama::CSRSparseMatrix< T >::swapLocalStorage(), lama::JDSSparseMatrix< T >::swapLocalStorage(), lama::ELLSparseMatrix< T >::swapLocalStorage(), and lama::DIASparseMatrix< T >::swapLocalStorage().
IndexType lama::_MatrixStorage::getNumValues | ( | ) | const [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).
This routine gives exactly the same number of elements that will be the size of the ja and values array when calling buildCSRData.
The default implementation uses the routine buildCSRSizes, but derived classes should override it if they can do it more efficiently.
Reimplemented in lama::SparseAssemblyStorage< T >, lama::JDSStorage< T >, lama::CSRStorage< T >, lama::COOStorage< T >, lama::ELLStorage< T >, and lama::DenseStorageView< T >.
References buildCSRSizes(), lama::ReadAccess< T >::get(), mNumRows, and lama::OpenMPUtils::sum().
virtual void lama::_MatrixStorage::getRow | ( | _LAMAArray & | row, |
const IndexType | i | ||
) | const [pure virtual] |
This method returns the i-th row of the matrix.
[out] | row | is the destination array that will contain the row |
[in] | i | is the row index |
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
const LAMAArray< IndexType > & lama::_MatrixStorage::getRowIndexes | ( | ) | const [inline] |
References mRowIndexes.
virtual const char* lama::_MatrixStorage::getTypeName | ( | ) | const [pure virtual] |
This method returns the type name of a matrix storage, e.g.
CSRStorage<double>.
This routine is more convenient for error messages than typeid(*this).name()
Implemented in lama::DenseStorage< T >, lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
virtual Scalar::ScalarType lama::_MatrixStorage::getValueType | ( | ) | const [pure virtual] |
Objects of this class should give info about their value type.
Implemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, and lama::DenseStorageView< T >.
Referenced by lama::DenseStorageView< T >::assign(), lama::DenseMatrix< T >::assign(), and lama::MatrixStorage< T >::assign().
bool lama::_MatrixStorage::hasDiagonalProperty | ( | ) | const [inline] |
void lama::_MatrixStorage::init | ( | const IndexType | numRows, |
const IndexType | numColumns | ||
) |
Initialization of base class due to a resize.
References mCompressThreshold, mDiagonalProperty, mNumColumns, and mNumRows.
Referenced by _MatrixStorage(), lama::SparseAssemblyStorage< T >::allocate(), lama::CSRStorage< T >::allocate(), lama::JDSStorage< T >::setCSRDataImpl(), lama::ELLStorage< T >::setCSRDataImpl(), lama::DIAStorage< T >::setCSRDataImpl(), and lama::CSRStorage< T >::setIdentity().
lama::_MatrixStorage::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected] |
logger for this matrix format
Reimplemented in lama::CSRStorage< T >, lama::SparseAssemblyStorage< T >, lama::ELLStorage< T >, lama::DIAStorage< T >, lama::JDSStorage< T >, lama::COOStorage< T >, and lama::DenseStorageView< T >.
void lama::_MatrixStorage::localize | ( | const _MatrixStorage & | global, |
const Distribution & | rowDist | ||
) | [virtual] |
This operation localizes the matrix storage of a full matrix to the part that is owned by this processor.
This means that only the owned rows of the matrix will be kept.
Notes:
* routine can also be used if global is aliased with this matrix. * this routine is the same as an assign in case of a replicated distribution
References lama::Distribution::getGlobalSize(), getNumColumns(), getNumRows(), LAMA_ASSERT_EQUAL_ERROR, and LAMA_THROWEXCEPTION.
void lama::_MatrixStorage::offsets2sizes | ( | LAMAArray< IndexType > & | offsets | ) | [static] |
Help routines to convert arrays with sizes to offsets and vice versa.
References lama::WriteAccess< T >::resize(), and lama::_LAMAArray::size().
Referenced by offsets2sizes().
void lama::_MatrixStorage::offsets2sizes | ( | LAMAArray< IndexType > & | sizes, |
const LAMAArray< IndexType > & | offsets | ||
) | [static] |
_MatrixStorage & lama::_MatrixStorage::operator= | ( | const _MatrixStorage & | other | ) |
Override default assignment operator.
Reimplemented in lama::MatrixStorage< T >, lama::MatrixStorage< ValueType >, lama::DenseStorage< T >, lama::SparseAssemblyStorage< T >, lama::CSRStorage< T >, lama::JDSStorage< T >, lama::COOStorage< T >, lama::ELLStorage< T >, and lama::DIAStorage< T >.
References assign().
virtual void lama::_MatrixStorage::prefetch | ( | const ContextPtr | context | ) | const [pure virtual] |
Pure method that prefetches storage data into a given context.
Implemented in lama::DIAStorage< T >, lama::COOStorage< T >, lama::JDSStorage< T >, lama::CSRStorage< T >, lama::ELLStorage< T >, lama::SparseAssemblyStorage< T >, and lama::DenseStorageView< T >.
Referenced by lama::SpecializedJacobi::iterateTyped().
void lama::_MatrixStorage::prefetch | ( | ) | const [inline] |
Method that prefetches storage data to its preferred location.
References prefetch().
Referenced by prefetch().
virtual void lama::_MatrixStorage::purge | ( | ) | [pure virtual] |
Purge clears the matrix and even frees the allocated memory.
Implemented in lama::DenseStorageView< T >, lama::JDSStorage< T >, lama::DIAStorage< T >, lama::ELLStorage< T >, lama::COOStorage< T >, lama::CSRStorage< T >, and lama::SparseAssemblyStorage< T >.
References checkDiagonalProperty(), and mDiagonalProperty.
Referenced by lama::COOStorage< T >::COOStorage(), lama::ELLStorage< T >::ELLStorage(), and lama::JDSStorage< T >::JDSStorage().
virtual void lama::_MatrixStorage::scale | ( | const Scalar | value | ) | [pure virtual] |
This method scales all matrix values with a scalar.
[in] | value | is the source value |
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
void lama::_MatrixStorage::scale | ( | const _LAMAArray & | values | ) | [pure virtual] |
This method scales each row of a matrix with a separate value.
[in] | values | contains one scale factor for each row. |
Each row of the matrix is scaled with the corresponding value.
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
References LAMA_THROWEXCEPTION.
void lama::_MatrixStorage::setCompressThreshold | ( | float | ratio | ) |
Allow for additional row compression.
References LAMA_THROWEXCEPTION, and mCompressThreshold.
Referenced by lama::MatrixStorage< T >::splitHalo().
void lama::_MatrixStorage::setContext | ( | ContextPtr | context | ) |
Set the preferred context for the matrix storage.
[in] | context | specifies where the storage should be allocated and where operations should be done |
References mContext.
Referenced by lama::CSRStorage< T >::CSRStorage(), lama::DenseStorage< T >::DenseStorage(), and lama::ELLStorage< T >::ELLStorage().
virtual void lama::_MatrixStorage::setCSRData | ( | const IndexType | numRows, |
const IndexType | numColumns, | ||
const IndexType | numValues, | ||
const LAMAArray< IndexType > & | csrIA, | ||
const LAMAArray< IndexType > & | csrJA, | ||
const _LAMAArray & | csrValues | ||
) | [pure virtual] |
Each storage class must provide a routine to set CSR storage data.
numRows | number of rows |
numColumns | number of columns |
numValues | number of non-zero values |
csrIA | offset array ia for column indexes, size is numRows + 1 |
csrJA | are the column indexes of matrix entries, size is numValues |
csrValues | are the values of matrix entries, size is numValues |
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
Referenced by lama::CSRStorage< T >::copyTo(), lama::MatrixStorage< T >::copyTo(), and lama::MatrixStorage< T >::splitHalo().
void lama::_MatrixStorage::setDiagonal | ( | const _LAMAArray & | diagonal | ) | [pure virtual] |
This method sets the diagonal of a matrix storage.
Implementation of this routine must be provided by all derived classes.
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
References LAMA_THROWEXCEPTION.
virtual void lama::_MatrixStorage::setDiagonal | ( | const Scalar | value | ) | [pure virtual] |
Implemented in lama::CRTPMatrixStorage< Derived, ValueType >, lama::CRTPMatrixStorage< COOStorage< T >, T >, lama::CRTPMatrixStorage< ELLStorage< T >, T >, lama::CRTPMatrixStorage< JDSStorage< T >, T >, lama::CRTPMatrixStorage< SparseAssemblyStorage< T >, T >, lama::CRTPMatrixStorage< DenseStorageView< T >, T >, lama::CRTPMatrixStorage< DIAStorage< T >, T >, and lama::CRTPMatrixStorage< CSRStorage< T >, T >.
virtual void lama::_MatrixStorage::setIdentity | ( | const IndexType | n | ) | [pure virtual] |
This method sets storage for the identity matrix.
in) | n is the size of the square matrix |
Implemented in lama::SparseAssemblyStorage< T >, lama::DIAStorage< T >, lama::JDSStorage< T >, lama::CSRStorage< T >, lama::ELLStorage< T >, lama::COOStorage< T >, and lama::DenseStorageView< T >.
IndexType lama::_MatrixStorage::sizes2offsets | ( | LAMAArray< IndexType > & | sizes | ) | [static] |
Utitily to compute the offset array from a sizes array.
References lama::WriteAccess< T >::resize(), and lama::_LAMAArray::size().
Referenced by lama::SparseAssemblyStorage< T >::buildCSR().
void lama::_MatrixStorage::swap | ( | _MatrixStorage & | other | ) | [protected] |
Swaps this with other.
swap is protected to avoid accidently wrong swaps of base classes which do not implement their own swap.
[in,out] | other | the _MatrixStorage to swap this with |
References mCompressThreshold, mContext, mDiagonalProperty, mNumColumns, mNumRows, mRowIndexes, and lama::LAMAArray< T >::swap().
virtual void lama::_MatrixStorage::wait | ( | ) | const [pure virtual] |
Will wait for all outstanding asynchronous data transfers.
Implemented in lama::DIAStorage< T >, lama::COOStorage< T >, lama::JDSStorage< T >, lama::CSRStorage< T >, lama::ELLStorage< T >, lama::SparseAssemblyStorage< T >, and lama::DenseStorageView< T >.
void lama::_MatrixStorage::writeAt | ( | std::ostream & | stream | ) | const [virtual] |
Writes some Information about this to the passed stream.
If a deriving class does not overrides writeAt, typeid(this).name() is written to stream.
[out] | stream | the stream to write to. |
Reimplemented from Printable.
Reimplemented in lama::DIAStorage< T >, lama::JDSStorage< T >, lama::CSRStorage< T >, lama::ELLStorage< T >, lama::COOStorage< T >, lama::DenseStorageView< T >, and lama::SparseAssemblyStorage< T >.
References mNumColumns, and mNumRows.
float lama::_MatrixStorage::mCompressThreshold [protected] |
ratio at which compression is done, 0 for never, 1 for always
Referenced by _assign(), _assignTranspose(), init(), setCompressThreshold(), and swap().
ContextPtr lama::_MatrixStorage::mContext [protected] |
preferred context for the storage
Referenced by setContext(), and swap().
bool lama::_MatrixStorage::mDiagonalProperty [protected] |
if true, diagonal elements are always stored at first position in each row
Referenced by _assign(), _assignTranspose(), lama::CSRStorage< T >::CSRStorage(), lama::DenseStorageView< T >::DenseStorageView(), lama::DIAStorage< T >::DIAStorage(), hasDiagonalProperty(), init(), lama::CSRStorage< T >::maxDiffNormImpl(), resetDiagonalProperty(), lama::SparseAssemblyStorage< T >::setCSRDataImpl(), swap(), and lama::SparseAssemblyStorage< T >::writeAt().
IndexType lama::_MatrixStorage::mNumColumns [protected] |
Referenced by _assign(), _assignTranspose(), _MatrixStorage(), lama::LUSolver::computeLUFactorization(), lama::COOStorage< T >::COOStorage(), lama::CSRStorage< T >::CSRStorage(), lama::DenseStorage< T >::DenseStorage(), lama::DIAStorage< T >::DIAStorage(), lama::ELLStorage< T >::ELLStorage(), lama::SparseAssemblyStorage< T >::fixDiagonalProperty(), lama::SparseAssemblyStorage< T >::getDiagonalImpl(), getNumColumns(), lama::SparseAssemblyStorage< T >::getRowImpl(), init(), lama::JDSStorage< T >::JDSStorage(), lama::SparseAssemblyStorage< T >::operator()(), lama::SparseAssemblyStorage< T >::operator=(), lama::LUSolver::piamax_own(), lama::SparseAssemblyStorage< T >::print(), lama::LUSolver::ptrsm(), lama::SparseAssemblyStorage< T >::set(), lama::SparseAssemblyStorage< T >::setCSRDataImpl(), lama::SparseAssemblyStorage< T >::setDiagonalImpl(), lama::SparseAssemblyStorage< T >::setNumColumns(), lama::SparseAssemblyStorage< T >::SparseAssemblyStorage(), swap(), lama::SparseAssemblyStorage< T >::writeAt(), and writeAt().
IndexType lama::_MatrixStorage::mNumRows [protected] |
Referenced by _assign(), _assignTranspose(), _MatrixStorage(), lama::SparseAssemblyStorage< T >::buildCSR(), lama::LUSolver::computeLUFactorization(), lama::COOStorage< T >::COOStorage(), lama::CSRStorage< T >::CSRStorage(), lama::DenseStorage< T >::DenseStorage(), lama::DIAStorage< T >::DIAStorage(), lama::ELLStorage< T >::ELLStorage(), lama::SparseAssemblyStorage< T >::getDiagonalImpl(), getNumRows(), getNumValues(), lama::SparseAssemblyStorage< T >::getRowImpl(), init(), lama::JDSStorage< T >::JDSStorage(), lama::SparseAssemblyStorage< T >::operator=(), lama::LUSolver::pgetf2(), lama::LUSolver::piamax_own(), lama::SparseAssemblyStorage< T >::print(), lama::LUSolver::ptrsm(), lama::SparseAssemblyStorage< T >::scaleImpl(), lama::SparseAssemblyStorage< T >::set(), lama::SparseAssemblyStorage< T >::setCSRDataImpl(), lama::SparseAssemblyStorage< T >::setDiagonalImpl(), lama::SparseAssemblyStorage< T >::setIdentity(), lama::SparseAssemblyStorage< T >::SparseAssemblyStorage(), swap(), lama::SparseAssemblyStorage< T >::writeAt(), and writeAt().
LAMAArray<IndexType> lama::_MatrixStorage::mRowIndexes [protected] |
used in case of sparse representation of ia
Referenced by _assign(), _assignTranspose(), getMemoryUsage(), getRowIndexes(), and swap().