LinearSolver::Summary::status -> LinearSolver::Summary::message. And a bunch of minor lint cleanups as they showed up. Change-Id: I430a6b05710923c72daf6a5df4dfcd16fbf44b3a
diff --git a/internal/ceres/block_jacobi_preconditioner.cc b/internal/ceres/block_jacobi_preconditioner.cc index 29974d4..19b749b 100644 --- a/internal/ceres/block_jacobi_preconditioner.cc +++ b/internal/ceres/block_jacobi_preconditioner.cc
@@ -94,7 +94,9 @@ // // MatrixRef(blocks_[cells[c].block_id], // col_block_size, - // col_block_size).selfadjointView<Eigen::Upper>().rankUpdate(m); + // col_block_size) + // .selfadjointView<Eigen::Upper>() + // .rankUpdate(m); // } }
diff --git a/internal/ceres/conjugate_gradients_solver.cc b/internal/ceres/conjugate_gradients_solver.cc index ffea501..fc1aef4 100644 --- a/internal/ceres/conjugate_gradients_solver.cc +++ b/internal/ceres/conjugate_gradients_solver.cc
@@ -75,7 +75,7 @@ LinearSolver::Summary summary; summary.termination_type = MAX_ITERATIONS; - summary.status = "Maximum number of iterations reached."; + summary.message = "Maximum number of iterations reached."; summary.num_iterations = 0; const int num_cols = A->num_cols(); @@ -86,7 +86,7 @@ if (norm_b == 0.0) { xref.setZero(); summary.termination_type = TOLERANCE; - summary.status = "Convergence. |b| = 0."; + summary.message = "Convergence. |b| = 0."; return summary; } @@ -103,7 +103,7 @@ double norm_r = r.norm(); if (norm_r <= tol_r) { summary.termination_type = TOLERANCE; - summary.status = + summary.message = StringPrintf("Convergence. |r| = %e <= %e.", norm_r, tol_r); return summary; } @@ -128,7 +128,7 @@ rho = r.dot(z); if (IsZeroOrInfinity(rho)) { summary.termination_type = FAILURE; - summary.status = StringPrintf("Numerical failure. rho = r'z = %e.", rho); + summary.message = StringPrintf("Numerical failure. rho = r'z = %e.", rho); break; }; @@ -138,7 +138,7 @@ double beta = rho / last_rho; if (IsZeroOrInfinity(beta)) { summary.termination_type = FAILURE; - summary.status = StringPrintf( + summary.message = StringPrintf( "Numerical failure. beta = rho_n / rho_{n-1} = %e.", beta); break; } @@ -151,14 +151,14 @@ const double pq = p.dot(q); if ((pq <= 0) || IsInfinite(pq)) { summary.termination_type = FAILURE; - summary.status = StringPrintf("Numerical failure. p'q = %e.", pq); + summary.message = StringPrintf("Numerical failure. p'q = %e.", pq); break; } const double alpha = rho / pq; if (IsInfinite(alpha)) { summary.termination_type = FAILURE; - summary.status = + summary.message = StringPrintf("Numerical failure. alpha = rho / pq = %e", alpha); break; } @@ -209,7 +209,7 @@ const double zeta = summary.num_iterations * (Q1 - Q0) / Q1; if (zeta < per_solve_options.q_tolerance) { summary.termination_type = TOLERANCE; - summary.status = + summary.message = StringPrintf("Convergence: zeta = %e < %e", zeta, per_solve_options.q_tolerance); @@ -221,7 +221,7 @@ norm_r = r. norm(); if (norm_r <= tol_r) { summary.termination_type = TOLERANCE; - summary.status = + summary.message = StringPrintf("Convergence. |r| = %e <= %e.", norm_r, tol_r); break; }
diff --git a/internal/ceres/corrector.cc b/internal/ceres/corrector.cc index f9deb87..581fc6d 100644 --- a/internal/ceres/corrector.cc +++ b/internal/ceres/corrector.cc
@@ -125,7 +125,7 @@ // The common case (rho[2] <= 0). if (alpha_sq_norm_ == 0.0) { VectorRef(jacobian, num_rows * num_cols) *= sqrt_rho1_; - return; + return; } // Equation 11 in BANS.
diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc index 6c79fa5..1bca3c3 100644 --- a/internal/ceres/covariance_impl.cc +++ b/internal/ceres/covariance_impl.cc
@@ -348,8 +348,8 @@ // values of the parameter blocks. Thus iterating over the keys of // parameter_block_to_row_index_ corresponds to iterating over the // rows of the covariance matrix in order. - int i = 0; // index into covariance_blocks. - int cursor = 0; // index into the covariance matrix. + int i = 0; // index into covariance_blocks. + int cursor = 0; // index into the covariance matrix. for (map<const double*, int>::const_iterator it = parameter_block_to_row_index_.begin(); it != parameter_block_to_row_index_.end(); @@ -393,12 +393,12 @@ bool CovarianceImpl::ComputeCovarianceValues() { switch (options_.algorithm_type) { - case (DENSE_SVD): + case DENSE_SVD: return ComputeCovarianceValuesUsingDenseSVD(); #ifndef CERES_NO_SUITESPARSE - case (SPARSE_CHOLESKY): + case SPARSE_CHOLESKY: return ComputeCovarianceValuesUsingSparseCholesky(); - case (SPARSE_QR): + case SPARSE_QR: return ComputeCovarianceValuesUsingSparseQR(); #endif default:
diff --git a/internal/ceres/cxsparse.cc b/internal/ceres/cxsparse.cc index c6d7743..7145f73 100644 --- a/internal/ceres/cxsparse.cc +++ b/internal/ceres/cxsparse.cc
@@ -175,8 +175,8 @@ cs_di* CXSparse::CreateSparseMatrix(TripletSparseMatrix* tsm) { cs_di_sparse tsm_wrapper; - tsm_wrapper.nzmax = tsm->num_nonzeros();; - tsm_wrapper.nz = tsm->num_nonzeros();; + tsm_wrapper.nzmax = tsm->num_nonzeros(); + tsm_wrapper.nz = tsm->num_nonzeros(); tsm_wrapper.m = tsm->num_rows(); tsm_wrapper.n = tsm->num_cols(); tsm_wrapper.p = tsm->mutable_cols();
diff --git a/internal/ceres/dense_normal_cholesky_solver.cc b/internal/ceres/dense_normal_cholesky_solver.cc index e0fe86e..b719c94 100644 --- a/internal/ceres/dense_normal_cholesky_solver.cc +++ b/internal/ceres/dense_normal_cholesky_solver.cc
@@ -96,14 +96,15 @@ LinearSolver::Summary summary; summary.num_iterations = 1; summary.termination_type = TOLERANCE; - Eigen::LLT<Matrix, Eigen::Upper> llt = lhs.selfadjointView<Eigen::Upper>().llt(); + Eigen::LLT<Matrix, Eigen::Upper> llt = + lhs.selfadjointView<Eigen::Upper>().llt(); if (llt.info() != Eigen::Success) { summary.termination_type = FAILURE; - summary.status = "Eigen LLT decomposition failed."; + summary.message = "Eigen LLT decomposition failed."; } else { summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; } VectorRef(x, num_cols) = llt.solve(rhs); @@ -153,10 +154,11 @@ LinearSolver::Summary summary; summary.num_iterations = 1; - summary.termination_type = LAPACK::SolveInPlaceUsingCholesky(num_cols, - lhs.data(), - x, - &summary.status); + summary.termination_type = + LAPACK::SolveInPlaceUsingCholesky(num_cols, + lhs.data(), + x, + &summary.message); event_logger.AddEvent("Solve"); return summary; }
diff --git a/internal/ceres/dense_qr_solver.cc b/internal/ceres/dense_qr_solver.cc index fcc87d2..f8927ae 100644 --- a/internal/ceres/dense_qr_solver.cc +++ b/internal/ceres/dense_qr_solver.cc
@@ -109,7 +109,7 @@ work_.rows(), work_.data(), rhs_.data(), - &summary.status); + &summary.message); event_logger.AddEvent("Solve"); if (summary.termination_type == TOLERANCE) { VectorRef(x, num_cols) = rhs_.head(num_cols); @@ -160,7 +160,7 @@ LinearSolver::Summary summary; summary.num_iterations = 1; summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; event_logger.AddEvent("TearDown"); return summary;
diff --git a/internal/ceres/iterative_schur_complement_solver.cc b/internal/ceres/iterative_schur_complement_solver.cc index 4777d02..c4c77af 100644 --- a/internal/ceres/iterative_schur_complement_solver.cc +++ b/internal/ceres/iterative_schur_complement_solver.cc
@@ -160,8 +160,8 @@ cg_summary.termination_type = FAILURE; // TODO(sameeragarwal): Refactor preconditioners to return a more - // sane status. - cg_summary.status = "Preconditioner update failed."; + // sane message. + cg_summary.message = "Preconditioner update failed."; if (preconditioner_update_was_successful) { cg_summary = cg_solver.Solve(schur_complement_.get(), schur_complement_->rhs().data(),
diff --git a/internal/ceres/line_search.cc b/internal/ceres/line_search.cc index c62cda7..77d1369 100644 --- a/internal/ceres/line_search.cc +++ b/internal/ceres/line_search.cc
@@ -29,8 +29,8 @@ // Author: sameeragarwal@google.com (Sameer Agarwal) #ifndef CERES_NO_LINE_SEARCH_MINIMIZER -#include <iomanip> // For std::setprecision. -#include <iostream> // For std::scientific. +#include <iomanip> +#include <iostream> // NOLINT #include "ceres/line_search.h" @@ -500,7 +500,8 @@ *do_zoom_search = true; *bracket_low = previous; *bracket_high = current; - VLOG(3) << std::scientific << std::setprecision(kErrorMessageNumericPrecision) + VLOG(3) << std::scientific + << std::setprecision(kErrorMessageNumericPrecision) << "Bracket found: current step (" << current.x << ") violates Armijo sufficient condition, or has passed an " << "inflection point of f() based on value."; @@ -514,7 +515,8 @@ // valid termination point, therefore a Zoom not required. *bracket_low = current; *bracket_high = current; - VLOG(3) << std::scientific << std::setprecision(kErrorMessageNumericPrecision) + VLOG(3) << std::scientific + << std::setprecision(kErrorMessageNumericPrecision) << "Bracketing phase found step size: " << current.x << ", satisfying strong Wolfe conditions, initial_position: " << initial_position << ", current: " << current; @@ -796,7 +798,8 @@ if (fabs(solution->gradient) <= -options().sufficient_curvature_decrease * initial_position.gradient) { // Found a valid termination point satisfying strong Wolfe conditions. - VLOG(3) << std::scientific << std::setprecision(kErrorMessageNumericPrecision) + VLOG(3) << std::scientific + << std::setprecision(kErrorMessageNumericPrecision) << "Zoom phase found step size: " << solution->x << ", satisfying strong Wolfe conditions."; break;
diff --git a/internal/ceres/line_search_direction.cc b/internal/ceres/line_search_direction.cc index 0230e8d..a865f11 100644 --- a/internal/ceres/line_search_direction.cc +++ b/internal/ceres/line_search_direction.cc
@@ -208,7 +208,8 @@ // // [1] Nocedal J, Wright S, Numerical Optimization, 2nd Ed. Springer, 1999. // - // TODO: Consider using Damped BFGS update instead of skipping update. + // TODO(alexs.mac): Consider using Damped BFGS update instead of + // skipping update. const double kBFGSSecantConditionHessianUpdateTolerance = 1e-14; if (delta_x_dot_delta_gradient <= kBFGSSecantConditionHessianUpdateTolerance) {
diff --git a/internal/ceres/linear_solver.h b/internal/ceres/linear_solver.h index fb50d7e..fa151e0 100644 --- a/internal/ceres/linear_solver.h +++ b/internal/ceres/linear_solver.h
@@ -273,7 +273,7 @@ double residual_norm; int num_iterations; LinearSolverTerminationType termination_type; - string status; + string message; }; virtual ~LinearSolver();
diff --git a/internal/ceres/low_rank_inverse_hessian.cc b/internal/ceres/low_rank_inverse_hessian.cc index 16d84c6..9aeafec 100644 --- a/internal/ceres/low_rank_inverse_hessian.cc +++ b/internal/ceres/low_rank_inverse_hessian.cc
@@ -66,7 +66,8 @@ // // [1] Nocedal J., Wright S., Numerical Optimization, 2nd Ed. Springer, 1999. // -// TODO: Consider using Damped BFGS update instead of skipping update. +// TODO(alexs.mac): Consider using Damped BFGS update instead of +// skipping update. const double kLBFGSSecantConditionHessianUpdateTolerance = 1e-14; LowRankInverseHessian::LowRankInverseHessian(
diff --git a/internal/ceres/problem_impl.cc b/internal/ceres/problem_impl.cc index 4197d59..ae87fcb 100644 --- a/internal/ceres/problem_impl.cc +++ b/internal/ceres/problem_impl.cc
@@ -762,7 +762,8 @@ if (options_.enable_fast_parameter_block_removal) { // In this case the residual blocks that depend on the parameter block are // stored in the parameter block already, so just copy them out. - CHECK_NOTNULL(residual_blocks)->resize(parameter_block->mutable_residual_blocks()->size()); + CHECK_NOTNULL(residual_blocks)->resize( + parameter_block->mutable_residual_blocks()->size()); std::copy(parameter_block->mutable_residual_blocks()->begin(), parameter_block->mutable_residual_blocks()->end(), residual_blocks->begin());
diff --git a/internal/ceres/schur_complement_solver.cc b/internal/ceres/schur_complement_solver.cc index ff51ab2..9bf9d9d 100644 --- a/internal/ceres/schur_complement_solver.cc +++ b/internal/ceres/schur_complement_solver.cc
@@ -117,7 +117,7 @@ LinearSolver::Summary summary; summary.num_iterations = 0; summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; const BlockRandomAccessDenseMatrix* m = down_cast<const BlockRandomAccessDenseMatrix*>(lhs()); @@ -138,7 +138,7 @@ .llt(); if (llt.info() != Eigen::Success) { summary.termination_type = FAILURE; - summary.status = "Eigen LLT decomposition failed."; + summary.message = "Eigen LLT decomposition failed."; return summary; } @@ -149,7 +149,7 @@ LAPACK::SolveInPlaceUsingCholesky(num_rows, m->values(), solution, - &summary.status); + &summary.message); } return summary; @@ -276,7 +276,7 @@ LinearSolver::Summary summary; summary.num_iterations = 0; summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; TripletSparseMatrix* tsm = const_cast<TripletSparseMatrix*>( @@ -305,7 +305,7 @@ factor_ = ss_.BlockAnalyzeCholesky(cholmod_lhs, blocks_, blocks_, - &summary.status); + &summary.message); } } else { // If we are going to use the natural ordering (i.e. rely on the @@ -319,7 +319,7 @@ if (factor_ == NULL) { factor_ = ss_.AnalyzeCholeskyWithNaturalOrdering(cholmod_lhs, - &summary.status); + &summary.message); } } @@ -330,7 +330,7 @@ } summary.termination_type = - ss_.Cholesky(cholmod_lhs, factor_, &summary.status); + ss_.Cholesky(cholmod_lhs, factor_, &summary.message); if (summary.termination_type != TOLERANCE) { return summary; } @@ -339,7 +339,7 @@ ss_.CreateDenseVector(const_cast<double*>(rhs()), num_rows, num_rows); cholmod_dense* cholmod_solution = ss_.Solve(factor_, cholmod_rhs, - &summary.status); + &summary.message); ss_.Free(cholmod_lhs); ss_.Free(cholmod_rhs); @@ -372,7 +372,7 @@ LinearSolver::Summary summary; summary.num_iterations = 0; summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; // Extract the TripletSparseMatrix that is used for actually storing S. TripletSparseMatrix* tsm = @@ -396,10 +396,11 @@ if (cxsparse_factor_ == NULL) { summary.termination_type = FATAL_ERROR; - summary.status = "CXSparse failure. Unable to find symbolic factorization."; + summary.message = + "CXSparse failure. Unable to find symbolic factorization."; } else if (!cxsparse_.SolveCholesky(lhs, cxsparse_factor_, solution)) { summary.termination_type = FAILURE; - summary.status = "CXSparse::SolveCholesky failed."; + summary.message = "CXSparse::SolveCholesky failed."; } cxsparse_.Free(lhs);
diff --git a/internal/ceres/sparse_normal_cholesky_solver.cc b/internal/ceres/sparse_normal_cholesky_solver.cc index 2d03c44..ceeb654 100644 --- a/internal/ceres/sparse_normal_cholesky_solver.cc +++ b/internal/ceres/sparse_normal_cholesky_solver.cc
@@ -103,7 +103,7 @@ LinearSolver::Summary summary; summary.num_iterations = 1; summary.termination_type = TOLERANCE; - summary.status = "Success."; + summary.message = "Success."; const int num_cols = A->num_cols(); Vector Atb = Vector::Zero(num_cols); @@ -151,7 +151,8 @@ if (cxsparse_factor_ == NULL) { summary.termination_type = FATAL_ERROR; - summary.status = "CXSparse failure. Unable to find symbolic factorization."; + summary.message = + "CXSparse failure. Unable to find symbolic factorization."; } else if (cxsparse_.SolveCholesky(AtA, cxsparse_factor_, Atb.data())) { VectorRef(x, Atb.rows()) = Atb; } else { @@ -186,7 +187,7 @@ LinearSolver::Summary summary; summary.termination_type = TOLERANCE; summary.num_iterations = 1; - summary.status = "Success."; + summary.message = "Success."; const int num_cols = A->num_cols(); Vector Atb = Vector::Zero(num_cols); @@ -208,9 +209,9 @@ factor_ = ss_.BlockAnalyzeCholesky(&lhs, A->col_blocks(), A->row_blocks(), - &summary.status); + &summary.message); } else { - factor_ = ss_.AnalyzeCholeskyWithNaturalOrdering(&lhs, &summary.status); + factor_ = ss_.AnalyzeCholeskyWithNaturalOrdering(&lhs, &summary.message); } } event_logger.AddEvent("Analysis"); @@ -223,7 +224,7 @@ return summary; } - summary.termination_type = ss_.Cholesky(&lhs, factor_, &summary.status); + summary.termination_type = ss_.Cholesky(&lhs, factor_, &summary.message); if (summary.termination_type != TOLERANCE) { if (per_solve_options.D != NULL) { A->DeleteRows(num_cols); @@ -232,7 +233,7 @@ } cholmod_dense* rhs = ss_.CreateDenseVector(Atb.data(), num_cols, num_cols); - cholmod_dense* sol = ss_.Solve(factor_, rhs, &summary.status); + cholmod_dense* sol = ss_.Solve(factor_, rhs, &summary.message); event_logger.AddEvent("Solve"); ss_.Free(rhs);
diff --git a/internal/ceres/stringprintf.cc b/internal/ceres/stringprintf.cc index ce20467..eabdcb6 100644 --- a/internal/ceres/stringprintf.cc +++ b/internal/ceres/stringprintf.cc
@@ -43,7 +43,7 @@ #ifdef _MSC_VER enum { IS_COMPILER_MSVC = 1 }; -#define va_copy(d,s) ((d) = (s)) +#define va_copy(d, s) ((d) = (s)) #else enum { IS_COMPILER_MSVC = 0 }; #endif
diff --git a/internal/ceres/suitesparse.cc b/internal/ceres/suitesparse.cc index 399b4ae..69a07ce 100644 --- a/internal/ceres/suitesparse.cc +++ b/internal/ceres/suitesparse.cc
@@ -137,7 +137,8 @@ } if (cc_.status != CHOLMOD_OK) { - *status = StringPrintf("cholmod_analyze failed. error code: %d", cc_.status); + *status = StringPrintf("cholmod_analyze failed. error code: %d", + cc_.status); return NULL; } @@ -171,7 +172,8 @@ cholmod_print_common(const_cast<char*>("Symbolic Analysis"), &cc_); } if (cc_.status != CHOLMOD_OK) { - *status = StringPrintf("cholmod_analyze failed. error code: %d", cc_.status); + *status = StringPrintf("cholmod_analyze failed. error code: %d", + cc_.status); return NULL; } @@ -190,7 +192,8 @@ cholmod_print_common(const_cast<char*>("Symbolic Analysis"), &cc_); } if (cc_.status != CHOLMOD_OK) { - *status = StringPrintf("cholmod_analyze failed. error code: %d", cc_.status); + *status = StringPrintf("cholmod_analyze failed. error code: %d", + cc_.status); return NULL; }
diff --git a/internal/ceres/visibility_based_preconditioner.cc b/internal/ceres/visibility_based_preconditioner.cc index e0737f2..13fe27b 100644 --- a/internal/ceres/visibility_based_preconditioner.cc +++ b/internal/ceres/visibility_based_preconditioner.cc
@@ -460,7 +460,8 @@ memcpy(CHECK_NOTNULL(tmp_rhs_)->x, x, m_->num_rows() * sizeof(*x)); // TODO(sameeragarwal): Better error handling. string status; - cholmod_dense* solution = CHECK_NOTNULL(ss->Solve(factor_, tmp_rhs_, &status)); + cholmod_dense* solution = + CHECK_NOTNULL(ss->Solve(factor_, tmp_rhs_, &status)); memcpy(y, solution->x, sizeof(*y) * num_rows); ss->Free(solution); }