LAMA
lama::CSRStorage< T > Class Template Reference

Storage format for a CSR (compressed storage row) sparse matrix. More...

#include <CSRStorage.hpp>

Inheritance diagram for lama::CSRStorage< T >:

Public Types

typedef T ValueType
 This is the type of the matrix values.

Public Member Functions

 CSRStorage ()
 Default constructor, stands for a zero matrix of size 0 x 0.
 CSRStorage (const IndexType numRows, const IndexType numColumns)
 Creates a sparse matrix with all values set to zero.
 CSRStorage (const IndexType numRows, const IndexType numColumns, const IndexType numValues, const LAMAArray< IndexType > &ia, const LAMAArray< IndexType > &ja, const LAMAArray< ValueType > &values)
 Constructor for CSR storage by corresponding arrays.
 CSRStorage (const _MatrixStorage &other)
 Copy constructor can take any matrix storage.
 CSRStorage (const _MatrixStorage &other, const ContextPtr context)
 Copy constructor can take any matrix storage or context.
CSRStorage< ValueType > & operator= (const _MatrixStorage &other)
 Assignment operator for matrix storage.
virtual void clear ()
 Implementation of pure method for _MatrixStorage.
virtual void purge ()
 Implementation of pure method of class MatrixStorage.
virtual CSRStoragecopy () const
 Implementation of MatrixStorage::copy for derived class.
virtual CSRStoragecreate () const
 Implementation of MatrixStorage::create for derived class.
virtual ~CSRStorage ()
 Destructor of CSR sparse storage.
void check (const char *msg) const
 Test the storage data for inconsistencies.
virtual MatrixStorageFormat getFormat () const
 Getter routine for the enum value that stands for this format.
virtual void setIdentity (const IndexType size)
 Implementation of pure method.
template<typename OtherValueType >
void setCSRDataImpl (const IndexType numRows, const IndexType numColumns, const IndexType numValues, const LAMAArray< IndexType > &ia, const LAMAArray< IndexType > &ja, const LAMAArray< OtherValueType > &values, const ContextPtr loc)
 fills CSR sparse matrix by csr sparse data.
template<typename OtherValueType >
void setCSRDataSwap (const IndexType numRows, const IndexType numColumns, const IndexType numValues, LAMAArray< IndexType > &ia, LAMAArray< IndexType > &ja, LAMAArray< OtherValueType > &values, const ContextPtr loc)
 fills CSR sparse matrix with csr sparse data without a copy operation
virtual void writeAt (std::ostream &stream) const
 Print relevant information about matrix storage format.
LAMAArray< IndexType > & getIA ()
 Getter routines for the CSR arrays: ia, ja, values.
LAMAArray< IndexType > & getJA ()
 Getter routines for the CSR arrays: ia, ja, values.
LAMAArray< ValueType > & getValues ()
 Getter routines for the values array of the CSR format.
const LAMAArray< IndexType > & getIA () const
const LAMAArray< IndexType > & getJA () const
const LAMAArray< ValueType > & getValues () const
IndexType getNumValues () const
 Getter routine for the number of stored values.
template<typename OtherType >
void getRowImpl (LAMAArray< OtherType > &row, const IndexType i) const
 Template method for getting row.
template<typename OtherValueType >
void getDiagonalImpl (LAMAArray< OtherValueType > &diagonal) const
 Typed version of getDiagonal.
template<typename OtherValueType >
void setDiagonalImpl (const LAMAArray< OtherValueType > &diagonal)
 Typed version of setDiagonal.
void setDiagonalImpl (const Scalar scalar)
 Implementation of pure method.
template<typename OtherType >
void scaleImpl (const LAMAArray< OtherType > &values)
 Template version used for virtual routine scale with known value type.
void scaleImpl (const Scalar value)
 Implementation of pure method.
getValue (IndexType i, IndexType j) const
 Get a value of the matrix.
virtual void prefetch (const ContextPtr location) const
 Initiate an asynchronous data transfer to a specified location.
void wait () const
 Will wait for all outstanding asynchronous data transfers.
void allocate (const IndexType numRows, const IndexType numColumns)
 Allocation of CSR storage for new fill up, allocates ia only.
void compress (const ValueType eps=0.0)
 compress compresses this by removing non-diagonal elements that are smaller than eps.
void swap (CSRStorage< ValueType > &other)
 Swap this CSR storage data with another CSR storage.
void swap (LAMAArray< IndexType > &ia, LAMAArray< IndexType > &ja, LAMAArray< ValueType > &values)
 Swap the CSR arrays with new arrays.
virtual size_t getMemoryUsageImpl () const
 Implementation for pure method is provided.
virtual void assignTranspose (const MatrixStorage< ValueType > &other)
 override method of MatrixStorage with a more efficient solution.
virtual void assign (const _MatrixStorage &other)
 override method of MatrixStorage with a more efficient solution.
virtual void copyTo (_MatrixStorage &other) const
 override method of MatrixStorage with a more efficient solution
template<typename OtherValueType >
void buildCSR (LAMAArray< IndexType > &ia, LAMAArray< IndexType > *ja, LAMAArray< OtherValueType > *values, const ContextPtr) const
 General routine to build any kind of CSR storage.
virtual void buildCSCData (LAMAArray< IndexType > &colIA, LAMAArray< IndexType > &colJA, LAMAArray< ValueType > &cscValues) const
 This routine builds compressed sparse column format data.
virtual void matrixTimesVector (LAMAArrayView< ValueType > result, const ValueType alpha, const LAMAArrayConstView< ValueType > x, const ValueType beta, const LAMAArrayConstView< ValueType > y) const
 Implementation of MatrixStorage::matrixTimesVector for CSR.
virtual void matrixTimesVectorN (LAMAArrayView< ValueType > result, const IndexType n, const ValueType alpha, const LAMAArrayConstView< ValueType > x, const ValueType beta, const LAMAArrayConstView< ValueType > y) const
virtual std::auto_ptr< SyncTokenmatrixTimesVectorAsync (LAMAArrayView< ValueType > result, const ValueType alpha, const LAMAArrayConstView< ValueType > x, const ValueType beta, const LAMAArrayConstView< ValueType > y) const
 Implementation of MatrixStorage::matrixTimesVectorAsync for CSR.
virtual void matrixTimesMatrix (const ValueType alpha, const MatrixStorage< ValueType > &a, const MatrixStorage< ValueType > &b, const ValueType beta, const MatrixStorage< ValueType > &c)
 Implementation of MatrixStorage::matrixTimesMatrix for CSR.
virtual void jacobiIterate (LAMAArrayView< ValueType > solution, const LAMAArrayConstView< ValueType > oldSolution, const LAMAArrayConstView< ValueType > rhs, const ValueType omega) const
 solution = xxx
virtual void jacobiIterateHalo (LAMAArrayView< ValueType > localSolution, const MatrixStorage< ValueType > &localStorage, const LAMAArrayConstView< ValueType > haloOldSolution, const ValueType omega) const
 Jacobi iteration step on a halo storage.
virtual ValueType maxDiffNorm (const MatrixStorage< ValueType > &other)
 Implementation for MatrixStorage::maxDiffNorm.
virtual ValueType maxDiffNormImpl (const CSRStorage< ValueType > &other)
 Implementation of maxDiffNorm for CSR matrices.
void print () const
 print matrix on cout, helpful for debug.
template<typename OtherValueType >
void scaleImpl (const LAMAArray< OtherValueType > &diagonal)
template<>
const char * typeName ()
template<>
const char * typeName ()
void setCSRData (const IndexType numRows, const IndexType numColumns, const IndexType numValues, const LAMAArray< IndexType > &ia, const LAMAArray< IndexType > &ja, const _LAMAArray &values)
 Implementation of _MatrixStorage::setCSRData for derived class.
void buildCSRSizes (LAMAArray< IndexType > &ia) const
 Implementation for _MatrixStorage::buildCSRSizes.
void buildCSRData (LAMAArray< IndexType > &ia, LAMAArray< IndexType > &ja, _LAMAArray &values) const
 Get the matrix data of the storage in CSR format.
void getRow (_LAMAArray &row, const IndexType i) const
 Get the i-th row of a storage as LAMA array.
void getDiagonal (_LAMAArray &diagonal) const
 This method returns the diagonal of the matrix.
void setDiagonal (const Scalar value)
void setDiagonal (const _LAMAArray &diagonal)
 This method sets the diagonal of a matrix storage.
void scale (const Scalar value)
 This method scales all matrix values with a scalar.
void scale (const _LAMAArray &diagonal)
 Polymorph implementation for MatrixStorage<T>::scale.
virtual const char * getTypeName () const
 Implementation of MatrixStorage::getTypeName for derived class.
virtual Scalar::ScalarType getValueType () const
 Implementation of pure method.
template<typename OtherValueType >
void setRawDenseData (const IndexType numRows, const IndexType numColumns, const OtherValueType values[], const ValueType eps=0.0)
 Construct a matrix from a dense matrix in row-major order (C-style).
template<typename OtherValueType >
void setRawCSRData (const IndexType numRows, const IndexType numColumns, const IndexType numValues, const IndexType *const ia, const IndexType *const ja, const OtherValueType *const values)
 fills matrix storage by csr sparse data.
virtual void joinHalo (const _MatrixStorage &localData, const _MatrixStorage &haloData, const class Halo &halo, const class Distribution &colDist)
 Join local and halo storage back into one storage as needed for NoDistribution.
virtual void splitHalo (MatrixStorage< ValueType > &localData, MatrixStorage< ValueType > &haloData, class Halo &halo, const class Distribution &colDist, const class Distribution *rowDist) const
 Splitting of matrix storage for halo.
virtual void buildHalo (class Halo &halo, const class Distribution &colDist)
 Special version of splitHalo where this matrix contains no local data and where haloData is aliased to this matrix.
virtual void localize (const _MatrixStorage &globalData, const class Distribution &rowDist)
 This method build for this matrix the local part of a global matrix.
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 void replicate (const _MatrixStorage &localData, const class Distribution &rowDist)
 This routine builds the full matrix storage for a distributed matrix.
virtual void redistribute (const _MatrixStorage &other, const class Redistributor &redistributor)
 This methods assigns a redistributed matrix.
virtual void exchangeHalo (const class Halo &halo, const MatrixStorage< ValueType > &matrix, const class Communicator &comm)
 Build a halo matrix with all rows of required indexes.
virtual void writeToFile (const std::string &fileName, const File::FileType fileType=File::BINARY, const File::DataType dataType=File::INTERNAL, const File::IndexDataType indexDataTypeIA=File::INT, const File::IndexDataType indexDataTypeJA=File::INT) const
 get the number of elements left/right of the diagonal for the given row
virtual void writeToFile (const PartitionId size, const PartitionId rank, const std::string &fileName, const File::FileType fileType=File::BINARY, const File::DataType dataType=File::INTERNAL, const File::IndexDataType indexDataTypeIA=File::INT, const File::IndexDataType indexDataTypeJA=File::INT) const
virtual void readFromFile (const std::string &fileName)
virtual void invert (const MatrixStorage< ValueType > &other)
 assign this storage with the inverse of another matrix.
virtual void matrixTimesScalar (const ValueType alpha, const MatrixStorage< ValueType > &a)
 Assign this = alpha * a.
virtual std::auto_ptr< SyncTokenjacobiIterateAsync (LAMAArrayView< ValueType > solution, const LAMAArrayConstView< ValueType > oldSolution, const LAMAArrayConstView< ValueType > rhs, const ValueType omega) const
 Asynchrounous version of jacobiIterate.
void init (const IndexType numRows, const IndexType numColumns)
 Initialization of base class due to a resize.
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 ContextgetContext () const
 Getter for the preferred context of the storage data.
void prefetch () const
 Method that prefetches storage data to its preferred location.
void setCompressThreshold (float ratio)
 Allow for additional row compression.
IndexType getNumRows () const
IndexType getNumColumns () const
void resetDiagonalProperty ()
bool hasDiagonalProperty () const
const LAMAArray< IndexType > & getRowIndexes () const
size_t getMemoryUsage () const
 Returns the number of bytes needed for the current matrix.

Static Public Member Functions

static const char * typeName ()
 get typename of the matrix storage format.
static void convertCSR2CSC (LAMAArray< IndexType > &colIA, LAMAArray< IndexType > &colJA, LAMAArray< ValueType > &colValues, const IndexType numColumns, const LAMAArray< IndexType > &rowIA, const LAMAArray< IndexType > &rowJA, const LAMAArray< ValueType > &rowValues, const ContextPtr loc)
 Conversion routine of Compressed Sparse Row data to Compressed Sparse Column.
static void joinRows (LAMAArray< IndexType > &outIA, LAMAArray< IndexType > &outJA, LAMAArray< ValueType > &outValues, const IndexType numRows, const LAMAArray< IndexType > &rowIndexes, const LAMAArray< IndexType > &inIA, const LAMAArray< IndexType > &inJA, const LAMAArray< ValueType > &inValues)
 Method that joins rows of another matrix storage.
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.

Data Fields

IndexType mNumValues
 number of stored elements
LAMAArray< IndexTypemIa
 offsets for ja and data, size is numRows+1
LAMAArray< IndexTypemJa
 column indexes, size is mIa[ numRows ]
LAMAArray< ValueTypemValues
 non-zero values, size is equal to mJa

Protected Member Functions

void swap (MatrixStorage< ValueType > &other)
 Swap member variables of base class MatrixStorage<T>
void swap (_MatrixStorage &other)
 Swaps this with other.
virtual void _assignTranspose (const _MatrixStorage &other)
virtual void _assign (const _MatrixStorage &other)

Protected Attributes

ValueType mEpsilon
 The value mEpsilon is an individual value for each matrix storage that specifies a threshold when a matrix values can be considered as zero.
IndexType mNumRows
IndexType mNumColumns
LAMAArray< IndexTypemRowIndexes
 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
 checks if in each row the diagonal element is stored first.
void buildRowIndexes ()
 Help routine that computes array with row indexes for non-empty rows.
 LAMA_LOG_DECL_STATIC_LOGGER (logger)
 logger for this matrix format
void matrixAddMatrixCSR (const ValueType alpha, const CSRStorage< ValueType > &a, const ValueType beta, const CSRStorage< ValueType > &b)
 Matrix + Matrix for CSR only.
void matrixTimesMatrixCSR (const ValueType alpha, const CSRStorage< ValueType > &a, const CSRStorage< ValueType > &b)
 Matrix times Matrix for CSR only.

Private Attributes

bool mSortedRows
 if true, all rows are sorted by column indexes

Detailed Description

template<typename T>
class lama::CSRStorage< T >

Storage format for a CSR (compressed storage row) sparse matrix.

The CSR format has the following data:

  • ia contains the offset for each row to the following arrays
  • ja is the array with the corresponding column indexes
  • values is the array with all non-zero values

The arrays ja and values are sorted by rows as the array ia indicates. For each row the matrix elements should be sorted by column indexes as this implies usually better cache usage. But it is not mandatory.

If the diagonal property flag is set, the first element in each row is the diagonal element.

     values[ja[ia[i]] !! is the matrix diagonal element at (i,i)

Usually each row has at least one non-zero element. In case of distributed matrixes this is not always the case for the non-local or halo part of the sparse matrix. For such matrixes it might be possible that many rows are completely empty. In such cases, an additional array rowIndexes will contain the non-empty rows. This allows faster traversing.

Generally it is not required that the column indexes of one row are sorted. Nevertheless some operations can benefit from it and so an internal flag is set if values of one row are sorted by column indexes.

Template Parameters:
Tis the value type for the matrix elements.

Member Typedef Documentation

template<typename T>
typedef T lama::CSRStorage< T >::ValueType

This is the type of the matrix values.

Reimplemented from lama::MatrixStorage< T >.


Constructor & Destructor Documentation

template<typename ValueType >
lama::CSRStorage< ValueType >::CSRStorage ( )

Default constructor, stands for a zero matrix of size 0 x 0.

References lama::CSRStorage< T >::allocate().

template<typename ValueType >
lama::CSRStorage< ValueType >::CSRStorage ( const IndexType  numRows,
const IndexType  numColumns 
)

Creates a sparse matrix with all values set to zero.

Parameters:
[in]numRowsthe number of rows of the matrix
[in]numColumnsthe number of columns of the matrix

References lama::CSRStorage< T >::allocate(), lama::_MatrixStorage::mNumColumns, lama::_MatrixStorage::mNumRows, and lama::CSRStorage< T >::mNumValues.

template<typename ValueType >
lama::CSRStorage< ValueType >::CSRStorage ( const IndexType  numRows,
const IndexType  numColumns,
const IndexType  numValues,
const LAMAArray< IndexType > &  ia,
const LAMAArray< IndexType > &  ja,
const LAMAArray< ValueType > &  values 
)
template<typename T>
lama::CSRStorage< T >::CSRStorage ( const _MatrixStorage other) [inline, explicit]

Copy constructor can take any matrix storage.

template<typename T>
lama::CSRStorage< T >::CSRStorage ( const _MatrixStorage other,
const ContextPtr  context 
) [inline]

Copy constructor can take any matrix storage or context.

References lama::_MatrixStorage::setContext().

template<typename ValueType >
lama::CSRStorage< ValueType >::~CSRStorage ( ) [virtual]

Destructor of CSR sparse storage.


Member Function Documentation

template<typename ValueType >
void lama::CSRStorage< ValueType >::allocate ( const IndexType  numRows,
const IndexType  numColumns 
) [virtual]

Allocation of CSR storage for new fill up, allocates ia only.

Parameters:
[in]initFlagif true arrays are correctly initialized for zero matrix

Implements lama::_MatrixStorage.

References lama::WriteAccess< T >::get(), lama::_MatrixStorage::init(), and lama::OpenMPUtils::setVal().

Referenced by lama::CSRStorage< T >::CSRStorage().

template<typename ValueType >
void lama::CSRStorage< ValueType >::assign ( const _MatrixStorage other) [virtual]

override method of MatrixStorage with a more efficient solution.

Reimplemented from lama::MatrixStorage< T >.

References lama::_MatrixStorage::_assign(), and lama::_MatrixStorage::buildCSRData().

template<typename ValueType >
void lama::CSRStorage< ValueType >::assignTranspose ( const MatrixStorage< ValueType > &  other) [virtual]

override method of MatrixStorage with a more efficient solution.

Reimplemented from lama::MatrixStorage< T >.

References lama::_MatrixStorage::_assignTranspose(), and lama::MatrixStorage< T >::buildCSCData().

template<typename ValueType >
void lama::CSRStorage< ValueType >::buildCSCData ( LAMAArray< IndexType > &  colIA,
LAMAArray< IndexType > &  colJA,
LAMAArray< ValueType > &  cscValues 
) const [virtual]

This routine builds compressed sparse column format data.

Note: this routine does not support type conversion

Reimplemented from lama::MatrixStorage< T >.

template<typename ValueType >
template<typename OtherValueType >
void lama::CSRStorage< ValueType >::buildCSR ( LAMAArray< IndexType > &  ia,
LAMAArray< IndexType > *  ja,
LAMAArray< OtherValueType > *  values,
const ContextPtr  loc 
) const

General routine to build any kind of CSR storage.

Parameters:
[out]iais the CSR offset array
[out]jais the array with the column indexes (optional)
[out]valuesis the array with the non-zero matrix values (optional)
[in]locis the Context where conversion should be done

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), LAMA_CONTEXT_ACCESS, LAMA_INTERFACE_FN, and LAMA_INTERFACE_FN_TT.

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::buildCSRData ( LAMAArray< IndexType > &  csrIA,
LAMAArray< IndexType > &  csrJA,
_LAMAArray csrValues 
) const [inline, virtual, inherited]

Get the matrix data of the storage in CSR format.

Parameters:
[out]csrIAoffset array for rows, csrIA.size() == numRows + 1
[out]csrJAcolumn indexes, csrJA.size() == csrIA[ csrIA.size() ]
[out]csrValuesare 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.

Implements lama::_MatrixStorage.

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

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::buildCSRSizes ( LAMAArray< IndexType > &  ia) const [inline, virtual, inherited]

Implementation for _MatrixStorage::buildCSRSizes.

Implements lama::_MatrixStorage.

template<typename T>
void lama::MatrixStorage< ValueType >::buildHalo ( class Halo halo,
const class Distribution colDist 
) [virtual, inherited]

Special version of splitHalo where this matrix contains no local data and where haloData is aliased to this matrix.

This routine is used to translate the non-local column indexes (required values) to local halo indexes and to set up the exchange schedule.

References lama::Distribution::getGlobalSize(), LAMA_ASSERT_EQUAL, and lama::_LAMAArray::size().

template<typename ValueType >
void lama::CSRStorage< ValueType >::buildRowIndexes ( ) [private]

Help routine that computes array with row indexes for non-empty rows.

The array is only built if number of non-zero rows is smaller than a certain percentage ( mThreshold ).

References lama::OpenMPCSRUtils::countNonEmptyRowsByOffsets(), lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::ContextFactory::getContext(), lama::Context::Host, and lama::OpenMPCSRUtils::setNonEmptyRowsByOffsets().

template<typename ValueType >
void lama::CSRStorage< ValueType >::check ( const char *  msg) const [virtual]

Test the storage data for inconsistencies.

Parameters:
[in]msgis additional message string that should be used to identify calling routine
Exceptions:
Exceptionin case of any inconsistency.

Implements lama::_MatrixStorage.

Referenced by lama::CSRStorage< T >::CSRStorage(), and lama::MatrixStorage< T >::matrixTimesMatrix().

template<typename ValueType >
bool lama::CSRStorage< ValueType >::checkDiagonalProperty ( ) const [private, virtual]

checks if in each row the diagonal element is stored first.

Implements lama::_MatrixStorage.

References lama::ReadAccess< T >::get(), LAMA_CONTEXT_ACCESS, LAMA_INTERFACE_FN, and lama::min().

Referenced by lama::CSRStorage< T >::CSRStorage().

template<typename ValueType >
void lama::CSRStorage< ValueType >::clear ( ) [virtual]

Implementation of pure method for _MatrixStorage.

Implements lama::_MatrixStorage.

template<typename ValueType >
void lama::CSRStorage< ValueType >::compress ( const ValueType  eps = 0.0)

compress compresses this by removing non-diagonal elements that are smaller than eps.

compress compresses this by removing non-diagonal elements that are smaller than eps. compress has linear runtime. compress is used by CSRSparseMatrix Multiplication.

Parameters:
[in]epsthe threshold to set a element of this to zero and remove it. (Default: 0.0)

References lama::abs(), LAMA_ASSERT_EQUAL_DEBUG, lama::ReadAccess< T >::release(), and lama::WriteAccess< T >::release().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::convertCSR2CSC ( LAMAArray< IndexType > &  colIA,
LAMAArray< IndexType > &  colJA,
LAMAArray< ValueType > &  colValues,
const IndexType  numColumns,
const LAMAArray< IndexType > &  rowIA,
const LAMAArray< IndexType > &  rowJA,
const LAMAArray< ValueType > &  rowValues,
const ContextPtr  loc 
) [static, inherited]

Conversion routine of Compressed Sparse Row data to Compressed Sparse Column.

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), LAMA_ASSERT_EQUAL_DEBUG, LAMA_CONTEXT_ACCESS, LAMA_INTERFACE_FN_T, LAMA_REGION, and lama::_LAMAArray::size().

template<typename ValueType >
CSRStorage< ValueType > * lama::CSRStorage< ValueType >::copy ( ) const [virtual]

Implementation of MatrixStorage::copy for derived class.

Implements lama::MatrixStorage< T >.

template<typename T >
void lama::CSRStorage< T >::copyTo ( _MatrixStorage other) const [virtual]

override method of MatrixStorage with a more efficient solution

Reimplemented from lama::MatrixStorage< T >.

References lama::_MatrixStorage::setCSRData().

template<typename ValueType >
CSRStorage< ValueType > * lama::CSRStorage< ValueType >::create ( ) const [virtual]

Implementation of MatrixStorage::create for derived class.

Implements lama::MatrixStorage< T >.

template<typename T>
void lama::MatrixStorage< ValueType >::exchangeHalo ( const class Halo halo,
const MatrixStorage< ValueType > &  matrix,
const class Communicator comm 
) [virtual, inherited]
const Context& lama::_MatrixStorage::getContext ( ) const [inline, inherited]

Getter for the preferred context of the storage data.

Referenced by lama::ELLStorage< T >::ELLStorage().

ContextPtr lama::_MatrixStorage::getContextPtr ( ) const [inline, inherited]

Getter for the preferred context of the storage data, returns pointer.

Referenced by lama::SpecializedJacobi::iterateTyped(), and lama::JDSStorage< T >::JDSStorage().

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::getDiagonal ( _LAMAArray diagonal) const [inline, virtual, inherited]

This method returns the diagonal of the matrix.

Parameters:
[out]diagonalis the destination array

The values will be stored in diagonal that can be of any type for which implicit conversion is available.

Implements lama::_MatrixStorage.

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

template<typename ValueType >
template<typename OtherValueType >
void lama::CSRStorage< ValueType >::getDiagonalImpl ( LAMAArray< OtherValueType > &  diagonal) const

Typed version of getDiagonal.

Parameters:
[out]diagonalis the typed LAMA array for output

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::min(), and lama::OpenMPUtils::setGather().

template<typename ValueType >
MatrixStorageFormat lama::CSRStorage< ValueType >::getFormat ( ) const [virtual]

Getter routine for the enum value that stands for this format.

Implements lama::_MatrixStorage.

References lama::CSR.

template<typename ValueType >
LAMAArray< IndexType > & lama::CSRStorage< ValueType >::getIA ( )

Getter routines for the CSR arrays: ia, ja, values.

Referenced by lama::SOR::iterateImpl(), lama::CSRStorage< T >::matrixAddMatrixCSR(), and lama::CSRStorage< T >::matrixTimesMatrixCSR().

template<typename ValueType >
const LAMAArray< IndexType > & lama::CSRStorage< ValueType >::getIA ( ) const
template<typename ValueType >
LAMAArray< IndexType > & lama::CSRStorage< ValueType >::getJA ( )

Getter routines for the CSR arrays: ia, ja, values.

Referenced by lama::SOR::iterateImpl(), lama::CSRStorage< T >::matrixAddMatrixCSR(), and lama::CSRStorage< T >::matrixTimesMatrixCSR().

template<typename ValueType >
const LAMAArray< IndexType > & lama::CSRStorage< ValueType >::getJA ( ) const
size_t lama::_MatrixStorage::getMemoryUsage ( ) const [inherited]

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 lama::_MatrixStorage::getMemoryUsageImpl(), lama::_MatrixStorage::mRowIndexes, and lama::_LAMAArray::size().

template<typename ValueType >
size_t lama::CSRStorage< ValueType >::getMemoryUsageImpl ( ) const [virtual]

Implementation for pure method is provided.

Implements lama::_MatrixStorage.

IndexType lama::_MatrixStorage::getNumColumns ( ) const [inline, inherited]

References lama::_MatrixStorage::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(), lama::_MatrixStorage::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, inherited]
template<typename ValueType >
IndexType lama::CSRStorage< ValueType >::getNumValues ( ) const [virtual]

Getter routine for the number of stored values.

Reimplemented from lama::_MatrixStorage.

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::getRow ( _LAMAArray row,
const IndexType  i 
) const [inline, virtual, inherited]

Get the i-th row of a storage as LAMA array.

Implements lama::_MatrixStorage.

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

template<typename ValueType >
template<typename OtherType >
void lama::CSRStorage< ValueType >::getRowImpl ( LAMAArray< OtherType > &  row,
const IndexType  i 
) const

Template method for getting row.

References LAMA_ASSERT_DEBUG.

const LAMAArray< IndexType > & lama::_MatrixStorage::getRowIndexes ( ) const [inline, inherited]
virtual const char* lama::CRTPMatrixStorage< CSRStorage< T > , T >::getTypeName ( ) const [inline, virtual, inherited]

Implementation of MatrixStorage::getTypeName for derived class.

Implements lama::_MatrixStorage.

template<typename ValueType >
ValueType lama::CSRStorage< ValueType >::getValue ( IndexType  i,
IndexType  j 
) const [virtual]

Get a value of the matrix.

Parameters:
[in]iis the row index, 0 <= i < mNumRows
[in]jis the colum index, 0 <= j < mNumRows

Out-of-range check is enabled for DEBUG version.

Implements lama::MatrixStorage< T >.

References LAMA_ASSERT_DEBUG.

template<typename ValueType >
LAMAArray< ValueType > & lama::CSRStorage< ValueType >::getValues ( )

Getter routines for the values array of the CSR format.

Referenced by lama::SOR::iterateImpl(), lama::CSRStorage< T >::matrixAddMatrixCSR(), and lama::CSRStorage< T >::matrixTimesMatrixCSR().

template<typename ValueType >
const LAMAArray< ValueType > & lama::CSRStorage< ValueType >::getValues ( ) const
template<typename ValueType >
Scalar::ScalarType lama::MatrixStorage< ValueType >::getValueType ( ) const [virtual, inherited]

Implementation of pure method.

Implements lama::_MatrixStorage.

Reimplemented in lama::DenseStorageView< T >.

Referenced by lama::DenseStorageView< T >::maxDiffNorm(), and lama::CSRStorage< T >::maxDiffNorm().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::invert ( const MatrixStorage< ValueType > &  other) [virtual, inherited]

assign this storage with the inverse of another matrix.

Parameters:
[in]otheris matrix to invert, must be square

Note: other matrix storage can be aliased with this storage.

Reimplemented in lama::DenseStorageView< T >.

References lama::DenseStorageView< T >::invert().

template<typename ValueType >
std::auto_ptr< SyncToken > lama::MatrixStorage< ValueType >::jacobiIterateAsync ( LAMAArrayView< ValueType solution,
const LAMAArrayConstView< ValueType oldSolution,
const LAMAArrayConstView< ValueType rhs,
const ValueType  omega 
) const [virtual, inherited]

Asynchrounous version of jacobiIterate.

Referenced by lama::SpecializedJacobi::iterateTyped().

template<typename ValueType >
void lama::CSRStorage< ValueType >::jacobiIterateHalo ( LAMAArrayView< ValueType localSolution,
const MatrixStorage< ValueType > &  localStorage,
const LAMAArrayConstView< ValueType haloOldSolution,
const ValueType  omega 
) const [virtual]

Jacobi iteration step on a halo storage.

solution -= omega * ( B(halo) * oldSolution) * dinv

Parameters:
[in,out]localSolutionis the solution vector that is updated
[in]localStorageis needed to get the diagonal
[in]haloOldSolutionis the old solution vector of halo part
[in]omegais the scaling factor.

While local storage must be square and have the diagonal property, this matrix storage does not have to be square.

Reimplemented from lama::MatrixStorage< T >.

References lama::CSR, lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::_MatrixStorage::getFormat(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::_MatrixStorage::hasDiagonalProperty(), LAMA_ASSERT_DEBUG, LAMA_ASSERT_EQUAL_DEBUG, LAMA_CONTEXT_ACCESS, LAMA_INTERFACE_FN_T, LAMA_THROWEXCEPTION, lama::LAMAArrayView< T >::size(), and lama::LAMAArrayConstView< T >::size().

Referenced by lama::MatrixStorage< T >::jacobiIterateHalo().

template<typename T>
void lama::MatrixStorage< ValueType >::joinHalo ( const _MatrixStorage< T > &  localData,
const _MatrixStorage< T > &  haloData,
const class Halo halo,
const class Distribution colDist 
) [virtual, inherited]

Join local and halo storage back into one storage as needed for NoDistribution.

This matrix storage is used as output matrix.

Parameters:
[in]localDatais matrix storage with local data
[in]haloDatais the matrix storage with halo data
[in]halois the communicaton halo, contains also mapping halo to global indexes
[in]colDistis the distribution that has be used for getting the local data

Attention: localData might be aliased with this matrix storage, while haloData must not

Derived classes might use a default implementation that is based on joining CSR data with corresponding conversions.

References lama::_MatrixStorage::buildCSRData(), lama::Distribution::getGlobalSize(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Halo::getRequiredIndexes(), lama::_MatrixStorage::hasDiagonalProperty(), lama::Distribution::local2global(), lama::min(), and lama::_LAMAArray::size().

Referenced by lama::SparseMatrix< T >::writeToFile().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::joinRows ( LAMAArray< IndexType > &  outIA,
LAMAArray< IndexType > &  outJA,
LAMAArray< ValueType > &  outValues,
const IndexType  numRows,
const LAMAArray< IndexType > &  rowIndexes,
const LAMAArray< IndexType > &  inIA,
const LAMAArray< IndexType > &  inJA,
const LAMAArray< ValueType > &  inValues 
) [static, inherited]

Method that joins rows of another matrix storage.

row(i) of out contains all elements of in(k) with rowIndexes[k] == i

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::WriteAccess< T >::resize(), lama::ReadAccess< T >::size(), and lama::WriteAccess< T >::size().

template<typename T>
lama::CSRStorage< T >::LAMA_LOG_DECL_STATIC_LOGGER ( logger  ) [private]

logger for this matrix format

Reimplemented from lama::_MatrixStorage.

void lama::_MatrixStorage::localize ( const _MatrixStorage global,
const Distribution rowDist 
) [virtual, inherited]

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(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), LAMA_ASSERT_EQUAL_ERROR, and LAMA_THROWEXCEPTION.

template<typename T>
void lama::MatrixStorage< ValueType >::localize ( const _MatrixStorage< T > &  globalData,
const class Distribution rowDist 
) [virtual, inherited]

This method build for this matrix the local part of a global matrix.

The row distribution specifies which rows of the global matrix will be used for this storage locally.

Attention: globalMatrix might be aliased to this storage.

References lama::_MatrixStorage::buildCSRData(), lama::Distribution::getGlobalSize(), lama::Distribution::getLocalSize(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Distribution::isReplicated(), LAMA_ASSERT_EQUAL_ERROR, and lama::_LAMAArray::size().

Referenced by lama::DenseMatrix< T >::assign(), and lama::MatrixStorage< T >::splitHalo().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::matrixTimesScalar ( const ValueType  alpha,
const MatrixStorage< ValueType > &  a 
) [virtual, inherited]

Assign this = alpha * a.

The default implementation assigns the matrix a and scales it afterwards.

void lama::_MatrixStorage::offsets2sizes ( LAMAArray< IndexType > &  offsets) [static, inherited]

Help routines to convert arrays with sizes to offsets and vice versa.

References lama::WriteAccess< T >::resize(), and lama::_LAMAArray::size().

Referenced by lama::_MatrixStorage::offsets2sizes().

template<typename T>
CSRStorage<ValueType>& lama::CSRStorage< T >::operator= ( const _MatrixStorage other) [inline]

Assignment operator for matrix storage.

Using 'assign'

Reimplemented from lama::MatrixStorage< T >.

void lama::_MatrixStorage::prefetch ( ) const [inline, inherited]

Method that prefetches storage data to its preferred location.

References lama::_MatrixStorage::prefetch().

Referenced by lama::_MatrixStorage::prefetch().

template<typename ValueType >
void lama::CSRStorage< ValueType >::prefetch ( const ContextPtr  location) const [virtual]

Initiate an asynchronous data transfer to a specified location.

Implements lama::_MatrixStorage.

template<typename ValueType >
void lama::CSRStorage< ValueType >::print ( ) const

print matrix on cout, helpful for debug.

template<typename ValueType >
void lama::CSRStorage< ValueType >::purge ( ) [virtual]

Implementation of pure method of class MatrixStorage.

Implements lama::_MatrixStorage.

template<typename ValueType >
void lama::MatrixStorage< ValueType >::readFromFile ( const std::string &  fileName) [virtual, inherited]
template<typename T>
void lama::MatrixStorage< ValueType >::redistribute ( const _MatrixStorage< T > &  other,
const class Redistributor redistributor 
) [virtual, inherited]

This methods assigns a redistributed matrix.

Parameters:
[in]otheris the local part of the matrix data to redistribute
[in]redistributorcontains source distribution of other and target distribution of this

References lama::_MatrixStorage::buildCSRData(), lama::Distribution::getLocalSize(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Redistributor::getSourceDistributionPtr(), lama::Redistributor::getTargetDistributionPtr(), lama::Distribution::isReplicated(), LAMA_ASSERT_EQUAL_ERROR, and lama::_LAMAArray::size().

template<typename T>
void lama::MatrixStorage< ValueType >::replicate ( const _MatrixStorage< T > &  localData,
const class Distribution rowDist 
) [virtual, inherited]

This routine builds the full matrix storage for a distributed matrix.

This routine is exactly the inverse routine to the localize routine. After this operation this matrix storage will contain on each processor the global matrix data.

References lama::Distribution::getGlobalSize(), lama::Distribution::getLocalSize(), lama::_MatrixStorage::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Distribution::isReplicated(), LAMA_ASSERT_EQUAL_ERROR, and lama::_LAMAArray::size().

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::scale ( const Scalar  value) [inline, virtual, inherited]

This method scales all matrix values with a scalar.

Parameters:
[in]valueis the source value

Implements lama::_MatrixStorage.

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::scale ( const _LAMAArray diagonal) [inline, virtual, inherited]
template<typename T>
template<typename OtherType >
void lama::CSRStorage< T >::scaleImpl ( const LAMAArray< OtherType > &  values)

Template version used for virtual routine scale with known value type.

template<typename ValueType >
void lama::CSRStorage< ValueType >::scaleImpl ( const Scalar  value)

Implementation of pure method.

References lama::WriteAccess< T >::get(), lama::Scalar::getValue(), and lama::OpenMPBLAS1::scal().

template<typename T>
template<typename OtherValueType >
void lama::CSRStorage< T >::scaleImpl ( const LAMAArray< OtherValueType > &  diagonal)
void lama::_MatrixStorage::setCompressThreshold ( float  ratio) [inherited]

Allow for additional row compression.

References LAMA_THROWEXCEPTION, and lama::_MatrixStorage::mCompressThreshold.

Referenced by lama::MatrixStorage< T >::splitHalo().

void lama::_MatrixStorage::setContext ( ContextPtr  context) [inherited]

Set the preferred context for the matrix storage.

Parameters:
[in]contextspecifies where the storage should be allocated and where operations should be done

References lama::_MatrixStorage::mContext.

Referenced by lama::CSRStorage< T >::CSRStorage(), lama::DenseStorage< T >::DenseStorage(), and lama::ELLStorage< T >::ELLStorage().

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::setCSRData ( const IndexType  numRows,
const IndexType  numColumns,
const IndexType  numValues,
const LAMAArray< IndexType > &  ia,
const LAMAArray< IndexType > &  ja,
const _LAMAArray values 
) [inline, virtual, inherited]

Implementation of _MatrixStorage::setCSRData for derived class.

This routine requires that the derived class provides a corresponding routine setCSRDataImpl that can deal with a typed version of values.

Implements lama::_MatrixStorage.

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

template<typename ValueType >
template<typename OtherValueType >
void lama::CSRStorage< ValueType >::setCSRDataImpl ( const IndexType  numRows,
const IndexType  numColumns,
const IndexType  numValues,
const LAMAArray< IndexType > &  ia,
const LAMAArray< IndexType > &  ja,
const LAMAArray< OtherValueType > &  values,
const ContextPtr  loc 
)

fills CSR sparse matrix by csr sparse data.

Parameters:
[in]numRowsnumber of rows
[in]numColumnsnumber of columns
[in]numValuesthe number of stored elements in the matrix
[in]iarow pointer of the input csr sparse matrix
[in]jacolumn indexes of the input csr sparse matrix
[in]valuesthe data values of the input csr sparse matrix
[in]locis the context where filling takes place

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::ContextFactory::getContext(), lama::OpenMPCSRUtils::hasDiagonalProperty(), lama::Context::Host, LAMA_THROWEXCEPTION, lama::WriteAccess< T >::release(), lama::OpenMPUtils::set(), lama::OpenMPUtils::validIndexes(), and lama::OpenMPCSRUtils::validOffsets().

template<typename ValueType >
template<typename OtherValueType >
template void lama::CSRStorage< T >::setCSRDataSwap ( const IndexType  numRows,
const IndexType  numColumns,
const IndexType  numValues,
LAMAArray< IndexType > &  ia,
LAMAArray< IndexType > &  ja,
LAMAArray< OtherValueType > &  values,
const ContextPtr  loc 
)

fills CSR sparse matrix with csr sparse data without a copy operation

Parameters:
[in]numRowsnumber of rows
[in]numColumnsnumber of columns
[in]numValuesthe number of stored elements in the matrix
[in]iarow pointer of the input csr sparse matrix (will be lost after)
[in]jacolumn indexes of the input csr sparse matrix (will be lost after)
[in]valuesthe data values of the input csr sparse matrix (will be lost after)
[in]locis the context where filling takes place

References lama::ReadAccess< T >::get(), LAMA_CONTEXT_ACCESS, LAMA_INTERFACE_FN, and lama::min().

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::setDiagonal ( const Scalar  value) [inline, virtual, inherited]

Implements lama::_MatrixStorage.

void lama::CRTPMatrixStorage< CSRStorage< T > , T >::setDiagonal ( const _LAMAArray diagonal) [inline, virtual, inherited]

This method sets the diagonal of a matrix storage.

Implementation of this routine must be provided by all derived classes.

Implements lama::_MatrixStorage.

References lama::Scalar::DOUBLE, lama::Scalar::FLOAT, lama::_LAMAArray::getValueType(), LAMA_THROWEXCEPTION, and lama::_LAMAArray::size().

template<typename ValueType >
template<typename OtherValueType >
void lama::CSRStorage< ValueType >::setDiagonalImpl ( const LAMAArray< OtherValueType > &  diagonal)

Typed version of setDiagonal.

Parameters:
[in]diagonalis the typed LAMA array for input

References lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::OpenMPUtils::setScatter(), and lama::_LAMAArray::size().

template<typename ValueType >
void lama::CSRStorage< ValueType >::setDiagonalImpl ( const Scalar  scalar)

Implementation of pure method.

References lama::Scalar::getValue(), LAMA_THROWEXCEPTION, and lama::min().

template<typename ValueType >
void lama::CSRStorage< ValueType >::setIdentity ( const IndexType  size) [virtual]
template<typename ValueType >
template<typename OtherValueType >
void lama::MatrixStorage< ValueType >::setRawCSRData ( const IndexType  numRows,
const IndexType  numColumns,
const IndexType  numValues,
const IndexType *const  ia,
const IndexType *const  ja,
const OtherValueType *const  values 
) [inherited]

fills matrix storage by csr sparse data.

Parameters:
[in]numRowsnumber of rows
[in]numColumnsnumber of columns
[in]numValuesthe number of stored elements in the matrix
[in]iarow pointer of the input csr sparse matrix
[in]jacolumn indexes of the input csr sparse matrix
[in]valuesthe data values of the input csr sparse matrix

Referenced by lama::MatrixCreator< T >::fillRandom().

template<typename ValueType >
template<typename OtherValueType >
template LAMA_DLL_IMPORTEXPORT void lama::MatrixStorage< T >::setRawDenseData ( const IndexType  numRows,
const IndexType  numColumns,
const OtherValueType  values[],
const ValueType  eps = 0.0 
) [inherited]

Construct a matrix from a dense matrix in row-major order (C-style).

Values of the matrix will be considered as zero if their absolute value is smaller than eps.

Parameters:
[in]numRowsnumber of rows
[in]numColumnsnumber of columns
[in]valuesthe dense matrix values in row-major order (C-style)
[in]epsthreshold value for non-zero elements

Sparse matrix formats will have the diagonal property if numRows == numColums

References LAMA_ASSERT_ERROR, and lama::_LAMAArray::size().

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

template<typename T>
void lama::MatrixStorage< ValueType >::splitHalo ( MatrixStorage< ValueType > &  localData,
MatrixStorage< ValueType > &  haloData,
class Halo halo,
const class Distribution colDist,
const class Distribution rowDist 
) const [virtual, inherited]

Splitting of matrix storage for halo.

Parameters:
[out]localDatawill contain all columns owned by this processor
[out]haloDatawill contain all columns not owned by this processor
[out]halowill be the exchange schedule
[in]colDistspecifies the distribution of the columns
[in]rowDistoptional, localizes the rows before splitting

References lama::_MatrixStorage::allocate(), lama::MatrixStorage< T >::assign(), lama::_MatrixStorage::check(), lama::Distribution::getGlobalSize(), lama::Distribution::getLocalSize(), lama::Distribution::isReplicated(), LAMA_ASSERT_EQUAL, LAMA_ASSERT_EQUAL_DEBUG, lama::MatrixStorage< T >::localize(), lama::_MatrixStorage::setCompressThreshold(), lama::_MatrixStorage::setCSRData(), and lama::_LAMAArray::size().

Referenced by lama::SparseMatrix< T >::set().

template<typename ValueType >
void lama::CSRStorage< ValueType >::swap ( CSRStorage< ValueType > &  other)

Swap this CSR storage data with another CSR storage.

Parameters:
[in,out]otheris the CSR storage with with this storage is swapped

Note: swap is only possible for two storages of the same format and same type.

References lama::CSRStorage< T >::mIa, lama::CSRStorage< T >::mJa, lama::CSRStorage< T >::mNumValues, lama::CSRStorage< T >::mValues, and lama::MatrixStorage< T >::swap().

Referenced by lama::MatrixCreator< T >::buildPoisson().

template<typename ValueType >
void lama::CSRStorage< ValueType >::swap ( LAMAArray< IndexType > &  ia,
LAMAArray< IndexType > &  ja,
LAMAArray< ValueType > &  values 
)

Swap the CSR arrays with new arrays.

This routine can be used to build a CSR storage with new values. Other member variables (e.g. mDiagonalProperty, rowIndexes, ... ) will be defined correctly.

References LAMA_ASSERT_EQUAL_ERROR, and lama::_LAMAArray::size().

void lama::_MatrixStorage::swap ( _MatrixStorage other) [protected, inherited]

Swaps this with other.

swap is protected to avoid accidently wrong swaps of base classes which do not implement their own swap.

Parameters:
[in,out]otherthe _MatrixStorage to swap this with

References lama::_MatrixStorage::mCompressThreshold, lama::_MatrixStorage::mContext, lama::_MatrixStorage::mDiagonalProperty, lama::_MatrixStorage::mNumColumns, lama::_MatrixStorage::mNumRows, lama::_MatrixStorage::mRowIndexes, and lama::LAMAArray< T >::swap().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::swap ( MatrixStorage< ValueType > &  other) [protected, inherited]

Swap member variables of base class MatrixStorage<T>

Parameters:
[in,out]otherthe MatrixStorage to swap this with

swap is protected to avoid accidently wrong swaps of derived classes which do not implement their own swap or where storages of different format or types are involved.

 CSRStorage<float> csr;
 CSRStorage<double> csr1;
 ELLStorage<float> ell;
 csr.swap( ell ); // NOT ALLOWED, different format
 csr.swap( csr1 ); // NOT ALLOWED, different type

References lama::MatrixStorage< T >::mEpsilon.

Referenced by lama::SparseAssemblyStorage< T >::swap(), lama::DenseStorageView< T >::swap(), lama::JDSStorage< T >::swap(), lama::COOStorage< T >::swap(), lama::DIAStorage< T >::swap(), lama::CSRStorage< T >::swap(), and lama::ELLStorage< T >::swap().

template<typename T>
static const char* lama::CSRStorage< T >::typeName ( ) [static]

get typename of the matrix storage format.

template<>
const char * lama::CSRStorage< float >::typeName ( )
template<>
const char * lama::CSRStorage< double >::typeName ( )
template<typename ValueType >
void lama::CSRStorage< ValueType >::wait ( ) const [virtual]

Will wait for all outstanding asynchronous data transfers.

Implements lama::_MatrixStorage.

template<typename ValueType >
void lama::CSRStorage< ValueType >::writeAt ( std::ostream &  stream) const [virtual]

Print relevant information about matrix storage format.

Reimplemented from lama::_MatrixStorage.

template<typename ValueType >
void lama::MatrixStorage< ValueType >::writeToFile ( const std::string &  fileName,
const File::FileType  fileType = File::BINARY,
const File::DataType  dataType = File::INTERNAL,
const File::IndexDataType  indexDataTypeIA = File::INT,
const File::IndexDataType  indexDataTypeJA = File::INT 
) const [virtual, inherited]

get the number of elements left/right of the diagonal for the given row

Parameters:
[in]rowglobal Index of row
[out]leftmaximal distance of non-zero element to diagonal from the left
[out]rightmaximal distance of non-zero element to diagonal from the right

Referenced by lama::SparseMatrix< T >::writeToFile().

template<typename ValueType >
void lama::MatrixStorage< ValueType >::writeToFile ( const PartitionId  size,
const PartitionId  rank,
const std::string &  fileName,
const File::FileType  fileType = File::BINARY,
const File::DataType  dataType = File::INTERNAL,
const File::IndexDataType  indexDataTypeIA = File::INT,
const File::IndexDataType  indexDataTypeJA = File::INT 
) const [virtual, inherited]

Field Documentation

preferred context for the storage

Referenced by lama::_MatrixStorage::setContext(), and lama::_MatrixStorage::swap().

template<typename T>
ValueType lama::MatrixStorage< T >::mEpsilon [protected, inherited]

The value mEpsilon is an individual value for each matrix storage that specifies a threshold when a matrix values can be considered as zero.

It is used internally especially when setting dense data or when the storage data is compressed.

Referenced by lama::MatrixStorage< T >::swap().

template<typename T>
LAMAArray<IndexType> lama::CSRStorage< T >::mIa

offsets for ja and data, size is numRows+1

Referenced by lama::CSRStorage< T >::maxDiffNormImpl(), and lama::CSRStorage< T >::swap().

template<typename T>
LAMAArray<IndexType> lama::CSRStorage< T >::mJa

column indexes, size is mIa[ numRows ]

Referenced by lama::CSRStorage< T >::maxDiffNormImpl(), and lama::CSRStorage< T >::swap().

template<typename T>
IndexType lama::CSRStorage< T >::mNumValues

number of stored elements

Referenced by lama::CSRStorage< T >::CSRStorage(), and lama::CSRStorage< T >::swap().

template<typename T>
bool lama::CSRStorage< T >::mSortedRows [private]

if true, all rows are sorted by column indexes

Referenced by lama::CSRStorage< T >::maxDiffNormImpl().

template<typename T>
LAMAArray<ValueType> lama::CSRStorage< T >::mValues

non-zero values, size is equal to mJa

Referenced by lama::CSRStorage< T >::maxDiffNormImpl(), and lama::CSRStorage< T >::swap().


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