/[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 1787 by artak, Mon Sep 15 01:36:34 2008 UTC revision 1979 by artak, Thu Nov 6 04:29:58 2008 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  /* TFQMR iterations */  /* MINRES iterations */
16    
17  #include "SystemMatrix.h"  #include "SystemMatrix.h"
18  #include "Paso.h"  #include "Paso.h"
# Line 71  err_t Paso_Solver_MINRES( Line 72  err_t Paso_Solver_MINRES(
72      double * r,      double * r,
73      double * x,      double * x,
74      dim_t *iter,      dim_t *iter,
     double *tol,  
75      double * tolerance,      double * tolerance,
76      Paso_Performance* pp) {      Paso_Performance* pp) {
77    
# Line 86  err_t Paso_Solver_MINRES( Line 86  err_t Paso_Solver_MINRES(
86    double Anorm,ynorm,oldb,dbar,epsln,phibar,rhs1,rhs2,rnorm,tnorm2,ynorm2,cs,sn,eps,s,alfa,denom,z,beta1,beta;    double Anorm,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;
88    
89    double norm_of_residual;    double norm_of_residual=0;
90        
91  /*                                                                 */  /*                                                                 */
92  /*-----------------------------------------------------------------*/  /*-----------------------------------------------------------------*/
# Line 161  err_t Paso_Solver_MINRES( Line 161  err_t Paso_Solver_MINRES(
161            
162       Performance_stopMonitor(pp,PERFORMANCE_SOLVER);       Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
163       Performance_startMonitor(pp,PERFORMANCE_MVM);       Performance_startMonitor(pp,PERFORMANCE_MVM);
164       Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(ONE, A, v,ZERO,y);       Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, v,PASO_ZERO,y);
165       Performance_stopMonitor(pp,PERFORMANCE_MVM);       Performance_stopMonitor(pp,PERFORMANCE_MVM);
166       Performance_startMonitor(pp,PERFORMANCE_SOLVER);       Performance_startMonitor(pp,PERFORMANCE_SOLVER);
167            
# Line 170  err_t Paso_Solver_MINRES( Line 170  err_t Paso_Solver_MINRES(
170       }       }
171    
172       alfa = Paso_InnerProduct(n,v,y,A->mpi_info);       alfa = Paso_InnerProduct(n,v,y,A->mpi_info);
173       Paso_Update(n, 1., y, -(alfa/beta), r2);       Paso_Update(n, 1., y, (-alfa/beta), r2);
174       Paso_Copy(n,r1,r2);       Paso_Copy(n,r1,r2);
175       Paso_Copy(n,r2,y);       Paso_Copy(n,r2,y);
176    
# Line 236  err_t Paso_Solver_MINRES( Line 236  err_t Paso_Solver_MINRES(
236       rnorm  = phibar;       rnorm  = phibar;
237    
238       maxIterFlag = (num_iter > maxit);       maxIterFlag = (num_iter > maxit);
239       norm_of_residual=rnorm;       norm_of_residual=rnorm/Anorm*ynorm;
240       convergeFlag=(norm_of_residual<Anorm*ynorm*(*tolerance));       convergeFlag=(norm_of_residual<(*tolerance));
241            
242            
243       if (maxIterFlag) {       if (maxIterFlag) {
# Line 246  err_t Paso_Solver_MINRES( Line 246  err_t Paso_Solver_MINRES(
246           status = SOLVER_BREAKDOWN;           status = SOLVER_BREAKDOWN;
247       }       }
248      ++(num_iter);      ++(num_iter);
     /*printf("residual norm %.10f < %.10f %.10f %.10f \n",rnorm,Anorm*ynorm*(*tolerance), Anorm*ynorm, (*tolerance));*/  
249    }    }
250      /* end of iteration */      /* end of iteration */
251            
# Line 260  err_t Paso_Solver_MINRES( Line 259  err_t Paso_Solver_MINRES(
259      TMPMEMFREE(v);      TMPMEMFREE(v);
260        
261      *iter=num_iter;      *iter=num_iter;
262      *tol=norm_of_residual;      *tolerance=norm_of_residual;
263            
264    /*     End of MINRES */    /*     End of MINRES */
265    return status;    return status;

Legend:
Removed from v.1787  
changed lines
  Added in v.1979

  ViewVC Help
Powered by ViewVC 1.1.26