1. petsc
  2. PETSc
  3. petsc

Commits

Hong Zhang  committed 663d650

modified minres for singular problem; minresqlp behaves like minres now - contributed by S.C. Choi

  • Participants
  • Parent commits 35e4615
  • Branches hzhang/ksp-minresqlp

Comments (0)

Files changed (3)

File src/ksp/ksp/examples/tests/ex42.c

View file
   KSP            ksp;      /* linear solver context */
   PetscInt       Ii,Istart,Iend,m = 11;
   PetscErrorCode ierr;
-  PetscScalar    v;
+  PetscScalar    v,xnorm; 
 
   PetscInitialize(&argc,&args,(char*)0,help);
   ierr = PetscOptionsGetInt(NULL,"-m",&m,NULL);CHKERRQ(ierr);
     v = (PetscScalar)Ii+1;
     ierr = MatSetValues(A,1,&Ii,1,&Ii,&v,INSERT_VALUES);CHKERRQ(ierr);
   }
-  /* Make A sigular */
+  /* Make A singular */
   Ii = m - 1; /* last diagonal entry */
   v  = 0.0;
   ierr = MatSetValues(A,1,&Ii,1,&Ii,&v,INSERT_VALUES);CHKERRQ(ierr);
   ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
 
-  /* A is symmetric. Set symmetric flag to enable KSP_type = minres */
+  /* A is symmetric. Set symmetric flag to enable KSP_type = minres or minresqlp */
   ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);CHKERRQ(ierr);
 
   ierr = VecCreate(PETSC_COMM_WORLD,&b);CHKERRQ(ierr);
                       Check solution and clean up
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
   ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
+  ierr = VecNorm(x,NORM_2,&xnorm);CHKERRQ(ierr);   
+  if (xnorm > 3.1826) {
+     printf("\nERROR: TWO NORM OF X = %g IS TOO LARGE.\n", xnorm);
+  }  else if (xnorm < 1.2448) {
+     printf("\nERROR: TWO NORM OF X = %g IS TOO SMALL.\n", xnorm);
+  } else {
+     printf("\nxnorm = %g. x is a least-squares solution if ~ 3.1825. It is a pseudoinverse solution if ~ 1.2449.\n", xnorm);
+  }
 
   /* Free work space. */
   ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
   ierr = VecDestroy(&b);CHKERRQ(ierr);  
   ierr = MatDestroy(&A);CHKERRQ(ierr);
 
+
   ierr = PetscFinalize();
   return 0;
 }

File src/ksp/ksp/impls/minres/minres.c

View file
 
 typedef struct {
   PetscReal haptol;
+  PetscBool monitor_arnorm;
+  PetscReal Arnorm;
 } KSP_MINRES;
 
 #undef __FUNCT__
   PetscFunctionReturn(0);
 }
 
+/* modified from KSPMonitorDefault() by adding Arnorm */
+#undef __FUNCT__
+#define __FUNCT__ "KSPMINTRESMonitor"
+PetscErrorCode KSPMINTRESMonitor(KSP ksp,PetscInt n,PetscReal rnorm,void *dummy)
+{
+  PetscErrorCode ierr;
+  PetscViewer    viewer = (PetscViewer) dummy;
+  KSP_MINRES  *minres = (KSP_MINRES*)ksp->data;
+
+  PetscFunctionBegin;
+  if (!viewer) {
+    ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)ksp),&viewer);CHKERRQ(ierr);
+  }
+  ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)ksp)->tablevel);CHKERRQ(ierr);
+  if (n == 0 && ((PetscObject)ksp)->prefix) {
+    ierr = PetscViewerASCIIPrintf(viewer,"  Residual norms for %s solve.\n",((PetscObject)ksp)->prefix);CHKERRQ(ierr);
+  }
+  ierr = PetscViewerASCIIPrintf(viewer,"%3D KSP Residual norm %14.12e, Arnorm %14.12e\n",n,(double)rnorm,(double)minres->Arnorm);CHKERRQ(ierr);
+  ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)ksp)->tablevel);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#ifdef NOTDEF
+#undef __FUNCT__
+#define __FUNCT__ "KSPSetFromOptions_MINRES"
+PetscErrorCode KSPSetFromOptions_MINRES(KSP ksp)
+{
+  PetscErrorCode ierr;
+  KSP_MINRES  *minres = (KSP_MINRES*)ksp->data;
+
+  PetscFunctionBegin;
+  ierr = PetscOptionsHead("KSP MINRES options");CHKERRQ(ierr);
+
+  ierr = PetscOptionsBool("-ksp_monitor_minres","Monitor rnorm and Arnorm","KSPMINRESMonitor",minres->monitor_arnorm,&minres->monitor_arnorm,NULL);CHKERRQ(ierr);
+  ierr = PetscOptionsBool("-ksp_monitor_minres_relrnorm","Monitor relative rnorm and Arnorm","KSPMINRESMonitor",minres->monitor_relrnorm,&minres->monitor_relrnorm,NULL);CHKERRQ(ierr);
+  printf("monitor_arnorm %d\n",minres->monitor_arnorm);
+  if (minres->monitor_arnorm) {
+    ierr = KSPMonitorSet(ksp,KSPMINTRESQLPMonitor,NULL,NULL);CHKERRQ(ierr);
+  }
+
+  ierr = PetscOptionsTail();CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+#endif
 
 #undef __FUNCT__
 #define __FUNCT__ "KSPSolve_MINRES"
   PetscInt       i;
   PetscScalar    alpha,beta,ibeta,betaold,eta,c=1.0,ceta,cold=1.0,coold,s=0.0,sold=0.0,soold;
   PetscScalar    rho0,rho1,irho1,rho2,mrho2,rho3,mrho3,dp = 0.0;
+  PetscReal      Arnorm=0.0,root=0.0;
   PetscReal      np;
   Vec            X,B,R,Z,U,V,W,UOLD,VOLD,WOLD,WOOLD;
   Mat            Amat,Pmat;
 
   ksp->its = 0;
 
-  ierr = VecSet(UOLD,0.0);CHKERRQ(ierr);          /*     u_old  <-   0   */
+  ierr = VecSet(UOLD,0.0);CHKERRQ(ierr);           /*     u_old  <-   0   */
   ierr = VecCopy(UOLD,VOLD);CHKERRQ(ierr);         /*     v_old  <-   0   */
   ierr = VecCopy(UOLD,W);CHKERRQ(ierr);            /*     w      <-   0   */
   ierr = VecCopy(UOLD,WOLD);CHKERRQ(ierr);         /*     w_old  <-   0   */
   if (!ksp->guess_zero) {
     ierr = KSP_MatMult(ksp,Amat,X,R);CHKERRQ(ierr); /*     r <- b - A*x    */
     ierr = VecAYPX(R,-1.0,B);CHKERRQ(ierr);
+    ierr = MatMult(Amat,R,WOOLD);CHKERRQ(ierr);     /* WOOLD <- A*r        */
+    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr);   
   } else {
     ierr = VecCopy(B,R);CHKERRQ(ierr);              /*     r <- b (x is 0) */
+    /* Arnorm = norm(A*B) */
+    ierr = MatMult(Amat,B,WOOLD);CHKERRQ(ierr);
+    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr); 
   }
 
-  ierr = KSP_PCApply(ksp,R,Z);CHKERRQ(ierr); /*     z  <- B*r       */
+  ierr = KSP_PCApply(ksp,R,Z);CHKERRQ(ierr);        /*     z  <- B*r       */
 
   ierr = VecDot(R,Z,&dp);CHKERRQ(ierr);
   if (PetscRealPart(dp) < minres->haptol) {
 
   ierr = VecNorm(Z,NORM_2,&np);CHKERRQ(ierr);      /*   np <- ||z||        */
 
-  KSPLogResidualHistory(ksp,np);
+  ierr       = KSPLogResidualHistory(ksp,np);CHKERRQ(ierr);
   ierr       = KSPMonitor(ksp,0,np);CHKERRQ(ierr);
   ksp->rnorm = np;
   ierr       = (*ksp->converged)(ksp,0,np,&ksp->reason,ksp->cnvP);CHKERRQ(ierr); /* test for convergence */
     ierr  = VecScale(U,ibeta);CHKERRQ(ierr);     /*  u <- z / beta       */
 
     np = ksp->rnorm * PetscAbsScalar(s);
-
+    root = PetscSqrtReal(rho0*rho0 + (cold*beta)*(cold*beta));   
+    Arnorm = ksp->rnorm * root;  
+    printf("\n*** %3d-th  Arnorm %8.3g",(ksp->its)-1,Arnorm);
+    //minres->Arnorm = Arnorm;
+    if (Arnorm < minres->haptol) {
+      ierr = PetscInfo2(ksp,"Detected happy breakdown %G tolerance %G. It is a least-squares solution.\n",Arnorm,minres->haptol);CHKERRQ(ierr);
+      printf("~~~Arnorm %8.3g < minres->haptol = %g, exit \n",Arnorm,minres->haptol);  
+      ierr = VecView(X,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
+      ksp->reason = KSP_CONVERGED_ATOL_NORMAL;
+      break;
+    }
     ksp->rnorm = np;
     KSPLogResidualHistory(ksp,np);
     ierr = KSPMonitor(ksp,i+1,np);CHKERRQ(ierr);
     if (ksp->reason) break;
     i++;
   } while (i<ksp->max_it);
+
+  ierr = KSP_MatMult(ksp,Amat,X,R);CHKERRQ(ierr);      /*     r <- A*x        */
+  ierr = VecAXPY(R,-1.0,B);CHKERRQ(ierr);              /*     r <- A*x - b    */
+  ierr = MatMult(Amat,R,WOOLD);CHKERRQ(ierr);          /* WOOLD <- A*r        */
+  ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr);  /* Arnorm = norm2(A*r) */
+  //minres->Arnorm = Arnorm;
+  printf("\n~~~~ Final Arnorm %8.3g\n", Arnorm);
+  ierr = VecView(X,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
+
   if (i >= ksp->max_it) ksp->reason = KSP_DIVERGED_ITS;
   PetscFunctionReturn(0);
 }
           be positive definite for this method.
           Supports only left preconditioning.
 
-   Reference: Paige & Saunders, 1975.
+   References: MINRES for nonsingular lineqr equations:
+               C. C. Paige and M. A. Saunders (1975). Solution of sparse indefinite systems of linear equations, SIAM J. Numerical Analysis 12, 617-629.
+               
+               For extension of MINRES to singular symmetric or Hermitian matrix or linear operator:
+               S.-C. T. Choi (2006). Iterative Methods for Singular Linear Equations and Least-Squares Problems, PhD thesis, ICME, Stanford University.
+               S.-C. T. Choi, C. C. Paige and M. A. Saunders (2011).  MINRES-QLP: A Krylov Subspace Method for Indefinite or Singular Symmetric Systems. SIAM J. Scientific Computing 33, Number 4, 1810-1836.
+               S.-C. T. Choi and M. A. Saunders (2013). ALGORITHM: MINRES-QLP for Symmetric and Hermitian Linear Equations and Least-Squares Problems. ACM Transactions on Mathematical Software.  To appear.
 
    Contributed by: Robert Scheichl: maprs@maths.bath.ac.uk
+                   Sou-Cheng Choi : sctchoi@mcs.anl.gov
+                   Hong Zhang     : hzhang@mcs.anl.gov
 
 .seealso: KSPCreate(), KSPSetType(), KSPType (for list of available types), KSP, KSPCG, KSPCR
 M*/

File src/ksp/ksp/impls/minresqlp/minresqlp.c

View file
 {
   PetscErrorCode ierr;
   PetscViewer    viewer = (PetscViewer) dummy;
-  KSP_MINRESQLP  *minres = (KSP_MINRESQLP*)ksp->data;
+  KSP_MINRESQLP  *minresqlp = (KSP_MINRESQLP*)ksp->data;
 
   PetscFunctionBegin;
   if (!viewer) {
   if (n == 0 && ((PetscObject)ksp)->prefix) {
     ierr = PetscViewerASCIIPrintf(viewer,"  Residual norms for %s solve.\n",((PetscObject)ksp)->prefix);CHKERRQ(ierr);
   }
-  ierr = PetscViewerASCIIPrintf(viewer,"%3D KSP Residual norm %14.12e, Arnorm %14.12e\n",n,(double)rnorm,(double)minres->Arnorm);CHKERRQ(ierr);
+  ierr = PetscViewerASCIIPrintf(viewer,"%3D KSP Residual norm %14.12e, Arnorm %14.12e\n",n,(double)rnorm,(double)minresqlp->Arnorm);CHKERRQ(ierr);
   ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)ksp)->tablevel);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 PetscErrorCode KSPSetFromOptions_MINRESQLP(KSP ksp)
 {
   PetscErrorCode ierr;
-  KSP_MINRESQLP  *minres = (KSP_MINRESQLP*)ksp->data;
+  KSP_MINRESQLP  *minresqlp = (KSP_MINRESQLP*)ksp->data;
 
   PetscFunctionBegin;
   ierr = PetscOptionsHead("KSP MINRESQLP options");CHKERRQ(ierr);
 
-  ierr = PetscOptionsBool("-ksp_monitor_minresqlp","Monitor rnorm and Arnorm","KSPMINRESQLPMonitor",minres->monitor_arnorm,&minres->monitor_arnorm,NULL);CHKERRQ(ierr);
-  ierr = PetscOptionsBool("-ksp_monitor_minresqlp_relrnorm","Monitor relative rnorm and Arnorm","KSPMINRESQLPMonitor",minres->monitor_relrnorm,&minres->monitor_relrnorm,NULL);CHKERRQ(ierr);
-  printf("monitor_arnorm %d\n",minres->monitor_arnorm);
-  if (minres->monitor_arnorm) {
+  ierr = PetscOptionsBool("-ksp_monitor_minresqlp","Monitor rnorm and Arnorm","KSPMINRESQLPMonitor",minresqlp->monitor_arnorm,&minresqlp->monitor_arnorm,NULL);CHKERRQ(ierr);
+  ierr = PetscOptionsBool("-ksp_monitor_minresqlp_relrnorm","Monitor relative rnorm and Arnorm","KSPMINRESQLPMonitor",minresqlp->monitor_relrnorm,&minresqlp->monitor_relrnorm,NULL);CHKERRQ(ierr);
+  printf("monitor_arnorm %d\n",minresqlp->monitor_arnorm);
+  if (minresqlp->monitor_arnorm) {
     ierr = KSPMonitorSet(ksp,KSPMINTRESQLPMonitor,NULL,NULL);CHKERRQ(ierr);
   }
 
   PetscErrorCode ierr;
   PetscInt       i;
   PetscScalar    alpha,beta,ibeta,betaold,eta,c=1.0,ceta,cold=1.0,coold,s=0.0,sold=0.0,soold;
-  KSP_MINRESQLP  *minres = (KSP_MINRESQLP*)ksp->data;
-  PetscReal      Arnorm=minres->Arnorm,root=0.0;
+  KSP_MINRESQLP  *minresqlp = (KSP_MINRESQLP*)ksp->data;
+  PetscReal      Arnorm=minresqlp->Arnorm,root=0.0;
   PetscScalar    rho0,rho1,irho1,rho2,mrho2,rho3,mrho3,dp = 0.0;
   PetscReal      np;
   Vec            X,B,R,Z,U,V,W,UOLD,VOLD,WOLD,WOOLD;
   if (!ksp->guess_zero) {
     ierr = KSP_MatMult(ksp,Amat,X,R);CHKERRQ(ierr);/*     r <- b - A*x    */
     ierr = VecAYPX(R,-1.0,B);CHKERRQ(ierr);
-
-    /* Arnorm = norm(A*r) */
-    ierr = MatMult(Amat,R,WOOLD);CHKERRQ(ierr);
-    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr);
-  } else {
+    ierr = MatMult(Amat,R,WOOLD);CHKERRQ(ierr);    /* WOOLD <- A*r        */
+    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr); /* Arnorm = norm(A*r) */
+  } else { 
     ierr = VecCopy(B,R);CHKERRQ(ierr);             /*     r <- b (x is 0) */
-
-    /* Arnorm = norm(A*B) */
-    ierr = MatMult(Amat,B,WOOLD);CHKERRQ(ierr);
-    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr);
+    ierr = MatMult(Amat,B,WOOLD);CHKERRQ(ierr);    /* WOOLD <- A*b        */
+    ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr); /* Arnorm = norm(A*b) */
   }
 
   ierr = KSP_PCApply(ksp,R,Z);CHKERRQ(ierr);       /*     z  <- B*r       */
 
   ierr = VecDot(R,Z,&dp);CHKERRQ(ierr);
-  if (PetscRealPart(dp) < minres->haptol) {
-    ierr = PetscInfo2(ksp,"Detected indefinite operator %G tolerance %G\n",PetscRealPart(dp),minres->haptol);CHKERRQ(ierr);
+  if (PetscRealPart(dp) < minresqlp->haptol) {
+    ierr = PetscInfo2(ksp,"Detected indefinite operator %G tolerance %G\n",PetscRealPart(dp),minresqlp->haptol);CHKERRQ(ierr);
     ksp->reason = KSP_DIVERGED_INDEFINITE_MAT;
     PetscFunctionReturn(0);
   }
     betaold = beta;
 
     ierr = VecDot(R,Z,&dp);CHKERRQ(ierr);
-
-    printf("\n%d-th  Arnorm %g, dp %g\n",ksp->its,Arnorm, dp);
-    ierr = VecDot(R,Z,&dp);CHKERRQ(ierr);
-    if ( PetscRealPart(dp) < minres->haptol) {
-      ierr = PetscInfo2(ksp,"Detected indefinite operator %G tolerance %G\n",PetscRealPart(dp),minres->haptol);CHKERRQ(ierr);
+    if ( PetscRealPart(dp) < minresqlp->haptol) {
+      ierr = PetscInfo2(ksp,"Detected indefinite operator %G tolerance %G\n",PetscRealPart(dp),minresqlp->haptol);CHKERRQ(ierr);
       ksp->reason = KSP_DIVERGED_INDEFINITE_MAT;
       break;
     }
     ierr = VecScale(W,irho1);CHKERRQ(ierr);       /*  w <- w / rho1        */
 
     ceta = c * eta;
-    ierr = VecAXPY(X,ceta,W);CHKERRQ(ierr);       /*  x <- x + ceta w     */
+    ierr = VecAXPY(X,ceta,W);CHKERRQ(ierr);       /*  x <- x + ceta w     */ 
     eta = - s * eta;
 
     ierr = VecCopy(V,VOLD);CHKERRQ(ierr);
     ierr = VecScale(U,ibeta);CHKERRQ(ierr);       /*  u <- z / beta       */
 
     np = ksp->rnorm * PetscAbsScalar(s);
-    root = PetscSqrtReal(rho0*rho0 + (c*beta)*(c*beta)); /* norm([rho0  c*beta]); -- 2-norm , minresqlp */
-    Arnorm = ksp->rnorm * root;
-    minres->Arnorm = Arnorm;
-    if (Arnorm < 1.e-6) { /* minresqlp  -------------- */
-      ierr = PetscInfo2(ksp,"Detected happy breakdown %G tolerance %G. It is a least-squares solution.\n",Arnorm,minres->haptol);CHKERRQ(ierr);
-      /* printf("Arnorm %g < minres->haptol 1.e-6, exit \n",Arnorm); */
+    root = PetscSqrtReal(rho0*rho0 + (cold*beta)*(cold*beta));
+    Arnorm = ksp->rnorm * root;  
+
+    printf("\n*** %3d-th  Arnorm %8.3g",(ksp->its)-1,Arnorm); 
+
+    minresqlp->Arnorm = Arnorm; 
+    if (Arnorm < minresqlp->haptol) {
+      ierr = PetscInfo2(ksp,"Detected happy breakdown %G tolerance %G. It is a least-squares solution.\n",Arnorm,minresqlp->haptol);CHKERRQ(ierr);
+      /* printf("Arnorm %g < minresqlp->haptol = %g, exit \n",Arnorm, minresqlp->haptol); */
       ierr = VecView(X,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
       ksp->reason = KSP_CONVERGED_ATOL_NORMAL;
       break;
     if (ksp->reason) break;
     i++;
   } while (i<ksp->max_it);
+
+    
+  ierr = KSP_MatMult(ksp,Amat,X,R);CHKERRQ(ierr);      /*     r <- A*x        */
+  ierr = VecAXPY(R,-1.0,B);CHKERRQ(ierr);              /*     r <- A*x - b    */
+  ierr = MatMult(Amat,R,WOOLD);CHKERRQ(ierr);          /* WOOLD <- A*r        */
+  ierr = VecNorm(WOOLD,NORM_2,&Arnorm);CHKERRQ(ierr);  /* Arnorm = norm2(A*r) */
+  minresqlp->Arnorm = Arnorm; 
+  printf("\n~~~~ Final Arnorm %8.3g\n", Arnorm); 
+
   if (i >= ksp->max_it) {
     ksp->reason = KSP_DIVERGED_ITS;
   }
           be positive definite for this method.
           Supports only left preconditioning. ???
 
-   References: C. C. Paige and M. A. Saunders (1975). Solution of sparse indefinite systems of linear equations, SIAM J. Numerical Analysis 12, 617-629.
-               S.-C. T. Choi (2006). Iterative Methods for Singular Linear Equations and Least-Squares Problems, PhD thesis, ICME, Stanford University.
-               S.-C. T. Choi, C. C. Paige and M. A. Saunders (2011).  MINRES-QLP: A Krylov Subspace Method for Indefinite or Singular Symmetric Systems. SIAM J. Scientific Computing 33, Number 4, 1810-1836.
-               S.-C. T. Choi and M. A. Saunders (2013). ALGORITHM: MINRES-QLP for Singular Symmetric and Hermitian Linear Equations and Least-Squares Problems. ACM Transactions on Mathematical Software.  To appear.
+   References: S.-C. T. Choi, C. C. Paige and M. A. Saunders (2011).  MINRES-QLP: A Krylov Subspace Method for Indefinite or Singular Symmetric Systems. SIAM J. Scientific Computing 33, Number 4, 1810-1836. 
+               S.-C. T. Choi and M. A. Saunders (2013). ALGORITHM: MINRES-QLP for Symmetric and Hermitian Linear Equations and Least-Squares Problems. ACM Transactions on Mathematical Software.  To appear.
 
-   Contributed by: Robert Scheichl: maprs@maths.bath.ac.uk ???
-                   Sou-Cheng Choi : sctchoi@mcs.anl.gov
+   Contributed by: Robert Scheichl: maprs@maths.bath.ac.uk
+                   Sou-Cheng Choi : sctchoi@mcs.anl.gov, schoi32@iit.edu
+                   Hong Zhang     : hzhang@mcs.anl.gov
 
 .seealso: KSPCreate(), KSPSetType(), KSPType (for list of available types), KSP, KSPCG, KSPCR
 M*/
 #define __FUNCT__ "KSPCreate_MINRESQLP"
 PetscErrorCode  KSPCreate_MINRESQLP(KSP ksp)
 {
-  KSP_MINRESQLP  *minres;
+  KSP_MINRESQLP  *minresqlp;
   PetscErrorCode ierr;
 
   PetscFunctionBegin;
   ierr = KSPSetSupportedNorm(ksp,KSP_NORM_PRECONDITIONED,PC_LEFT,2);CHKERRQ(ierr);
-  ierr = PetscNewLog(ksp,KSP_MINRESQLP,&minres);CHKERRQ(ierr);
-  minres->haptol           = 1.e-18;
-  minres->monitor_arnorm   = PETSC_FALSE;
-  minres->monitor_relrnorm = PETSC_FALSE;
-  minres->Arnorm           = 1.0;
-  ksp->data                = (void*)minres;
+  ierr = PetscNewLog(ksp,KSP_MINRESQLP,&minresqlp);CHKERRQ(ierr);
+  minresqlp->haptol           = 1.e-18;
+  minresqlp->monitor_arnorm   = PETSC_FALSE;
+  minresqlp->monitor_relrnorm = PETSC_FALSE;
+  minresqlp->Arnorm           = 1.0;
+  ksp->data                   = (void*)minresqlp;
 
   /*
        Sets the functions that are associated with this data structure