Skip to content
Snippets Groups Projects
Commit 5e948d3c authored by Max Kahnt's avatar Max Kahnt
Browse files

Improve readability (use C++11).

parent 9938b2c6
No related branches found
No related tags found
No related merge requests found
......@@ -16,19 +16,15 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::
residual(int index, VectorBlock& r) const
{
const MatrixType& mat = *this->mat_;
typedef typename MatrixType::row_type RowType;
const RowType& row = mat[index];
typedef typename RowType::ConstIterator ColumnIterator;
const auto& row = mat[index];
r = (*this->rhs_)[index];
/* The following loop subtracts
* \f[ sum_i = \sum_j A_{ij}w_j \f]
*/
ColumnIterator cIt = row.begin();
ColumnIterator cEndIt = row.end();
auto cIt = row.begin();
auto cEndIt = row.end();
for (; cIt!=cEndIt; ++cIt) {
// r_i -= A_ij x_j
......@@ -64,14 +60,14 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i)
VectorBlock r;
residual(i, r);
const auto& mat_ii = mat[i][i];
// Compute x_i += A_{i,i}^{-1} r[i]
// Compute correction v = A_{i,i}^{-1} r[i]
VectorBlock v;
VectorBlock& x = (*this->x_)[i];
if (count == 0) {
// No degree of freedom shall be ignored --> solve linear problem
mat[i][i].solve(v, r);
mat_ii.solve(v, r);
} else {
// Copy the matrix and adjust rhs and matrix so that dofs given in ignoreNodes[i]
// are not touched
......@@ -83,11 +79,12 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i)
for (int k = 0; k < BlockSize; ++k)
matRes[j][k] = (k == j);
} else
matRes[j] = mat[i][i][j];
matRes[j] = mat_ii[j];
}
matRes.solve(v, r);
}
// Add correction;
// Add correction
VectorBlock& x = (*this->x_)[i];
x += v;
}
......@@ -20,7 +20,7 @@ template<class MatrixType,
class BlockGSStep : public LinearIterationStep<MatrixType, DiscFuncType, BitVectorType>
{
typedef typename DiscFuncType::block_type VectorBlock;
using VectorBlock = typename DiscFuncType::block_type;
enum {BlockSize = VectorBlock::dimension};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment