/[escript]/trunk/paso/src/MINRES.c
ViewVC logotype

Diff of /trunk/paso/src/MINRES.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 2565 by artak, Tue Jul 28 05:50:15 2009 UTC
# Line 83  err_t Paso_Solver_MINRES( Line 83  err_t Paso_Solver_MINRES(
83    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);
84    double  *w=NULL, *w1=NULL, *w2=NULL, *r1=NULL, *r2=NULL, *y=NULL, *v=NULL;    double  *w=NULL, *w1=NULL, *w2=NULL, *r1=NULL, *r2=NULL, *y=NULL, *v=NULL;
85    
86    double Anorm,ynorm,oldb,dbar,epsln,phibar,rhs1,rhs2,rnorm,tnorm2,ynorm2,cs,sn,eps,s,alfa,denom,z,beta1,beta;    double Anorm,Arnorm,ynorm,oldb,dbar,epsln,phibar,rhs1,rhs2,rnorm,tnorm2,ynorm2,cs,sn,eps,s,alfa,denom,z,beta1,beta;
87    double gmax,gmin,oldeps,delta,gbar,gamma,phi;    double gmax,gmin,oldeps,delta,gbar,gamma,phi,root,epsx;
88    
89    double norm_of_residual=0;    double norm_of_residual=0;
90        
# Line 151  err_t Paso_Solver_MINRES( Line 151  err_t Paso_Solver_MINRES(
151    ynorm2 = 0;    ynorm2 = 0;
152    cs     = -1;    cs     = -1;
153    sn     = 0;    sn     = 0;
154    eps    = 0.0001;    eps    = 0.000001;
155    
156    while (!(convergeFlag || maxIterFlag || breakFlag || (status !=SOLVER_NO_ERROR) ))    while (!(convergeFlag || maxIterFlag || breakFlag || (status !=SOLVER_NO_ERROR) ))
157    {    {
# Line 204  err_t Paso_Solver_MINRES( Line 204  err_t Paso_Solver_MINRES(
204       epsln  =               sn * beta ;       epsln  =               sn * beta ;
205       dbar   =            -  cs * beta;       dbar   =            -  cs * beta;
206            
207         root   = sqrt(gbar*gbar+dbar*dbar) ;
208         Arnorm = phibar*root;
209        
210       gamma  = sqrt(gbar*gbar+beta*beta) ;       gamma  = sqrt(gbar*gbar+beta*beta) ;
211       gamma  = MAX(gamma,eps) ;       gamma  = MAX(gamma,eps) ;
212       cs     = gbar / gamma ;                   cs     = gbar / gamma ;            
# Line 234  err_t Paso_Solver_MINRES( Line 237  err_t Paso_Solver_MINRES(
237       ynorm  = sqrt( ynorm2 ) ;       ynorm  = sqrt( ynorm2 ) ;
238    
239       rnorm  = phibar;       rnorm  = phibar;
240         epsx   = Anorm*ynorm*eps;
241    
242       maxIterFlag = (num_iter > maxit);       maxIterFlag = (num_iter > maxit);
243       norm_of_residual=rnorm/Anorm*ynorm;       norm_of_residual=rnorm;
244       convergeFlag=(norm_of_residual<(*tolerance));       convergeFlag=((norm_of_residual/(Anorm*ynorm))<(*tolerance) || 1+(norm_of_residual/(Anorm*ynorm)) <=1);
       
245            
246       if (maxIterFlag) {       if (maxIterFlag) {
247           status = SOLVER_MAXITER_REACHED;           status = SOLVER_MAXITER_REACHED;

Legend:
Removed from v.2548  
changed lines
  Added in v.2565

  ViewVC Help
Powered by ViewVC 1.1.26