dune-fem  2.4.1-rc
Public Types | Public Member Functions | Protected Attributes | List of all members
Dune::Fem::SparseRowMatrix< T > Class Template Reference

SparseRowMatrix. More...

#include </local/tomalk/somewhere/tmp/dune-fem/dune/fem/operator/matrix/spmatrix.hh>

Public Types

enum  { defaultCol = -1 }
 
enum  { firstCol = defaultCol + 1 }
 
typedef T Ttype
 
typedef SparseRowMatrix< T > ThisType
 remember the value type More...
 
typedef ThisType MatrixBaseType
 type of the base matrix (for consistency with ISTLMatrixObject) More...
 

Public Member Functions

 SparseRowMatrix (const SparseRowMatrix< T > &S)=delete
 
 SparseRowMatrix (double omega=1.1)
 makes Matrix of zero length, omega is 1.1 by default More...
 
 SparseRowMatrix (int rows, int cols, int nz, const T &val=0, double omega=1.1)
 
void reserve (int rows, int cols, int nz, const T &dummy)
 
void resize (int newSize)
 resize keeping old values if possible, assuming rows == cols More...
 
void resize (int newRow, int newCol, int newNz=-1)
 resize keeping old values if possible More...
 
 ~SparseRowMatrix ()
 free memory for values_ and col_ More...
 
int numberOfValues () const
 length of array used to store matrix More...
 
T & val (int i)
 matrix value taken from real array More...
 
const T & val (int i) const
 return reference to value on given entry More...
 
popValue (int i)
 return value and clear matrix entry More...
 
int realCol (int row, int fakeCol) const
 return real column number for (row,localCol) More...
 
std::pair< T, int > realValue (int row, int fakeCol)
 return pair< value, column >, used by BlockMatrix More...
 
std::pair< const T, int > realValue (int row, int fakeCol) const
 return pair< value, column >, used by BlockMatrix More...
 
std::pair< T, int > realValue (int index)
 return pair< value, column >, used by BlockMatrix More...
 
std::pair< const T, int > realValue (int index) const
 return pair< value, column >, used by BlockMatrix More...
 
int colIndex (int row, int col)
 returns local col index for given global (row,col) More...
 
bool find (int row, int col) const
 returns true if entry (row,col) exists in matrix More...
 
int dim (int i) const
 return number of rows = 0, cols = 1 More...
 
int size (int i) const
 return number of rows = 0, cols = 1 More...
 
int rows () const
 return number of rows More...
 
int cols () const
 return number of columns More...
 
int numNonZeros () const
 return max number of non zeros More...
 
int numNonZeros (int i) const
 return number of non zeros in row More...
 
operator() (const int row, const int col) const
 return value of entry (row,col) More...
 
operator() (const unsigned int row, const unsigned int col) const
 
operator() (const long unsigned int row, const long unsigned int col) const
 
void set (int row, int col, T val)
 
void clearRow (int row)
 set all entries in row to zero More...
 
void clearCol (int col)
 ser all entris in column col to zero More...
 
void scaleRow (int row, const T &val)
 set all entries in row to zero More...
 
void clear ()
 
void add (int row, int col, T val)
 add value to row,col entry More...
 
void multScalar (int row, int col, T val)
 muliply with scalar value More...
 
void kroneckerKill (int row, int col)
 make unitRow(row) and unitCol(col) More...
 
template<class VECtype >
void mult (const VECtype *x, VECtype *ret) const
 same as apply A * x = ret More...
 
template<class VECtype >
multOEMRow (const VECtype *x, const int row) const
 same as apply A * x = ret, used by OEM-Solvers More...
 
template<class VECtype >
void multOEM (const VECtype *x, VECtype *ret) const
 same as apply A * x = ret, used by OEM-Solvers More...
 
template<class VECtype >
void multOEMAdd (const VECtype *x, VECtype *ret) const
 calculates ret += A * x More...
 
template<class VECtype >
void multOEM_t (const VECtype *x, VECtype *ret) const
 same as apply A^T * x = ret, used by OEM-Solvers More...
 
template<class DiscFType , class DiscFuncType >
void apply (const DiscFType &f, DiscFuncType &ret) const
 A(f) = ret, same as mult. More...
 
template<class ArgDFType , class DestDFType >
void apply_t (const ArgDFType &f, DestDFType &ret) const
 A^T(f) = ret. More...
 
template<class DiscFuncType >
void operator() (const DiscFuncType &f, DiscFuncType &ret) const
 A(f) = ret. More...
 
template<class DiscFuncType >
void getDiag (const ThisType &A, const ThisType &B, DiscFuncType &rhs) const
 return diagonal of (this * A * B) More...
 
template<class DiscFuncType >
void getDiag (const ThisType &A, DiscFuncType &rhs) const
 return diagonal of (this * A) More...
 
template<class DiscFuncType >
void getDiag (DiscFuncType &rhs) const
 return diagonal entries of this matrix More...
 
template<class DiscFuncType >
void addDiag (DiscFuncType &rhs) const
 add diagonal to given DiscreteFunction More...
 
void print (std::ostream &s, unsigned int offset=0) const
 print matrix More...
 
void printReal (std::ostream &s) const
 print values More...
 
void printColumns (std::ostream &s) const
 print columns More...
 
void printNonZeros (std::ostream &s) const
 
bool checkConsistency () const
 
void unitRow (int row)
 make row a row with 1 on diagonal and all other entries 0 More...
 
void unitCol (int col)
 make column a column with 1 on diagonal and all other entries 0 More...
 
void checkSym ()
 check symetry More...
 
void multiply (const ThisType &B, ThisType &res) const
 
void scale (const T &factor)
 multiply this matrix with scalar More...
 
void add (const ThisType &B)
 add other matrix to this matrix More...
 
void resort ()
 resort to have ascending column numbering More...
 
void resortRow (const int row)
 resort row to have ascending column numbering More...
 
void ssorPrecondition (const T *, T *) const
 SSOR preconditioning. More...
 
bool rightPrecondition () const
 returns true if preconditioing is called before matrix multiply More...
 
void precondition (const T *u, T *x) const
 apply preconditioning, calls ssorPreconditioning at the moment More...
 
void solveUMF (const T *b, T *x)
 
void solveUMFNonSymmetric (const T *b, T *x)
 
template<class ArgDFType , class DestDFType >
void apply (const ArgDFType &f, DestDFType &ret) const
 

Protected Attributes

T * values_
 
int * col_
 data values (nz_ * dim_[0] elements) More...
 
int * nonZeros_
 row_ptr (dim_[0]+1 elements) More...
 
int dim_ [2]
 row_ptr (dim_[0]+1 elements) More...
 
int nz_
 dim_[0] x dim_[1] Matrix More...
 
int memSize_
 number of nonzeros per row More...
 
bool sorted_
 
std::vector< int > newIndices_
 
std::vector< T > newValues_
 
const double omega_
 

Detailed Description

template<class T>
class Dune::Fem::SparseRowMatrix< T >

SparseRowMatrix.

Compressed row sparse matrix, where only the nonzeros of a row are keeped (except if you "set" a single element explicitly with the value 0, which is not forbidden and an element entry is created)

Member Typedef Documentation

template<class T>
typedef ThisType Dune::Fem::SparseRowMatrix< T >::MatrixBaseType

type of the base matrix (for consistency with ISTLMatrixObject)

template<class T>
typedef SparseRowMatrix<T> Dune::Fem::SparseRowMatrix< T >::ThisType

remember the value type

template<class T>
typedef T Dune::Fem::SparseRowMatrix< T >::Ttype

Member Enumeration Documentation

template<class T>
anonymous enum
Enumerator
defaultCol 
template<class T>
anonymous enum
Enumerator
firstCol 

Constructor & Destructor Documentation

template<class T>
Dune::Fem::SparseRowMatrix< T >::SparseRowMatrix ( const SparseRowMatrix< T > &  S)
delete
template<class T >
Dune::Fem::SparseRowMatrix< T >::SparseRowMatrix ( double  omega = 1.1)
template<class T >
Dune::Fem::SparseRowMatrix< T >::SparseRowMatrix ( int  rows,
int  cols,
int  nz,
const T &  val = 0,
double  omega = 1.1 
)
template<class T >
Dune::Fem::SparseRowMatrix< T >::~SparseRowMatrix ( )

Member Function Documentation

template<class T >
void Dune::Fem::SparseRowMatrix< T >::add ( int  row,
int  col,
val 
)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::add ( const ThisType B)
template<class T >
template<class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::addDiag ( DiscFuncType &  rhs) const

add diagonal to given DiscreteFunction

we assume that the dimension of the functionspace of f is the same as the size of the matrix

References Dune::Fem::SparseRowMatrix< T >::size().

template<class T>
template<class DiscFType , class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::apply ( const DiscFType &  f,
DiscFuncType &  ret 
) const

A(f) = ret, same as mult.

template<class T>
template<class ArgDFType , class DestDFType >
void Dune::Fem::SparseRowMatrix< T >::apply ( const ArgDFType &  f,
DestDFType &  ret 
) const
template<class T >
template<class ArgDFType , class DestDFType >
void Dune::Fem::SparseRowMatrix< T >::apply_t ( const ArgDFType &  f,
DestDFType &  ret 
) const
template<class T >
bool Dune::Fem::SparseRowMatrix< T >::checkConsistency ( ) const
template<class T >
void Dune::Fem::SparseRowMatrix< T >::checkSym ( )
template<class T >
void Dune::Fem::SparseRowMatrix< T >::clear ( )
template<class T >
void Dune::Fem::SparseRowMatrix< T >::clearCol ( int  col)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::clearRow ( int  row)
template<class T >
int Dune::Fem::SparseRowMatrix< T >::colIndex ( int  row,
int  col 
)
template<class T>
int Dune::Fem::SparseRowMatrix< T >::cols ( ) const
inline
template<class T>
int Dune::Fem::SparseRowMatrix< T >::dim ( int  i) const
inline

return number of rows = 0, cols = 1

template<class T >
bool Dune::Fem::SparseRowMatrix< T >::find ( int  row,
int  col 
) const
template<class T >
template<class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::getDiag ( const ThisType A,
const ThisType B,
DiscFuncType &  rhs 
) const
template<class T >
template<class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::getDiag ( const ThisType A,
DiscFuncType &  rhs 
) const

return diagonal of (this * A)

we assume that the dimension of the functionspace of f is the same as the size of the matrix

References Dune::Fem::SparseRowMatrix< T >::col_, Dune::Fem::SparseRowMatrix< T >::nz_, Dune::Fem::SparseRowMatrix< T >::realCol(), Dune::Fem::SparseRowMatrix< T >::size(), Dune::Std::sum(), and Dune::Fem::SparseRowMatrix< T >::values_.

template<class T >
template<class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::getDiag ( DiscFuncType &  rhs) const

return diagonal entries of this matrix

we assume that the dimension of the functionspace of f is the same as the size of the matrix

References Dune::Fem::SparseRowMatrix< T >::size().

template<class T >
void Dune::Fem::SparseRowMatrix< T >::kroneckerKill ( int  row,
int  col 
)
template<class T >
template<class VECtype >
void Dune::Fem::SparseRowMatrix< T >::mult ( const VECtype *  x,
VECtype *  ret 
) const

same as apply A * x = ret

References Dune::Fem::SparseRowMatrix< T >::multOEM().

template<class T >
void Dune::Fem::SparseRowMatrix< T >::multiply ( const ThisType B,
ThisType res 
) const
template<class T >
template<class VECtype >
void Dune::Fem::SparseRowMatrix< T >::multOEM ( const VECtype *  x,
VECtype *  ret 
) const

same as apply A * x = ret, used by OEM-Solvers

References Dune::Fem::SparseRowMatrix< T >::dim_, and Dune::Fem::SparseRowMatrix< T >::multOEMRow().

Referenced by Dune::Fem::SparseRowMatrix< T >::mult().

template<class T >
template<class VECtype >
void Dune::Fem::SparseRowMatrix< T >::multOEM_t ( const VECtype *  x,
VECtype *  ret 
) const
template<class T >
template<class VECtype >
void Dune::Fem::SparseRowMatrix< T >::multOEMAdd ( const VECtype *  x,
VECtype *  ret 
) const
template<class T >
template<class VECtype >
T Dune::Fem::SparseRowMatrix< T >::multOEMRow ( const VECtype *  x,
const int  row 
) const
template<class T >
void Dune::Fem::SparseRowMatrix< T >::multScalar ( int  row,
int  col,
val 
)
template<class T>
int Dune::Fem::SparseRowMatrix< T >::numberOfValues ( ) const
inline

length of array used to store matrix

template<class T>
int Dune::Fem::SparseRowMatrix< T >::numNonZeros ( ) const
inline

return max number of non zeros

Referenced by Dune::ColCompMatrix< Fem::SparseRowMatrix< B > >::setMatrix().

template<class T>
int Dune::Fem::SparseRowMatrix< T >::numNonZeros ( int  i) const
inline

return number of non zeros in row

template<class T >
T Dune::Fem::SparseRowMatrix< T >::operator() ( const int  row,
const int  col 
) const
inline
template<class T >
T Dune::Fem::SparseRowMatrix< T >::operator() ( const unsigned int  row,
const unsigned int  col 
) const
inline
template<class T>
T Dune::Fem::SparseRowMatrix< T >::operator() ( const long unsigned int  row,
const long unsigned int  col 
) const
inline

References OEMSolver::mult().

template<class T>
template<class DiscFuncType >
void Dune::Fem::SparseRowMatrix< T >::operator() ( const DiscFuncType &  f,
DiscFuncType &  ret 
) const
inline
template<class T>
T Dune::Fem::SparseRowMatrix< T >::popValue ( int  i)
inline

return value and clear matrix entry

template<class T>
void Dune::Fem::SparseRowMatrix< T >::precondition ( const T *  u,
T *  x 
) const
inline

apply preconditioning, calls ssorPreconditioning at the moment

template<class T >
void Dune::Fem::SparseRowMatrix< T >::print ( std::ostream &  s,
unsigned int  offset = 0 
) const
template<class T >
void Dune::Fem::SparseRowMatrix< T >::printColumns ( std::ostream &  s) const
template<class T >
void Dune::Fem::SparseRowMatrix< T >::printNonZeros ( std::ostream &  s) const

print row-wise stored number of nonzeros No counting is performed, but the member variable nonZeros_[] is reported. So here inconsistencies can occur to the true nonzero entries in the matrix.

References Dune::Fem::SparseRowMatrix< T >::dim_, and Dune::Fem::SparseRowMatrix< T >::nonZeros_.

template<class T >
void Dune::Fem::SparseRowMatrix< T >::printReal ( std::ostream &  s) const
template<class T>
int Dune::Fem::SparseRowMatrix< T >::realCol ( int  row,
int  fakeCol 
) const
inline
template<class T>
std::pair< T , int > Dune::Fem::SparseRowMatrix< T >::realValue ( int  row,
int  fakeCol 
)
inline

return pair< value, column >, used by BlockMatrix

Referenced by Dune::ColCompMatrix< Fem::SparseRowMatrix< B > >::setMatrix().

template<class T>
std::pair< const T , int > Dune::Fem::SparseRowMatrix< T >::realValue ( int  row,
int  fakeCol 
) const
inline

return pair< value, column >, used by BlockMatrix

template<class T>
std::pair< T , int > Dune::Fem::SparseRowMatrix< T >::realValue ( int  index)
inline

return pair< value, column >, used by BlockMatrix

template<class T>
std::pair< const T , int > Dune::Fem::SparseRowMatrix< T >::realValue ( int  index) const
inline

return pair< value, column >, used by BlockMatrix

template<class T >
void Dune::Fem::SparseRowMatrix< T >::reserve ( int  rows,
int  cols,
int  nz,
const T &  dummy 
)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::resize ( int  newSize)

resize keeping old values if possible, assuming rows == cols

Referenced by Dune::Fem::SparseRowMatrix< T >::colIndex().

template<class T >
void Dune::Fem::SparseRowMatrix< T >::resize ( int  newRow,
int  newCol,
int  newNz = -1 
)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::resort ( )
template<class T >
void Dune::Fem::SparseRowMatrix< T >::resortRow ( const int  row)
template<class T>
bool Dune::Fem::SparseRowMatrix< T >::rightPrecondition ( ) const
inline

returns true if preconditioing is called before matrix multiply

template<class T>
int Dune::Fem::SparseRowMatrix< T >::rows ( ) const
inline
template<class T >
void Dune::Fem::SparseRowMatrix< T >::scale ( const T &  factor)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::scaleRow ( int  row,
const T &  val 
)
template<class T >
void Dune::Fem::SparseRowMatrix< T >::set ( int  row,
int  col,
val 
)
template<class T>
int Dune::Fem::SparseRowMatrix< T >::size ( int  i) const
inline
template<class T >
void Dune::Fem::SparseRowMatrix< T >::solveUMF ( const T *  b,
T *  x 
)
Deprecated:
"Use directly Dune::Fem::UMFPACKOp instead of solveUMF"
template<class T >
void Dune::Fem::SparseRowMatrix< T >::solveUMFNonSymmetric ( const T *  b,
T *  x 
)
Deprecated:
"Use directly Dune::Fem::UMFPACKOp instead of solveUMFNonSymmetric"
template<class T >
void Dune::Fem::SparseRowMatrix< T >::ssorPrecondition ( const T *  u,
T *  x 
) const
template<class T >
void Dune::Fem::SparseRowMatrix< T >::unitCol ( int  col)

make column a column with 1 on diagonal and all other entries 0

References Dune::Fem::SparseRowMatrix< T >::checkConsistency(), and Dune::Fem::SparseRowMatrix< T >::dim_.

Referenced by Dune::Fem::SparseRowMatrix< T >::kroneckerKill().

template<class T >
void Dune::Fem::SparseRowMatrix< T >::unitRow ( int  row)
template<class T>
T& Dune::Fem::SparseRowMatrix< T >::val ( int  i)
inline
template<class T>
const T& Dune::Fem::SparseRowMatrix< T >::val ( int  i) const
inline

return reference to value on given entry

Member Data Documentation

template<class T>
int* Dune::Fem::SparseRowMatrix< T >::col_
protected
template<class T>
int Dune::Fem::SparseRowMatrix< T >::dim_[2]
protected
template<class T>
int Dune::Fem::SparseRowMatrix< T >::memSize_
protected
template<class T>
std::vector<int> Dune::Fem::SparseRowMatrix< T >::newIndices_
protected
template<class T>
std::vector<T> Dune::Fem::SparseRowMatrix< T >::newValues_
protected
template<class T>
int* Dune::Fem::SparseRowMatrix< T >::nonZeros_
protected
template<class T>
int Dune::Fem::SparseRowMatrix< T >::nz_
protected
template<class T>
const double Dune::Fem::SparseRowMatrix< T >::omega_
protected
template<class T>
bool Dune::Fem::SparseRowMatrix< T >::sorted_
protected
template<class T>
T* Dune::Fem::SparseRowMatrix< T >::values_
protected

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