3 #ifndef DUNE_BLOCK_TRIDIAGONAL_MATRIX_HH
4 #define DUNE_BLOCK_TRIDIAGONAL_MATRIX_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];
128 FMatrixHelp::invertMatrix((*
this)[0][0], a_00_inv);
132 FMatrixHelp::multMatrix(a_00_inv, c_0_tmp, c[0]);
135 typename V::block_type d_0_tmp = d[0];
136 (*this)[0][0].solve(d[0], d_0_tmp);
138 for (
unsigned int i = 1; i < this->
N(); i++) {
142 FMatrixHelp::multMatrix(c[i-1], (*
this)[i][i-1], tmp);
150 FMatrixHelp::multMatrix(tmp,
id, 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]);
182 void endrowsizes () {}
184 void endindices () {}
B::field_type field_type
export the type representing the field
Definition: bcrsmatrix.hh:436
A allocator_type
export the allocator type
Definition: btdmatrix.hh:38
BTDMatrix & operator=(const BTDMatrix &other)
assignment
Definition: btdmatrix.hh:95
Definition: btdmatrix.hh:47
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:1152
Build entries randomly.
Definition: bcrsmatrix.hh:480
BTDMatrix(int size)
Definition: btdmatrix.hh:52
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:413
BTDMatrix()
Default constructor.
Definition: btdmatrix.hh:50
void setrowsize(size_type i, size_type s)
set number of indices in row i to s
Definition: bcrsmatrix.hh:1078
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1850
Col col
Definition: matrixmatrix.hh:347
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1209
Matrix & A
Definition: matrixmatrix.hh:216
Implementation of the BCRSMatrix class.
Row row
Definition: matrixmatrix.hh:345
A block-tridiagonal matrix.
Definition: btdmatrix.hh:25
B block_type
export the type representing the components
Definition: bcrsmatrix.hh:439
B::field_type field_type
export the type representing the field
Definition: btdmatrix.hh:32
B block_type
export the type representing the components
Definition: btdmatrix.hh:35
A::size_type size_type
implement row_type with compressed vector
Definition: btdmatrix.hh:44
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
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1110