From 3c4f012606b95ca17d44b06c8a6ecfc794e47001 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Sun, 21 Jul 2024 20:31:32 -0700 Subject: [PATCH] ClangTidy fixes #2 Change-Id: Ib3baa62248342276d63b900b45561323fd81402d --- examples/circle_fit.cc | 1 - examples/slam/common/read_g2o.h | 3 +++ include/ceres/internal/autodiff.h | 5 +---- include/ceres/internal/fixed_array.h | 4 +++- internal/ceres/bundle_adjustment_test_util.h | 9 +++------ internal/ceres/covariance_test.cc | 2 ++ internal/ceres/cuda_streamed_buffer.h | 8 ++++---- internal/ceres/dense_cholesky_test.cc | 1 + internal/ceres/line_search_minimizer_test.cc | 2 +- internal/ceres/line_search_preprocessor_test.cc | 4 +++- internal/ceres/manifold_test.cc | 3 +-- internal/ceres/parallel_invoke.h | 2 +- internal/ceres/parallel_utils_test.cc | 3 +++ internal/ceres/parameter_dims_test.cc | 1 + internal/ceres/reorder_program_test.cc | 7 +++++++ internal/ceres/small_blas.h | 1 + internal/ceres/sparse_cholesky_test.cc | 9 +++++++-- internal/ceres/spmv_benchmark.cc | 1 - internal/ceres/system_test.cc | 8 ++------ internal/ceres/tiny_solver_autodiff_function_test.cc | 3 +-- internal/ceres/tiny_solver_cost_function_adapter_test.cc | 4 ++-- 21 files changed, 47 insertions(+), 34 deletions(-) diff --git a/examples/circle_fit.cc b/examples/circle_fit.cc index 7605604c7..6f08d3fa6 100644 --- a/examples/circle_fit.cc +++ b/examples/circle_fit.cc @@ -53,7 +53,6 @@ #include #include #include -#include #include "absl/flags/flag.h" #include "absl/flags/parse.h" diff --git a/examples/slam/common/read_g2o.h b/examples/slam/common/read_g2o.h index b270e2841..fe71955f8 100644 --- a/examples/slam/common/read_g2o.h +++ b/examples/slam/common/read_g2o.h @@ -34,8 +34,11 @@ #define EXAMPLES_CERES_READ_G2O_H_ #include +#include +#include #include #include +#include #include "absl/log/check.h" #include "absl/log/log.h" diff --git a/include/ceres/internal/autodiff.h b/include/ceres/internal/autodiff.h index e43741780..8e576016f 100644 --- a/include/ceres/internal/autodiff.h +++ b/include/ceres/internal/autodiff.h @@ -141,14 +141,11 @@ #define CERES_PUBLIC_INTERNAL_AUTODIFF_H_ #include -#include #include +#include "Eigen/Core" #include "absl/log/check.h" #include "ceres/internal/array_selector.h" -#include "ceres/internal/eigen.h" -#include "ceres/internal/fixed_array.h" -#include "ceres/internal/parameter_dims.h" #include "ceres/internal/variadic_evaluate.h" #include "ceres/jet.h" #include "ceres/types.h" diff --git a/include/ceres/internal/fixed_array.h b/include/ceres/internal/fixed_array.h index 7c1b65d4e..68193c978 100644 --- a/include/ceres/internal/fixed_array.h +++ b/include/ceres/internal/fixed_array.h @@ -32,8 +32,10 @@ #include // For Eigen::aligned_allocator #include -#include #include +#include +#include +#include #include #include #include diff --git a/internal/ceres/bundle_adjustment_test_util.h b/internal/ceres/bundle_adjustment_test_util.h index 0b2b8fb49..57f5ab6ec 100644 --- a/internal/ceres/bundle_adjustment_test_util.h +++ b/internal/ceres/bundle_adjustment_test_util.h @@ -32,9 +32,8 @@ // the generated bundle adjustment test binaries. The reason to split the // bundle tests into separate binaries is so the tests can get parallelized. -#include #include -#include +#include #include #include "absl/log/log.h" @@ -44,7 +43,6 @@ #include "ceres/problem.h" #include "ceres/rotation.h" #include "ceres/solver.h" -#include "ceres/stringprintf.h" #include "ceres/test_util.h" #include "ceres/types.h" @@ -60,7 +58,7 @@ const bool kUserOrdering = false; // problem is hard coded in the constructor. class BundleAdjustmentProblem { public: - BundleAdjustmentProblem(const std::string input_file) { + explicit BundleAdjustmentProblem(const std::string input_file) { ReadData(input_file); BuildProblem(); } @@ -93,7 +91,7 @@ class BundleAdjustmentProblem { const Solver::Options& options() const { return options_; } // clang-format on - static double kResidualTolerance; + static constexpr double kResidualTolerance = 1e-4; private: void ReadData(const std::string& filename) { @@ -242,7 +240,6 @@ class BundleAdjustmentProblem { double* parameters_; }; -double BundleAdjustmentProblem::kResidualTolerance = 1e-4; using BundleAdjustmentTest = SystemTest; } // namespace internal diff --git a/internal/ceres/covariance_test.cc b/internal/ceres/covariance_test.cc index 024d30231..77aca2e84 100644 --- a/internal/ceres/covariance_test.cc +++ b/internal/ceres/covariance_test.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include "ceres/manifold.h" #include "ceres/map_util.h" #include "ceres/problem_impl.h" +#include "ceres/types.h" #include "gtest/gtest.h" namespace ceres { diff --git a/internal/ceres/cuda_streamed_buffer.h b/internal/ceres/cuda_streamed_buffer.h index 4daa59518..a8532d036 100644 --- a/internal/ceres/cuda_streamed_buffer.h +++ b/internal/ceres/cuda_streamed_buffer.h @@ -319,10 +319,10 @@ class CERES_NO_EXPORT CudaStreamedBuffer { // This class only supports cpu memory as a source CHECK_NE(attributes.type, cudaMemoryTypeDevice); // If host memory was allocated (or registered) with CUDA API, or is a - // managed memory, then call to cudaMemcpyAsync will be asynchrnous. In case - // of managed memory it might be slightly better to perform a single call of - // user-provided call-back (and hope that page migration will provide a - // similar throughput with zero efforts from our side). + // managed memory, then call to cudaMemcpyAsync will be asynchronous. In + // case of managed memory it might be slightly better to perform a single + // call of user-provided call-back (and hope that page migration will + // provide a similar throughput with zero efforts from our side). return attributes.type == cudaMemoryTypeUnregistered; } diff --git a/internal/ceres/dense_cholesky_test.cc b/internal/ceres/dense_cholesky_test.cc index 6f5b7f24b..ac5075a66 100644 --- a/internal/ceres/dense_cholesky_test.cc +++ b/internal/ceres/dense_cholesky_test.cc @@ -36,6 +36,7 @@ #include #include +#include "Eigen/Core" #include "Eigen/Dense" #include "ceres/context_impl.h" #include "ceres/internal/config.h" diff --git a/internal/ceres/line_search_minimizer_test.cc b/internal/ceres/line_search_minimizer_test.cc index d5c2c692f..1825b367b 100644 --- a/internal/ceres/line_search_minimizer_test.cc +++ b/internal/ceres/line_search_minimizer_test.cc @@ -28,8 +28,8 @@ // // Author: sameeragarwal@google.com (Sameer Agarwal) -#include #include +#include #include "ceres/ceres.h" #include "gtest/gtest.h" diff --git a/internal/ceres/line_search_preprocessor_test.cc b/internal/ceres/line_search_preprocessor_test.cc index e002a4b0f..711997303 100644 --- a/internal/ceres/line_search_preprocessor_test.cc +++ b/internal/ceres/line_search_preprocessor_test.cc @@ -30,11 +30,13 @@ #include "ceres/line_search_preprocessor.h" -#include +#include +#include "ceres/preprocessor.h" #include "ceres/problem_impl.h" #include "ceres/sized_cost_function.h" #include "ceres/solver.h" +#include "ceres/types.h" #include "gtest/gtest.h" namespace ceres::internal { diff --git a/internal/ceres/manifold_test.cc b/internal/ceres/manifold_test.cc index 788e86570..019d648bb 100644 --- a/internal/ceres/manifold_test.cc +++ b/internal/ceres/manifold_test.cc @@ -35,14 +35,13 @@ #include #include +#include "Eigen/Core" #include "Eigen/Geometry" #include "ceres/constants.h" -#include "ceres/dynamic_numeric_diff_cost_function.h" #include "ceres/internal/eigen.h" #include "ceres/internal/port.h" #include "ceres/line_manifold.h" #include "ceres/manifold_test_utils.h" -#include "ceres/numeric_diff_options.h" #include "ceres/product_manifold.h" #include "ceres/rotation.h" #include "ceres/sphere_manifold.h" diff --git a/internal/ceres/parallel_invoke.h b/internal/ceres/parallel_invoke.h index c9cc29c9e..ea349dc94 100644 --- a/internal/ceres/parallel_invoke.h +++ b/internal/ceres/parallel_invoke.h @@ -240,7 +240,7 @@ void ParallelInvoke(ContextImpl* context, // * Total length of preceding blocks of size base_block_size + 1: // min(block_id, num_base_p1_sized_blocks) * (base_block_size + 1) // - // * Total length of preceeding blocks of size base_block_size: + // * Total length of preceding blocks of size base_block_size: // (block_id - min(block_id, num_base_p1_sized_blocks)) * // base_block_size // diff --git a/internal/ceres/parallel_utils_test.cc b/internal/ceres/parallel_utils_test.cc index b1f6b8665..138e4aa4b 100644 --- a/internal/ceres/parallel_utils_test.cc +++ b/internal/ceres/parallel_utils_test.cc @@ -30,6 +30,9 @@ #include "ceres/parallel_utils.h" +#include +#include + #include "ceres/internal/config.h" #include "gtest/gtest.h" diff --git a/internal/ceres/parameter_dims_test.cc b/internal/ceres/parameter_dims_test.cc index 54dd073ba..e51e0caed 100644 --- a/internal/ceres/parameter_dims_test.cc +++ b/internal/ceres/parameter_dims_test.cc @@ -24,6 +24,7 @@ #include "ceres/internal/parameter_dims.h" +#include #include #include diff --git a/internal/ceres/reorder_program_test.cc b/internal/ceres/reorder_program_test.cc index a8db314a4..0e1fa0558 100644 --- a/internal/ceres/reorder_program_test.cc +++ b/internal/ceres/reorder_program_test.cc @@ -30,15 +30,22 @@ #include "ceres/reorder_program.h" +#include +#include #include +#include +#include #include #include "ceres/internal/config.h" +#include "ceres/ordered_groups.h" #include "ceres/parameter_block.h" +#include "ceres/problem.h" #include "ceres/problem_impl.h" #include "ceres/program.h" #include "ceres/sized_cost_function.h" #include "ceres/solver.h" +#include "ceres/types.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/internal/ceres/small_blas.h b/internal/ceres/small_blas.h index 20fedf6d2..f862ff72c 100644 --- a/internal/ceres/small_blas.h +++ b/internal/ceres/small_blas.h @@ -35,6 +35,7 @@ #ifndef CERES_INTERNAL_SMALL_BLAS_H_ #define CERES_INTERNAL_SMALL_BLAS_H_ +#include "Eigen/Core" #include "absl/log/check.h" #include "ceres/internal/eigen.h" #include "ceres/internal/export.h" diff --git a/internal/ceres/sparse_cholesky_test.cc b/internal/ceres/sparse_cholesky_test.cc index 586febe5b..18a634219 100644 --- a/internal/ceres/sparse_cholesky_test.cc +++ b/internal/ceres/sparse_cholesky_test.cc @@ -30,13 +30,16 @@ #include "ceres/sparse_cholesky.h" +#include #include -#include #include +#include +#include #include +#include "Eigen/Cholesky" +#include "Eigen/Core" #include "Eigen/Dense" -#include "Eigen/SparseCore" #include "absl/log/check.h" #include "ceres/block_sparse_matrix.h" #include "ceres/compressed_row_sparse_matrix.h" @@ -45,6 +48,8 @@ #include "ceres/internal/config.h" #include "ceres/internal/eigen.h" #include "ceres/iterative_refiner.h" +#include "ceres/linear_solver.h" +#include "ceres/types.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/internal/ceres/spmv_benchmark.cc b/internal/ceres/spmv_benchmark.cc index 092df5ae0..3b619979f 100644 --- a/internal/ceres/spmv_benchmark.cc +++ b/internal/ceres/spmv_benchmark.cc @@ -43,7 +43,6 @@ #include "ceres/fake_bundle_adjustment_jacobian.h" #include "ceres/internal/config.h" #include "ceres/internal/eigen.h" -#include "ceres/linear_solver.h" #ifndef CERES_NO_CUDA #include "cuda_runtime.h" diff --git a/internal/ceres/system_test.cc b/internal/ceres/system_test.cc index 53c44519f..12e178cb1 100644 --- a/internal/ceres/system_test.cc +++ b/internal/ceres/system_test.cc @@ -31,11 +31,9 @@ // // End-to-end tests for Ceres using Powell's function. -#include -#include - #include "ceres/autodiff_cost_function.h" #include "ceres/internal/config.h" +#include "ceres/jet.h" #include "ceres/problem.h" #include "ceres/solver.h" #include "ceres/test_util.h" @@ -86,7 +84,7 @@ class PowellsFunction { Problem* mutable_problem() { return &problem_; } Solver::Options* mutable_solver_options() { return &options_; } - static double kResidualTolerance; + static constexpr double kResidualTolerance = 1e-8; private: // Templated functions used for automatically differentiated cost @@ -136,8 +134,6 @@ class PowellsFunction { Solver::Options options_; }; -double PowellsFunction::kResidualTolerance = 1e-8; - using PowellTest = SystemTest; TEST_F(PowellTest, DenseQR) { diff --git a/internal/ceres/tiny_solver_autodiff_function_test.cc b/internal/ceres/tiny_solver_autodiff_function_test.cc index c192cf334..ff55e82da 100644 --- a/internal/ceres/tiny_solver_autodiff_function_test.cc +++ b/internal/ceres/tiny_solver_autodiff_function_test.cc @@ -31,10 +31,9 @@ #include "ceres/tiny_solver_autodiff_function.h" -#include -#include #include +#include "Eigen/Core" #include "ceres/tiny_solver.h" #include "ceres/tiny_solver_test_util.h" #include "gtest/gtest.h" diff --git a/internal/ceres/tiny_solver_cost_function_adapter_test.cc b/internal/ceres/tiny_solver_cost_function_adapter_test.cc index 638d87322..e2c275516 100644 --- a/internal/ceres/tiny_solver_cost_function_adapter_test.cc +++ b/internal/ceres/tiny_solver_cost_function_adapter_test.cc @@ -30,10 +30,10 @@ #include "ceres/tiny_solver_cost_function_adapter.h" -#include -#include +#include #include +#include "Eigen/Core" #include "ceres/cost_function.h" #include "ceres/sized_cost_function.h" #include "gtest/gtest.h"