dune-istl
2.2.0
|
A sparse block matrix with compressed row storage. More...
#include <dune/istl/bcrsmatrix.hh>
Classes | |
class | CreateIterator |
Iterator class for sequential creation of blocks More... | |
class | Deallocator |
Class used by shared_ptr to deallocate memory using the proper allocator. | |
class | RealRowIterator |
Iterator access to matrix rows More... |
Public Types | |
enum | { blocklevel = B::blocklevel+1 } |
increment block level counter More... | |
enum | BuildMode { row_wise, random, unknown } |
we support two modes More... | |
typedef B::field_type | field_type |
export the type representing the field | |
typedef B | block_type |
export the type representing the components | |
typedef A | allocator_type |
export the allocator type | |
typedef CompressedBlockVectorWindow< B, A > | row_type |
implement row_type with compressed vector | |
typedef A::size_type | size_type |
The type for the index access and the size. | |
typedef RealRowIterator< row_type > | iterator |
The iterator over the (mutable matrix rows. | |
typedef RealRowIterator< row_type > | Iterator |
typedef Iterator | RowIterator |
rename the iterators for easier access | |
typedef row_type::Iterator | ColIterator |
Iterator for the entries of each row. | |
typedef RealRowIterator< const row_type > | const_iterator |
The const iterator over the matrix rows. | |
typedef RealRowIterator< const row_type > | ConstIterator |
typedef ConstIterator | ConstRowIterator |
rename the const row iterator for easier access | |
typedef row_type::ConstIterator | ConstColIterator |
Const iterator to the entries of a row. |
Public Member Functions | |
row_type & | operator[] (size_type i) |
random access to the rows | |
const row_type & | operator[] (size_type i) const |
same for read only access | |
Iterator | begin () |
Get iterator to first row. | |
Iterator | end () |
Get iterator to one beyond last row. | |
Iterator | beforeEnd () |
Iterator | beforeBegin () |
ConstIterator | begin () const |
Get const iterator to first row. | |
ConstIterator | end () const |
Get const iterator to one beyond last row. | |
ConstIterator | beforeEnd () const |
ConstIterator | beforeBegin () const |
BCRSMatrix () | |
an empty matrix | |
BCRSMatrix (size_type _n, size_type _m, size_type _nnz, BuildMode bm) | |
matrix with known number of nonzeroes | |
BCRSMatrix (size_type _n, size_type _m, BuildMode bm) | |
matrix with unknown number of nonzeroes | |
BCRSMatrix (const BCRSMatrix &Mat) | |
copy constructor | |
~BCRSMatrix () | |
destructor | |
void | setBuildMode (BuildMode bm) |
Sets the build mode of the matrix. | |
void | setSize (size_type rows, size_type columns, size_type nnz=0) |
Set the size of the matrix. | |
BCRSMatrix & | operator= (const BCRSMatrix &Mat) |
assignment | |
BCRSMatrix & | operator= (const field_type &k) |
Assignment from a scalar. | |
CreateIterator | createbegin () |
get initial create iterator | |
CreateIterator | createend () |
get create iterator pointing to one after the last block | |
void | setrowsize (size_type i, size_type s) |
set number of indices in row i to s | |
size_type | getrowsize (size_type i) const |
get current number of indices in row i | |
void | incrementrowsize (size_type i, size_type s=1) |
increment size of row i by s (1 by default) | |
void | endrowsizes () |
indicate that size of all rows is defined | |
void | addindex (size_type row, size_type col) |
add index (row,col) to the matrix | |
void | endindices () |
indicate that all indices are defined, check consistency | |
BCRSMatrix & | operator*= (const field_type &k) |
vector space multiplication with scalar | |
BCRSMatrix & | operator/= (const field_type &k) |
vector space division by scalar | |
BCRSMatrix & | operator+= (const BCRSMatrix &b) |
Add the entries of another matrix to this one. | |
BCRSMatrix & | operator-= (const BCRSMatrix &b) |
Substract the entries of another matrix to this one. | |
BCRSMatrix & | axpy (field_type alpha, const BCRSMatrix &b) |
Add the scaled entries of another matrix to this one. | |
template<class X , class Y > | |
void | mv (const X &x, Y &y) const |
y = A x | |
template<class X , class Y > | |
void | umv (const X &x, Y &y) const |
y += A x | |
template<class X , class Y > | |
void | mmv (const X &x, Y &y) const |
y -= A x | |
template<class X , class Y > | |
void | usmv (const field_type &alpha, const X &x, Y &y) const |
y += alpha A x | |
template<class X , class Y > | |
void | mtv (const X &x, Y &y) const |
y = A^T x | |
template<class X , class Y > | |
void | umtv (const X &x, Y &y) const |
y += A^T x | |
template<class X , class Y > | |
void | mmtv (const X &x, Y &y) const |
y -= A^T x | |
template<class X , class Y > | |
void | usmtv (const field_type &alpha, const X &x, Y &y) const |
y += alpha A^T x | |
template<class X , class Y > | |
void | umhv (const X &x, Y &y) const |
y += A^H x | |
template<class X , class Y > | |
void | mmhv (const X &x, Y &y) const |
y -= A^H x | |
template<class X , class Y > | |
void | usmhv (const field_type &alpha, const X &x, Y &y) const |
y += alpha A^H x | |
double | frobenius_norm2 () const |
square of frobenius norm, need for block recursion | |
double | frobenius_norm () const |
frobenius norm: sqrt(sum over squared values of entries) | |
double | infinity_norm () const |
infinity norm (row sum norm, how to generalize for blocks?) | |
double | infinity_norm_real () const |
simplified infinity norm (uses Manhattan norm for complex values) | |
size_type | N () const |
number of rows (counted in blocks) | |
size_type | M () const |
number of columns (counted in blocks) | |
size_type | nonzeroes () const |
number of blocks that are stored (the number of blocks that possibly are nonzero) | |
bool | exists (size_type i, size_type j) const |
return true if (i,j) is in pattern |
Friends | |
struct | MatrixDimension< BCRSMatrix > |
class | CreateIterator |
allow CreateIterator to access internal data |
A sparse block matrix with compressed row storage.
Implements a block compressed row storage scheme. The block type B can be any type implementing the matrix interface.
Different ways to build up a compressed row storage matrix are supported:
Error checking: no error checking is provided normally. Setting the compile time switch DUNE_ISTL_WITH_CHECKING enables error checking.
Details:
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)).
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.
typedef A Dune::BCRSMatrix< B, A >::allocator_type |
export the allocator type
typedef B Dune::BCRSMatrix< B, A >::block_type |
export the type representing the components
typedef row_type::Iterator Dune::BCRSMatrix< B, A >::ColIterator |
Iterator for the entries of each row.
typedef RealRowIterator<const row_type> Dune::BCRSMatrix< B, A >::const_iterator |
The const iterator over the matrix rows.
typedef row_type::ConstIterator Dune::BCRSMatrix< B, A >::ConstColIterator |
Const iterator to the entries of a row.
typedef RealRowIterator<const row_type> Dune::BCRSMatrix< B, A >::ConstIterator |
typedef ConstIterator Dune::BCRSMatrix< B, A >::ConstRowIterator |
rename the const row iterator for easier access
typedef B::field_type Dune::BCRSMatrix< B, A >::field_type |
export the type representing the field
typedef RealRowIterator<row_type> Dune::BCRSMatrix< B, A >::iterator |
The iterator over the (mutable matrix rows.
typedef RealRowIterator<row_type> Dune::BCRSMatrix< B, A >::Iterator |
typedef CompressedBlockVectorWindow<B,A> Dune::BCRSMatrix< B, A >::row_type |
implement row_type with compressed vector
typedef Iterator Dune::BCRSMatrix< B, A >::RowIterator |
rename the iterators for easier access
typedef A::size_type Dune::BCRSMatrix< B, A >::size_type |
The type for the index access and the size.
anonymous enum |
enum Dune::BCRSMatrix::BuildMode |
we support two modes
|
inline |
an empty matrix
|
inline |
matrix with known number of nonzeroes
|
inline |
matrix with unknown number of nonzeroes
|
inline |
copy constructor
Does a deep copy as expected.
References Dune::CompressedBlockVectorWindow< B, A >::getsize().
|
inline |
destructor
|
inline |
add index (row,col) to the matrix
This method can only be used when building the BCRSMatrix in random mode.
addindex adds a new column entry to the row. If this column entry already exists, nothing is done.
Don't call addindex after the setup phase is finished (after endindices is called).
References col, Dune::BCRSMatrix< B, A >::end(), Dune::CompressedBlockVectorWindow< B, A >::getindexptr(), Dune::CompressedBlockVectorWindow< B, A >::getsize(), Dune::BCRSMatrix< B, A >::random, and row.
Referenced by test_IO().
|
inline |
Add the scaled entries of another matrix to this one.
Matrix axpy operation: *this += alpha * b
alpha | Scaling factor. |
b | The matrix to add to this one. Its sparsity pattern has to be subset of the sparsity pattern of this matrix. |
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get iterator to first row.
Referenced by Dune::BCRSMatrix< B, A >::axpy(), Dune::MatrixDimension< BCRSMatrix< B, TA > >::coldim(), Dune::BCRSMatrix< B, A >::endindices(), Dune::BCRSMatrix< B, A >::endrowsizes(), Dune::BCRSMatrix< B, A >::frobenius_norm2(), Dune::BCRSMatrix< B, A >::infinity_norm(), Dune::BCRSMatrix< B, A >::infinity_norm_real(), Dune::BCRSMatrix< B, A >::mmhv(), Dune::BCRSMatrix< B, A >::mmtv(), Dune::BCRSMatrix< B, A >::mmv(), Dune::BCRSMatrix< B, A >::mv(), Dune::BCRSMatrix< B, A >::operator*=(), Dune::BCRSMatrix< B, A >::operator+=(), Dune::BCRSMatrix< B, A >::operator-=(), Dune::BCRSMatrix< B, A >::operator/=(), test_IO(), test_Iter(), Dune::BCRSMatrix< B, A >::umhv(), Dune::BCRSMatrix< B, A >::umtv(), Dune::BCRSMatrix< B, A >::umv(), Dune::BCRSMatrix< B, A >::usmhv(), Dune::BCRSMatrix< B, A >::usmtv(), and Dune::BCRSMatrix< B, A >::usmv().
|
inline |
Get const iterator to first row.
|
inline |
get initial create iterator
References Dune::BCRSMatrix< B, A >::CreateIterator.
Referenced by test_IO(), and test_Iter().
|
inline |
get create iterator pointing to one after the last block
References Dune::BCRSMatrix< B, A >::CreateIterator.
Referenced by test_IO(), and test_Iter().
|
inline |
Get iterator to one beyond last row.
Referenced by Dune::BCRSMatrix< B, A >::addindex(), Dune::BCRSMatrix< B, A >::axpy(), Dune::MatrixDimension< BCRSMatrix< B, TA > >::coldim(), Dune::BCRSMatrix< B, A >::endindices(), Dune::BCRSMatrix< B, A >::exists(), Dune::BCRSMatrix< B, A >::frobenius_norm2(), Dune::BCRSMatrix< B, A >::infinity_norm(), Dune::BCRSMatrix< B, A >::infinity_norm_real(), Dune::BCRSMatrix< B, A >::mmhv(), Dune::BCRSMatrix< B, A >::mmtv(), Dune::BCRSMatrix< B, A >::mmv(), Dune::BCRSMatrix< B, A >::mv(), Dune::BCRSMatrix< B, A >::operator*=(), Dune::BCRSMatrix< B, A >::operator+=(), Dune::BCRSMatrix< B, A >::operator-=(), Dune::BCRSMatrix< B, A >::operator/=(), Dune::DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix< K, n, n >, Al >, X, Y >::setSubMatrix(), test_IO(), test_Iter(), Dune::BCRSMatrix< B, A >::umhv(), Dune::BCRSMatrix< B, A >::umtv(), Dune::BCRSMatrix< B, A >::umv(), Dune::BCRSMatrix< B, A >::usmhv(), Dune::BCRSMatrix< B, A >::usmtv(), and Dune::BCRSMatrix< B, A >::usmv().
|
inline |
Get const iterator to one beyond last row.
|
inline |
indicate that all indices are defined, check consistency
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::random, and Dune::CompressedBlockVectorWindow< B, A >::setsize().
Referenced by test_IO().
|
inline |
indicate that size of all rows is defined
References Dune::BCRSMatrix< B, A >::begin(), Dune::CompressedBlockVectorWindow< B, A >::getsize(), and Dune::BCRSMatrix< B, A >::random.
Referenced by test_IO().
|
inline |
return true if (i,j) is in pattern
References Dune::BCRSMatrix< B, A >::end().
|
inline |
frobenius norm: sqrt(sum over squared values of entries)
References Dune::BCRSMatrix< B, A >::frobenius_norm2().
|
inline |
square of frobenius norm, need for block recursion
References Dune::BCRSMatrix< B, A >::begin(), and Dune::BCRSMatrix< B, A >::end().
Referenced by Dune::BCRSMatrix< B, A >::frobenius_norm().
|
inline |
get current number of indices in row i
References Dune::CompressedBlockVectorWindow< B, A >::getsize().
|
inline |
increment size of row i by s (1 by default)
References Dune::BCRSMatrix< B, A >::random, and Dune::CompressedBlockVectorWindow< B, A >::setsize().
|
inline |
infinity norm (row sum norm, how to generalize for blocks?)
References Dune::BCRSMatrix< B, A >::begin(), and Dune::BCRSMatrix< B, A >::end().
|
inline |
simplified infinity norm (uses Manhattan norm for complex values)
References Dune::BCRSMatrix< B, A >::begin(), and Dune::BCRSMatrix< B, A >::end().
|
inline |
number of columns (counted in blocks)
Referenced by Dune::BCRSMatrix< B, A >::axpy(), Dune::MatrixDimension< BCRSMatrix< B, TA > >::coldim(), Dune::MatrixDimension< BCRSMatrix< FieldMatrix< B, n, m >, TA > >::coldim(), Dune::BCRSMatrix< B, A >::mmhv(), Dune::BCRSMatrix< B, A >::mmtv(), Dune::BCRSMatrix< B, A >::mmv(), Dune::BCRSMatrix< B, A >::mtv(), Dune::BCRSMatrix< B, A >::mv(), Dune::BCRSMatrix< B, A >::operator+=(), Dune::BCRSMatrix< B, A >::operator-=(), Dune::BCRSMatrix< B, A >::umhv(), Dune::BCRSMatrix< B, A >::umtv(), Dune::BCRSMatrix< B, A >::umv(), Dune::BCRSMatrix< B, A >::usmhv(), Dune::BCRSMatrix< B, A >::usmtv(), and Dune::BCRSMatrix< B, A >::usmv().
|
inline |
y -= A^H x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
y -= A^T x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
y -= A x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
Referenced by test_Iter().
|
inline |
y = A^T x
References Dune::BCRSMatrix< B, A >::M(), Dune::BCRSMatrix< B, A >::N(), and Dune::BCRSMatrix< B, A >::umtv().
|
inline |
|
inline |
number of rows (counted in blocks)
Referenced by Dune::BCRSMatrix< B, A >::axpy(), Dune::MatrixDimension< BCRSMatrix< B, TA > >::coldim(), Dune::BDMatrix< B, A >::invert(), Dune::BCRSMatrix< B, A >::mmhv(), Dune::BCRSMatrix< B, A >::mmtv(), Dune::BCRSMatrix< B, A >::mmv(), Dune::BCRSMatrix< B, A >::mtv(), Dune::BCRSMatrix< B, A >::mv(), Dune::BCRSMatrix< B, A >::operator+=(), Dune::BCRSMatrix< B, A >::operator-=(), Dune::MatrixDimension< BCRSMatrix< B, TA > >::rowdim(), Dune::MatrixDimension< BCRSMatrix< FieldMatrix< B, n, m >, TA > >::rowdim(), Dune::BTDMatrix< B, A >::solve(), Dune::BCRSMatrix< B, A >::umhv(), Dune::BCRSMatrix< B, A >::umtv(), Dune::BCRSMatrix< B, A >::umv(), Dune::BCRSMatrix< B, A >::usmhv(), Dune::BCRSMatrix< B, A >::usmtv(), and Dune::BCRSMatrix< B, A >::usmv().
|
inline |
number of blocks that are stored (the number of blocks that possibly are nonzero)
|
inline |
vector space multiplication with scalar
References Dune::BCRSMatrix< B, A >::begin(), and Dune::BCRSMatrix< B, A >::end().
|
inline |
Add the entries of another matrix to this one.
b | The matrix to add to this one. Its sparsity pattern has to be subset of the sparsity pattern of this matrix. |
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
Substract the entries of another matrix to this one.
b | The matrix to add to this one. Its sparsity pattern has to be subset of the sparsity pattern of this matrix. |
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
vector space division by scalar
References Dune::BCRSMatrix< B, A >::begin(), and Dune::BCRSMatrix< B, A >::end().
|
inline |
assignment
Frees and reallocates space. Both sparsity pattern and values are set from Mat.
References Dune::CompressedBlockVectorWindow< B, A >::getsize().
|
inline |
Assignment from a scalar.
Reimplemented in Dune::BTDMatrix< B, A >, and Dune::BDMatrix< B, A >.
|
inline |
random access to the rows
|
inline |
same for read only access
|
inline |
Sets the build mode of the matrix.
bm | The build mode to use. |
|
inline |
set number of indices in row i to s
References Dune::BCRSMatrix< B, A >::random, and Dune::CompressedBlockVectorWindow< B, A >::setsize().
Referenced by test_IO().
|
inline |
Set the size of the matrix.
Sets the number of rows and columns of the matrix and allocates the memory needed for the storage of the matrix entries.
rows | The number of rows the matrix should contain. |
columns | the number of columns the matrix should contain. |
nnz | The number of nonzero entries the matrix should hold (if omitted defaults to 0). |
|
inline |
y += A^H x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
y += A^T x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
Referenced by Dune::BCRSMatrix< B, A >::mtv().
|
inline |
y += A x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
Referenced by test_Iter().
|
inline |
y += alpha A^H x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
y += alpha A^T x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
inline |
y += alpha A x
References Dune::BCRSMatrix< B, A >::begin(), Dune::BCRSMatrix< B, A >::end(), Dune::BCRSMatrix< B, A >::M(), and Dune::BCRSMatrix< B, A >::N().
|
friend |
allow CreateIterator to access internal data
Referenced by Dune::BCRSMatrix< B, A >::createbegin(), and Dune::BCRSMatrix< B, A >::createend().
|
friend |