ClangTidy fixes #2
Change-Id: Ib3baa62248342276d63b900b45561323fd81402d
diff --git a/examples/circle_fit.cc b/examples/circle_fit.cc
index 7605604..6f08d3f 100644
--- a/examples/circle_fit.cc
+++ b/examples/circle_fit.cc
@@ -53,7 +53,6 @@
#include <cmath>
#include <cstdio>
#include <iostream>
-#include <vector>
#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 b270e28..fe71955 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 <fstream>
+#include <functional>
+#include <istream>
#include <map>
#include <string>
+#include <vector>
#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 e437417..8e57601 100644
--- a/include/ceres/internal/autodiff.h
+++ b/include/ceres/internal/autodiff.h
@@ -141,14 +141,11 @@
#define CERES_PUBLIC_INTERNAL_AUTODIFF_H_
#include <array>
-#include <cstddef>
#include <utility>
+#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 7c1b65d..68193c9 100644
--- a/include/ceres/internal/fixed_array.h
+++ b/include/ceres/internal/fixed_array.h
@@ -32,8 +32,10 @@
#include <Eigen/Core> // For Eigen::aligned_allocator
#include <algorithm>
-#include <array>
#include <cstddef>
+#include <initializer_list>
+#include <iterator>
+#include <limits>
#include <memory>
#include <tuple>
#include <type_traits>
diff --git a/internal/ceres/bundle_adjustment_test_util.h b/internal/ceres/bundle_adjustment_test_util.h
index 0b2b8fb..57f5ab6 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 <cmath>
#include <cstdio>
-#include <cstdlib>
+#include <memory>
#include <string>
#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 @@
// 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 @@
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 @@
double* parameters_;
};
-double BundleAdjustmentProblem::kResidualTolerance = 1e-4;
using BundleAdjustmentTest = SystemTest<BundleAdjustmentProblem>;
} // namespace internal
diff --git a/internal/ceres/covariance_test.cc b/internal/ceres/covariance_test.cc
index 024d302..77aca2e 100644
--- a/internal/ceres/covariance_test.cc
+++ b/internal/ceres/covariance_test.cc
@@ -32,6 +32,7 @@
#include <algorithm>
#include <cstdint>
+#include <limits>
#include <map>
#include <memory>
#include <utility>
@@ -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 4daa595..a8532d0 100644
--- a/internal/ceres/cuda_streamed_buffer.h
+++ b/internal/ceres/cuda_streamed_buffer.h
@@ -319,10 +319,10 @@
// 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 6f5b7f2..ac5075a 100644
--- a/internal/ceres/dense_cholesky_test.cc
+++ b/internal/ceres/dense_cholesky_test.cc
@@ -36,6 +36,7 @@
#include <string>
#include <utility>
+#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 d5c2c69..1825b36 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 <cmath>
#include <cstdlib>
+#include <limits>
#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 e002a4b..7119973 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 <map>
+#include <limits>
+#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 788e865..019d648 100644
--- a/internal/ceres/manifold_test.cc
+++ b/internal/ceres/manifold_test.cc
@@ -35,14 +35,13 @@
#include <memory>
#include <utility>
+#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 c9cc29c..ea349dc 100644
--- a/internal/ceres/parallel_invoke.h
+++ b/internal/ceres/parallel_invoke.h
@@ -240,7 +240,7 @@
// * 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 b1f6b86..138e4aa 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 <set>
+#include <utility>
+
#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 54dd073..e51e0ca 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 <array>
#include <type_traits>
#include <utility>
diff --git a/internal/ceres/reorder_program_test.cc b/internal/ceres/reorder_program_test.cc
index a8db314..0e1fa05 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 <algorithm>
+#include <memory>
#include <random>
+#include <string>
+#include <unordered_set>
#include <vector>
#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 20fedf6..f862ff7 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 586febe..18a6342 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 <limits>
#include <memory>
-#include <numeric>
#include <random>
+#include <sstream>
+#include <utility>
#include <vector>
+#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 092df5a..3b61997 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 53c4451..12e178c 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 <cmath>
-#include <cstdlib>
-
#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 @@
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 @@
Solver::Options options_;
};
-double PowellsFunction::kResidualTolerance = 1e-8;
-
using PowellTest = SystemTest<PowellsFunction>;
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 c192cf3..ff55e82 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 <algorithm>
-#include <cmath>
#include <limits>
+#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 638d873..e2c2755 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 <algorithm>
-#include <cmath>
+#include <limits>
#include <memory>
+#include "Eigen/Core"
#include "ceres/cost_function.h"
#include "ceres/sized_cost_function.h"
#include "gtest/gtest.h"