A bunch of clang-tidy fixes. Change-Id: I1442d69eb9be91a8c368187848d65196273e3de6
diff --git a/internal/ceres/block_sparse_matrix_test.cc b/internal/ceres/block_sparse_matrix_test.cc index 7b64a7c..7fab13a 100644 --- a/internal/ceres/block_sparse_matrix_test.cc +++ b/internal/ceres/block_sparse_matrix_test.cc
@@ -45,7 +45,7 @@ namespace internal { namespace { -template<typename T> +template <typename T> void CheckVectorEq(const std::vector<T>& a, const std::vector<T>& b) { EXPECT_EQ(a.size(), b.size()); for (int i = 0; i < a.size(); ++i) { @@ -62,24 +62,20 @@ // [ 0 0 8 9 10 0 ] CompressedRowBlockStructure* bs = new CompressedRowBlockStructure; bs->cols = { - // Block size 2, position 0. - Block(2, 0), - // Block size 3, position 2. - Block(3, 2), - // Block size 1, position 5. - Block(1, 5), + // Block size 2, position 0. + Block(2, 0), + // Block size 3, position 2. + Block(3, 2), + // Block size 1, position 5. + Block(1, 5), }; - bs->rows = { - CompressedRow(1), - CompressedRow(1) - }; + bs->rows = {CompressedRow(1), CompressedRow(1)}; bs->rows[0].block = Block(2, 0); - bs->rows[0].cells = { Cell(0, 0) }; + bs->rows[0].cells = {Cell(0, 0)}; bs->rows[1].block = Block(2, 2); - bs->rows[1].cells = { Cell(1, 4) }; - std::unique_ptr<BlockSparseMatrix> m = - std::make_unique<BlockSparseMatrix>(bs); + bs->rows[1].cells = {Cell(1, 4)}; + auto m = std::make_unique<BlockSparseMatrix>(bs); EXPECT_NE(m, nullptr); EXPECT_EQ(m->num_rows(), 4); EXPECT_EQ(m->num_cols(), 6); @@ -96,26 +92,22 @@ // [ 0 0 9 0 0 0 ] CompressedRowBlockStructure* bs = new CompressedRowBlockStructure; bs->cols = { - // Block size 2, position 0. - Block(2, 0), - // Block size 1, position 2. - Block(1, 2), - // Block size 2, position 3. - Block(2, 3), - // Block size 1, position 5. - Block(1, 5), + // Block size 2, position 0. + Block(2, 0), + // Block size 1, position 2. + Block(1, 2), + // Block size 2, position 3. + Block(2, 3), + // Block size 1, position 5. + Block(1, 5), }; - bs->rows = { - CompressedRow(2), - CompressedRow(1) - }; + bs->rows = {CompressedRow(2), CompressedRow(1)}; bs->rows[0].block = Block(2, 0); - bs->rows[0].cells = { Cell(0, 0), Cell(2, 4) }; + bs->rows[0].cells = {Cell(0, 0), Cell(2, 4)}; bs->rows[1].block = Block(1, 2); - bs->rows[1].cells = { Cell(1, 8) }; - std::unique_ptr<BlockSparseMatrix> m = - std::make_unique<BlockSparseMatrix>(bs); + bs->rows[1].cells = {Cell(1, 8)}; + auto m = std::make_unique<BlockSparseMatrix>(bs); EXPECT_NE(m, nullptr); EXPECT_EQ(m->num_rows(), 3); EXPECT_EQ(m->num_cols(), 6); @@ -309,10 +301,8 @@ EXPECT_EQ(m_dense.rows(), 4); EXPECT_EQ(m_dense.cols(), 6); Matrix m_expected(4, 6); - m_expected << 1, 2, 0, 0, 0, 0, - 3, 4, 0, 0, 0, 0, - 0, 0, 5, 6, 7, 0, - 0, 0, 8, 9, 10, 0; + m_expected << 1, 2, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 0, 5, 6, 7, 0, 0, 0, 8, + 9, 10, 0; EXPECT_EQ(m_dense, m_expected); } @@ -323,9 +313,7 @@ EXPECT_EQ(m_dense.rows(), 3); EXPECT_EQ(m_dense.cols(), 6); Matrix m_expected(3, 6); - m_expected << 1, 2, 0, 5, 6, 0, - 3, 4, 0, 7, 8, 0, - 0, 0, 9, 0, 0, 0; + m_expected << 1, 2, 0, 5, 6, 0, 3, 4, 0, 7, 8, 0, 0, 0, 9, 0, 0, 0; EXPECT_EQ(m_dense, m_expected); } }
diff --git a/internal/ceres/compressed_row_sparse_matrix.cc b/internal/ceres/compressed_row_sparse_matrix.cc index da58b1a..9c78565 100644 --- a/internal/ceres/compressed_row_sparse_matrix.cc +++ b/internal/ceres/compressed_row_sparse_matrix.cc
@@ -645,7 +645,9 @@ CHECK_LE(options.block_density, 1.0); vector<int> row_blocks; + row_blocks.reserve(options.num_row_blocks); vector<int> col_blocks; + col_blocks.reserve(options.num_col_blocks); std::mt19937 prng; std::uniform_int_distribution<int> col_distribution(
diff --git a/internal/ceres/dense_cholesky.cc b/internal/ceres/dense_cholesky.cc index a6220e4..244de74 100644 --- a/internal/ceres/dense_cholesky.cc +++ b/internal/ceres/dense_cholesky.cc
@@ -33,6 +33,7 @@ #include <algorithm> #include <memory> #include <string> +#include <utility> #include <vector> #include "ceres/internal/config.h"
diff --git a/internal/ceres/dense_cholesky_test.cc b/internal/ceres/dense_cholesky_test.cc index f8e6567..1c0df56 100644 --- a/internal/ceres/dense_cholesky_test.cc +++ b/internal/ceres/dense_cholesky_test.cc
@@ -34,6 +34,7 @@ #include <numeric> #include <sstream> #include <string> +#include <utility> #include <vector> #include "Eigen/Dense"
diff --git a/internal/ceres/sparse_cholesky.cc b/internal/ceres/sparse_cholesky.cc index 22df3c9..f68bfe2 100644 --- a/internal/ceres/sparse_cholesky.cc +++ b/internal/ceres/sparse_cholesky.cc
@@ -31,6 +31,7 @@ #include "ceres/sparse_cholesky.h" #include <memory> +#include <utility> #include "ceres/accelerate_sparse.h" #include "ceres/eigensparse.h"