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> >
70 for (
int i=1; i<size-1; i++)
81 for (
int i=1; i<size-1; i++) {
112 void solve (V& x,
const V& rhs)
const {
116 (*this)[0][0].solve(x[0],rhs[0]);
122 std::vector<block_type> c(this->
N()-1);
123 for (
size_t i=0; i<this->
N()-1; i++)
124 c[i] = (*
this)[i][i+1];
127 block_type a_00_inv = (*this)[0][0];
131 block_type c_0_tmp = c[0];
132 FMatrixHelp::multMatrix(a_00_inv, c_0_tmp, c[0]);
135 typename V::block_type d_0_tmp = d[0];
136 a_00_inv.mv(d_0_tmp,d[0]);
138 for (
unsigned int i = 1; i < this->
N(); i++) {
142 FMatrixHelp::multMatrix((*
this)[i][i-1],c[i-1], tmp);
143 block_type
id = (*this)[i][i];
150 FMatrixHelp::multMatrix(
id,tmp, c[i]);
154 (*this)[i][i-1].mmv(d[i-1], d[i]);
155 typename V::block_type tmpVec = d[i];
162 x[this->
N() - 1] = d[this->
N() - 1];
163 for (
int i = this->
N() - 2; i >= 0; i--) {
166 c[i].mmv(x[i+1], x[i]);
180 void setrowsize (size_type i, size_type s) {}
181 void incrementrowsize (size_type i) {}
182 void endrowsizes () {}
183 void addindex (size_type row, size_type
col) {}
184 void endindices () {}
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:112
A block-tridiagonal matrix.
Definition: btdmatrix.hh:25
Definition: btdmatrix.hh:47
A::size_type size_type
implement row_type with compressed vector
Definition: btdmatrix.hh:44
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1109
BTDMatrix & operator=(const BTDMatrix &other)
assignment
Definition: btdmatrix.hh:95
A allocator_type
export the allocator type
Definition: btdmatrix.hh:38
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:412
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1151
Build entries randomly.
Definition: bcrsmatrix.hh:479
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:868
B block_type
export the type representing the components
Definition: btdmatrix.hh:35
BTDMatrix(int size)
Definition: btdmatrix.hh:52
Col col
Definition: matrixmatrix.hh:347
Implementation of the BCRSMatrix class.
BTDMatrix()
Default constructor.
Definition: btdmatrix.hh:50
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1208
B::field_type field_type
export the type representing the field
Definition: btdmatrix.hh:32
Definition: basearray.hh:19
void setrowsize(size_type i, size_type s)
set number of indices in row i to s
Definition: bcrsmatrix.hh:1077
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1849