Flow123d  release_2.2.0-914-gf1a3a4f
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
la::MatrixCoo< INDT, VALT > Class Template Reference

Temporary storage for a sparse matrix. More...

#include <matrix_coo.hpp>

Collaboration diagram for la::MatrixCoo< INDT, VALT >:
Collaboration graph
[legend]

Classes

struct  TripleDiagEntry_
 returns true if the entry is on diagonal, i.e. row == column More...
 
struct  TripleLessThan_
 returns true if the index pair of the first entry is smaller than of the second entry More...
 
struct  TripleRowIndexLessThan_
 returns true if the row of an entry is smaller than a prescribed index More...
 
struct  TripleRowLessThan_
 returns true if the first entry has smaller ROW index than the second one More...
 

Public Types

typedef INDT IndexType
 
typedef VALT ValueType
 

Public Member Functions

 MatrixCoo (unsigned nRows=0, unsigned nCols=0)
 
 ~MatrixCoo ()
 
IndexType nnz () const
 Return number of non-zeros. More...
 
void prepareAssembly (const IndexType length)
 
void insert (const IndexType i, const IndexType j, const ValueType value)
 Insert a value to unassembled vector. More...
 
void finishAssembly ()
 Finalize matrix assembly - build the assembled input and truncate matrix. More...
 
void getIntervalCounts (IndexType low, IndexType high, std::vector< IndexType > &nnzRowsIn, std::vector< IndexType > &nnzRowsOut)
 Determine number of nonzeros within a block [low,high) - used for PETSc preallocation. More...
 
void getEntry (IndexType index, IndexType &row, IndexType &col, ValueType &val)
 Get specific entry. More...
 
void zeroRow (const IndexType row, const ValueType factor)
 Zero a row and set diagonal to scalar. More...
 
void setCompressedRowArrays (std::vector< IndexType > &colIndices, std::vector< IndexType > &rowPtrs, std::vector< ValueType > &values)
 
void extractArrays (std::vector< IndexType > &rowIndices, std::vector< IndexType > &colIndices, std::vector< ValueType > &values, bool onlyUpperTriangle=false)
 Fill independent arrays with column indices, row pointers and values. More...
 
void clear ()
 destroy all contents More...
 
void erase ()
 erase all contents More...
 
std::ostream & write (std::ostream &out)
 debug-output More...
 
double infNorm ()
 Compute maximal row sum (infinity-norm) of a matrix in coordinate format. More...
 
ValueType frobeniusNorm ()
 Return Frobenius norm of matrix $||a_{ij}||_F=\sqrt{\sum_i\sum_j |a_{ij}|^2}$. More...
 
double getDiagScalar ()
 

Private Types

typedef std::pair< IndexType, IndexTypeIndexPair_
 pair of indices More...
 
typedef std::pair< IndexPair_, ValueTypeTriple_
 triple More...
 
typedef std::vector< Triple_MatrixCooVec_
 vector of triples More...
 

Private Member Functions

IndexType deduceNumRows_ ()
 
Triple_ combineTriples_ (typename MatrixCooVec_::const_iterator itb, typename MatrixCooVec_::const_iterator ite)
 merge range of triples by addition More...
 

Private Attributes

MatrixCooVec_ matrixCooVec_
 matrix in coordinate format <i,j, values> More...
 
IndexType nRows_
 number of rows of matrix More...
 
IndexType nCols_
 number of columns of matrix More...
 
unsigned sortedSize_
 number of sorted entries More...
 
bool sorted_
 state variable - is matrix sorted? More...
 

Detailed Description

template<typename INDT, typename VALT>
class la::MatrixCoo< INDT, VALT >

Temporary storage for a sparse matrix.

This object stores and handles matrix in coordinate format, i.e., <row_index,col_index,value>-combinations for each matrix entry of a sparse matrix. Functionalities are:

Definition at line 34 of file matrix_coo.hpp.

Member Typedef Documentation

template<typename INDT, typename VALT>
typedef std::pair<IndexType, IndexType> la::MatrixCoo< INDT, VALT >::IndexPair_
private

pair of indices

Definition at line 458 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
typedef INDT la::MatrixCoo< INDT, VALT >::IndexType

Definition at line 60 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
typedef std::vector<Triple_> la::MatrixCoo< INDT, VALT >::MatrixCooVec_
private

vector of triples

Definition at line 460 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
typedef std::pair<IndexPair_,ValueType> la::MatrixCoo< INDT, VALT >::Triple_
private

triple

Definition at line 459 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
typedef VALT la::MatrixCoo< INDT, VALT >::ValueType

Definition at line 61 of file matrix_coo.hpp.

Constructor & Destructor Documentation

template<typename INDT, typename VALT>
la::MatrixCoo< INDT, VALT >::MatrixCoo ( unsigned  nRows = 0,
unsigned  nCols = 0 
)
inline

Definition at line 64 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
la::MatrixCoo< INDT, VALT >::~MatrixCoo ( )
inline

Definition at line 72 of file matrix_coo.hpp.

Member Function Documentation

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::clear ( )
inline

destroy all contents

Definition at line 325 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
Triple_ la::MatrixCoo< INDT, VALT >::combineTriples_ ( typename MatrixCooVec_::const_iterator  itb,
typename MatrixCooVec_::const_iterator  ite 
)
inlineprivate

merge range of triples by addition

Definition at line 540 of file matrix_coo.hpp.

Here is the caller graph for this function:

template<typename INDT, typename VALT>
IndexType la::MatrixCoo< INDT, VALT >::deduceNumRows_ ( )
inlineprivate

deduce number of rows - if it was given by user, use it, otherwise, deduce it from the index of the last entry

Definition at line 475 of file matrix_coo.hpp.

Here is the caller graph for this function:

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::erase ( )
inline

erase all contents

Definition at line 334 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::extractArrays ( std::vector< IndexType > &  rowIndices,
std::vector< IndexType > &  colIndices,
std::vector< ValueType > &  values,
bool  onlyUpperTriangle = false 
)
inline

Fill independent arrays with column indices, row pointers and values.

Definition at line 290 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::finishAssembly ( )
inline

Finalize matrix assembly - build the assembled input and truncate matrix.

Definition at line 111 of file matrix_coo.hpp.

Here is the caller graph for this function:

template<typename INDT, typename VALT>
ValueType la::MatrixCoo< INDT, VALT >::frobeniusNorm ( )
inline

Return Frobenius norm of matrix $||a_{ij}||_F=\sqrt{\sum_i\sum_j |a_{ij}|^2}$.

Definition at line 391 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
double la::MatrixCoo< INDT, VALT >::getDiagScalar ( )
inline

Get scalar suitable to be put on diagonal while fixing BC This is the mean value of extremal entries on diagonal - the aim of this guess is to be within the spectra of the original matrix - this value immediately corresponds to an eigenvalue

Definition at line 416 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::getEntry ( IndexType  index,
IndexType row,
IndexType col,
ValueType val 
)
inline

Get specific entry.

Definition at line 194 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::getIntervalCounts ( IndexType  low,
IndexType  high,
std::vector< IndexType > &  nnzRowsIn,
std::vector< IndexType > &  nnzRowsOut 
)
inline

Determine number of nonzeros within a block [low,high) - used for PETSc preallocation.

Definition at line 158 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
double la::MatrixCoo< INDT, VALT >::infNorm ( )
inline

Compute maximal row sum (infinity-norm) of a matrix in coordinate format.

Definition at line 371 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::insert ( const IndexType  i,
const IndexType  j,
const ValueType  value 
)
inline

Insert a value to unassembled vector.

Definition at line 90 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
IndexType la::MatrixCoo< INDT, VALT >::nnz ( ) const
inline

Return number of non-zeros.

Definition at line 77 of file matrix_coo.hpp.

Here is the caller graph for this function:

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::prepareAssembly ( const IndexType  length)
inline

Prepare matrix for assembly - allocate buffer for UNASSEMBLED entries serial copies of element matrices to memory length = numElements * size( elementMatrix )

Definition at line 82 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::setCompressedRowArrays ( std::vector< IndexType > &  colIndices,
std::vector< IndexType > &  rowPtrs,
std::vector< ValueType > &  values 
)
inline

Fill arrays with column indices, row pointers and values for row-compressed data storage

Definition at line 247 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
std::ostream& la::MatrixCoo< INDT, VALT >::write ( std::ostream &  out)
inline

debug-output

Definition at line 349 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
void la::MatrixCoo< INDT, VALT >::zeroRow ( const IndexType  row,
const ValueType  factor 
)
inline

Zero a row and set diagonal to scalar.

Definition at line 202 of file matrix_coo.hpp.

Member Data Documentation

template<typename INDT, typename VALT>
MatrixCooVec_ la::MatrixCoo< INDT, VALT >::matrixCooVec_
private

matrix in coordinate format <i,j, values>

Definition at line 461 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
IndexType la::MatrixCoo< INDT, VALT >::nCols_
private

number of columns of matrix

Definition at line 464 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
IndexType la::MatrixCoo< INDT, VALT >::nRows_
private

number of rows of matrix

Definition at line 463 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
bool la::MatrixCoo< INDT, VALT >::sorted_
private

state variable - is matrix sorted?

Definition at line 468 of file matrix_coo.hpp.

template<typename INDT, typename VALT>
unsigned la::MatrixCoo< INDT, VALT >::sortedSize_
private

number of sorted entries

Definition at line 466 of file matrix_coo.hpp.


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