From 38fef81c64701b26c013330a1cc0e51c2cf9fe78 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@dune-project.org>
Date: Sat, 1 Sep 2012 16:19:42 +0000
Subject: [PATCH] Add some documentation to the dbgs method

Patch by Matthias Wohlmuth

FS 1170

[[Imported from SVN: r1688]]
---
 dune/istl/gsetc.hh | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/dune/istl/gsetc.hh b/dune/istl/gsetc.hh
index 5dbb0a86..6692c4ab 100644
--- a/dune/istl/gsetc.hh
+++ b/dune/istl/gsetc.hh
@@ -407,16 +407,17 @@ namespace Dune {
       rowiterator endi=A.end();
       for (rowiterator i=A.begin(); i!=endi; ++i)
       {
-        rhs = b[i.index()];
+        rhs = b[i.index()];           // rhs = b_i
         coliterator endj=(*i).end();
         coliterator j=(*i).begin();
-        for (; j.index()<i.index(); ++j)
-          (*j).mmv(x[j.index()],rhs);
-        coliterator diag=j++;
-        for (; j != endj; ++j)
-          (*j).mmv(x[j.index()],rhs);
-        algmeta_itsteps<I-1>::dbgs(*diag,x[i.index()],rhs,w);
+        for (; j.index()<i.index(); ++j)           // iterate over a_ij with j < i
+          (*j).mmv(x[j.index()],rhs);               // rhs -= sum_{j<i} a_ij * xnew_j
+        coliterator diag=j++;           // *diag = a_ii and increment coliterator j from a_ii to a_i+1,i to skip diagonal
+        for (; j != endj; ++j)           // iterate over a_ij with j > i
+          (*j).mmv(x[j.index()],rhs);               // rhs -= sum_{j>i} a_ij * xold_j
+        algmeta_itsteps<I-1>::dbgs(*diag,x[i.index()],rhs,w);           // if I==1: xnew_i = rhs/a_ii
       }
+      // next two lines: xnew_i = w / a_ii * (b_i - sum_{j<i} a_ij * xnew_j - sum_{j>=i} a_ij * xold_j) + (1-w)*xold;
       x *= w;
       x.axpy(K(1)-w,xold);
     }
@@ -458,16 +459,16 @@ namespace Dune {
       rowiterator endi=A.end();
       for (rowiterator i=A.begin(); i!=endi; ++i)
       {
-        rhs = b[i.index()];
-        coliterator endj=(*i).end();
+        rhs = b[i.index()];           // rhs = b_i
+        coliterator endj=(*i).end();           // iterate over a_ij with j < i
         coliterator j=(*i).begin();
         for (; j.index()<i.index(); ++j)
-          (*j).mmv(x[j.index()],rhs);
-        coliterator diag=j;
+          (*j).mmv(x[j.index()],rhs);               //  rhs -= sum_{j<i} a_ij * xnew_j
+        coliterator diag=j;           // *diag = a_ii
         for (; j!=endj; ++j)
-          (*j).mmv(x[j.index()],rhs);
-        algmeta_itsteps<I-1>::bsorf(*diag,v,rhs,w);
-        x[i.index()].axpy(w,v);
+          (*j).mmv(x[j.index()],rhs);               // rhs -= sum_{j<i} a_ij * xnew_j
+        algmeta_itsteps<I-1>::bsorf(*diag,v,rhs,w);           // if blocksize I==1: v = rhs/a_ii
+        x[i.index()].axpy(w,v);           // x_i = w / a_ii * (b_i - sum_{j<i} a_ij * xnew_j - sum_{j>=i} a_ij * xold_j)
       }
     }
 
-- 
GitLab