Commits

Peter Brune committed f1ab69e

Fix computation of squared-norm in for the bt linesearch in the VIRS snes case

  • Participants
  • Parent commits 66256ea

Comments (0)

Files changed (1)

src/snes/linesearch/impls/bt/linesearchbt.c

     if (linesearch->ops->vinorm) {
       gnorm = fnorm;
       ierr = (*linesearch->ops->vinorm)(snes, G, W, &gnorm);CHKERRQ(ierr);
-      g = PetscSqr(gnorm);
     } else {
       ierr = VecNorm(G,NORM_2,&gnorm);CHKERRQ(ierr);
-      g = gnorm*gnorm;
     }
+    g = PetscSqr(gnorm);
   }
 
   if (PetscIsInfOrNanReal(g)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"User provided compute function generated a Not-a-Number");
         ierr = (*linesearch->ops->vinorm)(snes, G, W, &gnorm);CHKERRQ(ierr);
       } else {
         ierr = VecNorm(G,NORM_2,&gnorm);CHKERRQ(ierr);
-        g = gnorm*gnorm;
       }
+      g = PetscSqr(gnorm);
     }
     if (PetscIsInfOrNanReal(g)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"User provided compute function generated a Not-a-Number");
     if (monitor) {
             ierr = (*linesearch->ops->vinorm)(snes, G, W, &gnorm);CHKERRQ(ierr);
           } else {
             ierr = VecNorm(G,NORM_2,&gnorm);CHKERRQ(ierr);
-            g = gnorm*gnorm;
           }
+          g = PetscSqr(gnorm);
         }
         if (PetscIsInfOrNanReal(gnorm)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"User provided compute function generated a Not-a-Number");
         if (.5*g < .5*f + lambda*alpha*initslope) { /* is reduction enough? */