diff options
Diffstat (limited to 'extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc')
-rw-r--r-- | extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc b/extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc index c85c8e5cbf5..f29376db793 100644 --- a/extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc +++ b/extern/libmv/third_party/ceres/internal/ceres/dogleg_strategy.cc @@ -99,7 +99,7 @@ TrustRegionStrategy::Summary DoglegStrategy::ComputeStep( } TrustRegionStrategy::Summary summary; summary.num_iterations = 0; - summary.termination_type = TOLERANCE; + summary.termination_type = LINEAR_SOLVER_SUCCESS; return summary; } @@ -135,7 +135,11 @@ TrustRegionStrategy::Summary DoglegStrategy::ComputeStep( summary.num_iterations = linear_solver_summary.num_iterations; summary.termination_type = linear_solver_summary.termination_type; - if (linear_solver_summary.termination_type != FAILURE) { + if (linear_solver_summary.termination_type == LINEAR_SOLVER_FATAL_ERROR) { + return summary; + } + + if (linear_solver_summary.termination_type != LINEAR_SOLVER_FAILURE) { switch (dogleg_type_) { // Interpolate the Cauchy point and the Gauss-Newton step. case TRADITIONAL_DOGLEG: @@ -146,7 +150,7 @@ TrustRegionStrategy::Summary DoglegStrategy::ComputeStep( // Cauchy point and the (Gauss-)Newton step. case SUBSPACE_DOGLEG: if (!ComputeSubspaceModel(jacobian)) { - summary.termination_type = FAILURE; + summary.termination_type = LINEAR_SOLVER_FAILURE; break; } ComputeSubspaceDoglegStep(step); @@ -513,7 +517,7 @@ LinearSolver::Summary DoglegStrategy::ComputeGaussNewtonStep( const double* residuals) { const int n = jacobian->num_cols(); LinearSolver::Summary linear_solver_summary; - linear_solver_summary.termination_type = FAILURE; + linear_solver_summary.termination_type = LINEAR_SOLVER_FAILURE; // The Jacobian matrix is often quite poorly conditioned. Thus it is // necessary to add a diagonal matrix at the bottom to prevent the @@ -526,7 +530,7 @@ LinearSolver::Summary DoglegStrategy::ComputeGaussNewtonStep( // If the solve fails, the multiplier to the diagonal is increased // up to max_mu_ by a factor of mu_increase_factor_ every time. If // the linear solver is still not successful, the strategy returns - // with FAILURE. + // with LINEAR_SOLVER_FAILURE. // // Next time when a new Gauss-Newton step is requested, the // multiplier starts out from the last successful solve. @@ -579,17 +583,21 @@ LinearSolver::Summary DoglegStrategy::ComputeGaussNewtonStep( } } - if (linear_solver_summary.termination_type == FAILURE || + if (linear_solver_summary.termination_type == LINEAR_SOLVER_FATAL_ERROR) { + return linear_solver_summary; + } + + if (linear_solver_summary.termination_type == LINEAR_SOLVER_FAILURE || !IsArrayValid(n, gauss_newton_step_.data())) { mu_ *= mu_increase_factor_; VLOG(2) << "Increasing mu " << mu_; - linear_solver_summary.termination_type = FAILURE; + linear_solver_summary.termination_type = LINEAR_SOLVER_FAILURE; continue; } break; } - if (linear_solver_summary.termination_type != FAILURE) { + if (linear_solver_summary.termination_type != LINEAR_SOLVER_FAILURE) { // The scaled Gauss-Newton step is D * GN: // // - (D^-1 J^T J D^-1)^-1 (D^-1 g) |