dune-istl  2.4
Modules | Files | Classes | Typedefs | Enumerations | Enumerator | Functions | Variables
Sparse Matrix and Vector classes

Matrix and Vector classes that support a block recursive structure capable of representing the natural structure from Finite Element discretisations. More...

Collaboration diagram for Sparse Matrix and Vector classes:

Modules

 Block Recursive Iterative Kernels
 
 IO for matrices and vectors.
 Provides methods for reading and writing matrices and vectors in various formats.
 

Files

file  matrixmatrix.hh
 provides functions for sparse matrix matrix multiplication.
 
file  matrixutils.hh
 Some handy generic functions for ISTL matrices.
 

Classes

struct  Dune::MatrixDimension< M >
 
struct  Dune::CompressionStatistics< size_type >
 Statistics about compression achieved in implicit mode. More...
 
class  Dune::ImplicitMatrixBuilder< M_ >::row_object
 Proxy row object for entry access. More...
 
class  Dune::ImplicitMatrixBuilder< M_ >
 A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mode. More...
 
class  Dune::BCRSMatrix< B, A >::RealRowIterator< T >
 Iterator access to matrix rows More...
 
class  Dune::BCRSMatrix< B, A >::CreateIterator
 Iterator class for sequential creation of blocks More...
 
class  Dune::BCRSMatrix< B, A >::Deallocator
 Class used by shared_ptr to deallocate memory using the proper allocator. More...
 
class  Dune::BCRSMatrix< B, A >
 A sparse block matrix with compressed row storage. More...
 
class  Dune::BDMatrix< B, A >
 A block-diagonal matrix. More...
 
class  Dune::BTDMatrix< B, A >
 A block-tridiagonal matrix. More...
 
class  Dune::BlockVector< B, A >
 A vector of blocks with memory management. More...
 
class  Dune::Matrix< T, A >
 A generic dynamic dense matrix. More...
 
struct  Dune::MatMultMatResult< M1, M2 >
 Helper TMP to get the result type of a sparse matrix matrix multiplication ( $C=A*B$) More...
 
struct  Dune::MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >
 
struct  Dune::MatMultMatResult< BCRSMatrix< FieldMatrix< T, n, k >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >
 
struct  Dune::TransposedMatMultMatResult< M1, M2 >
 Helper TMP to get the result type of a sparse matrix matrix multiplication ( $C=A*B$) More...
 
struct  Dune::TransposedMatMultMatResult< FieldMatrix< T, k, n >, FieldMatrix< T, k, m > >
 
struct  Dune::TransposedMatMultMatResult< BCRSMatrix< FieldMatrix< T, k, n >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >
 
struct  Dune::CheckIfDiagonalPresent< Matrix, blocklevel, l >
 Check whether the a matrix has diagonal values on blocklevel recursion levels. More...
 
struct  Dune::CheckIfDiagonalPresent< Matrix, 0, l >
 
class  Dune::MultiTypeBlockMatrix< T1, T2, T3, T4, T5, T6, T7, T8, T9 >
 
struct  Dune::CheckIfDiagonalPresent< MultiTypeBlockMatrix< T1, T2, T3, T4, T5, T6, T7, T8, T9 >, blocklevel, l >
 
class  Dune::VariableBlockVector< B, A >::CreateIterator
 Iterator class for sequential creation of blocks. More...
 
class  Dune::VariableBlockVector< B, A >::Iterator
 Iterator class for sequential access. More...
 
class  Dune::VariableBlockVector< B, A >::ConstIterator
 ConstIterator class for sequential access. More...
 
class  Dune::VariableBlockVector< B, A >
 A Vector of blocks with different blocksizes. More...
 

Typedefs

typedef BCRSMatrix< FieldMatrix< T, n, m >, A >::CreateIterator Dune::SparsityPatternInitializer< T, A, n, m >::CreateIterator
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, A >::size_type Dune::SparsityPatternInitializer< T, A, n, m >::size_type
 
typedef Dune::BCRSMatrix< FieldMatrix< T, n, m >, TA > Dune::MatrixInitializer< transpose, T, TA, n, m >::Matrix
 
typedef Matrix::CreateIterator Dune::MatrixInitializer< transpose, T, TA, n, m >::CreateIterator
 
typedef Matrix::size_type Dune::MatrixInitializer< transpose, T, TA, n, m >::size_type
 
typedef Dune::BCRSMatrix< Dune::FieldMatrix< T, n, m >, TA > Dune::MatrixInitializer< 1, T, TA, n, m >::Matrix
 
typedef Matrix::CreateIterator Dune::MatrixInitializer< 1, T, TA, n, m >::CreateIterator
 
typedef Matrix::size_type Dune::MatrixInitializer< 1, T, TA, n, m >::size_type
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, ADune::EntryAccumulatorFather< T, A, n, m >::Matrix
 
typedef Matrix::RowIterator Dune::EntryAccumulatorFather< T, A, n, m >::Row
 
typedef Matrix::ColIterator Dune::EntryAccumulatorFather< T, A, n, m >::Col
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, ADune::EntryAccumulator< T, A, n, m, transpose >::Matrix
 
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, transpose >::size_type
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, ADune::EntryAccumulator< T, A, n, m, 0 >::Matrix
 
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 0 >::size_type
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, ADune::EntryAccumulator< T, A, n, m, 1 >::Matrix
 
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 1 >::size_type
 
typedef BCRSMatrix< FieldMatrix< T, n, m >, ADune::EntryAccumulator< T, A, n, m, 2 >::Matrix
 
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 2 >::size_type
 
typedef FieldMatrix< T, n, m > Dune::MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type
 
typedef BCRSMatrix< typename MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type, std::allocator< typename MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type > > Dune::MatMultMatResult< BCRSMatrix< FieldMatrix< T, n, k >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >::type
 
typedef FieldMatrix< T, n, m > Dune::TransposedMatMultMatResult< FieldMatrix< T, k, n >, FieldMatrix< T, k, m > >::type
 
typedef BCRSMatrix< typename MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type, std::allocator< typename MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type > > Dune::TransposedMatMultMatResult< BCRSMatrix< FieldMatrix< T, k, n >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >::type
 

Enumerations

enum  Dune::BCRSMatrix< B, A >::BuildStage {
  Dune::BCRSMatrix< B, A >::notbuilt =0, Dune::BCRSMatrix< B, A >::notAllocated =0, Dune::BCRSMatrix< B, A >::building =1, Dune::BCRSMatrix< B, A >::rowSizesBuilt =2,
  Dune::BCRSMatrix< B, A >::built =3
}
 
enum  { Dune::BCRSMatrix< B, A >::blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
enum  Dune::BCRSMatrix< B, A >::BuildMode { Dune::BCRSMatrix< B, A >::row_wise, Dune::BCRSMatrix< B, A >::random, Dune::BCRSMatrix< B, A >::implicit, Dune::BCRSMatrix< B, A >::unknown }
 we support two modes More...
 
enum  { Dune::BDMatrix< B, A >::blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
enum  { Dune::BTDMatrix< B, A >::blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
enum  { Dune::BlockVector< B, A >::blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
enum  { Dune::Matrix< T, A >::blocklevel = T::blocklevel+1 }
 
enum  { Dune::SparsityPatternInitializer< T, A, n, m >::do_break =true }
 
enum  { Dune::MatrixInitializer< transpose, T, TA, n, m >::do_break =true }
 
enum  { Dune::MatrixInitializer< 1, T, TA, n, m >::do_break =false }
 
enum  { Dune::EntryAccumulatorFather< T, A, n, m >::do_break =false }
 
enum  { Dune::VariableBlockVector< B, A >::blocklevel = B::blocklevel+2 }
 

Functions

template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::matMultTransposeMat (BCRSMatrix< FieldMatrix< T, n, k >, A > &res, const BCRSMatrix< FieldMatrix< T, n, m >, A1 > &mat, const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &matt, bool tryHard=false)
 Calculate product of a sparse matrix with a transposed sparse matrices ( $C=A*B^T$). More...
 
template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::matMultMat (BCRSMatrix< FieldMatrix< T, n, m >, A > &res, const BCRSMatrix< FieldMatrix< T, n, k >, A1 > &mat, const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &matt, bool tryHard=false)
 Calculate product of two sparse matrices ( $C=A*B$). More...
 
template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::transposeMatMultMat (BCRSMatrix< FieldMatrix< T, n, m >, A > &res, const BCRSMatrix< FieldMatrix< T, k, n >, A1 > &mat, const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &matt, bool tryHard=false)
 Calculate product of a transposed sparse matrix with another sparse matrices ( $C=A^T*B$). More...
 
template<class M >
int Dune::countNonZeros (const M &matrix)
 Get the number of nonzero fields in the matrix. More...
 

Variables

Matrix &   mat
 
Col   col
 

Detailed Description

Matrix and Vector classes that support a block recursive structure capable of representing the natural structure from Finite Element discretisations.

The interface of our matrices is designed according to what they represent from a mathematical point of view. The vector classes are representations of vector spaces:

The matrix classes represent linear maps $A: V \mapsto W$ from vector space $V$ to vector space $W$ the recursive block structure of the matrix rows and columns immediately follows from the recursive block structure of the vectors representing the domain and range of the mapping, respectively:

Typedef Documentation

template<class T , class A , int n, int m>
typedef Matrix::ColIterator Dune::EntryAccumulatorFather< T, A, n, m >::Col
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A>::CreateIterator Dune::SparsityPatternInitializer< T, A, n, m >::CreateIterator
template<int transpose, class T , class TA , int n, int m>
typedef Matrix::CreateIterator Dune::MatrixInitializer< transpose, T, TA, n, m >::CreateIterator
template<class T , class TA , int n, int m>
typedef Matrix::CreateIterator Dune::MatrixInitializer< 1, T, TA, n, m >::CreateIterator
template<int transpose, class T , class TA , int n, int m>
typedef Dune::BCRSMatrix<FieldMatrix<T,n,m>,TA> Dune::MatrixInitializer< transpose, T, TA, n, m >::Matrix
template<class T , class TA , int n, int m>
typedef Dune::BCRSMatrix<Dune::FieldMatrix<T,n,m>,TA> Dune::MatrixInitializer< 1, T, TA, n, m >::Matrix
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Dune::EntryAccumulatorFather< T, A, n, m >::Matrix
template<class T , class A , int n, int m, int transpose>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Dune::EntryAccumulator< T, A, n, m, transpose >::Matrix
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Dune::EntryAccumulator< T, A, n, m, 0 >::Matrix
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Dune::EntryAccumulator< T, A, n, m, 1 >::Matrix
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A> Dune::EntryAccumulator< T, A, n, m, 2 >::Matrix
template<class T , class A , int n, int m>
typedef Matrix::RowIterator Dune::EntryAccumulatorFather< T, A, n, m >::Row
template<class T , class A , int n, int m>
typedef BCRSMatrix<FieldMatrix<T,n,m>,A>::size_type Dune::SparsityPatternInitializer< T, A, n, m >::size_type
template<int transpose, class T , class TA , int n, int m>
typedef Matrix::size_type Dune::MatrixInitializer< transpose, T, TA, n, m >::size_type
template<class T , class TA , int n, int m>
typedef Matrix::size_type Dune::MatrixInitializer< 1, T, TA, n, m >::size_type
template<class T , class A , int n, int m, int transpose>
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, transpose >::size_type
template<class T , class A , int n, int m>
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 0 >::size_type
template<class T , class A , int n, int m>
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 1 >::size_type
template<class T , class A , int n, int m>
typedef Matrix::size_type Dune::EntryAccumulator< T, A, n, m, 2 >::size_type
template<typename T , int n, int k, int m>
typedef FieldMatrix<T,n,m> Dune::MatMultMatResult< FieldMatrix< T, n, k >, FieldMatrix< T, k, m > >::type
template<typename T , typename A , typename A1 , int n, int k, int m>
typedef BCRSMatrix<typename MatMultMatResult<FieldMatrix<T,n,k>,FieldMatrix<T,k,m> >::type, std::allocator<typename MatMultMatResult<FieldMatrix<T,n,k>,FieldMatrix<T,k,m> >::type> > Dune::MatMultMatResult< BCRSMatrix< FieldMatrix< T, n, k >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >::type
template<typename T , int n, int k, int m>
typedef FieldMatrix<T,n,m> Dune::TransposedMatMultMatResult< FieldMatrix< T, k, n >, FieldMatrix< T, k, m > >::type
template<typename T , typename A , typename A1 , int n, int k, int m>
typedef BCRSMatrix<typename MatMultMatResult<FieldMatrix<T,n,k>,FieldMatrix<T,k,m> >::type, std::allocator<typename MatMultMatResult<FieldMatrix<T,n,k>,FieldMatrix<T,k,m> >::type> > Dune::TransposedMatMultMatResult< BCRSMatrix< FieldMatrix< T, k, n >, A >, BCRSMatrix< FieldMatrix< T, k, m >, A1 > >::type

Enumeration Type Documentation

template<class B, class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator
blocklevel 

The number of blocklevels the matrix contains.

template<class B , class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator
blocklevel 
template<class T , class A , int n, int m>
anonymous enum
Enumerator
do_break 
template<int transpose, class T , class TA , int n, int m>
anonymous enum
Enumerator
do_break 
template<class T , class TA , int n, int m>
anonymous enum
Enumerator
do_break 
template<class T , class A , int n, int m>
anonymous enum
Enumerator
do_break 
template<class B , class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator
blocklevel 
template<class B, class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator
blocklevel 

The number of blocklevel we contain.

template<class T, class A = std::allocator<T>>
anonymous enum
Enumerator
blocklevel 

The number of nesting levels the matrix contains.

template<class B, class A = std::allocator<B>>
anonymous enum

increment block level counter, yes, it is two levels because VariableBlockVector is a container of containers

Enumerator
blocklevel 

The number of blocklevels this vector contains.

template<class B, class A = std::allocator<B>>
enum Dune::BCRSMatrix::BuildMode

we support two modes

Enumerator
row_wise 

Build in a row-wise manner.

Rows are built up in sequential order. Size of the row and the column indices are defined. A row can be used as soon as it is initialized. With respect to memory there are two variants of this scheme: (a) number of non-zeroes known in advance (application finite difference schemes), (b) number of non-zeroes not known in advance (application: Sparse LU, ILU(n)).

random 

Build entries randomly.

For general finite element implementations the number of rows n is known, the number of non-zeroes might also be known (e.g. #edges + #nodes for P1) but the size of a row and the indices of a row can not be defined in sequential order.

implicit 

Build entries randomly with an educated guess on entries per row.

Allows random order generation as in random mode, but row sizes do not need to be given first. Instead an average number of non-zeroes per row is passed to the constructor. Matrix setup is finished with compress(), full data access during build stage is possible.

unknown 

Build mode not set!

template<class B, class A = std::allocator<B>>
enum Dune::BCRSMatrix::BuildStage
Enumerator
notbuilt 

Matrix is not built at all, no memory has been allocated, build mode and size can still be set.

notAllocated 

Matrix is not built at all, no memory has been allocated, build mode and size can still be set.

building 

Matrix is currently being built, some memory has been allocated, build mode and size are fixed.

rowSizesBuilt 

The row sizes of the matrix are known.

Only used in random mode.

built 

The matrix structure is fully built.

Function Documentation

template<class M >
int Dune::countNonZeros ( const M &  matrix)
inline

Get the number of nonzero fields in the matrix.

This is not the number of nonzero blocks, but the number of non zero scalar entries (on blocklevel 1) if the matrix is viewed as a flat matrix.

For FieldMatrix this is simply the number of columns times the number of rows, for a BCRSMatrix<FieldMatrix<K,n,m>> this is the number of nonzero blocks time n*m.

References count.

Referenced by Dune::Amg::MatrixHierarchy< M, PI, A >::build(), and Dune::writeMatrixMarket().

template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::matMultMat ( BCRSMatrix< FieldMatrix< T, n, m >, A > &  res,
const BCRSMatrix< FieldMatrix< T, n, k >, A1 > &  mat,
const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &  matt,
bool  tryHard = false 
)

Calculate product of two sparse matrices ( $C=A*B$).

Parameters
resMatrix for the result of the computation.
matMatrix A.
mattMatrix B.
tryHardignored

References mat.

template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::matMultTransposeMat ( BCRSMatrix< FieldMatrix< T, n, k >, A > &  res,
const BCRSMatrix< FieldMatrix< T, n, m >, A1 > &  mat,
const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &  matt,
bool  tryHard = false 
)

Calculate product of a sparse matrix with a transposed sparse matrices ( $C=A*B^T$).

Parameters
resMatrix for the result of the computation.
matMatrix A.
mattMatrix B, which will be transposed before the multiplication.
tryHardignored

References mat.

template<class T , class A , class A1 , class A2 , int n, int m, int k>
void Dune::transposeMatMultMat ( BCRSMatrix< FieldMatrix< T, n, m >, A > &  res,
const BCRSMatrix< FieldMatrix< T, k, n >, A1 > &  mat,
const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &  matt,
bool  tryHard = false 
)

Calculate product of a transposed sparse matrix with another sparse matrices ( $C=A^T*B$).

Parameters
resMatrix for the result of the computation.
matMatrix A, which will be transposed before the multiplication.
mattMatrix B.
tryHardignored

References mat.

Variable Documentation

Matrix& A
Col col
template<class T , class A , int n, int m>
Col Dune::EntryAccumulatorFather< T, A, n, m >::col
protected
std::size_t count
Matrix& mat
template<class T , class A , int n, int m>
Matrix& Dune::EntryAccumulatorFather< T, A, n, m >::mat
protected
Row row
CreateIterator rowiter