Improve logging for linear solver failures. Change-Id: Idc7dce702e99637f47d7585399ef8da38f0b8111
diff --git a/internal/ceres/conjugate_gradients_solver.cc b/internal/ceres/conjugate_gradients_solver.cc index 92e829c..d7aee31 100644 --- a/internal/ceres/conjugate_gradients_solver.cc +++ b/internal/ceres/conjugate_gradients_solver.cc
@@ -137,7 +137,8 @@ if (IsZeroOrInfinity(beta)) { summary.termination_type = LINEAR_SOLVER_FAILURE; summary.message = StringPrintf( - "Numerical failure. beta = rho_n / rho_{n-1} = %e.", beta); + "Numerical failure. beta = rho_n / rho_{n-1} = %e, " + "rho_n = %e, rho_{n-1} = %e", beta, rho, last_rho); break; } p = z + beta * p; @@ -157,7 +158,8 @@ if (IsInfinite(alpha)) { summary.termination_type = LINEAR_SOLVER_FAILURE; summary.message = - StringPrintf("Numerical failure. alpha = rho / pq = %e", alpha); + StringPrintf("Numerical failure. alpha = rho / pq = %e, " + "rho = %e, pq = %e.", alpha, rho, pq); break; }
diff --git a/internal/ceres/levenberg_marquardt_strategy.cc b/internal/ceres/levenberg_marquardt_strategy.cc index e47ef48..84a66f9 100644 --- a/internal/ceres/levenberg_marquardt_strategy.cc +++ b/internal/ceres/levenberg_marquardt_strategy.cc
@@ -108,9 +108,12 @@ linear_solver_->Solve(jacobian, residuals, solve_options, step); if (linear_solver_summary.termination_type == LINEAR_SOLVER_FATAL_ERROR) { - LOG(WARNING) << "Linear solver fatal error."; - } else if (linear_solver_summary.termination_type == LINEAR_SOLVER_FAILURE || - !IsArrayValid(num_parameters, step)) { + LOG(WARNING) << "Linear solver fatal error: " + << linear_solver_summary.message; + } else if (linear_solver_summary.termination_type == LINEAR_SOLVER_FAILURE) { + LOG(WARNING) << "Linear solver failure. Failed to compute a step: " + << linear_solver_summary.message; + } else if (!IsArrayValid(num_parameters, step)) { LOG(WARNING) << "Linear solver failure. Failed to compute a finite step."; linear_solver_summary.termination_type = LINEAR_SOLVER_FAILURE; } else {