3 #ifndef DUNE_ISTL_BTDMATRIX_HH 4 #define DUNE_ISTL_BTDMATRIX_HH 6 #include <dune/common/fmatrix.hh> 24 template <
class B,
class A=std::allocator<B> >
57 for (
size_t i=0; i<size; i++)
63 for (
size_t i=0; i<size; i++) {
77 auto nonZeros = (size==0) ? 0 : size + 2*(size-1);
84 for (
size_t i=0; i<size; i++)
90 for (
size_t i=0; i<size; i++) {
119 void solve (V& x,
const V& rhs)
const {
123 (*this)[0][0].solve(x[0],rhs[0]);
129 std::vector<block_type> c(this->
N()-1);
130 for (
size_t i=0; i<this->
N()-1; i++)
131 c[i] = (*
this)[i][i+1];
134 block_type a_00_inv = (*this)[0][0];
138 block_type c_0_tmp = c[0];
139 FMatrixHelp::multMatrix(a_00_inv, c_0_tmp, c[0]);
142 typename V::block_type d_0_tmp = d[0];
143 a_00_inv.mv(d_0_tmp,d[0]);
145 for (
unsigned int i = 1; i < this->
N(); i++) {
149 FMatrixHelp::multMatrix((*
this)[i][i-1],c[i-1], tmp);
150 block_type
id = (*this)[i][i];
157 FMatrixHelp::multMatrix(
id,tmp, c[i]);
161 (*this)[i][i-1].mmv(d[i-1], d[i]);
162 typename V::block_type tmpVec = d[i];
169 x[this->
N() - 1] = d[this->
N() - 1];
170 for (
int i = this->
N() - 2; i >= 0; i--) {
173 c[i].mmv(x[i+1], x[i]);
187 void setrowsize (size_type i, size_type s) {}
188 void incrementrowsize (size_type i) {}
189 void endrowsizes () {}
190 void addindex (size_type row, size_type
col) {}
191 void endindices () {}
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition: bcrsmatrix.hh:820
Definition: allocator.hh:7
B block_type
export the type representing the components
Definition: btdmatrix.hh:35
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:422
BTDMatrix(size_type size)
Definition: btdmatrix.hh:52
BTDMatrix()
Default constructor.
Definition: btdmatrix.hh:50
A::size_type size_type
implement row_type with compressed vector
Definition: btdmatrix.hh:44
A block-tridiagonal matrix.
Definition: btdmatrix.hh:25
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1894
A allocator_type
export the allocator type
Definition: btdmatrix.hh:38
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:870
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1150
void setSize(size_type size)
Resize the matrix. Invalidates the content!
Definition: btdmatrix.hh:75
Implementation of the BCRSMatrix class.
BTDMatrix & operator=(const BTDMatrix &other)
assignment
Definition: btdmatrix.hh:102
Build entries randomly.
Definition: bcrsmatrix.hh:489
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1207
Col col
Definition: matrixmatrix.hh:349
Definition: btdmatrix.hh:47
B::field_type field_type
export the type representing the field
Definition: btdmatrix.hh:32
void solve(V &x, const V &rhs) const
Use the Thomas algorithm to solve the system Ax=b in O(n) time.
Definition: btdmatrix.hh:119
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1108