
Public Types | |
| typedef MatrixType | BlockType |
| typedef BlockType::value_type | value_type |
| typedef value_type * | pointer |
| typedef const value_type * | const_pointer |
| typedef value_type & | reference |
| typedef const value_type & | const_reference |
| typedef size_t | size_type |
| typedef MatrixIterator < BlockMatrixIterators::Accessor < BlockMatrixBase, false > > | iterator |
| typedef MatrixIterator < BlockMatrixIterators::Accessor < BlockMatrixBase, true > > | const_iterator |
Public Member Functions | |
| BlockMatrixBase () | |
| template<class BlockMatrixType> | |
| BlockMatrixBase & | copy_from (const BlockMatrixType &source) |
| BlockType & | block (const unsigned int row, const unsigned int column) |
| const BlockType & | block (const unsigned int row, const unsigned int column) const |
| unsigned int | m () const |
| unsigned int | n () const |
| unsigned int | n_block_rows () const |
| unsigned int | n_block_cols () const |
| void | set (const unsigned int i, const unsigned int j, const value_type value) |
| void | add (const unsigned int i, const unsigned int j, const value_type value) |
| value_type | operator() (const unsigned int i, const unsigned int j) const |
| value_type | el (const unsigned int i, const unsigned int j) const |
| value_type | diag_element (const unsigned int i) const |
| void | compress () |
| BlockMatrixBase & | operator*= (const value_type factor) |
| BlockMatrixBase & | operator/= (const value_type factor) |
| template<class BlockMatrixType> | |
| void | add (const value_type factor, const BlockMatrixType &matrix) |
| template<class BlockVectorType> | |
| void | vmult_add (BlockVectorType &dst, const BlockVectorType &src) const |
| template<class BlockVectorType> | |
| void | Tvmult_add (BlockVectorType &dst, const BlockVectorType &src) const |
| template<class BlockVectorType> | |
| value_type | matrix_norm_square (const BlockVectorType &v) const |
| template<class BlockVectorType> | |
| value_type | matrix_scalar_product (const BlockVectorType &u, const BlockVectorType &v) const |
| template<class BlockVectorType> | |
| value_type | residual (BlockVectorType &dst, const BlockVectorType &x, const BlockVectorType &b) const |
| iterator | begin () |
| iterator | end () |
| iterator | begin (const unsigned int r) |
| iterator | end (const unsigned int r) |
| const_iterator | begin () const |
| const_iterator | end () const |
| const_iterator | begin (const unsigned int r) const |
| const_iterator | end (const unsigned int r) const |
Protected Member Functions | |
| void | clear () |
| void | collect_sizes () |
| template<class BlockVectorType> | |
| void | vmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const |
| template<class BlockVectorType, class VectorType> | |
| void | vmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const |
| template<class BlockVectorType, class VectorType> | |
| void | vmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const |
| template<class VectorType> | |
| void | vmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const |
| template<class BlockVectorType> | |
| void | Tvmult_block_block (BlockVectorType &dst, const BlockVectorType &src) const |
| template<class BlockVectorType, class VectorType> | |
| void | Tvmult_block_nonblock (BlockVectorType &dst, const VectorType &src) const |
| template<class BlockVectorType, class VectorType> | |
| void | Tvmult_nonblock_block (VectorType &dst, const BlockVectorType &src) const |
| template<class VectorType> | |
| void | Tvmult_nonblock_nonblock (VectorType &dst, const VectorType &src) const |
Protected Attributes | |
| BlockIndices | row_block_indices |
| BlockIndices | column_block_indices |
| Table< 2, SmartPointer < BlockType > > | sub_objects |
Friends | |
| class | BlockMatrixIterators::Accessor |
| class | MatrixIterator |
Classes | |
| class | ExcIncompatibleColNumbers |
| class | ExcIncompatibleRowNumbers |
In addition to the usual matrix access and linear algebra functions, there are functions block() which allow access to the different blocks of the matrix. This may, for example, be of help when you want to implement Schur complement methods, or block preconditioners, where each block belongs to a specific component of the equation you are presently discretizing.
Note that the numbers of blocks and rows are implicitly determined by the sparsity pattern objects used.
Objects of this type are frequently used when a system of differential equations has solutions with variables that fall into different classes. For example, solutions of the Stokes or Navier-Stokes equations have dim velocity components and one pressure component. In this case, it may make sense to consider the linear system of equations as a system of 2x2 blocks, and one can construct preconditioners or solvers based on this 2x2 block structure. This class can help you in these cases, as it allows to view the matrix alternatively as one big matrix, or as a number of individual blocks.
Since this class simply forwards its calls to the subobjects (if necessary after adjusting indices denoting which subobject is meant), this class is completely independent of the actual type of the subobject. The functions that set up block matrices and destroy them, however, have to be implemented in derived classes. These functions also have to fill the data members provided by this base class, as they are only used passively in this class.
Most of the functions take a vector or block vector argument. These functions can, in general, only successfully be compiled if the individual blocks of this matrix implement the respective functions operating on the vector type in question. For example, if you have a block sparse matrix over deal.II SparseMatrix objects, then you will likely not be able to form the matrix-vector multiplication with a block vector over PETScWrappers::SparseMatrix objects. If you attempt anyway, you will likely get a number of compiler errors.
<float> and <double>; others can be generated in application programs (see the section on Template instantiations in the manual).| typedef MatrixType BlockMatrixBase< MatrixType >::BlockType |
Typedef the type of the underlying matrix.
Reimplemented in BlockSparseMatrix< number >, PETScWrappers::BlockSparseMatrix, PETScWrappers::MPI::BlockSparseMatrix, and TrilinosWrappers::BlockSparseMatrix.
| typedef BlockType::value_type BlockMatrixBase< MatrixType >::value_type |
Type of matrix entries. In analogy to the STL container classes.
Reimplemented in BlockSparseMatrix< number >, PETScWrappers::BlockSparseMatrix, PETScWrappers::MPI::BlockSparseMatrix, and TrilinosWrappers::BlockSparseMatrix.
| typedef value_type* BlockMatrixBase< MatrixType >::pointer |
| typedef const value_type* BlockMatrixBase< MatrixType >::const_pointer |
| typedef value_type& BlockMatrixBase< MatrixType >::reference |
| typedef const value_type& BlockMatrixBase< MatrixType >::const_reference |
| typedef size_t BlockMatrixBase< MatrixType >::size_type |
| typedef MatrixIterator<BlockMatrixIterators::Accessor<BlockMatrixBase, false> > BlockMatrixBase< MatrixType >::iterator |
| typedef MatrixIterator<BlockMatrixIterators::Accessor<BlockMatrixBase, true> > BlockMatrixBase< MatrixType >::const_iterator |
| BlockMatrixBase< MatrixType >::BlockMatrixBase | ( | ) |
Default constructor.
| BlockMatrixBase& BlockMatrixBase< MatrixType >::copy_from | ( | const BlockMatrixType & | source | ) | [inline] |
Copy the given matrix to this one. The operation throws an error if the sparsity patterns of the two involved matrices do not point to the same object, since in this case the copy operation is cheaper. Since this operation is notheless not for free, we do not make it available through operator=(), since this may lead to unwanted usage, e.g. in copy arguments to functions, which should really be arguments by reference.
The source matrix may be a matrix of arbitrary type, as long as its data type is convertible to the data type of this matrix.
The function returns a reference to this.
| BlockType& BlockMatrixBase< MatrixType >::block | ( | const unsigned int | row, | |
| const unsigned int | column | |||
| ) |
Access the block with the given coordinates.
| const BlockType& BlockMatrixBase< MatrixType >::block | ( | const unsigned int | row, | |
| const unsigned int | column | |||
| ) | const |
Access the block with the given coordinates. Version for constant objects.
| unsigned int BlockMatrixBase< MatrixType >::m | ( | ) | const |
Return the dimension of the image space. To remember: the matrix is of dimension
.
| unsigned int BlockMatrixBase< MatrixType >::n | ( | ) | const |
Return the dimension of the range space. To remember: the matrix is of dimension
.
| unsigned int BlockMatrixBase< MatrixType >::n_block_rows | ( | ) | const |
Return the number of blocks in a column. Returns zero if no sparsity pattern is presently associated to this matrix.
| unsigned int BlockMatrixBase< MatrixType >::n_block_cols | ( | ) | const |
Return the number of blocks in a row. Returns zero if no sparsity pattern is presently associated to this matrix.
| void BlockMatrixBase< MatrixType >::set | ( | const unsigned int | i, | |
| const unsigned int | j, | |||
| const value_type | value | |||
| ) |
Set the element (i,j) to value. Throws an error if the entry does not exist or if value is not a finite number. Still, it is allowed to store zero values in non-existent fields.
| void BlockMatrixBase< MatrixType >::add | ( | const unsigned int | i, | |
| const unsigned int | j, | |||
| const value_type | value | |||
| ) |
Add value to the element (i,j). Throws an error if the entry does not exist or if value is not a finite number. Still, it is allowed to store zero values in non-existent fields.
| value_type BlockMatrixBase< MatrixType >::operator() | ( | const unsigned int | i, | |
| const unsigned int | j | |||
| ) | const |
Return the value of the entry (i,j). This may be an expensive operation and you should always take care where to call this function. In order to avoid abuse, this function throws an exception if the wanted element does not exist in the matrix.
| value_type BlockMatrixBase< MatrixType >::el | ( | const unsigned int | i, | |
| const unsigned int | j | |||
| ) | const |
This function is mostly like operator()() in that it returns the value of the matrix entry (i,j). The only difference is that if this entry does not exist in the sparsity pattern, then instead of raising an exception, zero is returned. While this may be convenient in some cases, note that it is simple to write algorithms that are slow compared to an optimal solution, since the sparsity of the matrix is not used.
| value_type BlockMatrixBase< MatrixType >::diag_element | ( | const unsigned int | i | ) | const |
Return the main diagonal element in the ith row. This function throws an error if the matrix is not quadratic and also if the diagonal blocks of the matrix are not quadratic.
This function is considerably faster than the operator()(), since for quadratic matrices, the diagonal entry may be the first to be stored in each row and access therefore does not involve searching for the right column number.
| void BlockMatrixBase< MatrixType >::compress | ( | ) |
Call the compress() function on all the subblocks of the matrix.
Reimplemented in TrilinosWrappers::BlockSparseMatrix.
| BlockMatrixBase& BlockMatrixBase< MatrixType >::operator*= | ( | const value_type | factor | ) |
Multiply the entire matrix by a fixed factor.
| BlockMatrixBase& BlockMatrixBase< MatrixType >::operator/= | ( | const value_type | factor | ) |
Divide the entire matrix by a fixed factor.
| void BlockMatrixBase< MatrixType >::add | ( | const value_type | factor, | |
| const BlockMatrixType & | matrix | |||
| ) | [inline] |
Add matrix scaled by factor to this matrix, i.e. the matrix factor*matrix is added to this. This function throws an error if the sparsity patterns of the two involved matrices do not point to the same object, since in this case the operation is cheaper.
The source matrix may be a sparse matrix over an arbitrary underlying scalar type, as long as its data type is convertible to the data type of this matrix.
| void BlockMatrixBase< MatrixType >::vmult_add | ( | BlockVectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline] |
Adding Matrix-vector multiplication. Add
on
with
being this matrix.
| void BlockMatrixBase< MatrixType >::Tvmult_add | ( | BlockVectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline] |
Adding Matrix-vector multiplication. Add MTsrc to dst with M being this matrix. This function does the same as vmult_add() but takes the transposed matrix.
| value_type BlockMatrixBase< MatrixType >::matrix_norm_square | ( | const BlockVectorType & | v | ) | const [inline] |
Return the norm of the vector v with respect to the norm induced by this matrix, i.e. vTMv). This is useful, e.g. in the finite element context, where the LT-norm of a function equals the matrix norm with respect to the mass matrix of the vector representing the nodal values of the finite element function. Note that even though the function's name might suggest something different, for historic reasons not the norm but its square is returned, as defined above by the scalar product.
Obviously, the matrix needs to be square for this operation.
| value_type BlockMatrixBase< MatrixType >::matrix_scalar_product | ( | const BlockVectorType & | u, | |
| const BlockVectorType & | v | |||
| ) | const [inline] |
Compute the matrix scalar product
.
| value_type BlockMatrixBase< MatrixType >::residual | ( | BlockVectorType & | dst, | |
| const BlockVectorType & | x, | |||
| const BlockVectorType & | b | |||
| ) | const [inline] |
Compute the residual r=b-Ax. Write the residual into dst.
| iterator BlockMatrixBase< MatrixType >::begin | ( | ) |
STL-like iterator with the first entry.
| iterator BlockMatrixBase< MatrixType >::end | ( | ) |
Final iterator.
| iterator BlockMatrixBase< MatrixType >::begin | ( | const unsigned int | r | ) |
STL-like iterator with the first entry of row r.
| iterator BlockMatrixBase< MatrixType >::end | ( | const unsigned int | r | ) |
Final iterator of row r.
| const_iterator BlockMatrixBase< MatrixType >::begin | ( | ) | const |
STL-like iterator with the first entry.
| const_iterator BlockMatrixBase< MatrixType >::end | ( | ) | const |
Final iterator.
| const_iterator BlockMatrixBase< MatrixType >::begin | ( | const unsigned int | r | ) | const |
STL-like iterator with the first entry of row r.
| const_iterator BlockMatrixBase< MatrixType >::end | ( | const unsigned int | r | ) | const |
Final iterator of row r.
| void BlockMatrixBase< MatrixType >::clear | ( | ) | [protected] |
Release all memory and return to a state just like after having called the default constructor. It also forgets the sparsity pattern it was previously tied to.
This calls clear for all sub-matrices and then resets this object to have no blocks at all.
This function is protected since it may be necessary to release additional structures. A derived class can make it public again, if it is sufficient.
Reimplemented in BlockSparseMatrix< number >.
| void BlockMatrixBase< MatrixType >::collect_sizes | ( | ) | [protected] |
This function collects the sizes of the sub-objects and stores them in internal arrays, in order to be able to relay global indices into the matrix to indices into the subobjects. You *must* call this function each time after you have changed the size of the sub-objects.
Derived classes should call this function whenever the size of the sub-objects has changed and the X_block_indices arrays need to be updated.
Note that this function is not public since not all derived classes need to export its interface. For example, for the usual deal.II SparseMatrix class, the sizes are implicitly determined whenever reinit() is called, and individual blocks cannot be resized. For that class, this function therefore does not have to be public. On the other hand, for the PETSc classes, there is no associated sparsity pattern object that determines the block sizes, and for these the function needs to be publicly available. These classes therefore export this function.
Reimplemented in PETScWrappers::BlockSparseMatrix, PETScWrappers::MPI::BlockSparseMatrix, and TrilinosWrappers::BlockSparseMatrix.
| void BlockMatrixBase< MatrixType >::vmult_block_block | ( | BlockVectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication: let
with
being this matrix.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::vmult_block_nonblock | ( | BlockVectorType & | dst, | |
| const VectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::vmult_nonblock_block | ( | VectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::vmult_nonblock_nonblock | ( | VectorType & | dst, | |
| const VectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::Tvmult_block_block | ( | BlockVectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication: let
with
being this matrix. This function does the same as vmult() but takes the transposed matrix.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::Tvmult_block_nonblock | ( | BlockVectorType & | dst, | |
| const VectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block row.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::Tvmult_nonblock_block | ( | VectorType & | dst, | |
| const BlockVectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block column.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
| void BlockMatrixBase< MatrixType >::Tvmult_nonblock_nonblock | ( | VectorType & | dst, | |
| const VectorType & | src | |||
| ) | const [inline, protected] |
Matrix-vector multiplication. Just like the previous function, but only applicable if the matrix has only one block.
Due to problems with deriving template arguments between the block and non-block versions of the vmult/Tvmult functions, the actual functions are implemented in derived classes, with implementations forwarding the calls to the implementations provided here under a unique name for which template arguments can be derived by the compiler.
friend class BlockMatrixIterators::Accessor [friend] |
Make the iterator class a friend. We have to work around a compiler bug here again.
friend class MatrixIterator [friend] |
BlockIndices BlockMatrixBase< MatrixType >::row_block_indices [protected] |
Index arrays for rows and columns.
BlockIndices BlockMatrixBase< MatrixType >::column_block_indices [protected] |
Table<2,SmartPointer<BlockType> > BlockMatrixBase< MatrixType >::sub_objects [protected] |
Array of sub-matrices.
documentation generated on Fri Nov 21 07:12:50 2008 by
doxygen
1.5.6