From 39388bd2ffc3dac63e80e713890f7ea48ad7d223 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Tue, 9 May 2017 17:23:43 -0700 Subject: [PATCH] Address comments from William Rucklidge Change-Id: I0c4f686b89798435741c55a5ca45cf000af842dc --- include/ceres/dynamic_cost_function_to_functor.h | 3 ++- internal/ceres/sparse_normal_cholesky_solver.cc | 4 ++-- internal/ceres/triplet_sparse_matrix.cc | 5 ++--- internal/ceres/visibility_based_preconditioner.cc | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/ceres/dynamic_cost_function_to_functor.h b/include/ceres/dynamic_cost_function_to_functor.h index 2c650596e..10bc99aaa 100644 --- a/include/ceres/dynamic_cost_function_to_functor.h +++ b/include/ceres/dynamic_cost_function_to_functor.h @@ -116,7 +116,8 @@ class DynamicCostFunctionToFunctor { bool operator()(JetT const* const* inputs, JetT* output) const { const std::vector& parameter_block_sizes = cost_function_->parameter_block_sizes(); - const int num_parameter_blocks = static_cast(parameter_block_sizes.size()); + const int num_parameter_blocks = + static_cast(parameter_block_sizes.size()); const int num_residuals = cost_function_->num_residuals(); const int num_parameters = std::accumulate(parameter_block_sizes.begin(), parameter_block_sizes.end(), 0); diff --git a/internal/ceres/sparse_normal_cholesky_solver.cc b/internal/ceres/sparse_normal_cholesky_solver.cc index 9c725ffd4..557ebd852 100644 --- a/internal/ceres/sparse_normal_cholesky_solver.cc +++ b/internal/ceres/sparse_normal_cholesky_solver.cc @@ -359,11 +359,11 @@ LinearSolver::Summary SparseNormalCholeskySolver::SolveImplUsingSuiteSparse( summary.num_iterations = 1; summary.message = "Success."; - // Map outer_product_ to an lower triangular column major matrix. + // Map outer_product_ to a lower triangular column major matrix. // // outer_product_ is a compressed row sparse matrix and in upper // triangular form, when mapped to a compressed column sparse - // matrix, it becomes an lower triangular matrix. + // matrix, it becomes a lower triangular matrix. const int num_cols = outer_product_->num_cols(); cholmod_sparse lhs = ss_.CreateSparseMatrixTransposeView(outer_product_.get()); diff --git a/internal/ceres/triplet_sparse_matrix.cc b/internal/ceres/triplet_sparse_matrix.cc index a7df060ea..cd19444b0 100644 --- a/internal/ceres/triplet_sparse_matrix.cc +++ b/internal/ceres/triplet_sparse_matrix.cc @@ -85,6 +85,8 @@ TripletSparseMatrix::TripletSparseMatrix(const int num_rows, // All the sizes should at least be zero CHECK_GE(num_rows, 0); CHECK_GE(num_cols, 0); + CHECK_EQ(rows.size(), cols.size()); + CHECK_EQ(rows.size(), values.size()); AllocateMemory(); std::copy(rows.begin(), rows.end(), rows_.get()); std::copy(cols.begin(), cols.end(), cols_.get()); @@ -305,9 +307,6 @@ TripletSparseMatrix* TripletSparseMatrix::CreateRandomMatrix( } } } - if (!rows.empty()) { - break; - } } return new TripletSparseMatrix( diff --git a/internal/ceres/visibility_based_preconditioner.cc b/internal/ceres/visibility_based_preconditioner.cc index 429626af3..7e1ac67b9 100644 --- a/internal/ceres/visibility_based_preconditioner.cc +++ b/internal/ceres/visibility_based_preconditioner.cc @@ -342,7 +342,8 @@ void VisibilityBasedPreconditioner::InitEliminator( eliminator_options.row_block_size = options_.row_block_size; eliminator_.reset(SchurEliminatorBase::Create(eliminator_options)); const bool kFullRankETE = true; - eliminator_->Init(eliminator_options.elimination_groups[0], kFullRankETE, &bs); + eliminator_->Init( + eliminator_options.elimination_groups[0], kFullRankETE, &bs); } // Update the values of the preconditioner matrix and factorize it.