Relax the requirements on loss functiond derivatives.

We now require that the first derivative of the loss function
be positive only if the second derivative is non-zero. This is
because when the second derivative is non-positive, we do not use
the second order correction suggested by BANS and instead use
a simpler first order strategy which does not use a division by
the gradient of the loss function.

Change-Id: I3d65713f152611998e196ff389a7081acfdfd8c1
diff --git a/internal/ceres/corrector.cc b/internal/ceres/corrector.cc
index 955feb5..cbf49ec 100644
--- a/internal/ceres/corrector.cc
+++ b/internal/ceres/corrector.cc
@@ -40,7 +40,6 @@
 
 Corrector::Corrector(const double sq_norm, const double rho[3]) {
   CHECK_GE(sq_norm, 0.0);
-  CHECK_GT(rho[1], 0.0);
   sqrt_rho1_ = sqrt(rho[1]);
 
   // If sq_norm = 0.0, the correction becomes trivial, the residual
@@ -85,6 +84,14 @@
     return;
   }
 
+  // We now require that the first derivative of the loss function be
+  // positive only if the second derivative is non-zero. This is
+  // because when the second derivative is non-positive, we do not use
+  // the second order correction suggested by BANS and instead use a
+  // simpler first order strategy which does not use a division by the
+  // gradient of the loss function.
+  CHECK_GT(rho[1], 0.0);
+
   // Calculate the smaller of the two solutions to the equation
   //
   // 0.5 *  alpha^2 - alpha - rho'' / rho' *  z'z = 0.