Commits

Jed Brown committed c0b2db7

SNESLineSearch CP: simplify control flow for initial dot product

This appeases imprecise -Wmaybe-initialized with gcc-4.8.1 and makes it
clear that max_its=0 is not relevant.

Acked-by: Peter Brune <brune@mcs.anl.gov>

  • Participants
  • Parent commits d45619d

Comments (0)

Files changed (1)

src/snes/linesearch/impls/cp/linesearchcp.c

   ierr       = SNESLineSearchPreCheck(linesearch,X,Y,&changed_y);CHKERRQ(ierr);
   lambda_old = 0.0;
 
+  ierr = VecDot(F,Y,&fty_old);CHKERRQ(ierr);
+  fty_init = fty_old;
 
   for (i = 0; i < max_its; i++) {
-    if (i == 0) {
-      ierr = VecDot(F,Y,&fty_old);CHKERRQ(ierr);
-      fty_init = fty_old;
-    }
     /* compute the norm at lambda */
     ierr = VecCopy(X, W);CHKERRQ(ierr);
     ierr = VecAXPY(W, -lambda, Y);CHKERRQ(ierr);