|
Discontinuous Galerkin Library
#include "dg/algorithm.h"
|
Coo Sparse Block Matrix format. More...
Public Member Functions | |
| CooSparseBlockMat ()=default | |
| default constructor does nothing | |
| CooSparseBlockMat (int num_block_rows, int num_block_cols, int n, int left_size, int right_size) | |
| Allocate storage. | |
| template<class other_real_type , template< class > class Other_Vector> | |
| CooSparseBlockMat (const CooSparseBlockMat< other_real_type, Other_Vector > &src) | |
| void | add_value (int row, int col, const Vector< real_type > &element) |
| Convenience function to assemble the matrix. | |
| void | add_value (int row, int col, int data) |
| Convenience function to assemble the matrix. | |
| int | total_num_rows () const |
total number of rows is num_rows*n*left_size*right_size | |
| int | total_num_cols () const |
total number of columns is num_cols*n*left_size*right_size | |
| template<class value_type > | |
| void | symv (SharedVectorTag, SerialTag, value_type alpha, const value_type **x, value_type beta, value_type *RESTRICT y) const |
| Apply the matrix to a vector. | |
| template<class value_type > | |
| void | symv (SharedVectorTag, CudaTag, value_type alpha, const value_type **x, value_type beta, value_type *y) const |
| void | display (std::ostream &os=std::cout, bool show_data=false) const |
| Display internal data to a stream. | |
Public Attributes | |
| Vector< real_type > | data |
The data array is of size n*n*num_different_blocks and contains the blocks. | |
| Vector< int > | cols_idx |
is of size num_entries and contains the column indices | |
| Vector< int > | rows_idx |
is of size num_entries and contains the row indices | |
| Vector< int > | data_idx |
is of size num_entries and contains indices into the data array | |
| int | num_rows |
| number of rows | |
| int | num_cols |
| number of columns (never actually used with pointer approach | |
| int | num_entries |
| number of entries in the matrix | |
| int | n |
| each block has size n*n | |
| int | left_size |
| size of the left Kronecker delta | |
| int | right_size |
| size of the right Kronecker delta (is e.g 1 for a x - derivative) | |
Friends | |
| template<class other_real_type , template< class > class Other_Vector> | |
| struct | CooSparseBlockMat |
Coo Sparse Block Matrix format.
The basis for this format is the well-known coordinate sparse matrix format. Instead of a values array we use an index array with indices into a data array that contains the actual blocks. This safes storage if the number of nonrecurrent blocks is small.
\[ M = \begin{pmatrix} A & & B& & & \\ & C & & & & \\ & & & & & \\ & A & & & B & C \end{pmatrix} \rightarrow \text{data}=(A,B,C)\quad \text{rows_idx} = ( 0,0,1,3,3,3) \quad\text{cols_idx} = (0,2,1,1,4,5) \]
where \(A,\ B,\ C,\ 0\) are \(n\times n\) block matrices. The matrix M in this example has num_rows=4, num_cols=6, num_entries=6.
The indices and blocks are those of a one-dimensional problem. When we want to apply the matrix to a multidimensional vector we can multiply it by Kronecker deltas of the form
\[ 1_\mathrm{left}\otimes M \otimes 1_\mathrm{right}\]
where \( 1\) are diagonal matrices of variable size and \( M\) is our one-dimensional matrix.
EllSparseBlockMat
|
default |
default constructor does nothing
|
inline |
Allocate storage.
| num_block_rows | number of rows. Each row contains blocks. |
| num_block_cols | number of columns. |
| n | each block is of size nxn |
| left_size | size of the left_size Kronecker delta |
| right_size | size of the right_size Kronecker delta |
|
inline |
|
inline |
Convenience function to assemble the matrix.
appends the given matrix entry to the existing matrix
| row | block row |
| col | block column |
| element | new block |
|
inline |
Convenience function to assemble the matrix.
| row | block row |
| col | block column |
| data | block index into the data array |
| void dg::CooSparseBlockMat< real_type, Vector >::display | ( | std::ostream & | os = std::cout, |
| bool | show_data = false ) const |
Display internal data to a stream.
| os | the output stream |
| show_data | if true, displays the whole data vector |
|
inline |
|
inline |
Apply the matrix to a vector.
| alpha | multiplies input |
| x | input |
| beta | premultiplies output (cannot be anything other than 1, the given value is ignored) |
| y | output may not alias input |
|
inline |
total number of columns is num_cols*n*left_size*right_size
|
inline |
total number of rows is num_rows*n*left_size*right_size
|
friend |
| Vector<int> dg::CooSparseBlockMat< real_type, Vector >::cols_idx |
is of size num_entries and contains the column indices
| Vector<real_type> dg::CooSparseBlockMat< real_type, Vector >::data |
The data array is of size n*n*num_different_blocks and contains the blocks.
| Vector<int> dg::CooSparseBlockMat< real_type, Vector >::data_idx |
is of size num_entries and contains indices into the data array
| int dg::CooSparseBlockMat< real_type, Vector >::left_size |
size of the left Kronecker delta
| int dg::CooSparseBlockMat< real_type, Vector >::n |
each block has size n*n
| int dg::CooSparseBlockMat< real_type, Vector >::num_cols |
number of columns (never actually used with pointer approach
| int dg::CooSparseBlockMat< real_type, Vector >::num_entries |
number of entries in the matrix
| int dg::CooSparseBlockMat< real_type, Vector >::num_rows |
number of rows
| int dg::CooSparseBlockMat< real_type, Vector >::right_size |
size of the right Kronecker delta (is e.g 1 for a x - derivative)
| Vector<int> dg::CooSparseBlockMat< real_type, Vector >::rows_idx |
is of size num_entries and contains the row indices