Remove using namespace std;
For historical reasons we had a "using namespace std;" in port.h. This
is generally a bad idea. So removing it and along the way doing a bunch
of cpplint cleanup.
Change-Id: Ia125601a55ae62695e247fb0250df4c6f86c46c6
diff --git a/internal/ceres/array_utils.cc b/internal/ceres/array_utils.cc
index 205ddaf..a22eb61 100644
--- a/internal/ceres/array_utils.cc
+++ b/internal/ceres/array_utils.cc
@@ -71,7 +71,7 @@
}
return size;
-};
+}
void InvalidateArray(const int size, double* x) {
if (x != NULL) {
diff --git a/internal/ceres/array_utils.h b/internal/ceres/array_utils.h
index 7f56947..c11129e 100644
--- a/internal/ceres/array_utils.h
+++ b/internal/ceres/array_utils.h
@@ -43,6 +43,7 @@
#ifndef CERES_INTERNAL_ARRAY_UTILS_H_
#define CERES_INTERNAL_ARRAY_UTILS_H_
+#include <string>
#include "ceres/internal/port.h"
namespace ceres {
diff --git a/internal/ceres/array_utils_test.cc b/internal/ceres/array_utils_test.cc
index 203a301..fd6a499 100644
--- a/internal/ceres/array_utils_test.cc
+++ b/internal/ceres/array_utils_test.cc
@@ -38,6 +38,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
TEST(ArrayUtils, IsArrayValid) {
double x[3];
x[0] = 0.0;
diff --git a/internal/ceres/autodiff_local_parameterization_test.cc b/internal/ceres/autodiff_local_parameterization_test.cc
index a73c6a6..5401d8f 100644
--- a/internal/ceres/autodiff_local_parameterization_test.cc
+++ b/internal/ceres/autodiff_local_parameterization_test.cc
@@ -72,7 +72,7 @@
}
struct ScaledPlus {
- ScaledPlus(const double &scale_factor)
+ explicit ScaledPlus(const double &scale_factor)
: scale_factor_(scale_factor)
{}
diff --git a/internal/ceres/block_jacobi_preconditioner.cc b/internal/ceres/block_jacobi_preconditioner.cc
index 7f79a4f..d8a7280 100644
--- a/internal/ceres/block_jacobi_preconditioner.cc
+++ b/internal/ceres/block_jacobi_preconditioner.cc
@@ -43,7 +43,7 @@
BlockJacobiPreconditioner::BlockJacobiPreconditioner(
const BlockSparseMatrix& A) {
const CompressedRowBlockStructure* bs = A.block_structure();
- vector<int> blocks(bs->cols.size());
+ std::vector<int> blocks(bs->cols.size());
for (int i = 0; i < blocks.size(); ++i) {
blocks[i] = bs->cols[i].size;
}
@@ -60,7 +60,7 @@
m_->SetZero();
for (int i = 0; i < bs->rows.size(); ++i) {
const int row_block_size = bs->rows[i].block.size;
- const vector<Cell>& cells = bs->rows[i].cells;
+ const std::vector<Cell>& cells = bs->rows[i].cells;
for (int j = 0; j < cells.size(); ++j) {
const int block_id = cells[j].block_id;
const int col_block_size = bs->cols[block_id].size;
diff --git a/internal/ceres/block_jacobian_writer.cc b/internal/ceres/block_jacobian_writer.cc
index f90c350..085b011 100644
--- a/internal/ceres/block_jacobian_writer.cc
+++ b/internal/ceres/block_jacobian_writer.cc
@@ -41,6 +41,9 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
// Given the residual block ordering, build a lookup table to determine which
@@ -163,8 +166,7 @@
}
// Construct the cells in each row.
- const vector<ResidualBlock*>& residual_blocks =
- program_->residual_blocks();
+ const vector<ResidualBlock*>& residual_blocks = program_->residual_blocks();
int row_block_position = 0;
bs->rows.resize(residual_blocks.size());
for (int i = 0; i < residual_blocks.size(); ++i) {
diff --git a/internal/ceres/block_jacobian_writer.h b/internal/ceres/block_jacobian_writer.h
index 140c721..1fb52a5 100644
--- a/internal/ceres/block_jacobian_writer.h
+++ b/internal/ceres/block_jacobian_writer.h
@@ -115,10 +115,10 @@
//
// which indicates that dr/dx is located at values_[0], and dr/dz is at
// values_[12]. See BlockEvaluatePreparer::Prepare()'s comments about 'j'.
- vector<int*> jacobian_layout_;
+ std::vector<int*> jacobian_layout_;
// The pointers in jacobian_layout_ point directly into this vector.
- vector<int> jacobian_layout_storage_;
+ std::vector<int> jacobian_layout_storage_;
};
} // namespace internal
diff --git a/internal/ceres/block_random_access_dense_matrix.cc b/internal/ceres/block_random_access_dense_matrix.cc
index e582279..d8a6b33 100644
--- a/internal/ceres/block_random_access_dense_matrix.cc
+++ b/internal/ceres/block_random_access_dense_matrix.cc
@@ -39,7 +39,7 @@
namespace internal {
BlockRandomAccessDenseMatrix::BlockRandomAccessDenseMatrix(
- const vector<int>& blocks) {
+ const std::vector<int>& blocks) {
const int num_blocks = blocks.size();
block_layout_.resize(num_blocks, 0);
num_rows_ = 0;
diff --git a/internal/ceres/block_random_access_dense_matrix.h b/internal/ceres/block_random_access_dense_matrix.h
index d160fd9..7de3303 100644
--- a/internal/ceres/block_random_access_dense_matrix.h
+++ b/internal/ceres/block_random_access_dense_matrix.h
@@ -56,7 +56,7 @@
public:
// blocks is a vector of block sizes. The resulting matrix has
// blocks.size() * blocks.size() cells.
- explicit BlockRandomAccessDenseMatrix(const vector<int>& blocks);
+ explicit BlockRandomAccessDenseMatrix(const std::vector<int>& blocks);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -85,7 +85,7 @@
private:
int num_rows_;
- vector<int> block_layout_;
+ std::vector<int> block_layout_;
scoped_array<double> values_;
scoped_array<CellInfo> cell_infos_;
diff --git a/internal/ceres/block_random_access_dense_matrix_test.cc b/internal/ceres/block_random_access_dense_matrix_test.cc
index 359eb93..fde0a9c 100644
--- a/internal/ceres/block_random_access_dense_matrix_test.cc
+++ b/internal/ceres/block_random_access_dense_matrix_test.cc
@@ -37,7 +37,7 @@
namespace internal {
TEST(BlockRandomAccessDenseMatrix, GetCell) {
- vector<int> blocks;
+ std::vector<int> blocks;
blocks.push_back(3);
blocks.push_back(4);
blocks.push_back(5);
@@ -69,7 +69,7 @@
}
TEST(BlockRandomAccessDenseMatrix, WriteCell) {
- vector<int> blocks;
+ std::vector<int> blocks;
blocks.push_back(3);
blocks.push_back(4);
blocks.push_back(5);
diff --git a/internal/ceres/block_random_access_diagonal_matrix.cc b/internal/ceres/block_random_access_diagonal_matrix.cc
index b7ff331..d4ce4ad 100644
--- a/internal/ceres/block_random_access_diagonal_matrix.cc
+++ b/internal/ceres/block_random_access_diagonal_matrix.cc
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// TODO(sameeragarwal): Drop the dependence on TripletSparseMatrix.
BlockRandomAccessDiagonalMatrix::BlockRandomAccessDiagonalMatrix(
diff --git a/internal/ceres/block_random_access_diagonal_matrix.h b/internal/ceres/block_random_access_diagonal_matrix.h
index ea99678..e57ed5e 100644
--- a/internal/ceres/block_random_access_diagonal_matrix.h
+++ b/internal/ceres/block_random_access_diagonal_matrix.h
@@ -52,7 +52,7 @@
class BlockRandomAccessDiagonalMatrix : public BlockRandomAccessMatrix {
public:
// blocks is an array of block sizes.
- explicit BlockRandomAccessDiagonalMatrix(const vector<int>& blocks);
+ explicit BlockRandomAccessDiagonalMatrix(const std::vector<int>& blocks);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -85,8 +85,8 @@
private:
// row/column block sizes.
- const vector<int> blocks_;
- vector<CellInfo*> layout_;
+ const std::vector<int> blocks_;
+ std::vector<CellInfo*> layout_;
// The underlying matrix object which actually stores the cells.
scoped_ptr<TripletSparseMatrix> tsm_;
diff --git a/internal/ceres/block_random_access_diagonal_matrix_test.cc b/internal/ceres/block_random_access_diagonal_matrix_test.cc
index aa2d664..9308861 100644
--- a/internal/ceres/block_random_access_diagonal_matrix_test.cc
+++ b/internal/ceres/block_random_access_diagonal_matrix_test.cc
@@ -43,7 +43,7 @@
class BlockRandomAccessDiagonalMatrixTest : public ::testing::Test {
public:
void SetUp() {
- vector<int> blocks;
+ std::vector<int> blocks;
blocks.push_back(3);
blocks.push_back(4);
blocks.push_back(5);
diff --git a/internal/ceres/block_random_access_sparse_matrix.cc b/internal/ceres/block_random_access_sparse_matrix.cc
index c43a9b7..f146403 100644
--- a/internal/ceres/block_random_access_sparse_matrix.cc
+++ b/internal/ceres/block_random_access_sparse_matrix.cc
@@ -44,6 +44,11 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::pair;
+using std::set;
+using std::vector;
+
BlockRandomAccessSparseMatrix::BlockRandomAccessSparseMatrix(
const vector<int>& blocks,
const set<pair<int, int> >& block_pairs)
diff --git a/internal/ceres/block_random_access_sparse_matrix.h b/internal/ceres/block_random_access_sparse_matrix.h
index 51b5d20..1b7d9c1 100644
--- a/internal/ceres/block_random_access_sparse_matrix.h
+++ b/internal/ceres/block_random_access_sparse_matrix.h
@@ -57,8 +57,9 @@
// blocks is an array of block sizes. block_pairs is a set of
// <row_block_id, col_block_id> pairs to identify the non-zero cells
// of this matrix.
- BlockRandomAccessSparseMatrix(const vector<int>& blocks,
- const set<pair<int, int> >& block_pairs);
+ BlockRandomAccessSparseMatrix(
+ const std::vector<int>& blocks,
+ const std::set<std::pair<int, int> >& block_pairs);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -103,8 +104,8 @@
const int64 kMaxRowBlocks;
// row/column block sizes.
- const vector<int> blocks_;
- vector<int> block_positions_;
+ const std::vector<int> blocks_;
+ std::vector<int> block_positions_;
// A mapping from <row_block_id, col_block_id> to the position in
// the values array of tsm_ where the block is stored.
@@ -114,7 +115,7 @@
// In order traversal of contents of the matrix. This allows us to
// implement a matrix-vector which is 20% faster than using the
// iterator in the Layout object instead.
- vector<pair<pair<int, int>, double*> > cell_values_;
+ std::vector<std::pair<std::pair<int, int>, double*> > cell_values_;
// The underlying matrix object which actually stores the cells.
scoped_ptr<TripletSparseMatrix> tsm_;
diff --git a/internal/ceres/block_random_access_sparse_matrix_test.cc b/internal/ceres/block_random_access_sparse_matrix_test.cc
index 10a4190..e6147dd 100644
--- a/internal/ceres/block_random_access_sparse_matrix_test.cc
+++ b/internal/ceres/block_random_access_sparse_matrix_test.cc
@@ -38,6 +38,11 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::pair;
+using std::set;
+using std::vector;
+
TEST(BlockRandomAccessSparseMatrix, GetCell) {
vector<int> blocks;
blocks.push_back(3);
@@ -169,7 +174,8 @@
};
TEST_F(BlockRandomAccessSparseMatrixTest, IntPairToLongOverflow) {
- CheckIntPairToLong(numeric_limits<int>::max(), numeric_limits<int>::max());
+ CheckIntPairToLong(std::numeric_limits<int>::max(),
+ std::numeric_limits<int>::max());
}
TEST_F(BlockRandomAccessSparseMatrixTest, LongToIntPair) {
diff --git a/internal/ceres/block_sparse_matrix.cc b/internal/ceres/block_sparse_matrix.cc
index a487262..6aa3c00 100644
--- a/internal/ceres/block_sparse_matrix.cc
+++ b/internal/ceres/block_sparse_matrix.cc
@@ -42,6 +42,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
BlockSparseMatrix::~BlockSparseMatrix() {}
BlockSparseMatrix::BlockSparseMatrix(
@@ -82,7 +84,7 @@
}
void BlockSparseMatrix::SetZero() {
- fill(values_.get(), values_.get() + num_nonzeros_, 0.0);
+ std::fill(values_.get(), values_.get() + num_nonzeros_, 0.0);
}
void BlockSparseMatrix::RightMultiply(const double* x, double* y) const {
diff --git a/internal/ceres/block_structure.h b/internal/ceres/block_structure.h
index 656716e..dde8f67 100644
--- a/internal/ceres/block_structure.h
+++ b/internal/ceres/block_structure.h
@@ -71,20 +71,20 @@
struct CompressedList {
Block block;
- vector<Cell> cells;
+ std::vector<Cell> cells;
};
typedef CompressedList CompressedRow;
typedef CompressedList CompressedColumn;
struct CompressedRowBlockStructure {
- vector<Block> cols;
- vector<CompressedRow> rows;
+ std::vector<Block> cols;
+ std::vector<CompressedRow> rows;
};
struct CompressedColumnBlockStructure {
- vector<Block> rows;
- vector<CompressedColumn> cols;
+ std::vector<Block> rows;
+ std::vector<CompressedColumn> cols;
};
} // namespace internal
diff --git a/internal/ceres/callbacks.cc b/internal/ceres/callbacks.cc
index 7d5ce25..3858309 100644
--- a/internal/ceres/callbacks.cc
+++ b/internal/ceres/callbacks.cc
@@ -78,27 +78,27 @@
summary.cumulative_time_in_seconds);
} else if (minimizer_type == TRUST_REGION) {
if (summary.iteration == 0) {
- output = "iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time\n";
+ output = "iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time\n"; // NOLINT
}
const char* kReportRowFormat =
- "% 4d % 8e % 3.2e % 3.2e % 3.2e % 3.2e % 3.2e % 4d % 3.2e % 3.2e";
+ "% 4d % 8e % 3.2e % 3.2e % 3.2e % 3.2e % 3.2e % 4d % 3.2e % 3.2e"; // NOLINT
output += StringPrintf(kReportRowFormat,
- summary.iteration,
- summary.cost,
- summary.cost_change,
- summary.gradient_max_norm,
- summary.step_norm,
- summary.relative_decrease,
- summary.trust_region_radius,
- summary.linear_solver_iterations,
- summary.iteration_time_in_seconds,
- summary.cumulative_time_in_seconds);
+ summary.iteration,
+ summary.cost,
+ summary.cost_change,
+ summary.gradient_max_norm,
+ summary.step_norm,
+ summary.relative_decrease,
+ summary.trust_region_radius,
+ summary.linear_solver_iterations,
+ summary.iteration_time_in_seconds,
+ summary.cumulative_time_in_seconds);
} else {
LOG(FATAL) << "Unknown minimizer type.";
}
if (log_to_stdout_) {
- cout << output << endl;
+ std::cout << output << std::endl;
} else {
VLOG(1) << output;
}
diff --git a/internal/ceres/canonical_views_clustering.cc b/internal/ceres/canonical_views_clustering.cc
index 9bbab4b..c629a44 100644
--- a/internal/ceres/canonical_views_clustering.cc
+++ b/internal/ceres/canonical_views_clustering.cc
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
typedef HashMap<int, int> IntMap;
typedef HashSet<int> IntSet;
diff --git a/internal/ceres/canonical_views_clustering.h b/internal/ceres/canonical_views_clustering.h
index d3fa572..1518ac9 100644
--- a/internal/ceres/canonical_views_clustering.h
+++ b/internal/ceres/canonical_views_clustering.h
@@ -102,7 +102,7 @@
void ComputeCanonicalViewsClustering(
const CanonicalViewsClusteringOptions& options,
const WeightedGraph<int>& graph,
- vector<int>* centers,
+ std::vector<int>* centers,
HashMap<int, int>* membership);
struct CanonicalViewsClusteringOptions {
diff --git a/internal/ceres/canonical_views_clustering_test.cc b/internal/ceres/canonical_views_clustering_test.cc
index 006b2dd..0a0e3c5 100644
--- a/internal/ceres/canonical_views_clustering_test.cc
+++ b/internal/ceres/canonical_views_clustering_test.cc
@@ -78,7 +78,7 @@
WeightedGraph<int> graph_;
CanonicalViewsClusteringOptions options_;
- vector<int> centers_;
+ std::vector<int> centers_;
HashMap<int, int> membership_;
};
diff --git a/internal/ceres/collections_port.h b/internal/ceres/collections_port.h
index 3f976b9..3c23856 100644
--- a/internal/ceres/collections_port.h
+++ b/internal/ceres/collections_port.h
@@ -69,7 +69,6 @@
#include <utility>
#include "ceres/integral_types.h"
-#include "ceres/internal/port.h"
// Some systems don't have access to unordered_map/unordered_set. In
// that case, substitute the hash map/set with normal map/set. The
diff --git a/internal/ceres/compressed_col_sparse_matrix_utils.cc b/internal/ceres/compressed_col_sparse_matrix_utils.cc
index b62a6ed..f4af098 100644
--- a/internal/ceres/compressed_col_sparse_matrix_utils.cc
+++ b/internal/ceres/compressed_col_sparse_matrix_utils.cc
@@ -38,12 +38,15 @@
namespace ceres {
namespace internal {
-void CompressedColumnScalarMatrixToBlockMatrix(const int* scalar_rows,
- const int* scalar_cols,
- const vector<int>& row_blocks,
- const vector<int>& col_blocks,
- vector<int>* block_rows,
- vector<int>* block_cols) {
+using std::vector;
+
+void CompressedColumnScalarMatrixToBlockMatrix(
+ const int* scalar_rows,
+ const int* scalar_cols,
+ const vector<int>& row_blocks,
+ const vector<int>& col_blocks,
+ vector<int>* block_rows,
+ vector<int>* block_cols) {
CHECK_NOTNULL(block_rows)->clear();
CHECK_NOTNULL(block_cols)->clear();
const int num_row_blocks = row_blocks.size();
@@ -66,9 +69,10 @@
for (int col_block = 0; col_block < num_col_blocks; ++col_block) {
int column_size = 0;
for (int idx = scalar_cols[c]; idx < scalar_cols[c + 1]; ++idx) {
- vector<int>::const_iterator it = lower_bound(row_block_starts.begin(),
- row_block_starts.end(),
- scalar_rows[idx]);
+ vector<int>::const_iterator it =
+ std::lower_bound(row_block_starts.begin(),
+ row_block_starts.end(),
+ scalar_rows[idx]);
// Since we are using lower_bound, it will return the row id
// where the row block starts. For everything but the first row
// of the block, where these values will be the same, we can
diff --git a/internal/ceres/compressed_col_sparse_matrix_utils.h b/internal/ceres/compressed_col_sparse_matrix_utils.h
index c8de2a1..e27eaa3 100644
--- a/internal/ceres/compressed_col_sparse_matrix_utils.h
+++ b/internal/ceres/compressed_col_sparse_matrix_utils.h
@@ -47,19 +47,21 @@
// and column block j, then it is expected that A contains at least
// one non-zero entry corresponding to the top left entry of c_ij,
// as that entry is used to detect the presence of a non-zero c_ij.
-void CompressedColumnScalarMatrixToBlockMatrix(const int* scalar_rows,
- const int* scalar_cols,
- const vector<int>& row_blocks,
- const vector<int>& col_blocks,
- vector<int>* block_rows,
- vector<int>* block_cols);
+void CompressedColumnScalarMatrixToBlockMatrix(
+ const int* scalar_rows,
+ const int* scalar_cols,
+ const std::vector<int>& row_blocks,
+ const std::vector<int>& col_blocks,
+ std::vector<int>* block_rows,
+ std::vector<int>* block_cols);
// Given a set of blocks and a permutation of these blocks, compute
// the corresponding "scalar" ordering, where the scalar ordering of
// size sum(blocks).
-void BlockOrderingToScalarOrdering(const vector<int>& blocks,
- const vector<int>& block_ordering,
- vector<int>* scalar_ordering);
+void BlockOrderingToScalarOrdering(
+ const std::vector<int>& blocks,
+ const std::vector<int>& block_ordering,
+ std::vector<int>* scalar_ordering);
// Solve the linear system
//
@@ -120,7 +122,7 @@
const double* values,
const int rhs_nonzero_index,
double* solution) {
- fill(solution, solution + num_cols, 0.0);
+ std::fill(solution, solution + num_cols, 0.0);
solution[rhs_nonzero_index] = 1.0 / values[cols[rhs_nonzero_index + 1] - 1];
for (IntegerType c = rhs_nonzero_index + 1; c < num_cols; ++c) {
diff --git a/internal/ceres/compressed_col_sparse_matrix_utils_test.cc b/internal/ceres/compressed_col_sparse_matrix_utils_test.cc
index 3faf06c..5f1fd8f 100644
--- a/internal/ceres/compressed_col_sparse_matrix_utils_test.cc
+++ b/internal/ceres/compressed_col_sparse_matrix_utils_test.cc
@@ -39,6 +39,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
TEST(_, BlockPermutationToScalarPermutation) {
vector<int> blocks;
// Block structure
@@ -133,7 +135,7 @@
TripletSparseMatrix tsm(5, 8, 18);
int* rows = tsm.mutable_rows();
int* cols = tsm.mutable_cols();
- fill(tsm.mutable_values(), tsm.mutable_values() + 18, 1.0);
+ std::fill(tsm.mutable_values(), tsm.mutable_values() + 18, 1.0);
int offset = 0;
#define CERES_TEST_FILL_BLOCK(row_block_id, col_block_id) \
diff --git a/internal/ceres/compressed_row_jacobian_writer.cc b/internal/ceres/compressed_row_jacobian_writer.cc
index ed8db14..9860b82 100644
--- a/internal/ceres/compressed_row_jacobian_writer.cc
+++ b/internal/ceres/compressed_row_jacobian_writer.cc
@@ -30,6 +30,9 @@
#include "ceres/compressed_row_jacobian_writer.h"
+#include <utility>
+#include <vector>
+
#include "ceres/casts.h"
#include "ceres/compressed_row_sparse_matrix.h"
#include "ceres/parameter_block.h"
@@ -40,6 +43,10 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::pair;
+using std::vector;
+
void CompressedRowJacobianWriter::PopulateJacobianRowAndColumnBlockVectors(
const Program* program, CompressedRowSparseMatrix* jacobian) {
const vector<ParameterBlock*>& parameter_blocks =
@@ -214,9 +221,9 @@
double* column_block_begin =
jacobian_values + jacobian_rows[residual_offset + r] + col_pos;
- copy(block_row_begin,
- block_row_begin + parameter_block_size,
- column_block_begin);
+ std::copy(block_row_begin,
+ block_row_begin + parameter_block_size,
+ column_block_begin);
}
col_pos += parameter_block_size;
}
diff --git a/internal/ceres/compressed_row_jacobian_writer.h b/internal/ceres/compressed_row_jacobian_writer.h
index a722a7c..517d691 100644
--- a/internal/ceres/compressed_row_jacobian_writer.h
+++ b/internal/ceres/compressed_row_jacobian_writer.h
@@ -33,6 +33,9 @@
#ifndef CERES_INTERNAL_COMPRESSED_ROW_JACOBIAN_WRITER_H_
#define CERES_INTERNAL_COMPRESSED_ROW_JACOBIAN_WRITER_H_
+#include <utility>
+#include <vector>
+
#include "ceres/evaluator.h"
#include "ceres/scratch_evaluate_preparer.h"
@@ -80,7 +83,7 @@
static void GetOrderedParameterBlocks(
const Program* program,
int residual_id,
- vector<pair<int, int> >* evaluated_jacobian_blocks);
+ std::vector<std::pair<int, int> >* evaluated_jacobian_blocks);
// JacobianWriter interface.
diff --git a/internal/ceres/compressed_row_sparse_matrix.cc b/internal/ceres/compressed_row_sparse_matrix.cc
index 7993ed6..b036bb5 100644
--- a/internal/ceres/compressed_row_sparse_matrix.cc
+++ b/internal/ceres/compressed_row_sparse_matrix.cc
@@ -40,6 +40,9 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
// Helper functor used by the constructor for reordering the contents
@@ -155,7 +158,7 @@
}
void CompressedRowSparseMatrix::SetZero() {
- fill(values_.begin(), values_.end(), 0);
+ std::fill(values_.begin(), values_.end(), 0);
}
void CompressedRowSparseMatrix::RightMultiply(const double* x,
@@ -184,7 +187,7 @@
void CompressedRowSparseMatrix::SquaredColumnNorm(double* x) const {
CHECK_NOTNULL(x);
- fill(x, x + num_cols_, 0.0);
+ std::fill(x, x + num_cols_, 0.0);
for (int idx = 0; idx < rows_[num_rows_]; ++idx) {
x[cols_[idx]] += values_[idx] * values_[idx];
}
@@ -244,20 +247,24 @@
}
// Copy the contents of m into this matrix.
- copy(m.cols(), m.cols() + m.num_nonzeros(), &cols_[num_nonzeros()]);
- copy(m.values(), m.values() + m.num_nonzeros(), &values_[num_nonzeros()]);
+ std::copy(m.cols(), m.cols() + m.num_nonzeros(), &cols_[num_nonzeros()]);
+ std::copy(m.values(),
+ m.values() + m.num_nonzeros(),
+ &values_[num_nonzeros()]);
rows_.resize(num_rows_ + m.num_rows() + 1);
// new_rows = [rows_, m.row() + rows_[num_rows_]]
- fill(rows_.begin() + num_rows_,
- rows_.begin() + num_rows_ + m.num_rows() + 1,
- rows_[num_rows_]);
+ std::fill(rows_.begin() + num_rows_,
+ rows_.begin() + num_rows_ + m.num_rows() + 1,
+ rows_[num_rows_]);
for (int r = 0; r < m.num_rows() + 1; ++r) {
rows_[num_rows_ + r] += m.rows()[r];
}
num_rows_ += m.num_rows();
- row_blocks_.insert(row_blocks_.end(), m.row_blocks().begin(), m.row_blocks().end());
+ row_blocks_.insert(row_blocks_.end(),
+ m.row_blocks().begin(),
+ m.row_blocks().end());
}
void CompressedRowSparseMatrix::ToTextFile(FILE* file) const {
@@ -329,7 +336,7 @@
int* rows = matrix->mutable_rows();
int* cols = matrix->mutable_cols();
double* values = matrix->mutable_values();
- fill(values, values + num_nonzeros, 0.0);
+ std::fill(values, values + num_nonzeros, 0.0);
int idx_cursor = 0;
int col_cursor = 0;
@@ -481,8 +488,9 @@
const CompressedRowSparseMatrix& m,
vector<int>* program) {
CHECK_NOTNULL(program)->clear();
- CHECK_GT(m.num_nonzeros(), 0) << "Congratulations, "
- << "you found a bug in Ceres. Please report it.";
+ CHECK_GT(m.num_nonzeros(), 0)
+ << "Congratulations, "
+ << "you found a bug in Ceres. Please report it.";
vector<ProductTerm> product;
const vector<int>& row_blocks = m.row_blocks();
@@ -495,7 +503,9 @@
// Compute the lower triangular part of the product.
for (int idx1 = m.rows()[r]; idx1 < m.rows()[r + 1]; ++idx1) {
for (int idx2 = m.rows()[r]; idx2 <= idx1; ++idx2) {
- product.push_back(ProductTerm(m.cols()[idx1], m.cols()[idx2], product.size()));
+ product.push_back(ProductTerm(m.cols()[idx1],
+ m.cols()[idx2],
+ product.size()));
}
}
row_block_begin = row_block_end;
diff --git a/internal/ceres/compressed_row_sparse_matrix.h b/internal/ceres/compressed_row_sparse_matrix.h
index a0ba7ee..13470ce 100644
--- a/internal/ceres/compressed_row_sparse_matrix.h
+++ b/internal/ceres/compressed_row_sparse_matrix.h
@@ -109,11 +109,11 @@
const int* rows() const { return &rows_[0]; }
int* mutable_rows() { return &rows_[0]; }
- const vector<int>& row_blocks() const { return row_blocks_; }
- vector<int>* mutable_row_blocks() { return &row_blocks_; }
+ const std::vector<int>& row_blocks() const { return row_blocks_; }
+ std::vector<int>* mutable_row_blocks() { return &row_blocks_; }
- const vector<int>& col_blocks() const { return col_blocks_; }
- vector<int>* mutable_col_blocks() { return &col_blocks_; }
+ const std::vector<int>& col_blocks() const { return col_blocks_; }
+ std::vector<int>* mutable_col_blocks() { return &col_blocks_; }
// Destructive array resizing method.
void SetMaxNumNonZeros(int num_nonzeros);
@@ -129,7 +129,7 @@
static CompressedRowSparseMatrix* CreateBlockDiagonalMatrix(
const double* diagonal,
- const vector<int>& blocks);
+ const std::vector<int>& blocks);
// Compute the sparsity structure of the product m.transpose() * m
// and create a CompressedRowSparseMatrix corresponding to it.
@@ -147,30 +147,30 @@
// this information for each row in the row block.
static CompressedRowSparseMatrix* CreateOuterProductMatrixAndProgram(
const CompressedRowSparseMatrix& m,
- vector<int>* program);
+ std::vector<int>* program);
// Compute the values array for the expression m.transpose() * m,
// where the matrix used to store the result and a program have been
// created using the CreateOuterProductMatrixAndProgram function
// above.
static void ComputeOuterProduct(const CompressedRowSparseMatrix& m,
- const vector<int>& program,
+ const std::vector<int>& program,
CompressedRowSparseMatrix* result);
private:
int num_rows_;
int num_cols_;
- vector<int> rows_;
- vector<int> cols_;
- vector<double> values_;
+ std::vector<int> rows_;
+ std::vector<int> cols_;
+ std::vector<double> values_;
// If the matrix has an underlying block structure, then it can also
// carry with it row and column block sizes. This is auxilliary and
// optional information for use by algorithms operating on the
// matrix. The class itself does not make use of this information in
// any way.
- vector<int> row_blocks_;
- vector<int> col_blocks_;
+ std::vector<int> row_blocks_;
+ std::vector<int> col_blocks_;
CERES_DISALLOW_COPY_AND_ASSIGN(CompressedRowSparseMatrix);
};
diff --git a/internal/ceres/compressed_row_sparse_matrix_test.cc b/internal/ceres/compressed_row_sparse_matrix_test.cc
index 999a661..5a210ae 100644
--- a/internal/ceres/compressed_row_sparse_matrix_test.cc
+++ b/internal/ceres/compressed_row_sparse_matrix_test.cc
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
void CompareMatrices(const SparseMatrix* a, const SparseMatrix* b) {
EXPECT_EQ(a->num_rows(), b->num_rows());
EXPECT_EQ(a->num_cols(), b->num_cols());
@@ -169,7 +171,7 @@
scoped_array<double> diagonal(new double[num_diagonal_rows]);
for (int i = 0; i < num_diagonal_rows; ++i) {
- diagonal[i] =i;
+ diagonal[i] = i;
}
vector<int> row_and_column_blocks;
@@ -384,7 +386,7 @@
cols[16] = 2;
rows[5] = 17;
- copy(values, values + 17, cols);
+ std::copy(values, values + 17, cols);
scoped_ptr<CompressedRowSparseMatrix> transpose(matrix.Transpose());
@@ -478,11 +480,11 @@
dense_matrix->setZero();
for (int c = 0; c < matrix->n; ++c) {
- for (int idx = matrix->p[c]; idx < matrix->p[c + 1]; ++idx) {
- const int r = matrix->i[idx];
- (*dense_matrix)(r, c) = matrix->x[idx];
- }
- }
+ for (int idx = matrix->p[c]; idx < matrix->p[c + 1]; ++idx) {
+ const int r = matrix->i[idx];
+ (*dense_matrix)(r, c) = matrix->x[idx];
+ }
+ }
}
TEST(CompressedRowSparseMatrix, ComputeOuterProduct) {
@@ -506,8 +508,6 @@
num_col_blocks < kMaxNumColBlocks;
++num_col_blocks) {
for (int trial = 0; trial < kNumTrials; ++trial) {
-
-
RandomMatrixOptions options;
options.num_row_blocks = num_row_blocks;
options.num_col_blocks = num_col_blocks;
@@ -528,7 +528,8 @@
scoped_ptr<CompressedRowSparseMatrix> matrix(
CreateRandomCompressedRowSparseMatrix(options));
- cs_di cs_matrix_transpose = cxsparse.CreateSparseMatrixTransposeView(matrix.get());
+ cs_di cs_matrix_transpose =
+ cxsparse.CreateSparseMatrixTransposeView(matrix.get());
cs_di* cs_matrix = cxsparse.TransposeMatrix(&cs_matrix_transpose);
cs_di* expected_outer_product =
cxsparse.MatrixMatrixMultiply(&cs_matrix_transpose, cs_matrix);
@@ -555,7 +556,8 @@
expected_matrix.triangularView<Eigen::StrictlyLower>().setZero();
ToDenseMatrix(&actual_outer_product, &actual_matrix);
- const double diff_norm = (actual_matrix - expected_matrix).norm() / expected_matrix.norm();
+ const double diff_norm =
+ (actual_matrix - expected_matrix).norm() / expected_matrix.norm();
ASSERT_NEAR(diff_norm, 0.0, kTolerance)
<< "expected: \n"
<< expected_matrix
diff --git a/internal/ceres/conditioned_cost_function.cc b/internal/ceres/conditioned_cost_function.cc
index 7322790..029dd5c 100644
--- a/internal/ceres/conditioned_cost_function.cc
+++ b/internal/ceres/conditioned_cost_function.cc
@@ -45,7 +45,7 @@
// the one it's wrapping.
ConditionedCostFunction::ConditionedCostFunction(
CostFunction* wrapped_cost_function,
- const vector<CostFunction*>& conditioners,
+ const std::vector<CostFunction*>& conditioners,
Ownership ownership)
: wrapped_cost_function_(wrapped_cost_function),
conditioners_(conditioners),
diff --git a/internal/ceres/conditioned_cost_function_test.cc b/internal/ceres/conditioned_cost_function_test.cc
index 03c553f..ad44653 100644
--- a/internal/ceres/conditioned_cost_function_test.cc
+++ b/internal/ceres/conditioned_cost_function_test.cc
@@ -87,7 +87,7 @@
identity.setIdentity();
NormalPrior* difference_cost_function = new NormalPrior(identity, v2_vector);
- vector<CostFunction*> conditioners;
+ std::vector<CostFunction*> conditioners;
for (int i = 0; i < kTestCostFunctionSize; i++) {
conditioners.push_back(new LinearCostFunction(i + 2, i * 7));
}
diff --git a/internal/ceres/conjugate_gradients_solver.cc b/internal/ceres/conjugate_gradients_solver.cc
index 3071a09..92e829c 100644
--- a/internal/ceres/conjugate_gradients_solver.cc
+++ b/internal/ceres/conjugate_gradients_solver.cc
@@ -114,7 +114,6 @@
double Q0 = -1.0 * xref.dot(bref + r);
for (summary.num_iterations = 1;; ++summary.num_iterations) {
-
// Apply preconditioner
if (per_solve_options.preconditioner != NULL) {
z.setZero();
@@ -129,7 +128,7 @@
summary.termination_type = LINEAR_SOLVER_FAILURE;
summary.message = StringPrintf("Numerical failure. rho = r'z = %e.", rho);
break;
- };
+ }
if (summary.num_iterations == 1) {
p = z;
@@ -233,7 +232,7 @@
}
return summary;
-};
+}
} // namespace internal
} // namespace ceres
diff --git a/internal/ceres/coordinate_descent_minimizer.cc b/internal/ceres/coordinate_descent_minimizer.cc
index 0d8adee..9f14840 100644
--- a/internal/ceres/coordinate_descent_minimizer.cc
+++ b/internal/ceres/coordinate_descent_minimizer.cc
@@ -48,11 +48,14 @@
#include "ceres/solver.h"
#include "ceres/trust_region_minimizer.h"
#include "ceres/trust_region_strategy.h"
-#include "ceres/parameter_block_ordering.h"
namespace ceres {
namespace internal {
+using std::map;
+using std::set;
+using std::vector;
+
CoordinateDescentMinimizer::~CoordinateDescentMinimizer() {
}
@@ -103,8 +106,7 @@
const int num_parameter_blocks = residual_block->NumParameterBlocks();
for (int j = 0; j < num_parameter_blocks; ++j) {
ParameterBlock* parameter_block = residual_block->parameter_blocks()[j];
- const map<ParameterBlock*, int>::const_iterator it =
- parameter_block_index.find(parameter_block);
+ const map<ParameterBlock*, int>::const_iterator it = parameter_block_index.find(parameter_block);
if (it != parameter_block_index.end()) {
residual_blocks_[it->second].push_back(residual_block);
}
@@ -244,7 +246,7 @@
// Verify that each group is an independent set
map<int, set<double*> >::const_iterator it = group_to_elements.begin();
- for ( ; it != group_to_elements.end(); ++it) {
+ for (; it != group_to_elements.end(); ++it) {
if (!program.IsParameterBlockSetIndependent(it->second)) {
*message =
StringPrintf("The user-provided "
diff --git a/internal/ceres/coordinate_descent_minimizer.h b/internal/ceres/coordinate_descent_minimizer.h
index c1f8ffc..7aed5d3 100644
--- a/internal/ceres/coordinate_descent_minimizer.h
+++ b/internal/ceres/coordinate_descent_minimizer.h
@@ -85,13 +85,13 @@
double* parameters,
Solver::Summary* summary);
- vector<ParameterBlock*> parameter_blocks_;
- vector<vector<ResidualBlock*> > residual_blocks_;
+ std::vector<ParameterBlock*> parameter_blocks_;
+ std::vector<std::vector<ResidualBlock*> > residual_blocks_;
// The optimization is performed in rounds. In each round all the
// parameter blocks that form one independent set are optimized in
// parallel. This array, marks the boundaries of the independent
// sets in parameter_blocks_.
- vector<int> independent_set_offsets_;
+ std::vector<int> independent_set_offsets_;
Evaluator::Options evaluator_options_;
};
diff --git a/internal/ceres/cost_function_to_functor_test.cc b/internal/ceres/cost_function_to_functor_test.cc
index f758efe..db29fe4 100644
--- a/internal/ceres/cost_function_to_functor_test.cc
+++ b/internal/ceres/cost_function_to_functor_test.cc
@@ -35,6 +35,7 @@
namespace ceres {
namespace internal {
+using std::vector;
const double kTolerance = 1e-18;
void ExpectCostFunctionsAreEqual(const CostFunction& cost_function,
@@ -109,7 +110,7 @@
<< "jacobian : " << i << " "
<< jacobians[i] << " " << actual_jacobians[i];
}
-};
+}
struct OneParameterBlockFunctor {
public:
diff --git a/internal/ceres/covariance.cc b/internal/ceres/covariance.cc
index 35146c5..4955f4a 100644
--- a/internal/ceres/covariance.cc
+++ b/internal/ceres/covariance.cc
@@ -38,6 +38,9 @@
namespace ceres {
+using std::pair;
+using std::vector;
+
Covariance::Covariance(const Covariance::Options& options) {
impl_.reset(new internal::CovarianceImpl(options));
}
diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc
index cbbf139..e5d0c44 100644
--- a/internal/ceres/covariance_impl.cc
+++ b/internal/ceres/covariance_impl.cc
@@ -58,6 +58,12 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::map;
+using std::pair;
+using std::swap;
+using std::vector;
+
typedef vector<pair<const double*, const double*> > CovarianceBlocks;
CovarianceImpl::CovarianceImpl(const Covariance::Options& options)
@@ -122,7 +128,7 @@
const double* parameter_block2 = original_parameter_block2;
const bool transpose = parameter_block1 > parameter_block2;
if (transpose) {
- std::swap(parameter_block1, parameter_block2);
+ swap(parameter_block1, parameter_block2);
}
// Find where in the covariance matrix the block is located.
@@ -242,7 +248,8 @@
problem->GetParameterBlocks(&all_parameter_blocks);
const ProblemImpl::ParameterMap& parameter_map = problem->parameter_map();
constant_parameter_blocks_.clear();
- vector<double*>& active_parameter_blocks = evaluate_options_.parameter_blocks;
+ vector<double*>& active_parameter_blocks =
+ evaluate_options_.parameter_blocks;
active_parameter_blocks.clear();
for (int i = 0; i < all_parameter_blocks.size(); ++i) {
double* parameter_block = all_parameter_blocks[i];
@@ -255,7 +262,7 @@
}
}
- sort(active_parameter_blocks.begin(), active_parameter_blocks.end());
+ std::sort(active_parameter_blocks.begin(), active_parameter_blocks.end());
// Compute the number of rows. Map each parameter block to the
// first row corresponding to it in the covariance matrix using the
@@ -594,8 +601,8 @@
sqrt(options_.min_reciprocal_condition_number);
const bool automatic_truncation = (options_.null_space_rank < 0);
- const int max_rank = min(num_singular_values,
- num_singular_values - options_.null_space_rank);
+ const int max_rank = std::min(num_singular_values,
+ num_singular_values - options_.null_space_rank);
// Compute the squared inverse of the singular values. Truncate the
// computation based on min_singular_value_ratio and
@@ -672,7 +679,7 @@
qr_solver(sparse_jacobian);
event_logger.AddEvent("QRDecomposition");
- if(qr_solver.info() != Eigen::Success) {
+ if (qr_solver.info() != Eigen::Success) {
LOG(ERROR) << "Eigen::SparseQR decomposition failed.";
return false;
}
diff --git a/internal/ceres/covariance_impl.h b/internal/ceres/covariance_impl.h
index 135f4a1..f2defe8 100644
--- a/internal/ceres/covariance_impl.h
+++ b/internal/ceres/covariance_impl.h
@@ -52,7 +52,8 @@
~CovarianceImpl();
bool Compute(
- const vector<pair<const double*, const double*> >& covariance_blocks,
+ const std::vector<std::pair<const double*,
+ const double*> >& covariance_blocks,
ProblemImpl* problem);
bool GetCovarianceBlock(const double* parameter_block1,
@@ -60,7 +61,8 @@
double* covariance_block) const;
bool ComputeCovarianceSparsity(
- const vector<pair<const double*, const double*> >& covariance_blocks,
+ const std::vector<std::pair<const double*,
+ const double*> >& covariance_blocks,
ProblemImpl* problem);
bool ComputeCovarianceValues();
@@ -78,8 +80,8 @@
Problem::EvaluateOptions evaluate_options_;
bool is_computed_;
bool is_valid_;
- map<const double*, int> parameter_block_to_row_index_;
- set<const double*> constant_parameter_blocks_;
+ std::map<const double*, int> parameter_block_to_row_index_;
+ std::set<const double*> constant_parameter_blocks_;
scoped_ptr<CompressedRowSparseMatrix> covariance_matrix_;
};
diff --git a/internal/ceres/covariance_test.cc b/internal/ceres/covariance_test.cc
index 6c506b7..f4fae0e 100644
--- a/internal/ceres/covariance_test.cc
+++ b/internal/ceres/covariance_test.cc
@@ -43,6 +43,11 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::map;
+using std::pair;
+using std::vector;
+
TEST(CovarianceImpl, ComputeCovarianceSparsity) {
double parameters[10];
@@ -247,7 +252,9 @@
{
double jacobian = 5.0;
- problem_.AddResidualBlock(new UnaryCostFunction(1, 1, &jacobian), NULL, z);
+ problem_.AddResidualBlock(new UnaryCostFunction(1, 1, &jacobian),
+ NULL,
+ z);
}
{
@@ -319,9 +326,15 @@
const double* block1 = covariance_blocks[i].first;
const double* block2 = covariance_blocks[i].second;
// block1, block2
- GetCovarianceBlockAndCompare(block1, block2, covariance, expected_covariance);
+ GetCovarianceBlockAndCompare(block1,
+ block2,
+ covariance,
+ expected_covariance);
// block2, block1
- GetCovarianceBlockAndCompare(block2, block1, covariance, expected_covariance);
+ GetCovarianceBlockAndCompare(block2,
+ block1,
+ covariance,
+ expected_covariance);
}
}
}
@@ -590,12 +603,12 @@
// was obtained by dropping the eigenvector corresponding to this
// eigenvalue.
double expected_covariance[] = {
- 5.4135e-02, -3.5121e-02, 1.7257e-04, 3.4514e-04, 5.1771e-04, -1.6076e-02,
- -3.5121e-02, 3.8667e-02, -1.9288e-03, -3.8576e-03, -5.7864e-03, 1.2549e-02,
- 1.7257e-04, -1.9288e-03, 2.3235e-01, -3.5297e-02, -5.2946e-02, -3.3329e-04,
- 3.4514e-04, -3.8576e-03, -3.5297e-02, 1.7941e-01, -1.0589e-01, -6.6659e-04,
- 5.1771e-04, -5.7864e-03, -5.2946e-02, -1.0589e-01, 9.1162e-02, -9.9988e-04,
- -1.6076e-02, 1.2549e-02, -3.3329e-04, -6.6659e-04, -9.9988e-04, 3.9539e-02
+ 5.4135e-02, -3.5121e-02, 1.7257e-04, 3.4514e-04, 5.1771e-04, -1.6076e-02, // NOLINT
+ -3.5121e-02, 3.8667e-02, -1.9288e-03, -3.8576e-03, -5.7864e-03, 1.2549e-02, // NOLINT
+ 1.7257e-04, -1.9288e-03, 2.3235e-01, -3.5297e-02, -5.2946e-02, -3.3329e-04, // NOLINT
+ 3.4514e-04, -3.8576e-03, -3.5297e-02, 1.7941e-01, -1.0589e-01, -6.6659e-04, // NOLINT
+ 5.1771e-04, -5.7864e-03, -5.2946e-02, -1.0589e-01, 9.1162e-02, -9.9988e-04, // NOLINT
+ -1.6076e-02, 1.2549e-02, -3.3329e-04, -6.6659e-04, -9.9988e-04, 3.9539e-02 // NOLINT
};
@@ -637,7 +650,9 @@
{
double jacobian = 5.0;
- problem_.AddResidualBlock(new UnaryCostFunction(1, 1, &jacobian), NULL, z);
+ problem_.AddResidualBlock(new UnaryCostFunction(1, 1, &jacobian),
+ NULL,
+ z);
}
{
@@ -715,7 +730,8 @@
virtual void SetUp() {
num_parameter_blocks_ = 2000;
parameter_block_size_ = 5;
- parameters_.reset(new double[parameter_block_size_ * num_parameter_blocks_]);
+ parameters_.reset(
+ new double[parameter_block_size_ * num_parameter_blocks_]);
Matrix jacobian(parameter_block_size_, parameter_block_size_);
for (int i = 0; i < num_parameter_blocks_; ++i) {
diff --git a/internal/ceres/cxsparse.cc b/internal/ceres/cxsparse.cc
index 87503d0..cf39518 100644
--- a/internal/ceres/cxsparse.cc
+++ b/internal/ceres/cxsparse.cc
@@ -38,13 +38,14 @@
#include <vector>
#include "ceres/compressed_col_sparse_matrix_utils.h"
#include "ceres/compressed_row_sparse_matrix.h"
-#include "ceres/internal/port.h"
#include "ceres/triplet_sparse_matrix.h"
#include "glog/logging.h"
namespace ceres {
namespace internal {
+using std::vector;
+
CXSparse::CXSparse() : scratch_(NULL), scratch_size_(0) {
}
@@ -128,7 +129,7 @@
int* ordering = cs_amd(1, &block_matrix);
vector<int> block_ordering(num_row_blocks, -1);
- copy(ordering, ordering + num_row_blocks, &block_ordering[0]);
+ std::copy(ordering, ordering + num_row_blocks, &block_ordering[0]);
cs_free(ordering);
vector<int> scalar_ordering;
@@ -191,7 +192,7 @@
void CXSparse::ApproximateMinimumDegreeOrdering(cs_di* A, int* ordering) {
int* cs_ordering = cs_amd(1, A);
- copy(cs_ordering, cs_ordering + A->m, ordering);
+ std::copy(cs_ordering, cs_ordering + A->m, ordering);
cs_free(cs_ordering);
}
diff --git a/internal/ceres/cxsparse.h b/internal/ceres/cxsparse.h
index 5868401..907bc51 100644
--- a/internal/ceres/cxsparse.h
+++ b/internal/ceres/cxsparse.h
@@ -107,8 +107,8 @@
// The returned matrix should be deallocated with Free when not used
// anymore.
cs_dis* BlockAnalyzeCholesky(cs_di* A,
- const vector<int>& row_blocks,
- const vector<int>& col_blocks);
+ const std::vector<int>& row_blocks,
+ const std::vector<int>& col_blocks);
// Compute an fill-reducing approximate minimum degree ordering of
// the matrix A. ordering should be non-NULL and should point to
@@ -133,8 +133,7 @@
class CXSparse {
public:
- void Free(void*) {};
-
+ void Free(void* arg) {}
};
#endif // CERES_NO_CXSPARSE
diff --git a/internal/ceres/dogleg_strategy.cc b/internal/ceres/dogleg_strategy.cc
index f29376d..a88c7e9 100644
--- a/internal/ceres/dogleg_strategy.cc
+++ b/internal/ceres/dogleg_strategy.cc
@@ -120,7 +120,8 @@
//
jacobian->SquaredColumnNorm(diagonal_.data());
for (int i = 0; i < n; ++i) {
- diagonal_[i] = min(max(diagonal_[i], min_diagonal_), max_diagonal_);
+ diagonal_[i] = std::min(std::max(diagonal_[i], min_diagonal_),
+ max_diagonal_);
}
diagonal_ = diagonal_.array().sqrt();
@@ -618,13 +619,13 @@
}
if (step_quality > increase_threshold_) {
- radius_ = max(radius_, 3.0 * dogleg_step_norm_);
+ radius_ = std::max(radius_, 3.0 * dogleg_step_norm_);
}
// Reduce the regularization multiplier, in the hope that whatever
// was causing the rank deficiency has gone away and we can return
// to doing a pure Gauss-Newton solve.
- mu_ = max(min_mu_, 2.0 * mu_ / mu_increase_factor_);
+ mu_ = std::max(min_mu_, 2.0 * mu_ / mu_increase_factor_);
reuse_ = false;
}
diff --git a/internal/ceres/dogleg_strategy_test.cc b/internal/ceres/dogleg_strategy_test.cc
index 795719d..45128a5 100644
--- a/internal/ceres/dogleg_strategy_test.cc
+++ b/internal/ceres/dogleg_strategy_test.cc
@@ -63,12 +63,12 @@
virtual void SetUp() {
Matrix basis(6, 6);
// The following lines exceed 80 characters for better readability.
- basis << -0.1046920933796121, -0.7449367449921986, -0.4190744502875876, -0.4480450716142566, 0.2375351607929440, -0.0363053418882862,
- 0.4064975684355914, 0.2681113508511354, -0.7463625494601520, -0.0803264850508117, -0.4463149623021321, 0.0130224954867195,
- -0.5514387729089798, 0.1026621026168657, -0.5008316122125011, 0.5738122212666414, 0.2974664724007106, 0.1296020877535158,
- 0.5037835370947156, 0.2668479925183712, -0.1051754618492798, -0.0272739396578799, 0.7947481647088278, -0.1776623363955670,
- -0.4005458426625444, 0.2939330589634109, -0.0682629380550051, -0.2895448882503687, -0.0457239396341685, -0.8139899477847840,
- -0.3247764582762654, 0.4528151365941945, -0.0276683863102816, -0.6155994592510784, 0.1489240599972848, 0.5362574892189350;
+ basis << -0.1046920933796121, -0.7449367449921986, -0.4190744502875876, -0.4480450716142566, 0.2375351607929440, -0.0363053418882862, // NOLINT
+ 0.4064975684355914, 0.2681113508511354, -0.7463625494601520, -0.0803264850508117, -0.4463149623021321, 0.0130224954867195, // NOLINT
+ -0.5514387729089798, 0.1026621026168657, -0.5008316122125011, 0.5738122212666414, 0.2974664724007106, 0.1296020877535158, // NOLINT
+ 0.5037835370947156, 0.2668479925183712, -0.1051754618492798, -0.0272739396578799, 0.7947481647088278, -0.1776623363955670, // NOLINT
+ -0.4005458426625444, 0.2939330589634109, -0.0682629380550051, -0.2895448882503687, -0.0457239396341685, -0.8139899477847840, // NOLINT
+ -0.3247764582762654, 0.4528151365941945, -0.0276683863102816, -0.6155994592510784, 0.1489240599972848, 0.5362574892189350; // NOLINT
Vector Ddiag(6);
Ddiag << 1.0, 2.0, 4.0, 8.0, 16.0, 32.0;
diff --git a/internal/ceres/dynamic_autodiff_cost_function_test.cc b/internal/ceres/dynamic_autodiff_cost_function_test.cc
index 42d6ab7..4e4faf9 100644
--- a/internal/ceres/dynamic_autodiff_cost_function_test.cc
+++ b/internal/ceres/dynamic_autodiff_cost_function_test.cc
@@ -39,6 +39,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// Takes 2 parameter blocks:
// parameters[0] is size 10.
// parameters[1] is size 5.
@@ -212,7 +214,7 @@
}
}
-TEST(DynamicAutodiffCostFunctionTest, JacobianWithSecondParameterBlockConstant) {
+TEST(DynamicAutodiffCostFunctionTest, JacobianWithSecondParameterBlockConstant) { // NOLINT
// Test the residual counting.
vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
diff --git a/internal/ceres/dynamic_compressed_row_finalizer.h b/internal/ceres/dynamic_compressed_row_finalizer.h
index 5e6b0d8..70c7d63 100644
--- a/internal/ceres/dynamic_compressed_row_finalizer.h
+++ b/internal/ceres/dynamic_compressed_row_finalizer.h
@@ -48,4 +48,4 @@
} // namespace internal
} // namespace ceres
-#endif // CERES_INTERNAL_DYNAMIC_COMPRESED_ROW_FINALISER_H_
+#endif // CERES_INTERNAL_DYNAMIC_COMPRESED_ROW_FINALISER_H_
diff --git a/internal/ceres/dynamic_compressed_row_jacobian_writer.cc b/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
index b46cb79..24dfdab 100644
--- a/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
+++ b/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
@@ -39,6 +39,9 @@
namespace ceres {
namespace internal {
+using std::pair;
+using std::vector;
+
ScratchEvaluatePreparer*
DynamicCompressedRowJacobianWriter::CreateEvaluatePreparers(int num_threads) {
return ScratchEvaluatePreparer::Create(*program_, num_threads);
diff --git a/internal/ceres/dynamic_compressed_row_jacobian_writer.h b/internal/ceres/dynamic_compressed_row_jacobian_writer.h
index df9581b..3d7d5e6 100644
--- a/internal/ceres/dynamic_compressed_row_jacobian_writer.h
+++ b/internal/ceres/dynamic_compressed_row_jacobian_writer.h
@@ -80,4 +80,4 @@
} // namespace internal
} // namespace ceres
-#endif // CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_JACOBIAN_WRITER_H_
+#endif // CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_JACOBIAN_WRITER_H_
diff --git a/internal/ceres/dynamic_compressed_row_sparse_matrix.h b/internal/ceres/dynamic_compressed_row_sparse_matrix.h
index 7a89a70..4a2ddd6 100644
--- a/internal/ceres/dynamic_compressed_row_sparse_matrix.h
+++ b/internal/ceres/dynamic_compressed_row_sparse_matrix.h
@@ -41,6 +41,8 @@
#ifndef CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_SPARSE_MATRIX_H_
#define CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_SPARSE_MATRIX_H_
+#include <vector>
+
#include "ceres/compressed_row_sparse_matrix.h"
namespace ceres {
@@ -89,11 +91,11 @@
void Finalize(int num_additional_elements);
private:
- vector<vector<int> > dynamic_cols_;
- vector<vector<double> > dynamic_values_;
+ std::vector<std::vector<int> > dynamic_cols_;
+ std::vector<std::vector<double> > dynamic_values_;
};
} // namespace internal
} // namespace ceres
-#endif // CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_SPARSE_MATRIX_H_
+#endif // CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_SPARSE_MATRIX_H_
diff --git a/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc b/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
index 03bfcb6..bc1de72 100644
--- a/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
+++ b/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
@@ -32,7 +32,6 @@
#include "ceres/casts.h"
#include "ceres/compressed_row_sparse_matrix.h"
-#include "ceres/casts.h"
#include "ceres/internal/eigen.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/linear_least_squares_problems.h"
@@ -42,6 +41,9 @@
namespace ceres {
namespace internal {
+using std::vector;
+using std::copy;
+
class DynamicCompressedRowSparseMatrixTest : public ::testing::Test {
protected:
virtual void SetUp() {
@@ -53,7 +55,7 @@
// Set this to some nonzero value to be sure.
num_additional_elements = 13;
- expected_num_nonzeros = num_rows * num_cols - min(num_rows, num_cols);
+ expected_num_nonzeros = num_rows * num_cols - std::min(num_rows, num_cols);
InitialiseDenseReference();
InitialiseSparseMatrixReferences();
@@ -82,8 +84,8 @@
}
void InitialiseSparseMatrixReferences() {
- std::vector<int> rows, cols;
- std::vector<double> values;
+ vector<int> rows, cols;
+ vector<double> values;
for (int i = 0; i < (num_rows * num_cols); ++i) {
const int r = i / num_cols, c = i % num_cols;
if (r != c) {
@@ -97,9 +99,9 @@
tsm.reset(new TripletSparseMatrix(num_rows,
num_cols,
expected_num_nonzeros));
- std::copy(rows.begin(), rows.end(), tsm->mutable_rows());
- std::copy(cols.begin(), cols.end(), tsm->mutable_cols());
- std::copy(values.begin(), values.end(), tsm->mutable_values());
+ copy(rows.begin(), rows.end(), tsm->mutable_rows());
+ copy(cols.begin(), cols.end(), tsm->mutable_cols());
+ copy(values.begin(), values.end(), tsm->mutable_values());
tsm->set_num_nonzeros(values.size());
Matrix dense_from_tsm;
diff --git a/internal/ceres/dynamic_numeric_diff_cost_function_test.cc b/internal/ceres/dynamic_numeric_diff_cost_function_test.cc
index 19f4d88..6d1f362 100644
--- a/internal/ceres/dynamic_numeric_diff_cost_function_test.cc
+++ b/internal/ceres/dynamic_numeric_diff_cost_function_test.cc
@@ -38,6 +38,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
const double kTolerance = 1e-6;
// Takes 2 parameter blocks:
diff --git a/internal/ceres/evaluator.h b/internal/ceres/evaluator.h
index 8fc60b8..7fec1ee 100644
--- a/internal/ceres/evaluator.h
+++ b/internal/ceres/evaluator.h
@@ -95,8 +95,8 @@
static bool Evaluate(Program* program,
int num_threads,
double* cost,
- vector<double>* residuals,
- vector<double>* gradient,
+ std::vector<double>* residuals,
+ std::vector<double>* gradient,
CRSMatrix* jacobian);
// Build and return a sparse matrix for storing and working with the Jacobian
@@ -190,12 +190,12 @@
// that the base class implementation does not have to worry about
// life time issues. Further, these calls are not expected to be
// frequent or performance sensitive.
- virtual map<string, int> CallStatistics() const {
- return map<string, int>();
+ virtual std::map<string, int> CallStatistics() const {
+ return std::map<string, int>();
}
- virtual map<string, double> TimeStatistics() const {
- return map<string, double>();
+ virtual std::map<string, double> TimeStatistics() const {
+ return std::map<string, double>();
}
};
diff --git a/internal/ceres/evaluator_test.cc b/internal/ceres/evaluator_test.cc
index c0de3fc..ddfafd9 100644
--- a/internal/ceres/evaluator_test.cc
+++ b/internal/ceres/evaluator_test.cc
@@ -51,6 +51,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// TODO(keir): Consider pushing this into a common test utils file.
template<int kFactor, int kNumResiduals,
int N0 = 0, int N1 = 0, int N2 = 0, bool kSucceeds = true>
diff --git a/internal/ceres/execution_summary.h b/internal/ceres/execution_summary.h
index 29bdc69..3f684f9 100644
--- a/internal/ceres/execution_summary.h
+++ b/internal/ceres/execution_summary.h
@@ -56,15 +56,15 @@
calls_[name] += 1;
}
- const map<string, double>& times() const { return times_; }
- const map<string, int>& calls() const { return calls_; }
+ const std::map<string, double>& times() const { return times_; }
+ const std::map<string, int>& calls() const { return calls_; }
private:
Mutex times_mutex_;
- map<string, double> times_;
+ std::map<string, double> times_;
Mutex calls_mutex_;
- map<string, int> calls_;
+ std::map<string, int> calls_;
};
class ScopedExecutionTimer {
diff --git a/internal/ceres/gradient_checker_test.cc b/internal/ceres/gradient_checker_test.cc
index fa0d841..aa60fdc 100644
--- a/internal/ceres/gradient_checker_test.cc
+++ b/internal/ceres/gradient_checker_test.cc
@@ -44,6 +44,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// We pick a (non-quadratic) function whose derivative are easy:
//
// f = exp(- a' x).
diff --git a/internal/ceres/gradient_checking_cost_function.cc b/internal/ceres/gradient_checking_cost_function.cc
index 3272848..52b649b 100644
--- a/internal/ceres/gradient_checking_cost_function.cc
+++ b/internal/ceres/gradient_checking_cost_function.cc
@@ -51,6 +51,9 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
// True if x and y have an absolute relative difference less than
@@ -68,7 +71,7 @@
relative_error = &local_relative_error;
}
*absolute_error = fabs(x - y);
- *relative_error = *absolute_error / max(fabs(x), fabs(y));
+ *relative_error = *absolute_error / std::max(fabs(x), fabs(y));
if (x == 0 || y == 0) {
// If x or y is exactly zero, then relative difference doesn't have any
// meaning. Take the absolute difference instead.
@@ -121,7 +124,8 @@
vector<Matrix> term_jacobians(block_sizes.size());
vector<Matrix> finite_difference_jacobians(block_sizes.size());
vector<double*> term_jacobian_pointers(block_sizes.size());
- vector<double*> finite_difference_jacobian_pointers(block_sizes.size());
+ vector<double*> finite_difference_jacobian_pointers(
+ block_sizes.size());
for (int i = 0; i < block_sizes.size(); i++) {
term_jacobians[i].resize(num_residuals, block_sizes[i]);
term_jacobian_pointers[i] = term_jacobians[i].data();
@@ -259,7 +263,8 @@
// For every ParameterBlock in problem_impl, create a new parameter
// block with the same local parameterization and constancy.
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program->parameter_blocks();
for (int i = 0; i < parameter_blocks.size(); ++i) {
ParameterBlock* parameter_block = parameter_blocks[i];
gradient_checking_problem_impl->AddParameterBlock(
@@ -276,7 +281,8 @@
// For every ResidualBlock in problem_impl, create a new
// ResidualBlock by wrapping its CostFunction inside a
// GradientCheckingCostFunction.
- const vector<ResidualBlock*>& residual_blocks = program->residual_blocks();
+ const vector<ResidualBlock*>& residual_blocks =
+ program->residual_blocks();
for (int i = 0; i < residual_blocks.size(); ++i) {
ResidualBlock* residual_block = residual_blocks[i];
diff --git a/internal/ceres/gradient_checking_cost_function_test.cc b/internal/ceres/gradient_checking_cost_function_test.cc
index caba2f6..7bdc4da 100644
--- a/internal/ceres/gradient_checking_cost_function_test.cc
+++ b/internal/ceres/gradient_checking_cost_function_test.cc
@@ -48,6 +48,7 @@
#include "gmock/mock-log.h"
#include "gtest/gtest.h"
+using std::vector;
using testing::AllOf;
using testing::AnyNumber;
using testing::HasSubstr;
diff --git a/internal/ceres/gradient_problem_evaluator.h b/internal/ceres/gradient_problem_evaluator.h
index 20053de..7d144e3 100644
--- a/internal/ceres/gradient_problem_evaluator.h
+++ b/internal/ceres/gradient_problem_evaluator.h
@@ -79,11 +79,11 @@
virtual int NumResiduals() const { return 1; }
- virtual map<string, int> CallStatistics() const {
+ virtual std::map<string, int> CallStatistics() const {
return execution_summary_.calls();
}
- virtual map<string, double> TimeStatistics() const {
+ virtual std::map<string, double> TimeStatistics() const {
return execution_summary_.times();
}
diff --git a/internal/ceres/gradient_problem_solver.cc b/internal/ceres/gradient_problem_solver.cc
index 4fda929..aea0804 100644
--- a/internal/ceres/gradient_problem_solver.cc
+++ b/internal/ceres/gradient_problem_solver.cc
@@ -155,7 +155,7 @@
SetSummaryFinalCost(summary);
}
- const map<string, double>& evaluator_time_statistics =
+ const std::map<string, double>& evaluator_time_statistics =
minimizer_options.evaluator->TimeStatistics();
summary->cost_evaluation_time_in_seconds =
FindWithDefault(evaluator_time_statistics, "Evaluator::Residual", 0.0);
@@ -199,7 +199,7 @@
initial_cost,
final_cost,
TerminationTypeToString(termination_type));
-};
+}
string GradientProblemSolver::Summary::FullReport() const {
using internal::VersionString;
@@ -263,7 +263,7 @@
StringAppendF(&report, "Termination: %25s (%s)\n",
TerminationTypeToString(termination_type), message.c_str());
return report;
-};
+}
void Solve(const GradientProblemSolver::Options& options,
const GradientProblem& problem,
diff --git a/internal/ceres/graph.h b/internal/ceres/graph.h
index f639d15..c9d8514 100644
--- a/internal/ceres/graph.h
+++ b/internal/ceres/graph.h
@@ -139,9 +139,9 @@
for (typename HashSet<Vertex>::const_iterator it = sinks.begin();
it != sinks.end(); ++it) {
if (vertex < *it) {
- edge_weights_.erase(make_pair(vertex, *it));
+ edge_weights_.erase(std::make_pair(vertex, *it));
} else {
- edge_weights_.erase(make_pair(*it, vertex));
+ edge_weights_.erase(std::make_pair(*it, vertex));
}
edges_[*it].erase(vertex);
}
@@ -165,9 +165,9 @@
}
if (vertex1 < vertex2) {
- edge_weights_[make_pair(vertex1, vertex2)] = weight;
+ edge_weights_[std::make_pair(vertex1, vertex2)] = weight;
} else {
- edge_weights_[make_pair(vertex2, vertex1)] = weight;
+ edge_weights_[std::make_pair(vertex2, vertex1)] = weight;
}
}
@@ -188,9 +188,11 @@
// the edge weight is zero.
double EdgeWeight(const Vertex& vertex1, const Vertex& vertex2) const {
if (vertex1 < vertex2) {
- return FindWithDefault(edge_weights_, make_pair(vertex1, vertex2), 0.0);
+ return FindWithDefault(edge_weights_,
+ std::make_pair(vertex1, vertex2), 0.0);
} else {
- return FindWithDefault(edge_weights_, make_pair(vertex2, vertex1), 0.0);
+ return FindWithDefault(edge_weights_,
+ std::make_pair(vertex2, vertex1), 0.0);
}
}
@@ -206,13 +208,13 @@
static double InvalidWeight() {
return std::numeric_limits<double>::quiet_NaN();
- };
+ }
private:
HashSet<Vertex> vertices_;
HashMap<Vertex, double> vertex_weights_;
HashMap<Vertex, HashSet<Vertex> > edges_;
- HashMap<pair<Vertex, Vertex>, double> edge_weights_;
+ HashMap<std::pair<Vertex, Vertex>, double> edge_weights_;
CERES_DISALLOW_COPY_AND_ASSIGN(WeightedGraph);
};
diff --git a/internal/ceres/graph_algorithms.h b/internal/ceres/graph_algorithms.h
index fb75e2f..7724f8d 100644
--- a/internal/ceres/graph_algorithms.h
+++ b/internal/ceres/graph_algorithms.h
@@ -95,7 +95,7 @@
// cardinality of S.
template <typename Vertex>
int IndependentSetOrdering(const Graph<Vertex>& graph,
- vector<Vertex>* ordering) {
+ std::vector<Vertex>* ordering) {
const HashSet<Vertex>& vertices = graph.vertices();
const int num_vertices = vertices.size();
@@ -110,7 +110,7 @@
// Mark all vertices white.
HashMap<Vertex, char> vertex_color;
- vector<Vertex> vertex_queue;
+ std::vector<Vertex> vertex_queue;
for (typename HashSet<Vertex>::const_iterator it = vertices.begin();
it != vertices.end();
++it) {
@@ -119,8 +119,8 @@
}
- sort(vertex_queue.begin(), vertex_queue.end(),
- VertexTotalOrdering<Vertex>(graph));
+ std::sort(vertex_queue.begin(), vertex_queue.end(),
+ VertexTotalOrdering<Vertex>(graph));
// Iterate over vertex_queue. Pick the first white vertex, add it
// to the independent set. Mark it black and its neighbors grey.
@@ -145,7 +145,7 @@
// Iterate over the vertices and add all the grey vertices to the
// ordering. At this stage there should only be black or grey
// vertices in the graph.
- for (typename vector<Vertex>::const_iterator it = vertex_queue.begin();
+ for (typename std::vector<Vertex>::const_iterator it = vertex_queue.begin();
it != vertex_queue.end();
++it) {
const Vertex vertex = *it;
@@ -171,7 +171,7 @@
// ordering algorithm over all.
template <typename Vertex>
int StableIndependentSetOrdering(const Graph<Vertex>& graph,
- vector<Vertex>* ordering) {
+ std::vector<Vertex>* ordering) {
CHECK_NOTNULL(ordering);
const HashSet<Vertex>& vertices = graph.vertices();
const int num_vertices = vertices.size();
@@ -182,10 +182,10 @@
const char kGrey = 1;
const char kBlack = 2;
- vector<Vertex> vertex_queue(*ordering);
+ std::vector<Vertex> vertex_queue(*ordering);
- stable_sort(vertex_queue.begin(), vertex_queue.end(),
- VertexDegreeLessThan<Vertex>(graph));
+ std::stable_sort(vertex_queue.begin(), vertex_queue.end(),
+ VertexDegreeLessThan<Vertex>(graph));
// Mark all vertices white.
HashMap<Vertex, char> vertex_color;
@@ -220,7 +220,7 @@
// Iterate over the vertices and add all the grey vertices to the
// ordering. At this stage there should only be black or grey
// vertices in the graph.
- for (typename vector<Vertex>::const_iterator it = vertex_queue.begin();
+ for (typename std::vector<Vertex>::const_iterator it = vertex_queue.begin();
it != vertex_queue.end();
++it) {
const Vertex vertex = *it;
@@ -274,7 +274,7 @@
WeightedGraph<Vertex>*
Degree2MaximumSpanningForest(const WeightedGraph<Vertex>& graph) {
// Array of edges sorted in decreasing order of their weights.
- vector<pair<double, pair<Vertex, Vertex> > > weighted_edges;
+ std::vector<std::pair<double, std::pair<Vertex, Vertex> > > weighted_edges;
WeightedGraph<Vertex>* forest = new WeightedGraph<Vertex>();
// Disjoint-set to keep track of the connected components in the
@@ -302,19 +302,20 @@
continue;
}
const double weight = graph.EdgeWeight(vertex1, vertex2);
- weighted_edges.push_back(make_pair(weight, make_pair(vertex1, vertex2)));
+ weighted_edges.push_back(
+ std::make_pair(weight, std::make_pair(vertex1, vertex2)));
}
}
// The elements of this vector, are pairs<edge_weight,
// edge>. Sorting it using the reverse iterators gives us the edges
// in decreasing order of edges.
- sort(weighted_edges.rbegin(), weighted_edges.rend());
+ std::sort(weighted_edges.rbegin(), weighted_edges.rend());
// Greedily add edges to the spanning tree/forest as long as they do
// not violate the degree/cycle constraint.
for (int i =0; i < weighted_edges.size(); ++i) {
- const pair<Vertex, Vertex>& edge = weighted_edges[i].second;
+ const std::pair<Vertex, Vertex>& edge = weighted_edges[i].second;
const Vertex vertex1 = edge.first;
const Vertex vertex2 = edge.second;
@@ -350,7 +351,7 @@
// lookup.
if (root2 < root1) {
std::swap(root1, root2);
- };
+ }
disjoint_set[root2] = root1;
}
diff --git a/internal/ceres/graph_algorithms_test.cc b/internal/ceres/graph_algorithms_test.cc
index bbb1e0d..61b9646 100644
--- a/internal/ceres/graph_algorithms_test.cc
+++ b/internal/ceres/graph_algorithms_test.cc
@@ -40,6 +40,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
TEST(IndependentSetOrdering, Chain) {
Graph<int> graph;
graph.AddVertex(0);
@@ -238,7 +240,7 @@
EXPECT_EQ(independent_set_size, 1);
EXPECT_EQ(ordering[0], 1);
}
-
}
+
} // namespace internal
} // namespace ceres
diff --git a/internal/ceres/implicit_schur_complement.h b/internal/ceres/implicit_schur_complement.h
index c992bdc..99b67af 100644
--- a/internal/ceres/implicit_schur_complement.h
+++ b/internal/ceres/implicit_schur_complement.h
@@ -97,7 +97,7 @@
//
// TODO(sameeragarwal): Get rid of the two bools below and replace
// them with enums.
- ImplicitSchurComplement(const LinearSolver::Options& options);
+ explicit ImplicitSchurComplement(const LinearSolver::Options& options);
virtual ~ImplicitSchurComplement();
// Initialize the Schur complement for a linear least squares
diff --git a/internal/ceres/implicit_schur_complement_test.cc b/internal/ceres/implicit_schur_complement_test.cc
index 3369ecb..8b40da4 100644
--- a/internal/ceres/implicit_schur_complement_test.cc
+++ b/internal/ceres/implicit_schur_complement_test.cc
@@ -74,7 +74,7 @@
Vector* solution) {
const CompressedRowBlockStructure* bs = A_->block_structure();
const int num_col_blocks = bs->cols.size();
- vector<int> blocks(num_col_blocks - num_eliminate_blocks_, 0);
+ std::vector<int> blocks(num_col_blocks - num_eliminate_blocks_, 0);
for (int i = num_eliminate_blocks_; i < num_col_blocks; ++i) {
blocks[i - num_eliminate_blocks_] = bs->cols[i].size;
}
diff --git a/internal/ceres/lapack.cc b/internal/ceres/lapack.cc
index e124d75..a3d9980 100644
--- a/internal/ceres/lapack.cc
+++ b/internal/ceres/lapack.cc
@@ -110,7 +110,7 @@
*message = "Success";
return LINEAR_SOLVER_SUCCESS;
#endif
-};
+}
int LAPACK::EstimateWorkSizeForQR(int num_rows, int num_cols) {
#ifdef CERES_NO_LAPACK
diff --git a/internal/ceres/levenberg_marquardt_strategy.cc b/internal/ceres/levenberg_marquardt_strategy.cc
index ce3b69a..e47ef48 100644
--- a/internal/ceres/levenberg_marquardt_strategy.cc
+++ b/internal/ceres/levenberg_marquardt_strategy.cc
@@ -79,7 +79,8 @@
jacobian->SquaredColumnNorm(diagonal_.data());
for (int i = 0; i < num_parameters; ++i) {
- diagonal_[i] = min(max(diagonal_[i], min_diagonal_), max_diagonal_);
+ diagonal_[i] = std::min(std::max(diagonal_[i], min_diagonal_),
+ max_diagonal_);
}
}
diff --git a/internal/ceres/line_search.cc b/internal/ceres/line_search.cc
index 8c2624e..d9343c9 100644
--- a/internal/ceres/line_search.cc
+++ b/internal/ceres/line_search.cc
@@ -44,6 +44,11 @@
namespace ceres {
namespace internal {
+
+using std::map;
+using std::ostream;
+using std::vector;
+
namespace {
// Precision used for floating point values in error message output.
const int kErrorMessageNumericPrecision = 8;
@@ -54,7 +59,7 @@
sample.value = value;
sample.value_is_valid = true;
return sample;
-};
+}
FunctionSample ValueAndGradientSample(const double x,
const double value,
@@ -66,15 +71,15 @@
sample.value_is_valid = true;
sample.gradient_is_valid = true;
return sample;
-};
+}
} // namespace
-std::ostream& operator<<(std::ostream &os, const FunctionSample& sample);
+ostream& operator<<(ostream &os, const FunctionSample& sample);
// Convenience stream operator for pushing FunctionSamples into log messages.
-std::ostream& operator<<(std::ostream &os, const FunctionSample& sample) {
+ostream& operator<<(ostream &os, const FunctionSample& sample) {
os << sample.ToDebugString();
return os;
}
@@ -208,7 +213,7 @@
max_step_size <= current.x)) {
// Either: sample is invalid; or we are using BISECTION and contracting
// the step size.
- return min(max(current.x * 0.5, min_step_size), max_step_size);
+ return std::min(std::max(current.x * 0.5, min_step_size), max_step_size);
} else if (interpolation_type == BISECTION) {
CHECK_GT(max_step_size, current.x);
// We are expanding the search (during a Wolfe bracketing phase) using
diff --git a/internal/ceres/line_search_direction.cc b/internal/ceres/line_search_direction.cc
index dddcecd..2d86c22 100644
--- a/internal/ceres/line_search_direction.cc
+++ b/internal/ceres/line_search_direction.cc
@@ -86,7 +86,7 @@
LOG(WARNING) << "Restarting non-linear conjugate gradients: "
<< directional_derivative;
*search_direction = -current.gradient;
- };
+ }
return true;
}
diff --git a/internal/ceres/line_search_minimizer.cc b/internal/ceres/line_search_minimizer.cc
index d36545d..85cc031 100644
--- a/internal/ceres/line_search_minimizer.cc
+++ b/internal/ceres/line_search_minimizer.cc
@@ -290,9 +290,9 @@
// iteration.
const double initial_step_size =
(iteration_summary.iteration == 1 || !line_search_status)
- ? min(1.0, 1.0 / current_state.gradient_max_norm)
- : min(1.0, 2.0 * (current_state.cost - previous_state.cost) /
- current_state.directional_derivative);
+ ? std::min(1.0, 1.0 / current_state.gradient_max_norm)
+ : std::min(1.0, 2.0 * (current_state.cost - previous_state.cost) /
+ current_state.directional_derivative);
// By definition, we should only ever go forwards along the specified search
// direction in a line search, most likely cause for this being violated
// would be a numerical failure in the line search direction calculation.
diff --git a/internal/ceres/linear_least_squares_problems.cc b/internal/ceres/linear_least_squares_problems.cc
index 24ba565..b6a6a8c 100644
--- a/internal/ceres/linear_least_squares_problems.cc
+++ b/internal/ceres/linear_least_squares_problems.cc
@@ -97,11 +97,11 @@
int counter = 0;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j< 2; ++j) {
- Ai[counter]=i;
- Aj[counter]=j;
+ Ai[counter] = i;
+ Aj[counter] = j;
++counter;
}
- };
+ }
Ax[0] = 1.;
Ax[1] = 2.;
@@ -527,7 +527,7 @@
LOG(INFO) << "x: \n" << ConstVectorRef(x, A->num_cols());
}
return true;
-};
+}
void WriteArrayToFileOrDie(const string& filename,
const double* x,
@@ -619,7 +619,7 @@
num_eliminate_blocks);
default:
LOG(FATAL) << "Unknown DumpFormatType " << dump_format_type;
- };
+ }
return true;
}
diff --git a/internal/ceres/linear_solver.h b/internal/ceres/linear_solver.h
index 5f59765..14f171c 100644
--- a/internal/ceres/linear_solver.h
+++ b/internal/ceres/linear_solver.h
@@ -144,7 +144,7 @@
// elimination group must form an independent set in the normal
// equations. The first elimination group corresponds to the
// num_eliminate_blocks in the Schur type solvers.
- vector<int> elimination_groups;
+ std::vector<int> elimination_groups;
// Iterative solvers, e.g. Preconditioned Conjugate Gradients
// maintain a cheap estimate of the residual which may become
@@ -296,12 +296,12 @@
// that the base class implementation does not have to worry about
// life time issues. Further, these calls are not expected to be
// frequent or performance sensitive.
- virtual map<string, int> CallStatistics() const {
- return map<string, int>();
+ virtual std::map<string, int> CallStatistics() const {
+ return std::map<string, int>();
}
- virtual map<string, double> TimeStatistics() const {
- return map<string, double>();
+ virtual std::map<string, double> TimeStatistics() const {
+ return std::map<string, double>();
}
// Factory
@@ -331,11 +331,11 @@
return SolveImpl(down_cast<MatrixType*>(A), b, per_solve_options, x);
}
- virtual map<string, int> CallStatistics() const {
+ virtual std::map<string, int> CallStatistics() const {
return execution_summary_.calls();
}
- virtual map<string, double> TimeStatistics() const {
+ virtual std::map<string, double> TimeStatistics() const {
return execution_summary_.times();
}
diff --git a/internal/ceres/local_parameterization.cc b/internal/ceres/local_parameterization.cc
index a4832c5..3d2e9d6 100644
--- a/internal/ceres/local_parameterization.cc
+++ b/internal/ceres/local_parameterization.cc
@@ -36,6 +36,8 @@
namespace ceres {
+using std::vector;
+
LocalParameterization::~LocalParameterization() {
}
diff --git a/internal/ceres/local_parameterization_test.cc b/internal/ceres/local_parameterization_test.cc
index 6e7e87b..6d52e4f 100644
--- a/internal/ceres/local_parameterization_test.cc
+++ b/internal/ceres/local_parameterization_test.cc
@@ -71,7 +71,7 @@
}
TEST(SubsetParameterization, DeathTests) {
- vector<int> constant_parameters;
+ std::vector<int> constant_parameters;
EXPECT_DEATH_IF_SUPPORTED(
SubsetParameterization parameterization(1, constant_parameters),
"at least");
@@ -98,7 +98,7 @@
double x[kGlobalSize] = {1.0, 2.0, 3.0, 4.0};
for (int i = 0; i < kGlobalSize; ++i) {
- vector<int> constant_parameters;
+ std::vector<int> constant_parameters;
constant_parameters.push_back(i);
SubsetParameterization parameterization(kGlobalSize, constant_parameters);
double delta[kLocalSize] = {1.0, 2.0, 3.0};
@@ -146,7 +146,7 @@
Matrix expected_local_matrix =
global_matrix * MatrixRef(jacobian, kGlobalSize, kLocalSize);
EXPECT_EQ((local_matrix - expected_local_matrix).norm(), 0.0);
- };
+ }
}
// Functor needed to implement automatically differentiated Plus for
diff --git a/internal/ceres/low_rank_inverse_hessian.cc b/internal/ceres/low_rank_inverse_hessian.cc
index 4816e3c..3a20c9b 100644
--- a/internal/ceres/low_rank_inverse_hessian.cc
+++ b/internal/ceres/low_rank_inverse_hessian.cc
@@ -37,6 +37,8 @@
namespace ceres {
namespace internal {
+using std::list;
+
// The (L)BFGS algorithm explicitly requires that the secant equation:
//
// B_{k+1} * s_k = y_k
@@ -126,7 +128,7 @@
const int num_corrections = indices_.size();
Vector alpha(num_corrections);
- for (std::list<int>::const_reverse_iterator it = indices_.rbegin();
+ for (list<int>::const_reverse_iterator it = indices_.rbegin();
it != indices_.rend();
++it) {
const double alpha_i = delta_x_history_.col(*it).dot(search_direction) /
@@ -173,7 +175,7 @@
<< "approximation.";
}
- for (std::list<int>::const_iterator it = indices_.begin();
+ for (list<int>::const_iterator it = indices_.begin();
it != indices_.end();
++it) {
const double beta = delta_gradient_history_.col(*it).dot(search_direction) /
diff --git a/internal/ceres/map_util.h b/internal/ceres/map_util.h
index 929c6b3..9ba81e5 100644
--- a/internal/ceres/map_util.h
+++ b/internal/ceres/map_util.h
@@ -87,8 +87,8 @@
Collection * const collection,
const typename Collection::value_type::first_type& key,
const typename Collection::value_type::second_type& value) {
- pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, value));
+ std::pair<typename Collection::iterator, bool> ret =
+ collection->insert(typename Collection::value_type(key, value));
return ret.second;
}
diff --git a/internal/ceres/minimizer.cc b/internal/ceres/minimizer.cc
index 558921b..50fbef7 100644
--- a/internal/ceres/minimizer.cc
+++ b/internal/ceres/minimizer.cc
@@ -68,7 +68,8 @@
return true;
case SOLVER_TERMINATE_SUCCESSFULLY:
summary->termination_type = USER_SUCCESS;
- summary->message = "User callback returned SOLVER_TERMINATE_SUCCESSFULLY.";
+ summary->message =
+ "User callback returned SOLVER_TERMINATE_SUCCESSFULLY.";
VLOG_IF(1, is_not_silent) << "Terminating: " << summary->message;
return false;
case SOLVER_ABORT:
diff --git a/internal/ceres/minimizer.h b/internal/ceres/minimizer.h
index dabf07e..24c8e67 100644
--- a/internal/ceres/minimizer.h
+++ b/internal/ceres/minimizer.h
@@ -132,7 +132,7 @@
bool jacobi_scaling;
bool use_nonmonotonic_steps;
int max_consecutive_nonmonotonic_steps;
- vector<int> trust_region_minimizer_iterations_to_dump;
+ std::vector<int> trust_region_minimizer_iterations_to_dump;
DumpFormatType trust_region_problem_dump_format_type;
string trust_region_problem_dump_directory;
int max_num_consecutive_invalid_steps;
@@ -163,7 +163,7 @@
// of each iteration.
//
// The Options struct does not own these pointers.
- vector<IterationCallback*> callbacks;
+ std::vector<IterationCallback*> callbacks;
// Object responsible for evaluating the cost, residuals and
// Jacobian matrix.
diff --git a/internal/ceres/ordered_groups_test.cc b/internal/ceres/ordered_groups_test.cc
index 9e16c1d..09569e1 100644
--- a/internal/ceres/ordered_groups_test.cc
+++ b/internal/ceres/ordered_groups_test.cc
@@ -166,7 +166,7 @@
ordering.AddElementToGroup(x + 1, 2);
ordering.AddElementToGroup(x + 2, 2);
- vector<double*> elements_to_remove;
+ std::vector<double*> elements_to_remove;
elements_to_remove.push_back(x);
elements_to_remove.push_back(x + 2);
@@ -181,7 +181,7 @@
ParameterBlockOrdering ordering;
double x[3];
- vector<double*> elements_to_remove;
+ std::vector<double*> elements_to_remove;
elements_to_remove.push_back(x);
elements_to_remove.push_back(x + 2);
diff --git a/internal/ceres/parameter_block.h b/internal/ceres/parameter_block.h
index 7bc823d..1ef8673 100644
--- a/internal/ceres/parameter_block.h
+++ b/internal/ceres/parameter_block.h
@@ -193,7 +193,7 @@
}
upper_bounds_[index] = upper_bound;
- };
+ }
void SetLowerBound(int index, double lower_bound) {
CHECK_LT(index, size_);
diff --git a/internal/ceres/parameter_block_ordering.cc b/internal/ceres/parameter_block_ordering.cc
index 1525de9..2df6988 100644
--- a/internal/ceres/parameter_block_ordering.cc
+++ b/internal/ceres/parameter_block_ordering.cc
@@ -43,6 +43,10 @@
namespace ceres {
namespace internal {
+using std::map;
+using std::set;
+using std::vector;
+
int ComputeStableSchurOrdering(const Program& program,
vector<ParameterBlock*>* ordering) {
CHECK_NOTNULL(ordering)->clear();
diff --git a/internal/ceres/parameter_block_ordering.h b/internal/ceres/parameter_block_ordering.h
index 5de9951..5a923e9 100644
--- a/internal/ceres/parameter_block_ordering.h
+++ b/internal/ceres/parameter_block_ordering.h
@@ -56,13 +56,13 @@
// complement of the independent set,
// fixed blocks]
int ComputeSchurOrdering(const Program& program,
- vector<ParameterBlock* >* ordering);
+ std::vector<ParameterBlock* >* ordering);
// Same as above, except that ties while computing the independent set
// ordering are resolved in favour of the order in which the parameter
// blocks occur in the program.
int ComputeStableSchurOrdering(const Program& program,
- vector<ParameterBlock* >* ordering);
+ std::vector<ParameterBlock* >* ordering);
// Use an approximate independent set ordering to decompose the
// parameter blocks of a problem in a sequence of independent
@@ -81,7 +81,7 @@
// Iterate over each of the groups in order of their priority and fill
// summary with their sizes.
void OrderingToGroupSizes(const ParameterBlockOrdering* ordering,
- vector<int>* group_sizes);
+ std::vector<int>* group_sizes);
} // namespace internal
} // namespace ceres
diff --git a/internal/ceres/parameter_block_ordering_test.cc b/internal/ceres/parameter_block_ordering_test.cc
index bc497d0..dfc7b20 100644
--- a/internal/ceres/parameter_block_ordering_test.cc
+++ b/internal/ceres/parameter_block_ordering_test.cc
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
typedef Graph<ParameterBlock*> HessianGraph;
typedef HashSet<ParameterBlock*> VertexSet;
@@ -82,7 +84,8 @@
TEST_F(SchurOrderingTest, NoFixed) {
const Program& program = problem_.program();
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program.parameter_blocks();
scoped_ptr<HessianGraph> graph(CreateHessianGraph(program));
const VertexSet& vertices = graph->vertices();
@@ -136,7 +139,8 @@
problem_.SetParameterBlockConstant(x_);
const Program& program = problem_.program();
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program.parameter_blocks();
scoped_ptr<HessianGraph> graph(CreateHessianGraph(program));
const VertexSet& vertices = graph->vertices();
diff --git a/internal/ceres/parameter_block_test.cc b/internal/ceres/parameter_block_test.cc
index 5a2db3c..f01e0ad 100644
--- a/internal/ceres/parameter_block_test.cc
+++ b/internal/ceres/parameter_block_test.cc
@@ -41,7 +41,7 @@
ParameterBlock parameter_block(x, 3, -1);
// The indices to set constant within the parameter block (used later).
- vector<int> indices;
+ std::vector<int> indices;
indices.push_back(1);
// Can't set the parameterization if the sizes don't match.
diff --git a/internal/ceres/partitioned_matrix_view_impl.h b/internal/ceres/partitioned_matrix_view_impl.h
index ae7f776..ff041b9 100644
--- a/internal/ceres/partitioned_matrix_view_impl.h
+++ b/internal/ceres/partitioned_matrix_view_impl.h
@@ -61,7 +61,7 @@
// explicit_schur_complement_solver.h
num_row_blocks_e_ = 0;
for (int r = 0; r < bs->rows.size(); ++r) {
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
if (cells[0].block_id < num_col_blocks_e_) {
++num_row_blocks_e_;
}
@@ -131,7 +131,7 @@
for (int r = 0; r < num_row_blocks_e_; ++r) {
const int row_block_pos = bs->rows[r].block.position;
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 1; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_pos = bs->cols[col_block_id].position;
@@ -146,7 +146,7 @@
for (int r = num_row_blocks_e_; r < bs->rows.size(); ++r) {
const int row_block_pos = bs->rows[r].block.position;
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 0; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_pos = bs->cols[col_block_id].position;
@@ -197,7 +197,7 @@
for (int r = 0; r < num_row_blocks_e_; ++r) {
const int row_block_pos = bs->rows[r].block.position;
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 1; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_pos = bs->cols[col_block_id].position;
@@ -212,7 +212,7 @@
for (int r = num_row_blocks_e_; r < bs->rows.size(); ++r) {
const int row_block_pos = bs->rows[r].block.position;
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 0; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_pos = bs->cols[col_block_id].position;
@@ -339,7 +339,7 @@
const double* values = matrix_.values();
for (int r = 0; r < num_row_blocks_e_; ++r) {
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 1; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_size = bs->cols[col_block_id].size;
@@ -358,7 +358,7 @@
for (int r = num_row_blocks_e_; r < bs->rows.size(); ++r) {
const int row_block_size = bs->rows[r].block.size;
- const vector<Cell>& cells = bs->rows[r].cells;
+ const std::vector<Cell>& cells = bs->rows[r].cells;
for (int c = 0; c < cells.size(); ++c) {
const int col_block_id = cells[c].block_id;
const int col_block_size = bs->cols[col_block_id].size;
diff --git a/internal/ceres/polynomial.cc b/internal/ceres/polynomial.cc
index 75f43de..848fbee 100644
--- a/internal/ceres/polynomial.cc
+++ b/internal/ceres/polynomial.cc
@@ -42,6 +42,9 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
// Balancing function as described by B. N. Parlett and C. Reinsch,
diff --git a/internal/ceres/polynomial.h b/internal/ceres/polynomial.h
index 80ce77e..aaa4401 100644
--- a/internal/ceres/polynomial.h
+++ b/internal/ceres/polynomial.h
@@ -32,6 +32,7 @@
#ifndef CERES_INTERNAL_POLYNOMIAL_SOLVER_H_
#define CERES_INTERNAL_POLYNOMIAL_SOLVER_H_
+#include <string>
#include <vector>
#include "ceres/internal/eigen.h"
#include "ceres/internal/port.h"
@@ -115,7 +116,7 @@
// Of course its possible to sample a polynomial any number of times,
// in which case, generally speaking the spurious higher order
// coefficients will be zero.
-Vector FindInterpolatingPolynomial(const vector<FunctionSample>& samples);
+Vector FindInterpolatingPolynomial(const std::vector<FunctionSample>& samples);
// Interpolate the function described by samples with a polynomial,
// and minimize it on the interval [x_min, x_max]. Depending on the
@@ -123,7 +124,7 @@
// finding algorithms may fail due to numerical difficulties. But the
// function is guaranteed to return its best guess of an answer, by
// considering the samples and the end points as possible solutions.
-void MinimizeInterpolatingPolynomial(const vector<FunctionSample>& samples,
+void MinimizeInterpolatingPolynomial(const std::vector<FunctionSample>& samples,
double x_min,
double x_max,
double* optimal_x,
diff --git a/internal/ceres/polynomial_test.cc b/internal/ceres/polynomial_test.cc
index 3339973..de111f6 100644
--- a/internal/ceres/polynomial_test.cc
+++ b/internal/ceres/polynomial_test.cc
@@ -40,6 +40,9 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
// For IEEE-754 doubles, machine precision is about 2e-16.
diff --git a/internal/ceres/preconditioner.h b/internal/ceres/preconditioner.h
index e8d5994..5db5356 100644
--- a/internal/ceres/preconditioner.h
+++ b/internal/ceres/preconditioner.h
@@ -80,7 +80,7 @@
// elimination group must form an independent set in the normal
// equations. The first elimination group corresponds to the
// num_eliminate_blocks in the Schur type solvers.
- vector<int> elimination_groups;
+ std::vector<int> elimination_groups;
// If the block sizes in a BlockSparseMatrix are fixed, then in
// some cases the Schur complement based solvers can detect and
diff --git a/internal/ceres/preprocessor.h b/internal/ceres/preprocessor.h
index b4ca5b1..5269eeb 100644
--- a/internal/ceres/preprocessor.h
+++ b/internal/ceres/preprocessor.h
@@ -31,6 +31,9 @@
#ifndef CERES_INTERNAL_PREPROCESSOR_H_
#define CERES_INTERNAL_PREPROCESSOR_H_
+#include <string>
+#include <vector>
+
#include "ceres/coordinate_descent_minimizer.h"
#include "ceres/evaluator.h"
#include "ceres/internal/eigen.h"
@@ -65,7 +68,7 @@
// The output of the Preprocessor is stored in a PreprocessedProblem
// object.
class Preprocessor {
-public:
+ public:
// Factory.
static Preprocessor* Create(MinimizerType minimizer_type);
virtual ~Preprocessor();
@@ -97,7 +100,7 @@
shared_ptr<Evaluator> evaluator;
shared_ptr<CoordinateDescentMinimizer> inner_iteration_minimizer;
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
Vector reduced_parameters;
double fixed_cost;
};
diff --git a/internal/ceres/problem.cc b/internal/ceres/problem.cc
index bbfaa98..5f914bc 100644
--- a/internal/ceres/problem.cc
+++ b/internal/ceres/problem.cc
@@ -37,6 +37,8 @@
namespace ceres {
+using std::vector;
+
Problem::Problem() : problem_impl_(new internal::ProblemImpl) {}
Problem::Problem(const Problem::Options& options)
: problem_impl_(new internal::ProblemImpl(options)) {}
@@ -225,11 +227,11 @@
int Problem::ParameterBlockSize(const double* parameter_block) const {
return problem_impl_->ParameterBlockSize(parameter_block);
-};
+}
int Problem::ParameterBlockLocalSize(const double* parameter_block) const {
return problem_impl_->ParameterBlockLocalSize(parameter_block);
-};
+}
bool Problem::HasParameterBlock(const double* values) const {
return problem_impl_->HasParameterBlock(values);
diff --git a/internal/ceres/problem_impl.cc b/internal/ceres/problem_impl.cc
index 67cac94..a363248 100644
--- a/internal/ceres/problem_impl.cc
+++ b/internal/ceres/problem_impl.cc
@@ -55,7 +55,10 @@
namespace ceres {
namespace internal {
-typedef map<double*, internal::ParameterBlock*> ParameterMap;
+using std::vector;
+using std::map;
+
+typedef std::map<double*, internal::ParameterBlock*> ParameterMap;
namespace {
internal::ParameterBlock* FindParameterBlockOrDie(
@@ -784,12 +787,12 @@
int ProblemImpl::ParameterBlockSize(const double* parameter_block) const {
return FindParameterBlockOrDie(parameter_block_map_,
const_cast<double*>(parameter_block))->Size();
-};
+}
int ProblemImpl::ParameterBlockLocalSize(const double* parameter_block) const {
return FindParameterBlockOrDie(
parameter_block_map_, const_cast<double*>(parameter_block))->LocalSize();
-};
+}
bool ProblemImpl::HasParameterBlock(const double* parameter_block) const {
return (parameter_block_map_.find(const_cast<double*>(parameter_block)) !=
diff --git a/internal/ceres/problem_impl.h b/internal/ceres/problem_impl.h
index 3d84de8..f527d15 100644
--- a/internal/ceres/problem_impl.h
+++ b/internal/ceres/problem_impl.h
@@ -63,7 +63,7 @@
class ProblemImpl {
public:
- typedef map<double*, ParameterBlock*> ParameterMap;
+ typedef std::map<double*, ParameterBlock*> ParameterMap;
typedef HashSet<ResidualBlock*> ResidualBlockSet;
ProblemImpl();
@@ -72,9 +72,10 @@
~ProblemImpl();
// See the public problem.h file for description of these methods.
- ResidualBlockId AddResidualBlock(CostFunction* cost_function,
- LossFunction* loss_function,
- const vector<double*>& parameter_blocks);
+ ResidualBlockId AddResidualBlock(
+ CostFunction* cost_function,
+ LossFunction* loss_function,
+ const std::vector<double*>& parameter_blocks);
ResidualBlockId AddResidualBlock(CostFunction* cost_function,
LossFunction* loss_function,
double* x0);
@@ -136,8 +137,8 @@
bool Evaluate(const Problem::EvaluateOptions& options,
double* cost,
- vector<double>* residuals,
- vector<double>* gradient,
+ std::vector<double>* residuals,
+ std::vector<double>* gradient,
CRSMatrix* jacobian);
int NumParameterBlocks() const;
@@ -150,12 +151,12 @@
bool HasParameterBlock(const double* parameter_block) const;
- void GetParameterBlocks(vector<double*>* parameter_blocks) const;
- void GetResidualBlocks(vector<ResidualBlockId>* residual_blocks) const;
+ void GetParameterBlocks(std::vector<double*>* parameter_blocks) const;
+ void GetResidualBlocks(std::vector<ResidualBlockId>* residual_blocks) const;
void GetParameterBlocksForResidualBlock(
const ResidualBlockId residual_block,
- vector<double*>* parameter_blocks) const;
+ std::vector<double*>* parameter_blocks) const;
const CostFunction* GetCostFunctionForResidualBlock(
const ResidualBlockId residual_block) const;
@@ -164,7 +165,7 @@
void GetResidualBlocksForParameterBlock(
const double* values,
- vector<ResidualBlockId>* residual_blocks) const;
+ std::vector<ResidualBlockId>* residual_blocks) const;
const Program& program() const { return *program_; }
Program* mutable_program() { return program_.get(); }
@@ -182,15 +183,15 @@
bool InternalEvaluate(Program* program,
double* cost,
- vector<double>* residuals,
- vector<double>* gradient,
+ std::vector<double>* residuals,
+ std::vector<double>* gradient,
CRSMatrix* jacobian);
// Delete the arguments in question. These differ from the Remove* functions
// in that they do not clean up references to the block to delete; they
// merely delete them.
template<typename Block>
- void DeleteBlockInVector(vector<Block*>* mutable_blocks,
+ void DeleteBlockInVector(std::vector<Block*>* mutable_blocks,
Block* block_to_remove);
void DeleteBlock(ResidualBlock* residual_block);
void DeleteBlock(ParameterBlock* parameter_block);
@@ -198,7 +199,7 @@
const Problem::Options options_;
// The mapping from user pointers to parameter blocks.
- map<double*, ParameterBlock*> parameter_block_map_;
+ std::map<double*, ParameterBlock*> parameter_block_map_;
// Iff enable_fast_removal is enabled, contains the current residual blocks.
ResidualBlockSet residual_block_set_;
@@ -212,9 +213,9 @@
// residual or parameter blocks, buffer them until destruction.
//
// TODO(keir): See if it makes sense to use sets instead.
- vector<CostFunction*> cost_functions_to_delete_;
- vector<LossFunction*> loss_functions_to_delete_;
- vector<LocalParameterization*> local_parameterizations_to_delete_;
+ std::vector<CostFunction*> cost_functions_to_delete_;
+ std::vector<LossFunction*> loss_functions_to_delete_;
+ std::vector<LocalParameterization*> local_parameterizations_to_delete_;
CERES_DISALLOW_COPY_AND_ASSIGN(ProblemImpl);
};
diff --git a/internal/ceres/problem_test.cc b/internal/ceres/problem_test.cc
index 36e4996..7f8c158 100644
--- a/internal/ceres/problem_test.cc
+++ b/internal/ceres/problem_test.cc
@@ -35,7 +35,7 @@
#include "ceres/casts.h"
#include "ceres/cost_function.h"
#include "ceres/crs_matrix.h"
-#include "ceres/evaluator_test_utils.cc"
+#include "ceres/evaluator_test_utils.h"
#include "ceres/internal/eigen.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/local_parameterization.h"
@@ -51,6 +51,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// The following three classes are for the purposes of defining
// function signatures. They have dummy Evaluate functions.
diff --git a/internal/ceres/program.cc b/internal/ceres/program.cc
index 1d0a157..77bc63a 100644
--- a/internal/ceres/program.cc
+++ b/internal/ceres/program.cc
@@ -50,6 +50,9 @@
namespace ceres {
namespace internal {
+using std::set;
+using std::vector;
+
Program::Program() {}
Program::Program(const Program& program)
@@ -261,9 +264,10 @@
return true;
}
-Program* Program::CreateReducedProgram(vector<double*>* removed_parameter_blocks,
- double* fixed_cost,
- string* error) const {
+Program* Program::CreateReducedProgram(
+ vector<double*>* removed_parameter_blocks,
+ double* fixed_cost,
+ string* error) const {
CHECK_NOTNULL(removed_parameter_blocks);
CHECK_NOTNULL(fixed_cost);
CHECK_NOTNULL(error);
@@ -279,9 +283,10 @@
return reduced_program.release();
}
-bool Program::RemoveFixedBlocks(vector<double*>* removed_parameter_blocks,
- double* fixed_cost,
- string* error) {
+bool Program::RemoveFixedBlocks(
+ vector<double*>* removed_parameter_blocks,
+ double* fixed_cost,
+ string* error) {
CHECK_NOTNULL(removed_parameter_blocks);
CHECK_NOTNULL(fixed_cost);
CHECK_NOTNULL(error);
@@ -342,7 +347,8 @@
for (int i = 0; i < parameter_blocks_.size(); ++i) {
ParameterBlock* parameter_block = parameter_blocks_[i];
if (parameter_block->index() == -1) {
- removed_parameter_blocks->push_back(parameter_block->mutable_user_state());
+ removed_parameter_blocks->push_back(
+ parameter_block->mutable_user_state());
} else {
parameter_blocks_[num_active_parameter_blocks++] = parameter_block;
}
@@ -360,14 +366,14 @@
return true;
}
-bool Program::IsParameterBlockSetIndependent(const set<double*>& independent_set) const {
+bool Program::IsParameterBlockSetIndependent(
+ const set<double*>& independent_set) const {
// Loop over each residual block and ensure that no two parameter
// blocks in the same residual block are part of
// parameter_block_ptrs as that would violate the assumption that it
// is an independent set in the Hessian matrix.
- for (vector<ResidualBlock*>::const_iterator it = residual_blocks_.begin();
- it != residual_blocks_.end();
- ++it) {
+ vector<ResidualBlock*>::const_iterator it = residual_blocks_.begin();
+ for (; it != residual_blocks_.end(); ++it) {
ParameterBlock* const* parameter_blocks = (*it)->parameter_blocks();
const int num_parameter_blocks = (*it)->NumParameterBlocks();
int count = 0;
@@ -462,8 +468,8 @@
int max_scratch_bytes_for_evaluate = 0;
for (int i = 0; i < residual_blocks_.size(); ++i) {
max_scratch_bytes_for_evaluate =
- max(max_scratch_bytes_for_evaluate,
- residual_blocks_[i]->NumScratchDoublesForEvaluate());
+ std::max(max_scratch_bytes_for_evaluate,
+ residual_blocks_[i]->NumScratchDoublesForEvaluate());
}
return max_scratch_bytes_for_evaluate;
}
@@ -478,7 +484,7 @@
derivatives += residual_block->NumResiduals() *
residual_block->parameter_blocks()[j]->LocalSize();
}
- max_derivatives = max(max_derivatives, derivatives);
+ max_derivatives = std::max(max_derivatives, derivatives);
}
return max_derivatives;
}
@@ -486,8 +492,8 @@
int Program::MaxParametersPerResidualBlock() const {
int max_parameters = 0;
for (int i = 0; i < residual_blocks_.size(); ++i) {
- max_parameters = max(max_parameters,
- residual_blocks_[i]->NumParameterBlocks());
+ max_parameters = std::max(max_parameters,
+ residual_blocks_[i]->NumParameterBlocks());
}
return max_parameters;
}
@@ -495,8 +501,8 @@
int Program::MaxResidualsPerResidualBlock() const {
int max_residuals = 0;
for (int i = 0; i < residual_blocks_.size(); ++i) {
- max_residuals = max(max_residuals,
- residual_blocks_[i]->NumResiduals());
+ max_residuals = std::max(max_residuals,
+ residual_blocks_[i]->NumResiduals());
}
return max_residuals;
}
diff --git a/internal/ceres/program.h b/internal/ceres/program.h
index c7b22c4..54dc271 100644
--- a/internal/ceres/program.h
+++ b/internal/ceres/program.h
@@ -60,10 +60,10 @@
explicit Program(const Program& program);
// The ordered parameter and residual blocks for the program.
- const vector<ParameterBlock*>& parameter_blocks() const;
- const vector<ResidualBlock*>& residual_blocks() const;
- vector<ParameterBlock*>* mutable_parameter_blocks();
- vector<ResidualBlock*>* mutable_residual_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks() const;
+ const std::vector<ResidualBlock*>& residual_blocks() const;
+ std::vector<ParameterBlock*>* mutable_parameter_blocks();
+ std::vector<ResidualBlock*>* mutable_residual_blocks();
// Serialize to/from the program and update states.
//
@@ -120,7 +120,8 @@
// blocks in the same residual block are part of
// parameter_blocks as that would violate the assumption that it
// is an independent set in the Hessian matrix.
- bool IsParameterBlockSetIndependent(const set<double*>& independent_set) const;
+ bool IsParameterBlockSetIndependent(
+ const std::set<double*>& independent_set) const;
// Create a TripletSparseMatrix which contains the zero-one
// structure corresponding to the block sparsity of the transpose of
@@ -142,7 +143,7 @@
// If there was a problem, then the function will return a NULL
// pointer and error will contain a human readable description of
// the problem.
- Program* CreateReducedProgram(vector<double*>* removed_parameter_blocks,
+ Program* CreateReducedProgram(std::vector<double*>* removed_parameter_blocks,
double* fixed_cost,
string* error) const;
@@ -174,13 +175,13 @@
//
// If there was a problem, then the function will return false and
// error will contain a human readable description of the problem.
- bool RemoveFixedBlocks(vector<double*>* removed_parameter_blocks,
+ bool RemoveFixedBlocks(std::vector<double*>* removed_parameter_blocks,
double* fixed_cost,
string* message);
// The Program does not own the ParameterBlock or ResidualBlock objects.
- vector<ParameterBlock*> parameter_blocks_;
- vector<ResidualBlock*> residual_blocks_;
+ std::vector<ParameterBlock*> parameter_blocks_;
+ std::vector<ResidualBlock*> residual_blocks_;
friend class ProblemImpl;
};
diff --git a/internal/ceres/program_evaluator.h b/internal/ceres/program_evaluator.h
index 672c233..24ed3ae 100644
--- a/internal/ceres/program_evaluator.h
+++ b/internal/ceres/program_evaluator.h
@@ -297,11 +297,11 @@
return program_->NumResiduals();
}
- virtual map<string, int> CallStatistics() const {
+ virtual std::map<string, int> CallStatistics() const {
return execution_summary_.calls();
}
- virtual map<string, double> TimeStatistics() const {
+ virtual std::map<string, double> TimeStatistics() const {
return execution_summary_.times();
}
@@ -332,8 +332,9 @@
};
static void BuildResidualLayout(const Program& program,
- vector<int>* residual_layout) {
- const vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
+ std::vector<int>* residual_layout) {
+ const std::vector<ResidualBlock*>& residual_blocks =
+ program.residual_blocks();
residual_layout->resize(program.NumResidualBlocks());
int residual_pos = 0;
for (int i = 0; i < residual_blocks.size(); ++i) {
@@ -369,7 +370,7 @@
JacobianWriter jacobian_writer_;
scoped_array<EvaluatePreparer> evaluate_preparers_;
scoped_array<EvaluateScratch> evaluate_scratch_;
- vector<int> residual_layout_;
+ std::vector<int> residual_layout_;
::ceres::internal::ExecutionSummary execution_summary_;
};
diff --git a/internal/ceres/program_test.cc b/internal/ceres/program_test.cc
index 10bfa12..77a1c44 100644
--- a/internal/ceres/program_test.cc
+++ b/internal/ceres/program_test.cc
@@ -42,6 +42,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// A cost function that simply returns its argument.
class UnaryIdentityCostFunction : public SizedCostFunction<1, 1> {
public:
@@ -222,7 +224,8 @@
problem.AddResidualBlock(new BinaryCostFunction(), NULL, &x, &y);
problem.SetParameterBlockConstant(&x);
- ResidualBlock *expected_removed_block = problem.program().residual_blocks()[0];
+ ResidualBlock *expected_removed_block =
+ problem.program().residual_blocks()[0];
scoped_array<double> scratch(
new double[expected_removed_block->NumScratchDoublesForEvaluate()]);
double expected_fixed_cost;
@@ -307,7 +310,7 @@
rows[13] = 1;
cols[13] = 7;
- fill(values, values + 14, 1.0);
+ std::fill(values, values + 14, 1.0);
expected_block_sparse_jacobian.set_num_nonzeros(14);
}
@@ -374,7 +377,7 @@
}
double* values = expected_block_sparse_jacobian.mutable_values();
- fill(values, values + 20, 1.0);
+ std::fill(values, values + 20, 1.0);
expected_block_sparse_jacobian.set_num_nonzeros(20);
}
diff --git a/internal/ceres/reorder_program.cc b/internal/ceres/reorder_program.cc
index aa3d4ce..fad69f9 100644
--- a/internal/ceres/reorder_program.cc
+++ b/internal/ceres/reorder_program.cc
@@ -56,6 +56,11 @@
namespace ceres {
namespace internal {
+
+using std::map;
+using std::set;
+using std::vector;
+
namespace {
// Find the minimum index of any parameter block to the given
@@ -87,7 +92,7 @@
const int* rows = block_jacobian_transpose.rows();
const int* cols = block_jacobian_transpose.cols();
int num_nonzeros = block_jacobian_transpose.num_nonzeros();
- std::vector<Triplet> triplets;
+ vector<Triplet> triplets;
triplets.reserve(num_nonzeros);
for (int i = 0; i < num_nonzeros; ++i) {
triplets.push_back(Triplet(cols[i], rows[i], 1));
@@ -220,13 +225,11 @@
const map<int, set<double*> >& groups =
ordering.group_to_elements();
- for (map<int, set<double*> >::const_iterator group_it = groups.begin();
- group_it != groups.end();
- ++group_it) {
+ map<int, set<double*> >::const_iterator group_it = groups.begin();
+ for ( ; group_it != groups.end(); ++group_it) {
const set<double*>& group = group_it->second;
- for (set<double*>::const_iterator parameter_block_ptr_it = group.begin();
- parameter_block_ptr_it != group.end();
- ++parameter_block_ptr_it) {
+ set<double*>::const_iterator parameter_block_ptr_it = group.begin();
+ for ( ; parameter_block_ptr_it != group.end(); ++parameter_block_ptr_it) {
ProblemImpl::ParameterMap::const_iterator parameter_block_it =
parameter_map.find(*parameter_block_ptr_it);
if (parameter_block_it == parameter_map.end()) {
@@ -252,8 +255,10 @@
// Create a histogram of the number of residuals for each E block. There is an
// extra bucket at the end to catch all non-eliminated F blocks.
- vector<int> residual_blocks_per_e_block(size_of_first_elimination_group + 1);
- vector<ResidualBlock*>* residual_blocks = program->mutable_residual_blocks();
+ vector<int> residual_blocks_per_e_block(
+ size_of_first_elimination_group + 1);
+ vector<ResidualBlock*>* residual_blocks =
+ program->mutable_residual_blocks();
vector<int> min_position_per_residual(residual_blocks->size());
for (int i = 0; i < residual_blocks->size(); ++i) {
ResidualBlock* residual_block = (*residual_blocks)[i];
@@ -409,7 +414,8 @@
Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> perm;
amd_ordering(block_schur_complement, perm);
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program->parameter_blocks();
vector<ParameterBlock*> ordering(num_cols);
// The ordering of the first size_of_first_elimination_group does
diff --git a/internal/ceres/reorder_program_test.cc b/internal/ceres/reorder_program_test.cc
index 2a0c4eb..6f2b1b0 100644
--- a/internal/ceres/reorder_program_test.cc
+++ b/internal/ceres/reorder_program_test.cc
@@ -41,6 +41,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// Templated base class for the CostFunction signatures.
template <int kNumResiduals, int N0, int N1, int N2>
class MockCostFunctionBase : public
@@ -158,7 +160,8 @@
linear_solver_ordering,
program,
&message));
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program->parameter_blocks();
EXPECT_EQ(parameter_blocks.size(), 3);
EXPECT_EQ(parameter_blocks[0]->user_state(), &x);
diff --git a/internal/ceres/residual_block.cc b/internal/ceres/residual_block.cc
index 621082a..5eb2117 100644
--- a/internal/ceres/residual_block.cc
+++ b/internal/ceres/residual_block.cc
@@ -49,10 +49,11 @@
namespace ceres {
namespace internal {
-ResidualBlock::ResidualBlock(const CostFunction* cost_function,
- const LossFunction* loss_function,
- const vector<ParameterBlock*>& parameter_blocks,
- int index)
+ResidualBlock::ResidualBlock(
+ const CostFunction* cost_function,
+ const LossFunction* loss_function,
+ const std::vector<ParameterBlock*>& parameter_blocks,
+ int index)
: cost_function_(cost_function),
loss_function_(loss_function),
parameter_blocks_(
diff --git a/internal/ceres/residual_block.h b/internal/ceres/residual_block.h
index 9c3671b..b936064 100644
--- a/internal/ceres/residual_block.h
+++ b/internal/ceres/residual_block.h
@@ -71,7 +71,7 @@
// residual_blocks array.
ResidualBlock(const CostFunction* cost_function,
const LossFunction* loss_function,
- const vector<ParameterBlock*>& parameter_blocks,
+ const std::vector<ParameterBlock*>& parameter_blocks,
int index);
// Evaluates the residual term, storing the scalar cost in *cost, the residual
diff --git a/internal/ceres/residual_block_test.cc b/internal/ceres/residual_block_test.cc
index b37f50f..22873e7 100644
--- a/internal/ceres/residual_block_test.cc
+++ b/internal/ceres/residual_block_test.cc
@@ -39,6 +39,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
// Trivial cost function that accepts three arguments.
class TernaryCostFunction: public CostFunction {
public:
diff --git a/internal/ceres/residual_block_utils_test.cc b/internal/ceres/residual_block_utils_test.cc
index d3c917a..64bf0db 100644
--- a/internal/ceres/residual_block_utils_test.cc
+++ b/internal/ceres/residual_block_utils_test.cc
@@ -46,7 +46,7 @@
void CheckEvaluation(const CostFunction& cost_function, bool is_good) {
double x = 1.0;
ParameterBlock parameter_block(&x, 1, -1);
- vector<ParameterBlock*> parameter_blocks;
+ std::vector<ParameterBlock*> parameter_blocks;
parameter_blocks.push_back(¶meter_block);
ResidualBlock residual_block(&cost_function,
diff --git a/internal/ceres/rotation_test.cc b/internal/ceres/rotation_test.cc
index 2764e66..ef1adf7 100644
--- a/internal/ceres/rotation_test.cc
+++ b/internal/ceres/rotation_test.cc
@@ -44,6 +44,8 @@
namespace ceres {
namespace internal {
+using std::swap;
+
const double kPi = 3.14159265358979323846;
const double kHalfSqrt2 = 0.707106781186547524401;
@@ -53,7 +55,7 @@
}
// A tolerance value for floating-point comparisons.
-static double const kTolerance = numeric_limits<double>::epsilon() * 10;
+static double const kTolerance = std::numeric_limits<double>::epsilon() * 10;
// Looser tolerance used for numerically unstable conversions.
static double const kLooseTolerance = 1e-9;
@@ -241,7 +243,7 @@
// Test that approximate conversion works for very small angles.
TEST(Rotation, TinyAngleAxisToQuaternion) {
// Very small value that could potentially cause underflow.
- double theta = pow(numeric_limits<double>::min(), 0.75);
+ double theta = pow(std::numeric_limits<double>::min(), 0.75);
double axis_angle[3] = { theta, 0, 0 };
double quaternion[4];
double expected[4] = { cos(theta/2), sin(theta/2.0), 0, 0 };
@@ -302,7 +304,7 @@
// Test that approximate conversion works for very small angles.
TEST(Rotation, TinyQuaternionToAngleAxis) {
// Very small value that could potentially cause underflow.
- double theta = pow(numeric_limits<double>::min(), 0.75);
+ double theta = pow(std::numeric_limits<double>::min(), 0.75);
double quaternion[4] = { cos(theta/2), sin(theta/2.0), 0, 0 };
double axis_angle[3];
double expected[3] = { theta, 0, 0 };
@@ -604,9 +606,9 @@
// Transposes a 3x3 matrix.
static void Transpose3x3(double m[9]) {
- std::swap(m[1], m[3]);
- std::swap(m[2], m[6]);
- std::swap(m[5], m[7]);
+ swap(m[1], m[3]);
+ swap(m[2], m[6]);
+ swap(m[5], m[7]);
}
// Convert Euler angles from radians to degrees.
@@ -699,7 +701,7 @@
if (x == 0 || y == 0) {
return absdiff <= kTolerance;
}
- double reldiff = absdiff / max(fabs(x), fabs(y));
+ double reldiff = absdiff / std::max(fabs(x), fabs(y));
return reldiff <= kTolerance;
}
@@ -735,11 +737,11 @@
// Log-10 of a value well below machine precision.
static const int kSmallTinyCutoff =
- static_cast<int>(2 * log(numeric_limits<double>::epsilon())/log(10.0));
+ static_cast<int>(2 * log(std::numeric_limits<double>::epsilon())/log(10.0));
// Log-10 of a value just below values representable by double.
static const int kTinyZeroLimit =
- static_cast<int>(1 + log(numeric_limits<double>::min())/log(10.0));
+ static_cast<int>(1 + log(std::numeric_limits<double>::min())/log(10.0));
// Test that exact conversion works for small angles when jets are used.
TEST(Rotation, SmallAngleAxisToQuaternionForJets) {
diff --git a/internal/ceres/schur_complement_solver.cc b/internal/ceres/schur_complement_solver.cc
index 33f812b..0c72eb3 100644
--- a/internal/ceres/schur_complement_solver.cc
+++ b/internal/ceres/schur_complement_solver.cc
@@ -57,10 +57,16 @@
namespace ceres {
namespace internal {
+
+using std::make_pair;
+using std::pair;
+using std::set;
+using std::vector;
+
namespace {
class BlockRandomAccessSparseMatrixAdapter : public LinearOperator {
- public:
+ public:
explicit BlockRandomAccessSparseMatrixAdapter(
const BlockRandomAccessSparseMatrix& m)
: m_(m) {
@@ -86,7 +92,7 @@
};
class BlockRandomAccessDiagonalMatrixAdapter : public LinearOperator {
- public:
+ public:
explicit BlockRandomAccessDiagonalMatrixAdapter(
const BlockRandomAccessDiagonalMatrix& m)
: m_(m) {
@@ -130,7 +136,7 @@
eliminator_.reset(CHECK_NOTNULL(SchurEliminatorBase::Create(options_)));
eliminator_->Init(options_.elimination_groups[0], A->block_structure());
};
- fill(x, x + A->num_cols(), 0.0);
+ std::fill(x, x + A->num_cols(), 0.0);
event_logger.AddEvent("Setup");
eliminator_->Eliminate(A, b, per_solve_options.D, lhs_.get(), rhs_.get());
diff --git a/internal/ceres/schur_complement_solver.h b/internal/ceres/schur_complement_solver.h
index 93d23e3..59d900f 100644
--- a/internal/ceres/schur_complement_solver.h
+++ b/internal/ceres/schur_complement_solver.h
@@ -188,7 +188,7 @@
double* solution);
// Size of the blocks in the Schur complement.
- vector<int> blocks_;
+ std::vector<int> blocks_;
SuiteSparse ss_;
// Symbolic factorization of the reduced linear system. Precomputed
diff --git a/internal/ceres/schur_eliminator.h b/internal/ceres/schur_eliminator.h
index 8fe8b9c..abe2a60 100644
--- a/internal/ceres/schur_eliminator.h
+++ b/internal/ceres/schur_eliminator.h
@@ -263,7 +263,7 @@
// buffer_layout[z1] = 0
// buffer_layout[z5] = y1 * z1
// buffer_layout[z2] = y1 * z1 + y1 * z5
- typedef map<int, int> BufferLayoutType;
+ typedef std::map<int, int> BufferLayoutType;
struct Chunk {
Chunk() : size(0) {}
int size;
@@ -315,11 +315,11 @@
// position of each f block in the row/col of the reduced linear
// system. Thus lhs_row_layout_[i] is the row/col position of the
// i^th f block.
- vector<int> lhs_row_layout_;
+ std::vector<int> lhs_row_layout_;
// Combinatorial structure of the chunks in A. For more information
// see the documentation of the Chunk object above.
- vector<Chunk> chunks_;
+ std::vector<Chunk> chunks_;
// TODO(sameeragarwal): The following two arrays contain per-thread
// storage. They should be refactored into a per thread struct.
@@ -346,7 +346,7 @@
// Locks for the blocks in the right hand side of the reduced linear
// system.
- vector<Mutex*> rhs_locks_;
+ std::vector<Mutex*> rhs_locks_;
};
} // namespace internal
diff --git a/internal/ceres/schur_eliminator_impl.h b/internal/ceres/schur_eliminator_impl.h
index 305d94e..3318061 100644
--- a/internal/ceres/schur_eliminator_impl.h
+++ b/internal/ceres/schur_eliminator_impl.h
@@ -139,7 +139,7 @@
}
}
- buffer_size_ = max(buffer_size, buffer_size_);
+ buffer_size_ = std::max(buffer_size, buffer_size_);
++chunk.size;
}
diff --git a/internal/ceres/schur_eliminator_test.cc b/internal/ceres/schur_eliminator_test.cc
index bed8f3a..f36ec0f 100644
--- a/internal/ceres/schur_eliminator_test.cc
+++ b/internal/ceres/schur_eliminator_test.cc
@@ -129,7 +129,7 @@
const double relative_tolerance) {
const CompressedRowBlockStructure* bs = A->block_structure();
const int num_col_blocks = bs->cols.size();
- vector<int> blocks(num_col_blocks - num_eliminate_blocks, 0);
+ std::vector<int> blocks(num_col_blocks - num_eliminate_blocks, 0);
for (int i = num_eliminate_blocks; i < num_col_blocks; ++i) {
blocks[i - num_eliminate_blocks] = bs->cols[i].size;
}
diff --git a/internal/ceres/schur_jacobi_preconditioner.cc b/internal/ceres/schur_jacobi_preconditioner.cc
index cbdb708..2b5ef56 100644
--- a/internal/ceres/schur_jacobi_preconditioner.cc
+++ b/internal/ceres/schur_jacobi_preconditioner.cc
@@ -54,7 +54,7 @@
<< "Jacobian should have atleast 1 f_block for "
<< "SCHUR_JACOBI preconditioner.";
- vector<int> blocks(num_blocks);
+ std::vector<int> blocks(num_blocks);
for (int i = 0; i < num_blocks; ++i) {
blocks[i] = bs.cols[i + options_.elimination_groups[0]].size;
}
diff --git a/internal/ceres/single_linkage_clustering_test.cc b/internal/ceres/single_linkage_clustering_test.cc
index 95692ea..cd31f5e 100644
--- a/internal/ceres/single_linkage_clustering_test.cc
+++ b/internal/ceres/single_linkage_clustering_test.cc
@@ -109,7 +109,7 @@
// 0-1-2-3 4-5
graph.AddEdge(0, 1, 1.0);
graph.AddEdge(1, 2, 1.0);
- graph.AddEdge(2, 3, 0.5); // Weak link
+ graph.AddEdge(2, 3, 0.5); // Weak link
graph.AddEdge(0, 3, 1.0);
// This component should break up into two.
diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc
index 738828b..b60efd9 100644
--- a/internal/ceres/solver.cc
+++ b/internal/ceres/solver.cc
@@ -49,6 +49,9 @@
namespace ceres {
namespace {
+using std::vector;
+using std::map;
+
#define OPTION_OP(x, y, OP) \
if (!(options.x OP y)) { \
std::stringstream ss; \
@@ -625,7 +628,7 @@
initial_cost,
final_cost,
TerminationTypeToString(termination_type));
-};
+}
string Solver::Summary::FullReport() const {
using internal::VersionString;
@@ -844,7 +847,7 @@
StringAppendF(&report, "Termination: %25s (%s)\n",
TerminationTypeToString(termination_type), message.c_str());
return report;
-};
+}
bool Solver::Summary::IsSolutionUsable() const {
return internal::IsSolutionUsable(*this);
diff --git a/internal/ceres/solver_test.cc b/internal/ceres/solver_test.cc
index 4069578..e4abdef 100644
--- a/internal/ceres/solver_test.cc
+++ b/internal/ceres/solver_test.cc
@@ -79,7 +79,7 @@
}
int calls;
double *x;
- vector<double> x_values;
+ std::vector<double> x_values;
};
TEST(Solver, UpdateStateEveryIterationOption) {
diff --git a/internal/ceres/solver_utils.cc b/internal/ceres/solver_utils.cc
index bd304e7..86440eb 100644
--- a/internal/ceres/solver_utils.cc
+++ b/internal/ceres/solver_utils.cc
@@ -31,6 +31,7 @@
#include <string>
#include "ceres/internal/port.h"
+#include "ceres/solver_utils.h"
#include "ceres/version.h"
namespace ceres {
diff --git a/internal/ceres/solver_utils.h b/internal/ceres/solver_utils.h
index 41c8a6e..2d1edf8 100644
--- a/internal/ceres/solver_utils.h
+++ b/internal/ceres/solver_utils.h
@@ -31,6 +31,9 @@
#include <algorithm>
#include <string>
+#include "ceres/iteration_callback.h"
+#include "ceres/types.h"
+
namespace ceres {
namespace internal {
@@ -48,7 +51,7 @@
// iteration because the minimizer maybe making non-monotonic steps.
for (int i = 0; i < summary->iterations.size(); ++i) {
const IterationSummary& iteration_summary = summary->iterations[i];
- summary->final_cost = min(iteration_summary.cost, summary->final_cost);
+ summary->final_cost = std::min(iteration_summary.cost, summary->final_cost);
}
}
diff --git a/internal/ceres/sparse_normal_cholesky_solver.h b/internal/ceres/sparse_normal_cholesky_solver.h
index 12c0524..73edf48 100644
--- a/internal/ceres/sparse_normal_cholesky_solver.h
+++ b/internal/ceres/sparse_normal_cholesky_solver.h
@@ -120,7 +120,7 @@
#endif
scoped_ptr<CompressedRowSparseMatrix> outer_product_;
- vector<int> pattern_;
+ std::vector<int> pattern_;
const LinearSolver::Options options_;
CERES_DISALLOW_COPY_AND_ASSIGN(SparseNormalCholeskySolver);
};
diff --git a/internal/ceres/split.cc b/internal/ceres/split.cc
index 3edbc28..0afe1c5 100644
--- a/internal/ceres/split.cc
+++ b/internal/ceres/split.cc
@@ -30,12 +30,16 @@
#include "ceres/split.h"
+#include <iterator>
#include <string>
#include <vector>
-#include <iterator>
+
#include "ceres/internal/port.h"
namespace ceres {
+namespace internal {
+
+using std::vector;
// If we know how much to allocate for a vector of strings, we can allocate the
// vector<string> only once and directly to the right size. This saves in
@@ -110,8 +114,9 @@
const char* delim,
vector<string>* result) {
result->reserve(result->size() + CalculateReserveForVector(full, delim));
- back_insert_iterator< vector<string> > it(*result);
+ std::back_insert_iterator<vector<string> > it(*result);
SplitStringToIteratorUsing(full, delim, it);
}
+} // namespace internal
} // namespace ceres
diff --git a/internal/ceres/split.h b/internal/ceres/split.h
index 2334d26..ada6676 100644
--- a/internal/ceres/split.h
+++ b/internal/ceres/split.h
@@ -36,13 +36,15 @@
#include "ceres/internal/port.h"
namespace ceres {
+namespace internal {
// Split a string using one or more character delimiters, presented as a
// nul-terminated c string. Append the components to 'result'. If there are
// consecutive delimiters, this function skips over all of them.
void SplitStringUsing(const string& full, const char* delim,
- vector<string>* res);
+ std::vector<string>* res);
+} // namespace internal
} // namespace ceres
#endif // CERES_INTERNAL_SPLIT_H_
diff --git a/internal/ceres/suitesparse.cc b/internal/ceres/suitesparse.cc
index 1df7566..d8b1a49 100644
--- a/internal/ceres/suitesparse.cc
+++ b/internal/ceres/suitesparse.cc
@@ -44,6 +44,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
SuiteSparse::SuiteSparse() {
cholmod_start(&cc_);
}
diff --git a/internal/ceres/suitesparse.h b/internal/ceres/suitesparse.h
index baab899..5aa9cb9 100644
--- a/internal/ceres/suitesparse.h
+++ b/internal/ceres/suitesparse.h
@@ -42,7 +42,6 @@
#include <string>
#include <vector>
-#include "ceres/internal/port.h"
#include "ceres/linear_solver.h"
#include "cholmod.h"
#include "glog/logging.h"
@@ -147,8 +146,8 @@
cholmod_factor* AnalyzeCholesky(cholmod_sparse* A, string* message);
cholmod_factor* BlockAnalyzeCholesky(cholmod_sparse* A,
- const vector<int>& row_blocks,
- const vector<int>& col_blocks,
+ const std::vector<int>& row_blocks,
+ const std::vector<int>& col_blocks,
string* message);
// If A is symmetric, then compute the symbolic Cholesky
@@ -162,9 +161,10 @@
// message contains an explanation of the failures if any.
//
// Caller owns the result.
- cholmod_factor* AnalyzeCholeskyWithUserOrdering(cholmod_sparse* A,
- const vector<int>& ordering,
- string* message);
+ cholmod_factor* AnalyzeCholeskyWithUserOrdering(
+ cholmod_sparse* A,
+ const std::vector<int>& ordering,
+ string* message);
// Perform a symbolic factorization of A without re-ordering A. No
// postordering of the elimination tree is performed. This ensures
@@ -215,9 +215,9 @@
// A. If this is the case, only the first sum(col_blocks) are used
// to compute the ordering.
bool BlockAMDOrdering(const cholmod_sparse* A,
- const vector<int>& row_blocks,
- const vector<int>& col_blocks,
- vector<int>* ordering);
+ const std::vector<int>& row_blocks,
+ const std::vector<int>& col_blocks,
+ std::vector<int>* ordering);
// Find a fill reducing approximate minimum degree
// ordering. ordering is expected to be large enough to hold the
@@ -236,7 +236,7 @@
// being conservative and choosing the next minor version where
// things are stable.
static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() {
- return (SUITESPARSE_VERSION>4001);
+ return (SUITESPARSE_VERSION > 4001);
}
// Find a fill reducing approximate minimum degree
@@ -298,7 +298,7 @@
return false;
}
- void Free(void*) {};
+ void Free(void* arg) {}
};
#endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/system_test.cc b/internal/ceres/system_test.cc
index be56f20..54fd30a 100644
--- a/internal/ceres/system_test.cc
+++ b/internal/ceres/system_test.cc
@@ -60,6 +60,8 @@
namespace ceres {
namespace internal {
+using std::vector;
+
const bool kAutomaticOrdering = true;
const bool kUserOrdering = false;
@@ -122,8 +124,9 @@
// Solver::Options* mutable_solver_options();
// };
template <typename SystemTestProblem>
-void RunSolversAndCheckTheyMatch(const vector<SolverConfig>& configurations,
- const double max_abs_difference) {
+void RunSolversAndCheckTheyMatch(
+ const vector<SolverConfig>& configurations,
+ const double max_abs_difference) {
int num_configurations = configurations.size();
vector<SystemTestProblem*> problems;
vector<vector<double> > final_residuals(num_configurations);
@@ -348,7 +351,7 @@
if (!fptr) {
LOG(FATAL) << "File Error: unable to open file " << filename;
- };
+ }
// This will die horribly on invalid files. Them's the breaks.
FscanfOrDie(fptr, "%d", &num_cameras_);
diff --git a/internal/ceres/test_util.cc b/internal/ceres/test_util.cc
index 8af48ab..9d252e9 100644
--- a/internal/ceres/test_util.cc
+++ b/internal/ceres/test_util.cc
@@ -30,6 +30,8 @@
//
// Utility functions useful for testing.
+#include "ceres/test_util.h"
+
#include <algorithm>
#include <cmath>
#include "ceres/file.h"
diff --git a/internal/ceres/triplet_sparse_matrix.cc b/internal/ceres/triplet_sparse_matrix.cc
index 824b123..6fdd69c 100644
--- a/internal/ceres/triplet_sparse_matrix.cc
+++ b/internal/ceres/triplet_sparse_matrix.cc
@@ -128,7 +128,7 @@
}
void TripletSparseMatrix::SetZero() {
- fill(values_.get(), values_.get() + max_num_nonzeros_, 0.0);
+ std::fill(values_.get(), values_.get() + max_num_nonzeros_, 0.0);
num_nonzeros_ = 0;
}
@@ -136,7 +136,7 @@
CHECK_GE(num_nonzeros, 0);
CHECK_LE(num_nonzeros, max_num_nonzeros_);
num_nonzeros_ = num_nonzeros;
-};
+}
void TripletSparseMatrix::AllocateMemory() {
rows_.reset(new int[max_num_nonzeros_]);
diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc
index 605284d..0a6ce80 100644
--- a/internal/ceres/trust_region_minimizer.cc
+++ b/internal/ceres/trust_region_minimizer.cc
@@ -31,8 +31,8 @@
#include "ceres/trust_region_minimizer.h"
#include <algorithm>
-#include <cstdlib>
#include <cmath>
+#include <cstdlib>
#include <cstring>
#include <limits>
#include <string>
@@ -417,7 +417,7 @@
LOG_IF(WARNING, is_not_silent)
<< "Step failed to evaluate. "
<< "Treating it as a step with infinite cost";
- new_cost = numeric_limits<double>::max();
+ new_cost = std::numeric_limits<double>::max();
}
} else {
LOG_IF(WARNING, is_not_silent)
@@ -521,7 +521,7 @@
// reference iteration, allowing for non-monotonic steps.
iteration_summary.relative_decrease =
options.use_nonmonotonic_steps
- ? max(relative_decrease, historical_relative_decrease)
+ ? std::max(relative_decrease, historical_relative_decrease)
: relative_decrease;
// Normally, the quality of a trust region step is measured by
diff --git a/internal/ceres/trust_region_minimizer_test.cc b/internal/ceres/trust_region_minimizer_test.cc
index 4cad989..0cc2af8 100644
--- a/internal/ceres/trust_region_minimizer_test.cc
+++ b/internal/ceres/trust_region_minimizer_test.cc
@@ -252,7 +252,7 @@
EXPECT_NEAR(0.0, parameters[1], 0.001);
EXPECT_NEAR(0.0, parameters[2], 0.001);
EXPECT_NEAR(0.0, parameters[3], 0.001);
-};
+}
TEST(TrustRegionMinimizer, PowellsSingularFunctionUsingLevenbergMarquardt) {
// This case is excluded because this has a local minimum and does
@@ -373,7 +373,7 @@
TEST(TrustRegionMinimizer, JacobiScalingTest) {
int N = 6;
- std::vector< double* > y(N);
+ std::vector<double*> y(N);
const double pi = 3.1415926535897932384626433;
for (int i = 0; i < N; i++) {
double theta = i * 2. * pi/ static_cast< double >(N);
diff --git a/internal/ceres/trust_region_preprocessor.cc b/internal/ceres/trust_region_preprocessor.cc
index 22ea1ec..129442c 100644
--- a/internal/ceres/trust_region_preprocessor.cc
+++ b/internal/ceres/trust_region_preprocessor.cc
@@ -48,12 +48,16 @@
namespace ceres {
namespace internal {
+
+using std::vector;
+
namespace {
ParameterBlockOrdering* CreateDefaultLinearSolverOrdering(
const Program& program) {
ParameterBlockOrdering* ordering = new ParameterBlockOrdering;
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const vector<ParameterBlock*>& parameter_blocks =
+ program.parameter_blocks();
for (int i = 0; i < parameter_blocks.size(); ++i) {
ordering->AddElementToGroup(
const_cast<double*>(parameter_blocks[i]->user_state()), 0);
diff --git a/internal/ceres/unsymmetric_linear_solver_test.cc b/internal/ceres/unsymmetric_linear_solver_test.cc
index 0b82e6a..b773627 100644
--- a/internal/ceres/unsymmetric_linear_solver_test.cc
+++ b/internal/ceres/unsymmetric_linear_solver_test.cc
@@ -57,8 +57,6 @@
}
void TestSolver(const LinearSolver::Options& options) {
-
-
LinearSolver::PerSolveOptions per_solve_options;
LinearSolver::Summary unregularized_solve_summary;
LinearSolver::Summary regularized_solve_summary;
@@ -109,7 +107,8 @@
for (int i = 0; i < A_->num_cols(); ++i) {
EXPECT_NEAR(sol_unregularized_[i], x_unregularized[i], 1e-8)
<< "\nExpected: "
- << ConstVectorRef(sol_unregularized_.get(), A_->num_cols()).transpose()
+ << ConstVectorRef(sol_unregularized_.get(),
+ A_->num_cols()).transpose()
<< "\nActual: " << x_unregularized.transpose();
}
diff --git a/internal/ceres/visibility.cc b/internal/ceres/visibility.cc
index da8beed..9dfb0f4 100644
--- a/internal/ceres/visibility.cc
+++ b/internal/ceres/visibility.cc
@@ -49,6 +49,12 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::max;
+using std::pair;
+using std::set;
+using std::vector;
+
void ComputeVisibility(const CompressedRowBlockStructure& block_structure,
const int num_eliminate_blocks,
vector< set<int> >* visibility) {
diff --git a/internal/ceres/visibility.h b/internal/ceres/visibility.h
index 322efe9..2ef00be 100644
--- a/internal/ceres/visibility.h
+++ b/internal/ceres/visibility.h
@@ -59,7 +59,7 @@
// points and f_blocks correspond to cameras.
void ComputeVisibility(const CompressedRowBlockStructure& block_structure,
int num_eliminate_blocks,
- vector<set<int> >* visibility);
+ std::vector<std::set<int> >* visibility);
// Given f_block visibility as computed by the ComputeVisibility
// function above, construct and return a graph whose vertices are
@@ -75,7 +75,7 @@
// Caller acquires ownership of the returned WeightedGraph pointer
// (heap-allocated).
WeightedGraph<int>* CreateSchurComplementGraph(
- const vector<set<int> >& visibility);
+ const std::vector<std::set<int> >& visibility);
} // namespace internal
} // namespace ceres
diff --git a/internal/ceres/visibility_based_preconditioner.cc b/internal/ceres/visibility_based_preconditioner.cc
index c7ed049..125856e 100644
--- a/internal/ceres/visibility_based_preconditioner.cc
+++ b/internal/ceres/visibility_based_preconditioner.cc
@@ -58,6 +58,12 @@
namespace ceres {
namespace internal {
+using std::make_pair;
+using std::pair;
+using std::set;
+using std::swap;
+using std::vector;
+
// TODO(sameeragarwal): Currently these are magic weights for the
// preconditioner construction. Move these higher up into the Options
// struct and provide some guidelines for choosing them.
@@ -399,7 +405,7 @@
// matrix. Scaling these off-diagonal entries by 1/2 forces this
// matrix to be positive definite.
void VisibilityBasedPreconditioner::ScaleOffDiagonalCells() {
- for (set< pair<int, int> >::const_iterator it = block_pairs_.begin();
+ for (set<pair<int, int> >::const_iterator it = block_pairs_.begin();
it != block_pairs_.end();
++it) {
const int block1 = it->first;
@@ -484,7 +490,7 @@
int cluster1 = cluster_membership_[block1];
int cluster2 = cluster_membership_[block2];
if (cluster1 > cluster2) {
- std::swap(cluster1, cluster2);
+ swap(cluster1, cluster2);
}
return (cluster_pairs_.count(make_pair(cluster1, cluster2)) > 0);
}
diff --git a/internal/ceres/visibility_based_preconditioner.h b/internal/ceres/visibility_based_preconditioner.h
index 2f6922d..10959d6 100644
--- a/internal/ceres/visibility_based_preconditioner.h
+++ b/internal/ceres/visibility_based_preconditioner.h
@@ -151,15 +151,16 @@
LinearSolverTerminationType Factorize();
void ScaleOffDiagonalCells();
- void ClusterCameras(const vector< set<int> >& visibility);
+ void ClusterCameras(const std::vector< std::set<int> >& visibility);
void FlattenMembershipMap(const HashMap<int, int>& membership_map,
- vector<int>* membership_vector) const;
- void ComputeClusterVisibility(const vector<set<int> >& visibility,
- vector<set<int> >* cluster_visibility) const;
+ std::vector<int>* membership_vector) const;
+ void ComputeClusterVisibility(
+ const std::vector<std::set<int> >& visibility,
+ std::vector<std::set<int> >* cluster_visibility) const;
WeightedGraph<int>* CreateClusterGraph(
- const vector<set<int> >& visibility) const;
+ const std::vector<std::set<int> >& visibility) const;
void ForestToClusterPairs(const WeightedGraph<int>& forest,
- HashSet<pair<int, int> >* cluster_pairs) const;
+ HashSet<std::pair<int, int> >* cluster_pairs) const;
void ComputeBlockPairsInPreconditioner(const CompressedRowBlockStructure& bs);
bool IsBlockPairInPreconditioner(int block1, int block2) const;
bool IsBlockPairOffDiagonal(int block1, int block2) const;
@@ -171,19 +172,19 @@
int num_clusters_;
// Sizes of the blocks in the schur complement.
- vector<int> block_size_;
+ std::vector<int> block_size_;
// Mapping from cameras to clusters.
- vector<int> cluster_membership_;
+ std::vector<int> cluster_membership_;
// Non-zero camera pairs from the schur complement matrix that are
// present in the preconditioner, sorted by row (first element of
// each pair), then column (second).
- set<pair<int, int> > block_pairs_;
+ std::set<std::pair<int, int> > block_pairs_;
// Set of cluster pairs (including self pairs (i,i)) in the
// preconditioner.
- HashSet<pair<int, int> > cluster_pairs_;
+ HashSet<std::pair<int, int> > cluster_pairs_;
scoped_ptr<SchurEliminatorBase> eliminator_;
// Preconditioner matrix.
diff --git a/internal/ceres/visibility_test.cc b/internal/ceres/visibility_test.cc
index 01f2bdf..183ab88 100644
--- a/internal/ceres/visibility_test.cc
+++ b/internal/ceres/visibility_test.cc
@@ -47,6 +47,9 @@
namespace ceres {
namespace internal {
+using std::set;
+using std::vector;
+
class VisibilityTest : public ::testing::Test {
};