3 #ifndef DUNE_ISTL_BDMATRIX_HH
4 #define DUNE_ISTL_BDMATRIX_HH
8 #include <dune/common/rangeutilities.hh>
9 #include <dune/common/scalarmatrixview.hh>
29 template <
class B,
class A=std::allocator<B> >
37 using field_type =
typename Imp::BlockTraits<B>::field_type;
52 [[deprecated(
"Use free function blockLevel(). Will be removed after 2.8.")]]
53 static constexpr
unsigned int blocklevel = blockLevel<B>()+1;
61 for (
int i=0; i<size; i++)
66 for (
int i=0; i<size; i++)
74 BDMatrix (std::initializer_list<B>
const &list)
78 for (
auto it = list.begin(); it != list.end(); ++it, ++i)
89 for (
auto i : range(size))
94 for (
auto i : range(size))
118 void solve (V& x,
const V& rhs)
const {
121 auto&& xv = Impl::asVector(x[i]);
122 auto&& rhsv = Impl::asVector(rhs[i]);
123 Impl::asMatrix((*
this)[i][i]).solve(xv,rhsv);
130 Impl::asMatrix((*
this)[i][i]).
invert();
144 void endrowsizes () {}
146 void endindices () {}
Implementation of the BCRSMatrix class.
Helper functions for determining the vector/matrix block level.
Col col
Definition: matrixmatrix.hh:349
Definition: allocator.hh:9
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:464
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:909
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1147
void setrowsize(size_type i, size_type s)
Set number of indices in row i to s.
Definition: bcrsmatrix.hh:1115
@ random
Build entries randomly.
Definition: bcrsmatrix.hh:528
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1189
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1246
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1970
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition: bcrsmatrix.hh:859
A block-diagonal matrix.
Definition: bdmatrix.hh:31
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition: bdmatrix.hh:37
A::size_type size_type
implement row_type with compressed vector
Definition: bdmatrix.hh:49
BDMatrix()
Default constructor.
Definition: bdmatrix.hh:56
BDMatrix(std::initializer_list< B > const &list)
Construct from a std::initializer_list.
Definition: bdmatrix.hh:74
B block_type
export the type representing the components
Definition: bdmatrix.hh:40
void solve(V &x, const V &rhs) const
Solve the system Ax=b in O(n) time.
Definition: bdmatrix.hh:118
A allocator_type
export the allocator type
Definition: bdmatrix.hh:43
BDMatrix & operator=(const BDMatrix &other)
assignment
Definition: bdmatrix.hh:101
BDMatrix(int size)
Definition: bdmatrix.hh:58
static constexpr unsigned int blocklevel
increment block level counter
Definition: bdmatrix.hh:53
void setSize(size_type size)
Resize the matrix. Invalidates the content!
Definition: bdmatrix.hh:83
void invert()
Inverts the matrix.
Definition: bdmatrix.hh:128