]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Krylov-space methods do not use residual() anymore
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 7 Dec 2000 10:42:19 +0000 (10:42 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 7 Dec 2000 10:42:19 +0000 (10:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@3527 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/solver_bicgstab.h
deal.II/lac/include/lac/solver_cg.h
deal.II/lac/include/lac/solver_gmres.h
deal.II/lac/include/lac/solver_qmrs.h

index ed2a1fcbe6c4735db34553ba4e8ed97f73c9fefd..c01f19051b4c156d9fb89801f373a7055f9fda13 100644 (file)
@@ -241,7 +241,10 @@ template <class MATRIX>
 double
 SolverBicgstab<VECTOR>::criterion (const MATRIX& A, const VECTOR& x, const VECTOR& b)
 {
-  res = A.residual(*Vt, x, b);
+  A.vmult(*Vt, x);
+  Vt->sadd(-1.,1.,b);
+  res = Vt->l2_norm();
+  
   return res;
 }
 
@@ -252,7 +255,10 @@ template <class MATRIX>
 SolverControl::State
 SolverBicgstab<VECTOR>::start(const MATRIX& A)
 {
-  res = A.residual(*Vr, *Vx, *Vb);
+  A.vmult(*Vr, *Vx);
+  Vr->sadd(-1.,1.,*Vb);
+  res = Vr->l2_norm();
+  
   Vp->reinit(*Vx);
   Vv->reinit(*Vx);
   Vrbar->equ(1.,*Vr);
index 5ebb3e822e7dcbd53533c5fbc1665d927b105b68..d6c8aeae32dfd2ba3b621caec2bbdf769897e34d 100644 (file)
@@ -199,8 +199,11 @@ SolverCG<VECTOR>::solve (const MATRIX &A,
                                   // library
   int  it=0;
   double res,gh,alpha,beta;
-  res = A.residual(g,x,b);
+
+  A.vmult(g,x);
+  g.sadd(-1.,1.,b);
+  res = g.l2_norm();
+  
   conv = control().check(0,res);
   if (conv) 
     {
index 23e5e190b11ff75d9e9fae02bca80de3160d44a7..fd77abd2a5429f0550bca9ec01d9b96122b3c1f0 100644 (file)
@@ -279,10 +279,12 @@ unsigned int dim = 0;
       
       if (left_precondition)
        {
-         A.residual(p,x,b);
+         A.vmult(p,x);
+         p.sadd(-1.,1.,b);
          precondition.vmult(v,p);
        } else {
-         A.residual(v,x,b);
+         A.vmult(v,x);
+         v.sadd(-1.,1.,b);
        };
  
       double rho = v.l2_norm();
index 81a2ac359f635ecd93df134e490d9c1e4388d025..3376d6263fbef1f71f31bba740be05d3dda34ff4 100644 (file)
@@ -304,7 +304,9 @@ SolverQMRS<VECTOR>::iterate(const MATRIX& A,
                                   // Apply right preconditioning to x
   precondition.vmult(q,x);  
                                   // Preconditioned residual
-  res = A.residual(v, q, b);
+  A.vmult(v,q);
+  v.sadd(-1.,1.,b);
+  res = v.l2_norm();
 
   if (control().check(step, res) == SolverControl::success)
     return success;
@@ -352,7 +354,11 @@ while (state == SolverControl::iterate)
       print_vectors(step,x,v,d);
                                       // Step 5
       if (additional_data.exact_residual)
-       res = A.residual(q,x,b);
+       {
+         A.vmult(q,x);
+         q.sadd(-1.,1.,b);
+         res = q.l2_norm();
+       }
       else
        res = sqrt((it+1)*tau);
       state = control().check(step,res);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.