Removing using std::...
Change-Id: I584402e2a34869183c1d59071a15d97b216c52fb
diff --git a/examples/libmv_bundle_adjuster.cc b/examples/libmv_bundle_adjuster.cc
index fc45139..30ec111 100644
--- a/examples/libmv_bundle_adjuster.cc
+++ b/examples/libmv_bundle_adjuster.cc
@@ -123,8 +123,6 @@
using Vec3 = Eigen::Vector3d;
using Vec4 = Eigen::Vector4d;
-using std::vector;
-
DEFINE_string(input, "", "Input File name");
DEFINE_string(refine_intrinsics,
"",
@@ -207,7 +205,7 @@
};
// Returns a pointer to the camera corresponding to a image.
-EuclideanCamera* CameraForImage(vector<EuclideanCamera>* all_cameras,
+EuclideanCamera* CameraForImage(std::vector<EuclideanCamera>* all_cameras,
const int image) {
if (image < 0 || image >= all_cameras->size()) {
return nullptr;
@@ -220,7 +218,7 @@
}
const EuclideanCamera* CameraForImage(
- const vector<EuclideanCamera>& all_cameras, const int image) {
+ const std::vector<EuclideanCamera>& all_cameras, const int image) {
if (image < 0 || image >= all_cameras.size()) {
return nullptr;
}
@@ -232,7 +230,7 @@
}
// Returns maximal image number at which marker exists.
-int MaxImage(const vector<Marker>& all_markers) {
+int MaxImage(const std::vector<Marker>& all_markers) {
if (all_markers.size() == 0) {
return -1;
}
@@ -245,7 +243,7 @@
}
// Returns a pointer to the point corresponding to a track.
-EuclideanPoint* PointForTrack(vector<EuclideanPoint>* all_points,
+EuclideanPoint* PointForTrack(std::vector<EuclideanPoint>* all_points,
const int track) {
if (track < 0 || track >= all_points->size()) {
return nullptr;
@@ -373,10 +371,10 @@
// reading.
bool ReadProblemFromFile(const std::string& file_name,
double camera_intrinsics[8],
- vector<EuclideanCamera>* all_cameras,
- vector<EuclideanPoint>* all_points,
+ std::vector<EuclideanCamera>* all_cameras,
+ std::vector<EuclideanPoint>* all_points,
bool* is_image_space,
- vector<Marker>* all_markers) {
+ std::vector<Marker>* all_markers) {
EndianAwareFileReader file_reader;
if (!file_reader.OpenFile(file_name)) {
return false;
@@ -614,10 +612,10 @@
//
// Element with index i matches to a rotation+translation for
// camera at image i.
-vector<Vec6> PackCamerasRotationAndTranslation(
- const vector<Marker>& all_markers,
- const vector<EuclideanCamera>& all_cameras) {
- vector<Vec6> all_cameras_R_t;
+std::vector<Vec6> PackCamerasRotationAndTranslation(
+ const std::vector<Marker>& all_markers,
+ const std::vector<EuclideanCamera>& all_cameras) {
+ std::vector<Vec6> all_cameras_R_t;
int max_image = MaxImage(all_markers);
all_cameras_R_t.resize(max_image + 1);
@@ -637,9 +635,9 @@
}
// Convert cameras rotations fro mangle axis back to rotation matrix.
-void UnpackCamerasRotationAndTranslation(const vector<Marker>& all_markers,
- const vector<Vec6>& all_cameras_R_t,
- vector<EuclideanCamera>* all_cameras) {
+void UnpackCamerasRotationAndTranslation(const std::vector<Marker>& all_markers,
+ const std::vector<Vec6>& all_cameras_R_t,
+ std::vector<EuclideanCamera>* all_cameras) {
int max_image = MaxImage(all_markers);
for (int i = 0; i <= max_image; i++) {
@@ -654,12 +652,12 @@
}
}
-void EuclideanBundleCommonIntrinsics(const vector<Marker>& all_markers,
+void EuclideanBundleCommonIntrinsics(const std::vector<Marker>& all_markers,
const int bundle_intrinsics,
const int bundle_constraints,
double* camera_intrinsics,
- vector<EuclideanCamera>* all_cameras,
- vector<EuclideanPoint>* all_points) {
+ std::vector<EuclideanCamera>* all_cameras,
+ std::vector<EuclideanPoint>* all_points) {
PrintCameraIntrinsics("Original intrinsics: ", camera_intrinsics);
ceres::Problem::Options problem_options;
@@ -671,7 +669,7 @@
//
// Block for minimization has got the following structure:
// <3 elements for angle-axis> <3 elements for translation>
- vector<Vec6> all_cameras_R_t =
+ std::vector<Vec6> all_cameras_R_t =
PackCamerasRotationAndTranslation(all_markers, *all_cameras);
// Manifold used to restrict camera motion for modal solvers.
@@ -799,10 +797,10 @@
}
double camera_intrinsics[8];
- vector<EuclideanCamera> all_cameras;
- vector<EuclideanPoint> all_points;
+ std::vector<EuclideanCamera> all_cameras;
+ std::vector<EuclideanPoint> all_points;
bool is_image_space;
- vector<Marker> all_markers;
+ std::vector<Marker> all_markers;
if (!ReadProblemFromFile(CERES_GET_FLAG(FLAGS_input),
camera_intrinsics,
diff --git a/examples/nist.cc b/examples/nist.cc
index 05c15b2..04f1474 100644
--- a/examples/nist.cc
+++ b/examples/nist.cc
@@ -159,17 +159,10 @@
using Vector = Eigen::Matrix<double, Dynamic, 1>;
using Matrix = Eigen::Matrix<double, Dynamic, Dynamic, RowMajor>;
-using std::atof;
-using std::atoi;
-using std::cout;
-using std::ifstream;
-using std::string;
-using std::vector;
-
-void SplitStringUsingChar(const string& full,
+void SplitStringUsingChar(const std::string& full,
const char delim,
- vector<string>* result) {
- std::back_insert_iterator<vector<string>> it(*result);
+ std::vector<std::string>* result) {
+ std::back_insert_iterator<std::vector<std::string>> it(*result);
const char* p = full.data();
const char* end = p + full.size();
@@ -181,20 +174,20 @@
while (++p != end && *p != delim) {
// Skip to the next occurrence of the delimiter.
}
- *it++ = string(start, p - start);
+ *it++ = std::string(start, p - start);
}
}
}
-bool GetAndSplitLine(ifstream& ifs, vector<string>* pieces) {
+bool GetAndSplitLine(std::ifstream& ifs, std::vector<std::string>* pieces) {
pieces->clear();
char buf[256];
ifs.getline(buf, 256);
- SplitStringUsingChar(string(buf), ' ', pieces);
+ SplitStringUsingChar(std::string(buf), ' ', pieces);
return true;
}
-void SkipLines(ifstream& ifs, int num_lines) {
+void SkipLines(std::ifstream& ifs, int num_lines) {
char buf[256];
for (int i = 0; i < num_lines; ++i) {
ifs.getline(buf, 256);
@@ -203,24 +196,24 @@
class NISTProblem {
public:
- explicit NISTProblem(const string& filename) {
- ifstream ifs(filename.c_str(), ifstream::in);
+ explicit NISTProblem(const std::string& filename) {
+ std::ifstream ifs(filename.c_str(), std::ifstream::in);
CHECK(ifs) << "Unable to open : " << filename;
- vector<string> pieces;
+ std::vector<std::string> pieces;
SkipLines(ifs, 24);
GetAndSplitLine(ifs, &pieces);
- const int kNumResponses = atoi(pieces[1].c_str());
+ const int kNumResponses = std::atoi(pieces[1].c_str());
GetAndSplitLine(ifs, &pieces);
- const int kNumPredictors = atoi(pieces[0].c_str());
+ const int kNumPredictors = std::atoi(pieces[0].c_str());
GetAndSplitLine(ifs, &pieces);
- const int kNumObservations = atoi(pieces[0].c_str());
+ const int kNumObservations = std::atoi(pieces[0].c_str());
SkipLines(ifs, 4);
GetAndSplitLine(ifs, &pieces);
- const int kNumParameters = atoi(pieces[0].c_str());
+ const int kNumParameters = std::atoi(pieces[0].c_str());
SkipLines(ifs, 8);
// Get the first line of initial and final parameter values to
@@ -236,24 +229,24 @@
// Parse the line for parameter b1.
int parameter_id = 0;
for (int i = 0; i < kNumTries; ++i) {
- initial_parameters_(i, parameter_id) = atof(pieces[i + 2].c_str());
+ initial_parameters_(i, parameter_id) = std::atof(pieces[i + 2].c_str());
}
- final_parameters_(0, parameter_id) = atof(pieces[2 + kNumTries].c_str());
+ final_parameters_(0, parameter_id) = std::atof(pieces[2 + kNumTries].c_str());
// Parse the remaining parameter lines.
for (int parameter_id = 1; parameter_id < kNumParameters; ++parameter_id) {
GetAndSplitLine(ifs, &pieces);
// b2, b3, ....
for (int i = 0; i < kNumTries; ++i) {
- initial_parameters_(i, parameter_id) = atof(pieces[i + 2].c_str());
+ initial_parameters_(i, parameter_id) = std::atof(pieces[i + 2].c_str());
}
- final_parameters_(0, parameter_id) = atof(pieces[2 + kNumTries].c_str());
+ final_parameters_(0, parameter_id) = std::atof(pieces[2 + kNumTries].c_str());
}
// Certified cost
SkipLines(ifs, 1);
GetAndSplitLine(ifs, &pieces);
- certified_cost_ = atof(pieces[4].c_str()) / 2.0;
+ certified_cost_ = std::atof(pieces[4].c_str()) / 2.0;
// Read the observations.
SkipLines(ifs, 18 - kNumParameters);
@@ -261,12 +254,12 @@
GetAndSplitLine(ifs, &pieces);
// Response.
for (int j = 0; j < kNumResponses; ++j) {
- response_(i, j) = atof(pieces[j].c_str());
+ response_(i, j) = std::atof(pieces[j].c_str());
}
// Predictor variables.
for (int j = 0; j < kNumPredictors; ++j) {
- predictor_(i, j) = atof(pieces[j + kNumResponses].c_str());
+ predictor_(i, j) = std::atof(pieces[j + kNumResponses].c_str());
}
}
}
@@ -507,7 +500,7 @@
options->parameter_tolerance = std::numeric_limits<double>::epsilon();
}
-string JoinPath(const string& dirname, const string& basename) {
+std::string JoinPath(const std::string& dirname, const std::string& basename) {
#ifdef _WIN32
static const char separator = '\\';
#else
@@ -519,7 +512,7 @@
} else if (dirname[dirname.size() - 1] == separator) {
return dirname + basename;
} else {
- return dirname + string(&separator, 1) + basename;
+ return dirname + std::string(&separator, 1) + basename;
}
}
@@ -583,7 +576,7 @@
}
template <typename Model, int num_parameters>
-int RegressionDriver(const string& filename) {
+int RegressionDriver(const std::string& filename) {
NISTProblem nist_problem(
JoinPath(CERES_GET_FLAG(FLAGS_nist_data_dir), filename));
CHECK_EQ(num_parameters, nist_problem.num_parameters());
@@ -663,7 +656,7 @@
LOG(FATAL) << "Must specify the directory containing the NIST problems";
}
- cout << "Lower Difficulty\n";
+ std::cout << "Lower Difficulty\n";
int easy_success = 0;
easy_success += RegressionDriver<Misra1a, 2>("Misra1a.dat");
easy_success += RegressionDriver<Chwirut, 3>("Chwirut1.dat");
@@ -674,7 +667,7 @@
easy_success += RegressionDriver<DanWood, 2>("DanWood.dat");
easy_success += RegressionDriver<Misra1b, 2>("Misra1b.dat");
- cout << "\nMedium Difficulty\n";
+ std::cout << "\nMedium Difficulty\n";
int medium_success = 0;
medium_success += RegressionDriver<Kirby2, 5>("Kirby2.dat");
medium_success += RegressionDriver<Hahn1, 7>("Hahn1.dat");
@@ -688,7 +681,7 @@
medium_success += RegressionDriver<Roszman1, 4>("Roszman1.dat");
medium_success += RegressionDriver<ENSO, 9>("ENSO.dat");
- cout << "\nHigher Difficulty\n";
+ std::cout << "\nHigher Difficulty\n";
int hard_success = 0;
hard_success += RegressionDriver<MGH09, 4>("MGH09.dat");
hard_success += RegressionDriver<Thurber, 7>("Thurber.dat");
@@ -699,11 +692,11 @@
hard_success += RegressionDriver<Rat43, 4>("Rat43.dat");
hard_success += RegressionDriver<Bennet5, 3>("Bennett5.dat");
- cout << "\n";
- cout << "Easy : " << easy_success << "/16\n";
- cout << "Medium : " << medium_success << "/22\n";
- cout << "Hard : " << hard_success << "/16\n";
- cout << "Total : " << easy_success + medium_success + hard_success
+ std::cout << "\n";
+ std::cout << "Easy : " << easy_success << "/16\n";
+ std::cout << "Medium : " << medium_success << "/22\n";
+ std::cout << "Hard : " << hard_success << "/16\n";
+ std::cout << "Total : " << easy_success + medium_success + hard_success
<< "/54\n";
}
diff --git a/examples/robot_pose_mle.cc b/examples/robot_pose_mle.cc
index 5f57a89..7dd981d 100644
--- a/examples/robot_pose_mle.cc
+++ b/examples/robot_pose_mle.cc
@@ -143,8 +143,6 @@
using ceres::Problem;
using ceres::Solve;
using ceres::Solver;
-using std::min;
-using std::vector;
DEFINE_double(corridor_length,
30.0,
@@ -215,8 +213,8 @@
// conveniently add to a ceres problem.
static RangeCostFunction* Create(const int pose_index,
const double range_reading,
- vector<double>* odometry_values,
- vector<double*>* parameter_blocks) {
+ std::vector<double>* odometry_values,
+ std::vector<double*>* parameter_blocks) {
auto* constraint =
new RangeConstraint(pose_index,
range_reading,
@@ -241,8 +239,8 @@
namespace {
-void SimulateRobot(vector<double>* odometry_values,
- vector<double>* range_readings) {
+void SimulateRobot(std::vector<double>* odometry_values,
+ std::vector<double>* range_readings) {
const int num_steps =
static_cast<int>(ceil(CERES_GET_FLAG(FLAGS_corridor_length) /
CERES_GET_FLAG(FLAGS_pose_separation)));
@@ -256,8 +254,8 @@
double robot_location = 0.0;
for (int i = 0; i < num_steps; ++i) {
const double actual_odometry_value =
- min(CERES_GET_FLAG(FLAGS_pose_separation),
- CERES_GET_FLAG(FLAGS_corridor_length) - robot_location);
+ std::min(CERES_GET_FLAG(FLAGS_pose_separation),
+ CERES_GET_FLAG(FLAGS_corridor_length) - robot_location);
robot_location += actual_odometry_value;
const double actual_range =
CERES_GET_FLAG(FLAGS_corridor_length) - robot_location;
@@ -269,8 +267,8 @@
}
}
-void PrintState(const vector<double>& odometry_readings,
- const vector<double>& range_readings) {
+void PrintState(const std::vector<double>& odometry_readings,
+ const std::vector<double>& range_readings) {
CHECK_EQ(odometry_readings.size(), range_readings.size());
double robot_location = 0.0;
printf("pose: location odom range r.error o.error\n");
@@ -301,8 +299,8 @@
CHECK_GT(CERES_GET_FLAG(FLAGS_odometry_stddev), 0.0);
CHECK_GT(CERES_GET_FLAG(FLAGS_range_stddev), 0.0);
- vector<double> odometry_values;
- vector<double> range_readings;
+ std::vector<double> odometry_values;
+ std::vector<double> range_readings;
SimulateRobot(&odometry_values, &range_readings);
printf("Initial values:\n");
@@ -312,7 +310,7 @@
for (int i = 0; i < odometry_values.size(); ++i) {
// Create and add a DynamicAutoDiffCostFunction for the RangeConstraint from
// pose i.
- vector<double*> parameter_blocks;
+ std::vector<double*> parameter_blocks;
RangeConstraint::RangeCostFunction* range_cost_function =
RangeConstraint::Create(
i, range_readings[i], &odometry_values, ¶meter_blocks);
diff --git a/internal/ceres/array_utils.cc b/internal/ceres/array_utils.cc
index 1501866..8362618 100644
--- a/internal/ceres/array_utils.cc
+++ b/internal/ceres/array_utils.cc
@@ -38,9 +38,8 @@
#include "ceres/stringprintf.h"
#include "ceres/types.h"
-namespace ceres::internal {
-using std::string;
+namespace ceres::internal {
bool IsArrayValid(const int size, const double* x) {
if (x != nullptr) {
@@ -75,7 +74,7 @@
}
}
-void AppendArrayToString(const int size, const double* x, string* result) {
+void AppendArrayToString(const int size, const double* x, std::string* result) {
for (int i = 0; i < size; ++i) {
if (x == nullptr) {
StringAppendF(result, "Not Computed ");
diff --git a/internal/ceres/array_utils_test.cc b/internal/ceres/array_utils_test.cc
index 8a94ec1..5820728 100644
--- a/internal/ceres/array_utils_test.cc
+++ b/internal/ceres/array_utils_test.cc
@@ -38,8 +38,6 @@
namespace ceres::internal {
-using std::vector;
-
TEST(ArrayUtils, IsArrayValid) {
double x[3];
x[0] = 0.0;
@@ -75,10 +73,10 @@
}
TEST(MapValuesToContiguousRange, ContiguousEntries) {
- vector<int> array;
+ std::vector<int> array;
array.push_back(0);
array.push_back(1);
- vector<int> expected = array;
+ std::vector<int> expected = array;
MapValuesToContiguousRange(array.size(), &array[0]);
EXPECT_EQ(array, expected);
array.clear();
@@ -91,10 +89,10 @@
}
TEST(MapValuesToContiguousRange, NonContiguousEntries) {
- vector<int> array;
+ std::vector<int> array;
array.push_back(0);
array.push_back(2);
- vector<int> expected;
+ std::vector<int> expected;
expected.push_back(0);
expected.push_back(1);
MapValuesToContiguousRange(array.size(), &array[0]);
@@ -102,14 +100,14 @@
}
TEST(MapValuesToContiguousRange, NonContiguousRepeatingEntries) {
- vector<int> array;
+ std::vector<int> array;
array.push_back(3);
array.push_back(1);
array.push_back(0);
array.push_back(0);
array.push_back(0);
array.push_back(5);
- vector<int> expected;
+ std::vector<int> expected;
expected.push_back(2);
expected.push_back(1);
expected.push_back(0);
diff --git a/internal/ceres/block_jacobian_writer.cc b/internal/ceres/block_jacobian_writer.cc
index d7e1e95..a481626 100644
--- a/internal/ceres/block_jacobian_writer.cc
+++ b/internal/ceres/block_jacobian_writer.cc
@@ -43,8 +43,6 @@
namespace ceres::internal {
-using std::vector;
-
namespace {
// Given the residual block ordering, build a lookup table to determine which
@@ -59,9 +57,9 @@
// instead of num_eliminate_blocks.
void BuildJacobianLayout(const Program& program,
int num_eliminate_blocks,
- vector<int*>* jacobian_layout,
- vector<int>* jacobian_layout_storage) {
- const vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
+ std::vector<int*>* jacobian_layout,
+ std::vector<int>* jacobian_layout_storage) {
+ const std::vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
// Iterate over all the active residual blocks and determine how many E blocks
// are there. This will determine where the F blocks start in the jacobian
@@ -153,7 +151,7 @@
std::unique_ptr<SparseMatrix> BlockJacobianWriter::CreateJacobian() const {
auto* bs = new CompressedRowBlockStructure;
- const vector<ParameterBlock*>& parameter_blocks =
+ const std::vector<ParameterBlock*>& parameter_blocks =
program_->parameter_blocks();
// Construct the column blocks.
@@ -167,7 +165,7 @@
}
// Construct the cells in each row.
- const vector<ResidualBlock*>& residual_blocks = program_->residual_blocks();
+ const std::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/bundle_adjustment_test_util.h b/internal/ceres/bundle_adjustment_test_util.h
index 696b39e..68d7a7c 100644
--- a/internal/ceres/bundle_adjustment_test_util.h
+++ b/internal/ceres/bundle_adjustment_test_util.h
@@ -51,9 +51,6 @@
namespace ceres {
namespace internal {
-using std::string;
-using std::vector;
-
const bool kAutomaticOrdering = true;
const bool kUserOrdering = false;
@@ -68,7 +65,7 @@
BuildProblem();
}
BundleAdjustmentProblem() {
- const string input_file = TestFileAbsolutePath("problem-16-22106-pre.txt");
+ const std::string input_file = TestFileAbsolutePath("problem-16-22106-pre.txt");
ReadData(input_file);
BuildProblem();
}
@@ -98,7 +95,7 @@
static double kResidualTolerance;
private:
- void ReadData(const string& filename) {
+ void ReadData(const std::string& filename) {
FILE* fptr = fopen(filename.c_str(), "r");
if (!fptr) {
diff --git a/internal/ceres/callbacks.cc b/internal/ceres/callbacks.cc
index fcdcb2a..b46f62c 100644
--- a/internal/ceres/callbacks.cc
+++ b/internal/ceres/callbacks.cc
@@ -39,8 +39,6 @@
namespace ceres::internal {
-using std::string;
-
StateUpdatingCallback::StateUpdatingCallback(Program* program,
double* parameters)
: program_(program), parameters_(parameters) {}
@@ -82,7 +80,7 @@
CallbackReturnType LoggingCallback::operator()(
const IterationSummary& summary) {
- string output;
+ std::string output;
if (minimizer_type == LINE_SEARCH) {
output = StringPrintf(
"% 4d: f:% 8e d:% 3.2e g:% 3.2e h:% 3.2e s:% 3.2e e:% 3d it:% 3.2e "
diff --git a/internal/ceres/canonical_views_clustering.cc b/internal/ceres/canonical_views_clustering.cc
index 7c385fc..7599f6d 100644
--- a/internal/ceres/canonical_views_clustering.cc
+++ b/internal/ceres/canonical_views_clustering.cc
@@ -41,8 +41,6 @@
namespace ceres::internal {
-using std::vector;
-
using IntMap = std::unordered_map<int, int>;
using IntSet = std::unordered_set<int>;
@@ -58,15 +56,15 @@
// are assigned to a cluster with id = kInvalidClusterId.
void ComputeClustering(const CanonicalViewsClusteringOptions& options,
const WeightedGraph<int>& graph,
- vector<int>* centers,
+ std::vector<int>* centers,
IntMap* membership);
private:
void FindValidViews(IntSet* valid_views) const;
double ComputeClusteringQualityDifference(const int candidate,
- const vector<int>& centers) const;
+ const std::vector<int>& centers) const;
void UpdateCanonicalViewAssignments(const int canonical_view);
- void ComputeClusterMembership(const vector<int>& centers,
+ void ComputeClusterMembership(const std::vector<int>& centers,
IntMap* membership) const;
CanonicalViewsClusteringOptions options_;
@@ -81,7 +79,7 @@
void ComputeCanonicalViewsClustering(
const CanonicalViewsClusteringOptions& options,
const WeightedGraph<int>& graph,
- vector<int>* centers,
+ std::vector<int>* centers,
IntMap* membership) {
time_t start_time = time(nullptr);
CanonicalViewsClustering cv;
@@ -94,7 +92,7 @@
void CanonicalViewsClustering::ComputeClustering(
const CanonicalViewsClusteringOptions& options,
const WeightedGraph<int>& graph,
- vector<int>* centers,
+ std::vector<int>* centers,
IntMap* membership) {
options_ = options;
CHECK(centers != nullptr);
@@ -150,7 +148,7 @@
// Computes the difference in the quality score if 'candidate' were
// added to the set of canonical views.
double CanonicalViewsClustering::ComputeClusteringQualityDifference(
- const int candidate, const vector<int>& centers) const {
+ const int candidate, const std::vector<int>& centers) const {
// View score.
double difference =
options_.view_score_weight * graph_->VertexWeight(candidate);
@@ -197,7 +195,7 @@
// Assign a cluster id to each view.
void CanonicalViewsClustering::ComputeClusterMembership(
- const vector<int>& centers, IntMap* membership) const {
+ const std::vector<int>& centers, IntMap* membership) const {
CHECK(membership != nullptr);
membership->clear();
diff --git a/internal/ceres/coordinate_descent_minimizer.cc b/internal/ceres/coordinate_descent_minimizer.cc
index de22822..cd0caf2 100644
--- a/internal/ceres/coordinate_descent_minimizer.cc
+++ b/internal/ceres/coordinate_descent_minimizer.cc
@@ -51,13 +51,6 @@
namespace ceres::internal {
-using std::map;
-using std::max;
-using std::min;
-using std::set;
-using std::string;
-using std::vector;
-
CoordinateDescentMinimizer::CoordinateDescentMinimizer(ContextImpl* context)
: context_(context) {
CHECK(context_ != nullptr);
@@ -69,15 +62,15 @@
const Program& program,
const ProblemImpl::ParameterMap& parameter_map,
const ParameterBlockOrdering& ordering,
- string* error) {
+ std::string* error) {
parameter_blocks_.clear();
independent_set_offsets_.clear();
independent_set_offsets_.push_back(0);
// Serialize the OrderedGroups into a vector of parameter block
// offsets for parallel access.
- map<ParameterBlock*, int> parameter_block_index;
- map<int, set<double*>> group_to_elements = ordering.group_to_elements();
+ std::map<ParameterBlock*, int> parameter_block_index;
+ std::map<int, std::set<double*>> group_to_elements = ordering.group_to_elements();
for (const auto& g_t_e : group_to_elements) {
const auto& elements = g_t_e.second;
for (double* parameter_block : elements) {
@@ -92,7 +85,7 @@
// The ordering does not have to contain all parameter blocks, so
// assign zero offsets/empty independent sets to these parameter
// blocks.
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
for (auto* parameter_block : parameter_blocks) {
if (!ordering.IsMember(parameter_block->mutable_user_state())) {
parameter_blocks_.push_back(parameter_block);
@@ -103,7 +96,7 @@
// Compute the set of residual blocks that depend on each parameter
// block.
residual_blocks_.resize(parameter_block_index.size());
- const vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
+ const std::vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
for (auto* residual_block : residual_blocks) {
const int num_parameter_blocks = residual_block->NumParameterBlocks();
for (int j = 0; j < num_parameter_blocks; ++j) {
@@ -152,9 +145,9 @@
}
const int num_inner_iteration_threads =
- min(options.num_threads, num_problems);
+ std::min(options.num_threads, num_problems);
evaluator_options_.num_threads =
- max(1, options.num_threads / num_inner_iteration_threads);
+ std::max(1, options.num_threads / num_inner_iteration_threads);
// The parameter blocks in each independent set can be optimized
// in parallel, since they do not co-occur in any residual block.
@@ -214,7 +207,7 @@
summary->initial_cost = 0.0;
summary->fixed_cost = 0.0;
summary->final_cost = 0.0;
- string error;
+ std::string error;
Minimizer::Options minimizer_options;
minimizer_options.evaluator =
@@ -237,8 +230,8 @@
bool CoordinateDescentMinimizer::IsOrderingValid(
const Program& program,
const ParameterBlockOrdering& ordering,
- string* message) {
- const map<int, set<double*>>& group_to_elements =
+ std::string* message) {
+ const std::map<int, std::set<double*>>& group_to_elements =
ordering.group_to_elements();
// Verify that each group is an independent set
diff --git a/internal/ceres/cost_function_to_functor_test.cc b/internal/ceres/cost_function_to_functor_test.cc
index f26fc1d..cf4a57b 100644
--- a/internal/ceres/cost_function_to_functor_test.cc
+++ b/internal/ceres/cost_function_to_functor_test.cc
@@ -40,7 +40,6 @@
namespace ceres::internal {
-using std::vector;
const double kTolerance = 1e-18;
static void ExpectCostFunctionsAreEqual(
@@ -49,9 +48,9 @@
EXPECT_EQ(cost_function.num_residuals(),
actual_cost_function.num_residuals());
const int num_residuals = cost_function.num_residuals();
- const vector<int32_t>& parameter_block_sizes =
+ const std::vector<int32_t>& parameter_block_sizes =
cost_function.parameter_block_sizes();
- const vector<int32_t>& actual_parameter_block_sizes =
+ const std::vector<int32_t>& actual_parameter_block_sizes =
actual_cost_function.parameter_block_sizes();
EXPECT_EQ(parameter_block_sizes.size(), actual_parameter_block_sizes.size());
diff --git a/internal/ceres/covariance.cc b/internal/ceres/covariance.cc
index 029f3f5..b24999d 100644
--- a/internal/ceres/covariance.cc
+++ b/internal/ceres/covariance.cc
@@ -39,9 +39,6 @@
namespace ceres {
-using std::pair;
-using std::vector;
-
Covariance::Covariance(const Covariance::Options& options) {
impl_ = std::make_unique<internal::CovarianceImpl>(options);
}
@@ -49,12 +46,12 @@
Covariance::~Covariance() = default;
bool Covariance::Compute(
- const vector<pair<const double*, const double*>>& covariance_blocks,
+ const std::vector<std::pair<const double*, const double*>>& covariance_blocks,
Problem* problem) {
return impl_->Compute(covariance_blocks, problem->mutable_impl());
}
-bool Covariance::Compute(const vector<const double*>& parameter_blocks,
+bool Covariance::Compute(const std::vector<const double*>& parameter_blocks,
Problem* problem) {
return impl_->Compute(parameter_blocks, problem->mutable_impl());
}
@@ -79,7 +76,7 @@
}
bool Covariance::GetCovarianceMatrix(
- const vector<const double*>& parameter_blocks,
+ const std::vector<const double*>& parameter_blocks,
double* covariance_matrix) const {
return impl_->GetCovarianceMatrixInTangentOrAmbientSpace(parameter_blocks,
true, // ambient
diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc
index 5d8b87f..4245e43 100644
--- a/internal/ceres/covariance_impl.cc
+++ b/internal/ceres/covariance_impl.cc
@@ -59,8 +59,6 @@
namespace ceres::internal {
-using std::swap;
-
using CovarianceBlocks = std::vector<std::pair<const double*, const double*>>;
CovarianceImpl::CovarianceImpl(const Covariance::Options& options)
@@ -166,7 +164,7 @@
const double* parameter_block2 = original_parameter_block2;
const bool transpose = parameter_block1 > parameter_block2;
if (transpose) {
- swap(parameter_block1, parameter_block2);
+ std::swap(parameter_block1, parameter_block2);
}
// Find where in the covariance matrix the block is located.
diff --git a/internal/ceres/covariance_test.cc b/internal/ceres/covariance_test.cc
index 76fcb12..7d477a7 100644
--- a/internal/ceres/covariance_test.cc
+++ b/internal/ceres/covariance_test.cc
@@ -50,11 +50,6 @@
namespace ceres {
namespace internal {
-using std::make_pair;
-using std::map;
-using std::pair;
-using std::vector;
-
class UnaryCostFunction : public CostFunction {
public:
UnaryCostFunction(const int num_residuals,
@@ -84,7 +79,7 @@
}
private:
- vector<double> jacobian_;
+ std::vector<double> jacobian_;
};
class BinaryCostFunction : public CostFunction {
@@ -126,8 +121,8 @@
}
private:
- vector<double> jacobian1_;
- vector<double> jacobian2_;
+ std::vector<double> jacobian1_;
+ std::vector<double> jacobian2_;
};
TEST(CovarianceImpl, ComputeCovarianceSparsity) {
@@ -184,7 +179,7 @@
6, 7, 8, 9};
// clang-format on
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(block1, block1);
covariance_blocks.emplace_back(block4, block4);
covariance_blocks.emplace_back(block2, block2);
@@ -265,7 +260,7 @@
3, 4, 5, 6};
// clang-format on
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(block1, block1);
covariance_blocks.emplace_back(block4, block4);
covariance_blocks.emplace_back(block2, block2);
@@ -344,7 +339,7 @@
3, 4, 5, 6};
// clang-format on
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(block1, block1);
covariance_blocks.emplace_back(block4, block4);
covariance_blocks.emplace_back(block2, block2);
@@ -409,7 +404,7 @@
class CovarianceTest : public ::testing::Test {
protected:
- using BoundsMap = map<const double*, pair<int, int>>;
+ using BoundsMap = std::map<const double*, std::pair<int, int>>;
void SetUp() override {
double* x = parameters_;
@@ -462,9 +457,9 @@
all_covariance_blocks_.emplace_back(x, z);
all_covariance_blocks_.emplace_back(y, z);
- column_bounds_[x] = make_pair(0, 2);
- column_bounds_[y] = make_pair(2, 5);
- column_bounds_[z] = make_pair(5, 6);
+ column_bounds_[x] = std::make_pair(0, 2);
+ column_bounds_[y] = std::make_pair(2, 5);
+ column_bounds_[z] = std::make_pair(5, 6);
}
// Computes covariance in ambient space.
@@ -492,7 +487,7 @@
// Generate all possible combination of block pairs and check if the
// covariance computation is correct.
for (int i = 0; i <= 64; ++i) {
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
if (i & 1) {
covariance_blocks.push_back(all_covariance_blocks_[0]);
}
@@ -585,7 +580,7 @@
double parameters_[6];
Problem problem_;
- vector<pair<const double*, const double*>> all_covariance_blocks_;
+ std::vector<std::pair<const double*, const double*>> all_covariance_blocks_;
BoundsMap column_bounds_;
BoundsMap local_column_bounds_;
};
@@ -746,7 +741,7 @@
problem_.SetManifold(x, new PolynomialManifold);
- vector<int> subset;
+ std::vector<int> subset;
subset.push_back(2);
problem_.SetManifold(y, new SubsetManifold(3, subset));
@@ -806,13 +801,13 @@
problem_.SetManifold(x, new PolynomialManifold);
- vector<int> subset;
+ std::vector<int> subset;
subset.push_back(2);
problem_.SetManifold(y, new SubsetManifold(3, subset));
- local_column_bounds_[x] = make_pair(0, 1);
- local_column_bounds_[y] = make_pair(1, 3);
- local_column_bounds_[z] = make_pair(3, 4);
+ local_column_bounds_[x] = std::make_pair(0, 1);
+ local_column_bounds_[y] = std::make_pair(1, 3);
+ local_column_bounds_[z] = std::make_pair(3, 4);
// Raw Jacobian: J
//
@@ -870,14 +865,14 @@
problem_.SetManifold(x, new PolynomialManifold);
problem_.SetParameterBlockConstant(x);
- vector<int> subset;
+ std::vector<int> subset;
subset.push_back(2);
problem_.SetManifold(y, new SubsetManifold(3, subset));
problem_.SetParameterBlockConstant(y);
- local_column_bounds_[x] = make_pair(0, 1);
- local_column_bounds_[y] = make_pair(1, 3);
- local_column_bounds_[z] = make_pair(3, 4);
+ local_column_bounds_[x] = std::make_pair(0, 1);
+ local_column_bounds_[y] = std::make_pair(1, 3);
+ local_column_bounds_[z] = std::make_pair(3, 4);
// Raw Jacobian: J
//
@@ -987,7 +982,7 @@
double* x = parameters_;
double* y = x + 2;
double* z = y + 3;
- vector<const double*> parameter_blocks;
+ std::vector<const double*> parameter_blocks;
parameter_blocks.push_back(x);
parameter_blocks.push_back(y);
parameter_blocks.push_back(z);
@@ -1016,7 +1011,7 @@
double* x = parameters_;
double* y = x + 2;
double* z = y + 3;
- vector<const double*> parameter_blocks;
+ std::vector<const double*> parameter_blocks;
parameter_blocks.push_back(x);
parameter_blocks.push_back(y);
parameter_blocks.push_back(z);
@@ -1047,15 +1042,15 @@
problem_.SetManifold(x, new PolynomialManifold);
- vector<int> subset;
+ std::vector<int> subset;
subset.push_back(2);
problem_.SetManifold(y, new SubsetManifold(3, subset));
- local_column_bounds_[x] = make_pair(0, 1);
- local_column_bounds_[y] = make_pair(1, 3);
- local_column_bounds_[z] = make_pair(3, 4);
+ local_column_bounds_[x] = std::make_pair(0, 1);
+ local_column_bounds_[y] = std::make_pair(1, 3);
+ local_column_bounds_[z] = std::make_pair(3, 4);
- vector<const double*> parameter_blocks;
+ std::vector<const double*> parameter_blocks;
parameter_blocks.push_back(x);
parameter_blocks.push_back(y);
parameter_blocks.push_back(z);
@@ -1084,7 +1079,7 @@
Covariance covariance(options);
double* x = parameters_;
double* y = x + 2;
- vector<const double*> parameter_blocks;
+ std::vector<const double*> parameter_blocks;
parameter_blocks.push_back(x);
parameter_blocks.push_back(x);
parameter_blocks.push_back(y);
@@ -1092,7 +1087,7 @@
EXPECT_DEATH_IF_SUPPORTED(covariance.Compute(parameter_blocks, &problem_),
"Covariance::Compute called with duplicate blocks "
"at indices \\(0, 1\\) and \\(2, 3\\)");
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(x, x);
covariance_blocks.emplace_back(x, x);
covariance_blocks.emplace_back(y, y);
@@ -1148,9 +1143,9 @@
all_covariance_blocks_.emplace_back(x, z);
all_covariance_blocks_.emplace_back(y, z);
- column_bounds_[x] = make_pair(0, 2);
- column_bounds_[y] = make_pair(2, 5);
- column_bounds_[z] = make_pair(5, 6);
+ column_bounds_[x] = std::make_pair(0, 2);
+ column_bounds_[y] = std::make_pair(2, 5);
+ column_bounds_[z] = std::make_pair(5, 6);
}
};
@@ -1217,7 +1212,7 @@
Covariance::Options options;
options.algorithm_type = DENSE_SVD;
Covariance covariance(options);
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(&x, &x);
covariance_blocks.emplace_back(&x, &y);
covariance_blocks.emplace_back(&y, &x);
@@ -1252,7 +1247,7 @@
Covariance::Options options;
options.algorithm_type = DENSE_SVD;
Covariance covariance(options);
- vector<pair<const double*, const double*>> covariance_blocks;
+ std::vector<std::pair<const double*, const double*>> covariance_blocks;
covariance_blocks.emplace_back(&x, &x);
covariance_blocks.emplace_back(&x, &y);
covariance_blocks.emplace_back(&y, &x);
@@ -1348,7 +1343,7 @@
int num_parameter_blocks_;
Problem problem_;
- vector<pair<const double*, const double*>> all_covariance_blocks_;
+ std::vector<std::pair<const double*, const double*>> all_covariance_blocks_;
};
#if !defined(CERES_NO_SUITESPARSE)
diff --git a/internal/ceres/dynamic_autodiff_cost_function_test.cc b/internal/ceres/dynamic_autodiff_cost_function_test.cc
index 6777d0c..d4800c2 100644
--- a/internal/ceres/dynamic_autodiff_cost_function_test.cc
+++ b/internal/ceres/dynamic_autodiff_cost_function_test.cc
@@ -39,8 +39,6 @@
namespace ceres::internal {
-using std::vector;
-
// Takes 2 parameter blocks:
// parameters[0] is size 10.
// parameters[1] is size 5.
@@ -74,8 +72,8 @@
};
TEST(DynamicAutodiffCostFunctionTest, TestResiduals) {
- vector<double> param_block_0(10, 0.0);
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicAutoDiffCostFunction<MyCostFunctor, 3> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -83,8 +81,8 @@
cost_function.SetNumResiduals(21);
// Test residual computation.
- vector<double> residuals(21, -100000);
- vector<double*> parameter_blocks(2);
+ std::vector<double> residuals(21, -100000);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
EXPECT_TRUE(
@@ -98,11 +96,11 @@
TEST(DynamicAutodiffCostFunctionTest, TestJacobian) {
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicAutoDiffCostFunction<MyCostFunctor, 3> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -110,18 +108,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect[0].data());
jacobian.push_back(jacobian_vect[1].data());
@@ -164,11 +162,11 @@
TEST(DynamicAutodiffCostFunctionTest, JacobianWithFirstParameterBlockConstant) {
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicAutoDiffCostFunction<MyCostFunctor, 3> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -176,18 +174,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect[1].data());
@@ -214,11 +212,11 @@
TEST(DynamicAutodiffCostFunctionTest,
JacobianWithSecondParameterBlockConstant) { // NOLINT
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicAutoDiffCostFunction<MyCostFunctor, 3> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -226,18 +224,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect[0].data());
jacobian.push_back(nullptr);
@@ -408,25 +406,25 @@
}
protected:
- vector<double> x_;
- vector<double> y_;
- vector<double> z_;
+ std::vector<double> x_;
+ std::vector<double> y_;
+ std::vector<double> z_;
- vector<double*> parameter_blocks_;
+ std::vector<double*> parameter_blocks_;
std::unique_ptr<CostFunction> cost_function_;
- vector<vector<double>> jacobian_vect_;
+ std::vector<std::vector<double>> jacobian_vect_;
- vector<double> expected_residuals_;
+ std::vector<double> expected_residuals_;
- vector<double> expected_jacobian_x_;
- vector<double> expected_jacobian_y_;
- vector<double> expected_jacobian_z_;
+ std::vector<double> expected_jacobian_x_;
+ std::vector<double> expected_jacobian_y_;
+ std::vector<double> expected_jacobian_z_;
};
TEST_F(ThreeParameterCostFunctorTest, TestThreeParameterResiduals) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
EXPECT_TRUE(cost_function_->Evaluate(
parameter_blocks_.data(), residuals.data(), nullptr));
for (int i = 0; i < 7; ++i) {
@@ -435,9 +433,9 @@
}
TEST_F(ThreeParameterCostFunctorTest, TestThreeParameterJacobian) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(jacobian_vect_[2].data());
@@ -464,9 +462,9 @@
TEST_F(ThreeParameterCostFunctorTest,
ThreeParameterJacobianWithFirstAndLastParameterBlockConstant) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(nullptr);
@@ -485,9 +483,9 @@
TEST_F(ThreeParameterCostFunctorTest,
ThreeParameterJacobianWithSecondParameterBlockConstant) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect_[2].data());
@@ -654,18 +652,18 @@
double z1_;
double z2_;
- vector<double*> parameter_blocks_;
+ std::vector<double*> parameter_blocks_;
std::unique_ptr<CostFunction> cost_function_;
- vector<vector<double>> jacobian_vect_;
+ std::vector<std::vector<double>> jacobian_vect_;
- vector<double> expected_residuals_;
- vector<vector<double>> expected_jacobians_;
+ std::vector<double> expected_residuals_;
+ std::vector<std::vector<double>> expected_jacobians_;
};
TEST_F(SixParameterCostFunctorTest, TestSixParameterResiduals) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
EXPECT_TRUE(cost_function_->Evaluate(
parameter_blocks_.data(), residuals.data(), nullptr));
for (int i = 0; i < 7; ++i) {
@@ -674,9 +672,9 @@
}
TEST_F(SixParameterCostFunctorTest, TestSixParameterJacobian) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(jacobian_vect_[2].data());
@@ -699,9 +697,9 @@
}
TEST_F(SixParameterCostFunctorTest, TestSixParameterJacobianVVCVVC) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(nullptr);
@@ -729,9 +727,9 @@
}
TEST_F(SixParameterCostFunctorTest, TestSixParameterJacobianVCCVCV) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(nullptr);
jacobian.push_back(nullptr);
diff --git a/internal/ceres/dynamic_compressed_row_jacobian_writer.cc b/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
index a97c333..78d1875 100644
--- a/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
+++ b/internal/ceres/dynamic_compressed_row_jacobian_writer.cc
@@ -41,9 +41,6 @@
namespace ceres::internal {
-using std::pair;
-using std::vector;
-
std::unique_ptr<ScratchEvaluatePreparer[]>
DynamicCompressedRowJacobianWriter::CreateEvaluatePreparers(int num_threads) {
return ScratchEvaluatePreparer::Create(*program_, num_threads);
@@ -68,7 +65,7 @@
program_->residual_blocks()[residual_id];
const int num_residuals = residual_block->NumResiduals();
- vector<pair<int, int>> evaluated_jacobian_blocks;
+ std::vector<std::pair<int, int>> evaluated_jacobian_blocks;
CompressedRowJacobianWriter::GetOrderedParameterBlocks(
program_, residual_id, &evaluated_jacobian_blocks);
diff --git a/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc b/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
index 269858f..c32233c 100644
--- a/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
+++ b/internal/ceres/dynamic_compressed_row_sparse_matrix_test.cc
@@ -42,9 +42,6 @@
namespace ceres {
namespace internal {
-using std::copy;
-using std::vector;
-
class DynamicCompressedRowSparseMatrixTest : public ::testing::Test {
protected:
void SetUp() final {
@@ -82,8 +79,8 @@
}
void InitialiseSparseMatrixReferences() {
- vector<int> rows, cols;
- vector<double> values;
+ std::vector<int> rows, cols;
+ std::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) {
@@ -96,9 +93,9 @@
tsm = std::make_unique<TripletSparseMatrix>(
num_rows, num_cols, expected_num_nonzeros);
- copy(rows.begin(), rows.end(), tsm->mutable_rows());
- copy(cols.begin(), cols.end(), tsm->mutable_cols());
- copy(values.begin(), values.end(), tsm->mutable_values());
+ 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());
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 f2a37e3..0dae837 100644
--- a/internal/ceres/dynamic_numeric_diff_cost_function_test.cc
+++ b/internal/ceres/dynamic_numeric_diff_cost_function_test.cc
@@ -38,8 +38,6 @@
namespace ceres::internal {
-using std::vector;
-
const double kTolerance = 1e-6;
// Takes 2 parameter blocks:
@@ -74,8 +72,8 @@
};
TEST(DynamicNumericdiffCostFunctionTest, TestResiduals) {
- vector<double> param_block_0(10, 0.0);
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicNumericDiffCostFunction<MyCostFunctor> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -83,8 +81,8 @@
cost_function.SetNumResiduals(21);
// Test residual computation.
- vector<double> residuals(21, -100000);
- vector<double*> parameter_blocks(2);
+ std::vector<double> residuals(21, -100000);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
EXPECT_TRUE(
@@ -98,11 +96,11 @@
TEST(DynamicNumericdiffCostFunctionTest, TestJacobian) {
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicNumericDiffCostFunction<MyCostFunctor> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -110,18 +108,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect[0].data());
jacobian.push_back(jacobian_vect[1].data());
@@ -165,11 +163,11 @@
TEST(DynamicNumericdiffCostFunctionTest,
JacobianWithFirstParameterBlockConstant) { // NOLINT
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicNumericDiffCostFunction<MyCostFunctor> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -177,18 +175,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect[1].data());
@@ -215,11 +213,11 @@
TEST(DynamicNumericdiffCostFunctionTest,
JacobianWithSecondParameterBlockConstant) { // NOLINT
// Test the residual counting.
- vector<double> param_block_0(10, 0.0);
+ std::vector<double> param_block_0(10, 0.0);
for (int i = 0; i < 10; ++i) {
param_block_0[i] = 2 * i;
}
- vector<double> param_block_1(5, 0.0);
+ std::vector<double> param_block_1(5, 0.0);
DynamicNumericDiffCostFunction<MyCostFunctor> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(param_block_0.size());
@@ -227,18 +225,18 @@
cost_function.SetNumResiduals(21);
// Prepare the residuals.
- vector<double> residuals(21, -100000);
+ std::vector<double> residuals(21, -100000);
// Prepare the parameters.
- vector<double*> parameter_blocks(2);
+ std::vector<double*> parameter_blocks(2);
parameter_blocks[0] = ¶m_block_0[0];
parameter_blocks[1] = ¶m_block_1[0];
// Prepare the jacobian.
- vector<vector<double>> jacobian_vect(2);
+ std::vector<std::vector<double>> jacobian_vect(2);
jacobian_vect[0].resize(21 * 10, -100000);
jacobian_vect[1].resize(21 * 5, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect[0].data());
jacobian.push_back(nullptr);
@@ -409,25 +407,25 @@
}
protected:
- vector<double> x_;
- vector<double> y_;
- vector<double> z_;
+ std::vector<double> x_;
+ std::vector<double> y_;
+ std::vector<double> z_;
- vector<double*> parameter_blocks_;
+ std::vector<double*> parameter_blocks_;
std::unique_ptr<CostFunction> cost_function_;
- vector<vector<double>> jacobian_vect_;
+ std::vector<std::vector<double>> jacobian_vect_;
- vector<double> expected_residuals_;
+ std::vector<double> expected_residuals_;
- vector<double> expected_jacobian_x_;
- vector<double> expected_jacobian_y_;
- vector<double> expected_jacobian_z_;
+ std::vector<double> expected_jacobian_x_;
+ std::vector<double> expected_jacobian_y_;
+ std::vector<double> expected_jacobian_z_;
};
TEST_F(ThreeParameterCostFunctorTest, TestThreeParameterResiduals) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
EXPECT_TRUE(cost_function_->Evaluate(
parameter_blocks_.data(), residuals.data(), nullptr));
for (int i = 0; i < 7; ++i) {
@@ -436,9 +434,9 @@
}
TEST_F(ThreeParameterCostFunctorTest, TestThreeParameterJacobian) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(jacobian_vect_[2].data());
@@ -465,9 +463,9 @@
TEST_F(ThreeParameterCostFunctorTest,
ThreeParameterJacobianWithFirstAndLastParameterBlockConstant) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect_[1].data());
jacobian.push_back(nullptr);
@@ -486,9 +484,9 @@
TEST_F(ThreeParameterCostFunctorTest,
ThreeParameterJacobianWithSecondParameterBlockConstant) {
- vector<double> residuals(7, -100000);
+ std::vector<double> residuals(7, -100000);
- vector<double*> jacobian;
+ std::vector<double*> jacobian;
jacobian.push_back(jacobian_vect_[0].data());
jacobian.push_back(nullptr);
jacobian.push_back(jacobian_vect_[2].data());
diff --git a/internal/ceres/evaluator_test.cc b/internal/ceres/evaluator_test.cc
index 24da250..d9a1b21 100644
--- a/internal/ceres/evaluator_test.cc
+++ b/internal/ceres/evaluator_test.cc
@@ -52,9 +52,6 @@
namespace ceres {
namespace internal {
-using std::string;
-using std::vector;
-
// TODO(keir): Consider pushing this into a common test utils file.
template <int kFactor, int kNumResiduals, int... Ns>
class ParameterIgnoringCostFunction
@@ -122,7 +119,7 @@
program->SetParameterOffsetsAndIndex();
if (VLOG_IS_ON(1)) {
- string report;
+ std::string report;
StringAppendF(&report,
"Creating evaluator with type: %d",
GetParam().linear_solver_type);
@@ -140,7 +137,7 @@
options.num_eliminate_blocks = GetParam().num_eliminate_blocks;
options.dynamic_sparsity = GetParam().dynamic_sparsity;
options.context = problem.context();
- string error;
+ std::string error;
return Evaluator::Create(options, program, &error);
}
@@ -171,7 +168,7 @@
ASSERT_EQ(expected_num_rows, jacobian->num_rows());
ASSERT_EQ(expected_num_cols, jacobian->num_cols());
- vector<double> state(evaluator->NumParameters());
+ std::vector<double> state(evaluator->NumParameters());
// clang-format off
ASSERT_TRUE(evaluator->Evaluate(
@@ -399,12 +396,12 @@
problem.AddParameterBlock(x, 2);
// Fix y's first dimension.
- vector<int> y_fixed;
+ std::vector<int> y_fixed;
y_fixed.push_back(0);
problem.AddParameterBlock(y, 3, new SubsetManifold(3, y_fixed));
// Fix z's second dimension.
- vector<int> z_fixed;
+ std::vector<int> z_fixed;
z_fixed.push_back(1);
problem.AddParameterBlock(z, 4, new SubsetManifold(4, z_fixed));
@@ -486,7 +483,7 @@
// Normally, the preprocessing of the program that happens in solver_impl
// takes care of this, but we don't want to invoke the solver here.
Program reduced_program;
- vector<ParameterBlock*>* parameter_blocks =
+ std::vector<ParameterBlock*>* parameter_blocks =
problem.mutable_program()->mutable_parameter_blocks();
// "z" is the last parameter; save it for later and pop it off temporarily.
@@ -620,7 +617,7 @@
options.linear_solver_type = DENSE_QR;
options.num_eliminate_blocks = 0;
options.context = problem.context();
- string error;
+ std::string error;
std::unique_ptr<Evaluator> evaluator(
Evaluator::Create(options, program, &error));
std::unique_ptr<SparseMatrix> jacobian(evaluator->CreateJacobian());
diff --git a/internal/ceres/file.cc b/internal/ceres/file.cc
index cd91843..601964f 100644
--- a/internal/ceres/file.cc
+++ b/internal/ceres/file.cc
@@ -38,9 +38,7 @@
namespace ceres::internal {
-using std::string;
-
-void WriteStringToFileOrDie(const string& data, const string& filename) {
+void WriteStringToFileOrDie(const std::string& data, const std::string& filename) {
FILE* file_descriptor = fopen(filename.c_str(), "wb");
if (!file_descriptor) {
LOG(FATAL) << "Couldn't write to file: " << filename;
@@ -49,7 +47,7 @@
fclose(file_descriptor);
}
-void ReadFileToStringOrDie(const string& filename, string* data) {
+void ReadFileToStringOrDie(const std::string& filename, std::string* data) {
FILE* file_descriptor = fopen(filename.c_str(), "r");
if (!file_descriptor) {
@@ -73,7 +71,7 @@
fclose(file_descriptor);
}
-string JoinPath(const string& dirname, const string& basename) {
+std::string JoinPath(const std::string& dirname, const std::string& basename) {
#ifdef _WIN32
static const char separator = '\\';
#else
@@ -85,7 +83,7 @@
} else if (dirname[dirname.size() - 1] == separator) {
return dirname + basename;
} else {
- return dirname + string(&separator, 1) + basename;
+ return dirname + std::string(&separator, 1) + basename;
}
}
diff --git a/internal/ceres/gradient_checker.cc b/internal/ceres/gradient_checker.cc
index 68bcf86..dfd5c6a 100644
--- a/internal/ceres/gradient_checker.cc
+++ b/internal/ceres/gradient_checker.cc
@@ -48,8 +48,6 @@
using internal::IsClose;
using internal::StringAppendF;
using internal::StringPrintf;
-using std::string;
-using std::vector;
namespace {
// Evaluate the cost function and transform the returned Jacobians to
@@ -64,12 +62,12 @@
CHECK(jacobians != nullptr);
CHECK(local_jacobians != nullptr);
- const vector<int32_t>& block_sizes = function->parameter_block_sizes();
+ const std::vector<int32_t>& block_sizes = function->parameter_block_sizes();
const int num_parameter_blocks = block_sizes.size();
// Allocate Jacobian matrices in tangent space.
local_jacobians->resize(num_parameter_blocks);
- vector<double*> local_jacobian_data(num_parameter_blocks);
+ std::vector<double*> local_jacobian_data(num_parameter_blocks);
for (int i = 0; i < num_parameter_blocks; ++i) {
int block_size = block_sizes.at(i);
if (manifolds.at(i) != nullptr) {
@@ -82,7 +80,7 @@
// Allocate Jacobian matrices in ambient space.
jacobians->resize(num_parameter_blocks);
- vector<double*> jacobian_data(num_parameter_blocks);
+ std::vector<double*> jacobian_data(num_parameter_blocks);
for (int i = 0; i < num_parameter_blocks; ++i) {
jacobians->at(i).resize(function->num_residuals(), block_sizes.at(i));
jacobians->at(i).setZero();
@@ -116,7 +114,7 @@
} // namespace
GradientChecker::GradientChecker(const CostFunction* function,
- const vector<const Manifold*>* manifolds,
+ const std::vector<const Manifold*>* manifolds,
const NumericDiffOptions& options)
: function_(function) {
CHECK(function != nullptr);
@@ -129,7 +127,7 @@
auto finite_diff_cost_function =
std::make_unique<DynamicNumericDiffCostFunction<CostFunction, RIDDERS>>(
function, DO_NOT_TAKE_OWNERSHIP, options);
- const vector<int32_t>& parameter_block_sizes =
+ const std::vector<int32_t>& parameter_block_sizes =
function->parameter_block_sizes();
const int num_parameter_blocks = parameter_block_sizes.size();
for (int i = 0; i < num_parameter_blocks; ++i) {
@@ -164,8 +162,8 @@
results->return_value = true;
// Evaluate the derivative using the user supplied code.
- vector<Matrix>& jacobians = results->jacobians;
- vector<Matrix>& local_jacobians = results->local_jacobians;
+ std::vector<Matrix>& jacobians = results->jacobians;
+ std::vector<Matrix>& local_jacobians = results->local_jacobians;
if (!EvaluateCostFunction(function_,
parameters,
manifolds_,
@@ -177,8 +175,8 @@
}
// Evaluate the derivative using numeric derivatives.
- vector<Matrix>& numeric_jacobians = results->numeric_jacobians;
- vector<Matrix>& local_numeric_jacobians = results->local_numeric_jacobians;
+ std::vector<Matrix>& numeric_jacobians = results->numeric_jacobians;
+ std::vector<Matrix>& local_numeric_jacobians = results->local_numeric_jacobians;
Vector finite_diff_residuals;
if (!EvaluateCostFunction(finite_diff_cost_function_.get(),
parameters,
@@ -218,7 +216,7 @@
// Accumulate the error message for all the jacobians, since it won't get
// output if there are no bad jacobian components.
- string error_log;
+ std::string error_log;
for (int k = 0; k < function_->parameter_block_sizes().size(); k++) {
StringAppendF(&error_log,
"========== "
@@ -272,7 +270,7 @@
// Since there were some bad errors, dump comprehensive debug info.
if (num_bad_jacobian_components) {
- string header = StringPrintf(
+ std::string header = StringPrintf(
"\nDetected %d bad Jacobian component(s). "
"Worst relative error was %g.\n",
num_bad_jacobian_components,
diff --git a/internal/ceres/gradient_checker_test.cc b/internal/ceres/gradient_checker_test.cc
index 1e6fe9a..3508455 100644
--- a/internal/ceres/gradient_checker_test.cc
+++ b/internal/ceres/gradient_checker_test.cc
@@ -46,7 +46,6 @@
namespace ceres::internal {
-using std::vector;
const double kTolerance = 1e-12;
// We pick a (non-quadratic) function whose derivative are easy:
@@ -115,7 +114,7 @@
private:
int arity_;
bool return_value_;
- vector<vector<double>> a_; // our vectors.
+ std::vector<std::vector<double>> a_; // our vectors.
};
class BadTestTerm : public CostFunction {
@@ -170,7 +169,7 @@
private:
int arity_;
- vector<vector<double>> a_; // our vectors.
+ std::vector<std::vector<double>> a_; // our vectors.
};
static void CheckDimensions(const GradientChecker::ProbeResults& results,
diff --git a/internal/ceres/gradient_checking_cost_function.cc b/internal/ceres/gradient_checking_cost_function.cc
index 04440c2..013a98a 100644
--- a/internal/ceres/gradient_checking_cost_function.cc
+++ b/internal/ceres/gradient_checking_cost_function.cc
@@ -54,11 +54,6 @@
namespace ceres::internal {
-using std::abs;
-using std::max;
-using std::string;
-using std::vector;
-
namespace {
class GradientCheckingCostFunction final : public CostFunction {
@@ -67,7 +62,7 @@
const std::vector<const Manifold*>* manifolds,
const NumericDiffOptions& options,
double relative_precision,
- string extra_info,
+ std::string extra_info,
GradientCheckingIterationCallback* callback)
: function_(function),
gradient_checker_(function, manifolds, options),
@@ -75,7 +70,7 @@
extra_info_(std::move(extra_info)),
callback_(callback) {
CHECK(callback_ != nullptr);
- const vector<int32_t>& parameter_block_sizes =
+ const std::vector<int32_t>& parameter_block_sizes =
function->parameter_block_sizes();
*mutable_parameter_block_sizes() = parameter_block_sizes;
set_num_residuals(function->num_residuals());
@@ -104,7 +99,7 @@
MatrixRef(residuals, num_residuals, 1) = results.residuals;
// Copy the original jacobian blocks into the jacobians array.
- const vector<int32_t>& block_sizes = function_->parameter_block_sizes();
+ const std::vector<int32_t>& block_sizes = function_->parameter_block_sizes();
for (int k = 0; k < block_sizes.size(); k++) {
if (jacobians[k] != nullptr) {
MatrixRef(jacobians[k],
@@ -126,7 +121,7 @@
const CostFunction* function_;
GradientChecker gradient_checker_;
double relative_precision_;
- string extra_info_;
+ std::string extra_info_;
GradientCheckingIterationCallback* callback_;
};
@@ -197,7 +192,7 @@
// For every ParameterBlock in problem_impl, create a new parameter block with
// the same manifold and constancy.
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
for (auto* parameter_block : parameter_blocks) {
gradient_checking_problem_impl->AddParameterBlock(
parameter_block->mutable_user_state(),
@@ -224,17 +219,17 @@
// 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 std::vector<ResidualBlock*>& residual_blocks = program->residual_blocks();
for (int i = 0; i < residual_blocks.size(); ++i) {
ResidualBlock* residual_block = residual_blocks[i];
// Build a human readable string which identifies the
// ResidualBlock. This is used by the GradientCheckingCostFunction
// when logging debugging information.
- string extra_info =
+ std::string extra_info =
StringPrintf("Residual block id %d; depends on parameters [", i);
- vector<double*> parameter_blocks;
- vector<const Manifold*> manifolds;
+ std::vector<double*> parameter_blocks;
+ std::vector<const Manifold*> manifolds;
parameter_blocks.reserve(residual_block->NumParameterBlocks());
manifolds.reserve(residual_block->NumParameterBlocks());
for (int j = 0; j < residual_block->NumParameterBlocks(); ++j) {
diff --git a/internal/ceres/gradient_checking_cost_function_test.cc b/internal/ceres/gradient_checking_cost_function_test.cc
index 87c3278..027aa67 100644
--- a/internal/ceres/gradient_checking_cost_function_test.cc
+++ b/internal/ceres/gradient_checking_cost_function_test.cc
@@ -51,7 +51,6 @@
namespace ceres::internal {
-using std::vector;
using testing::_;
using testing::AllOf;
using testing::AnyNumber;
@@ -128,7 +127,7 @@
private:
int arity_;
- vector<vector<double>> a_;
+ std::vector<std::vector<double>> a_;
};
TEST(GradientCheckingCostFunction, ResidualsAndJacobiansArePreservedTest) {
@@ -137,7 +136,7 @@
int const dim[arity] = {2, 3, 4};
// Make a random set of blocks.
- vector<double*> parameters(arity);
+ std::vector<double*> parameters(arity);
std::mt19937 prng;
std::uniform_real_distribution<double> distribution(-1.0, 1.0);
auto randu = [&prng, &distribution] { return distribution(prng); };
@@ -150,8 +149,8 @@
double original_residual;
double residual;
- vector<double*> original_jacobians(arity);
- vector<double*> jacobians(arity);
+ std::vector<double*> original_jacobians(arity);
+ std::vector<double*> jacobians(arity);
for (int j = 0; j < arity; ++j) {
// Since residual is one dimensional the jacobians have the same
@@ -195,7 +194,7 @@
int const dim[arity] = {2, 3, 4};
// Make a random set of blocks.
- vector<double*> parameters(arity);
+ std::vector<double*> parameters(arity);
std::mt19937 prng;
std::uniform_real_distribution<double> distribution(-1.0, 1.0);
auto randu = [&prng, &distribution] { return distribution(prng); };
@@ -207,7 +206,7 @@
}
double residual;
- vector<double*> jacobians(arity);
+ std::vector<double*> jacobians(arity);
for (int j = 0; j < arity; ++j) {
// Since residual is one dimensional the jacobians have the same size as the
// parameter blocks.
diff --git a/internal/ceres/gradient_problem_solver.cc b/internal/ceres/gradient_problem_solver.cc
index 114b0ee..3438409 100644
--- a/internal/ceres/gradient_problem_solver.cc
+++ b/internal/ceres/gradient_problem_solver.cc
@@ -49,7 +49,6 @@
namespace ceres {
using internal::StringAppendF;
using internal::StringPrintf;
-using std::string;
namespace {
@@ -181,7 +180,7 @@
SetSummaryFinalCost(summary);
}
- const std::map<string, CallStatistics>& evaluator_statistics =
+ const std::map<std::string, CallStatistics>& evaluator_statistics =
minimizer_options.evaluator->Statistics();
{
const CallStatistics& call_stats = FindWithDefault(
@@ -204,7 +203,7 @@
return internal::IsSolutionUsable(*this);
}
-string GradientProblemSolver::Summary::BriefReport() const {
+std::string GradientProblemSolver::Summary::BriefReport() const {
return StringPrintf(
"Ceres GradientProblemSolver Report: "
"Iterations: %d, "
@@ -217,12 +216,12 @@
TerminationTypeToString(termination_type));
}
-string GradientProblemSolver::Summary::FullReport() const {
+std::string GradientProblemSolver::Summary::FullReport() const {
using internal::VersionString;
// NOTE operator+ is not usable for concatenating a string and a string_view.
- string report =
- string{"\nSolver Summary (v "}.append(VersionString()) + ")\n\n";
+ std::string report =
+ std::string{"\nSolver Summary (v "}.append(VersionString()) + ")\n\n";
StringAppendF(&report, "Parameters % 25d\n", num_parameters);
if (num_tangent_parameters != num_parameters) {
@@ -230,7 +229,7 @@
&report, "Tangent parameters % 25d\n", num_tangent_parameters);
}
- string line_search_direction_string;
+ std::string line_search_direction_string;
if (line_search_direction_type == LBFGS) {
line_search_direction_string = StringPrintf("LBFGS (%d)", max_lbfgs_rank);
} else if (line_search_direction_type == NONLINEAR_CONJUGATE_GRADIENT) {
@@ -245,7 +244,7 @@
"Line search direction %19s\n",
line_search_direction_string.c_str());
- const string line_search_type_string = StringPrintf(
+ const std::string line_search_type_string = StringPrintf(
"%s %s",
LineSearchInterpolationTypeToString(line_search_interpolation_type),
LineSearchTypeToString(line_search_type));
diff --git a/internal/ceres/graph_algorithms_test.cc b/internal/ceres/graph_algorithms_test.cc
index c03cda4..ac56497 100644
--- a/internal/ceres/graph_algorithms_test.cc
+++ b/internal/ceres/graph_algorithms_test.cc
@@ -40,8 +40,6 @@
namespace ceres::internal {
-using std::vector;
-
TEST(IndependentSetOrdering, Chain) {
Graph<int> graph;
graph.AddVertex(0);
@@ -57,7 +55,7 @@
// 0-1-2-3-4
// 0, 2, 4 should be in the independent set.
- vector<int> ordering;
+ std::vector<int> ordering;
int independent_set_size = IndependentSetOrdering(graph, &ordering);
sort(ordering.begin(), ordering.begin() + 3);
@@ -91,7 +89,7 @@
// |
// 3
// 1, 2, 3, 4 should be in the independent set.
- vector<int> ordering;
+ std::vector<int> ordering;
int independent_set_size = IndependentSetOrdering(graph, &ordering);
EXPECT_EQ(independent_set_size, 4);
EXPECT_EQ(ordering.size(), 5);
@@ -219,7 +217,7 @@
// guarantees that it will always be the first vertex in the
// ordering vector.
{
- vector<int> ordering;
+ std::vector<int> ordering;
ordering.push_back(0);
ordering.push_back(1);
ordering.push_back(2);
@@ -231,7 +229,7 @@
}
{
- vector<int> ordering;
+ std::vector<int> ordering;
ordering.push_back(1);
ordering.push_back(0);
ordering.push_back(2);
diff --git a/internal/ceres/line_search.cc b/internal/ceres/line_search.cc
index 68d6bbe..2b6fe4d 100644
--- a/internal/ceres/line_search.cc
+++ b/internal/ceres/line_search.cc
@@ -47,20 +47,15 @@
namespace ceres::internal {
-using std::map;
-using std::ostream;
-using std::string;
-using std::vector;
-
namespace {
// Precision used for floating point values in error message output.
const int kErrorMessageNumericPrecision = 8;
} // namespace
-ostream& operator<<(ostream& os, const FunctionSample& sample);
+std::ostream& operator<<(std::ostream& os, const FunctionSample& sample);
// Convenience stream operator for pushing FunctionSamples into log messages.
-ostream& operator<<(ostream& os, const FunctionSample& sample) {
+std::ostream& operator<<(std::ostream& os, const FunctionSample& sample) {
os << sample.ToDebugString();
return os;
}
@@ -73,16 +68,16 @@
std::unique_ptr<LineSearch> LineSearch::Create(
const LineSearchType line_search_type,
const LineSearch::Options& options,
- string* error) {
+ std::string* error) {
switch (line_search_type) {
case ceres::ARMIJO:
return std::make_unique<ArmijoLineSearch>(options);
case ceres::WOLFE:
return std::make_unique<WolfeLineSearch>(options);
default:
- *error = string("Invalid line search algorithm type: ") +
+ *error = std::string("Invalid line search algorithm type: ") +
LineSearchTypeToString(line_search_type) +
- string(", unable to create line search.");
+ std::string(", unable to create line search.");
}
return nullptr;
}
@@ -149,7 +144,7 @@
}
void LineSearchFunction::ResetTimeStatistics() {
- const map<string, CallStatistics> evaluator_statistics =
+ const std::map<std::string, CallStatistics> evaluator_statistics =
evaluator_->Statistics();
initial_evaluator_residual_time_in_seconds =
@@ -165,7 +160,7 @@
void LineSearchFunction::TimeStatistics(
double* cost_evaluation_time_in_seconds,
double* gradient_evaluation_time_in_seconds) const {
- const map<string, CallStatistics> evaluator_time_statistics =
+ const std::map<std::string, CallStatistics> evaluator_time_statistics =
evaluator_->Statistics();
*cost_evaluation_time_in_seconds =
FindWithDefault(
@@ -242,7 +237,7 @@
// Select step size by interpolating the function and gradient values
// and minimizing the corresponding polynomial.
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
samples.push_back(lowerbound);
if (interpolation_type == QUADRATIC) {
diff --git a/internal/ceres/linear_least_squares_problems.cc b/internal/ceres/linear_least_squares_problems.cc
index 4c55fbc..7b87c9a 100644
--- a/internal/ceres/linear_least_squares_problems.cc
+++ b/internal/ceres/linear_least_squares_problems.cc
@@ -46,8 +46,6 @@
namespace ceres::internal {
-using std::string;
-
std::unique_ptr<LinearLeastSquaresProblem>
CreateLinearLeastSquaresProblemFromId(int id) {
switch (id) {
@@ -952,7 +950,7 @@
return true;
}
-void WriteArrayToFileOrDie(const string& filename,
+void WriteArrayToFileOrDie(const std::string& filename,
const double* x,
const int size) {
CHECK(x != nullptr);
@@ -965,7 +963,7 @@
fclose(fptr);
}
-bool DumpLinearLeastSquaresProblemToTextFile(const string& filename_base,
+bool DumpLinearLeastSquaresProblemToTextFile(const std::string& filename_base,
const SparseMatrix* A,
const double* D,
const double* b,
@@ -974,14 +972,14 @@
CHECK(A != nullptr);
LOG(INFO) << "writing to: " << filename_base << "*";
- string matlab_script;
+ std::string matlab_script;
StringAppendF(&matlab_script,
"function lsqp = load_trust_region_problem()\n");
StringAppendF(&matlab_script, "lsqp.num_rows = %d;\n", A->num_rows());
StringAppendF(&matlab_script, "lsqp.num_cols = %d;\n", A->num_cols());
{
- string filename = filename_base + "_A.txt";
+ std::string filename = filename_base + "_A.txt";
FILE* fptr = fopen(filename.c_str(), "w");
CHECK(fptr != nullptr);
A->ToTextFile(fptr);
@@ -996,33 +994,33 @@
}
if (D != nullptr) {
- string filename = filename_base + "_D.txt";
+ std::string filename = filename_base + "_D.txt";
WriteArrayToFileOrDie(filename, D, A->num_cols());
StringAppendF(
&matlab_script, "lsqp.D = load('%s', '-ascii');\n", filename.c_str());
}
if (b != nullptr) {
- string filename = filename_base + "_b.txt";
+ std::string filename = filename_base + "_b.txt";
WriteArrayToFileOrDie(filename, b, A->num_rows());
StringAppendF(
&matlab_script, "lsqp.b = load('%s', '-ascii');\n", filename.c_str());
}
if (x != nullptr) {
- string filename = filename_base + "_x.txt";
+ std::string filename = filename_base + "_x.txt";
WriteArrayToFileOrDie(filename, x, A->num_cols());
StringAppendF(
&matlab_script, "lsqp.x = load('%s', '-ascii');\n", filename.c_str());
}
- string matlab_filename = filename_base + ".m";
+ std::string matlab_filename = filename_base + ".m";
WriteStringToFileOrDie(matlab_script, matlab_filename);
return true;
}
} // namespace
-bool DumpLinearLeastSquaresProblem(const string& filename_base,
+bool DumpLinearLeastSquaresProblem(const std::string& filename_base,
DumpFormatType dump_format_type,
const SparseMatrix* A,
const double* D,
diff --git a/internal/ceres/low_rank_inverse_hessian.cc b/internal/ceres/low_rank_inverse_hessian.cc
index c471844..a11a197 100644
--- a/internal/ceres/low_rank_inverse_hessian.cc
+++ b/internal/ceres/low_rank_inverse_hessian.cc
@@ -37,8 +37,6 @@
namespace ceres::internal {
-using std::list;
-
// The (L)BFGS algorithm explicitly requires that the secant equation:
//
// B_{k+1} * s_k = y_k
diff --git a/internal/ceres/parameter_block_ordering.cc b/internal/ceres/parameter_block_ordering.cc
index c01eb20..5f675ab 100644
--- a/internal/ceres/parameter_block_ordering.cc
+++ b/internal/ceres/parameter_block_ordering.cc
@@ -44,19 +44,15 @@
namespace ceres::internal {
-using std::map;
-using std::set;
-using std::vector;
-
int ComputeStableSchurOrdering(const Program& program,
- vector<ParameterBlock*>* ordering) {
+ std::vector<ParameterBlock*>* ordering) {
CHECK(ordering != nullptr);
ordering->clear();
EventLogger event_logger("ComputeStableSchurOrdering");
auto graph = CreateHessianGraph(program);
event_logger.AddEvent("CreateHessianGraph");
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
const std::unordered_set<ParameterBlock*>& vertices = graph->vertices();
for (auto* parameter_block : parameter_blocks) {
if (vertices.count(parameter_block) > 0) {
@@ -80,13 +76,13 @@
}
int ComputeSchurOrdering(const Program& program,
- vector<ParameterBlock*>* ordering) {
+ std::vector<ParameterBlock*>* ordering) {
CHECK(ordering != nullptr);
ordering->clear();
auto graph = CreateHessianGraph(program);
int independent_set_size = IndependentSetOrdering(*graph, ordering);
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
// Add the excluded blocks to back of the ordering vector.
for (auto* parameter_block : parameter_blocks) {
@@ -102,13 +98,13 @@
ParameterBlockOrdering* ordering) {
CHECK(ordering != nullptr);
ordering->Clear();
- const vector<ParameterBlock*> parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*> parameter_blocks = program.parameter_blocks();
auto graph = CreateHessianGraph(program);
int num_covered = 0;
int round = 0;
while (num_covered < parameter_blocks.size()) {
- vector<ParameterBlock*> independent_set_ordering;
+ std::vector<ParameterBlock*> independent_set_ordering;
const int independent_set_size =
IndependentSetOrdering(*graph, &independent_set_ordering);
for (int i = 0; i < independent_set_size; ++i) {
@@ -125,14 +121,14 @@
const Program& program) {
auto graph = std::make_unique<Graph<ParameterBlock*>>();
CHECK(graph != nullptr);
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
for (auto* parameter_block : parameter_blocks) {
if (!parameter_block->IsConstant()) {
graph->AddVertex(parameter_block);
}
}
- const vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
+ const std::vector<ResidualBlock*>& residual_blocks = program.residual_blocks();
for (auto* residual_block : residual_blocks) {
const int num_parameter_blocks = residual_block->NumParameterBlocks();
ParameterBlock* const* parameter_blocks =
@@ -156,14 +152,14 @@
}
void OrderingToGroupSizes(const ParameterBlockOrdering* ordering,
- vector<int>* group_sizes) {
+ std::vector<int>* group_sizes) {
CHECK(group_sizes != nullptr);
group_sizes->clear();
if (ordering == nullptr) {
return;
}
- const map<int, set<double*>>& group_to_elements =
+ const std::map<int, std::set<double*>>& group_to_elements =
ordering->group_to_elements();
for (const auto& g_t_e : group_to_elements) {
group_sizes->push_back(g_t_e.second.size());
diff --git a/internal/ceres/polynomial.cc b/internal/ceres/polynomial.cc
index a3e790d..0577643 100644
--- a/internal/ceres/polynomial.cc
+++ b/internal/ceres/polynomial.cc
@@ -42,8 +42,6 @@
namespace ceres::internal {
-using std::vector;
-
namespace {
// Balancing function as described by B. N. Parlett and C. Reinsch,
@@ -325,7 +323,7 @@
}
}
-Vector FindInterpolatingPolynomial(const vector<FunctionSample>& samples) {
+Vector FindInterpolatingPolynomial(const std::vector<FunctionSample>& samples) {
const int num_samples = samples.size();
int num_constraints = 0;
for (int i = 0; i < num_samples; ++i) {
@@ -368,7 +366,7 @@
return lu.setThreshold(0.0).solve(rhs);
}
-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 6b6d718..ea701b0 100644
--- a/internal/ceres/polynomial_test.cc
+++ b/internal/ceres/polynomial_test.cc
@@ -42,8 +42,6 @@
namespace ceres::internal {
-using std::vector;
-
namespace {
// For IEEE-754 doubles, machine precision is about 2e-16.
@@ -314,7 +312,7 @@
Vector true_polynomial(1);
true_polynomial << 1.0;
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
FunctionSample sample;
sample.x = 1.0;
sample.value = 1.0;
@@ -330,7 +328,7 @@
Vector true_polynomial(2);
true_polynomial << 2.0, -1.0;
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
FunctionSample sample;
sample.x = 1.0;
sample.value = 1.0;
@@ -348,7 +346,7 @@
Vector true_polynomial(3);
true_polynomial << 2.0, 3.0, 2.0;
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
{
FunctionSample sample;
sample.x = 1.0;
@@ -376,7 +374,7 @@
Vector true_polynomial(4);
true_polynomial << 0.0, 2.0, 3.0, 2.0;
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
{
FunctionSample sample;
sample.x = 1.0;
@@ -406,7 +404,7 @@
Vector true_polynomial(4);
true_polynomial << 1.0, 2.0, 3.0, 2.0;
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
{
FunctionSample sample;
sample.x = 1.0;
@@ -449,7 +447,7 @@
true_polynomial << 1.0, 2.0, 3.0, 2.0;
Vector true_gradient_polynomial = DifferentiatePolynomial(true_polynomial);
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
{
FunctionSample sample;
sample.x = 1.0;
@@ -486,7 +484,7 @@
true_polynomial << 1.0, 2.0, 3.0, 2.0;
Vector true_gradient_polynomial = DifferentiatePolynomial(true_polynomial);
- vector<FunctionSample> samples;
+ std::vector<FunctionSample> samples;
{
FunctionSample sample;
sample.x = -3.0;
diff --git a/internal/ceres/problem.cc b/internal/ceres/problem.cc
index e8589be..ca775fc 100644
--- a/internal/ceres/problem.cc
+++ b/internal/ceres/problem.cc
@@ -39,8 +39,6 @@
namespace ceres {
-using std::vector;
-
Problem::Problem() : impl_(new internal::ProblemImpl) {}
Problem::Problem(const Problem::Options& options)
: impl_(new internal::ProblemImpl(options)) {}
@@ -52,7 +50,7 @@
ResidualBlockId Problem::AddResidualBlock(
CostFunction* cost_function,
LossFunction* loss_function,
- const vector<double*>& parameter_blocks) {
+ const std::vector<double*>& parameter_blocks) {
return impl_->AddResidualBlock(cost_function,
loss_function,
parameter_blocks.data(),
@@ -129,8 +127,8 @@
bool Problem::Evaluate(const EvaluateOptions& evaluate_options,
double* cost,
- vector<double>* residuals,
- vector<double>* gradient,
+ std::vector<double>* residuals,
+ std::vector<double>* gradient,
CRSMatrix* jacobian) {
return impl_->Evaluate(evaluate_options, cost, residuals, gradient, jacobian);
}
@@ -182,18 +180,18 @@
return impl_->HasParameterBlock(values);
}
-void Problem::GetParameterBlocks(vector<double*>* parameter_blocks) const {
+void Problem::GetParameterBlocks(std::vector<double*>* parameter_blocks) const {
impl_->GetParameterBlocks(parameter_blocks);
}
void Problem::GetResidualBlocks(
- vector<ResidualBlockId>* residual_blocks) const {
+ std::vector<ResidualBlockId>* residual_blocks) const {
impl_->GetResidualBlocks(residual_blocks);
}
void Problem::GetParameterBlocksForResidualBlock(
const ResidualBlockId residual_block,
- vector<double*>* parameter_blocks) const {
+ std::vector<double*>* parameter_blocks) const {
impl_->GetParameterBlocksForResidualBlock(residual_block, parameter_blocks);
}
@@ -208,7 +206,7 @@
}
void Problem::GetResidualBlocksForParameterBlock(
- const double* values, vector<ResidualBlockId>* residual_blocks) const {
+ const double* values, std::vector<ResidualBlockId>* residual_blocks) const {
impl_->GetResidualBlocksForParameterBlock(values, residual_blocks);
}
diff --git a/internal/ceres/problem_test.cc b/internal/ceres/problem_test.cc
index eb5a86f..a3f26dd 100644
--- a/internal/ceres/problem_test.cc
+++ b/internal/ceres/problem_test.cc
@@ -52,8 +52,6 @@
namespace ceres::internal {
-using std::vector;
-
// The following three classes are for the purposes of defining
// function signatures. They have dummy Evaluate functions.
@@ -624,14 +622,14 @@
problem.AddParameterBlock(x, 3);
problem.AddParameterBlock(y, 4);
- vector<int> constant_parameters;
+ std::vector<int> constant_parameters;
constant_parameters.push_back(0);
problem.SetManifold(x, new SubsetManifold(3, constant_parameters));
EXPECT_EQ(problem.ParameterBlockSize(x), 3);
EXPECT_EQ(problem.ParameterBlockTangentSize(x), 2);
EXPECT_EQ(problem.ParameterBlockTangentSize(y), 4);
- vector<double*> parameter_blocks;
+ std::vector<double*> parameter_blocks;
problem.GetParameterBlocks(¶meter_blocks);
EXPECT_EQ(parameter_blocks.size(), 2);
EXPECT_NE(parameter_blocks[0], parameter_blocks[1]);
@@ -653,14 +651,14 @@
problem.AddParameterBlock(x, 3);
problem.AddParameterBlock(y, 4);
- vector<int> constant_parameters;
+ std::vector<int> constant_parameters;
constant_parameters.push_back(0);
problem.SetManifold(x, new SubsetManifold(3, constant_parameters));
EXPECT_EQ(problem.ParameterBlockSize(x), 3);
EXPECT_EQ(problem.ParameterBlockTangentSize(x), 2);
EXPECT_EQ(problem.ParameterBlockTangentSize(y), 4);
- vector<double*> parameter_blocks;
+ std::vector<double*> parameter_blocks;
problem.GetParameterBlocks(¶meter_blocks);
EXPECT_EQ(parameter_blocks.size(), 2);
EXPECT_NE(parameter_blocks[0], parameter_blocks[1]);
@@ -978,7 +976,7 @@
// Check that a null-terminated array, a, has the same elements as b.
template <typename T>
-void ExpectVectorContainsUnordered(const T* a, const vector<T>& b) {
+void ExpectVectorContainsUnordered(const T* a, const std::vector<T>& b) {
// Compute the size of a.
int size = 0;
while (a[size]) {
@@ -987,12 +985,12 @@
ASSERT_EQ(size, b.size());
// Sort a.
- vector<T> a_sorted(size);
+ std::vector<T> a_sorted(size);
copy(a, a + size, a_sorted.begin());
sort(a_sorted.begin(), a_sorted.end());
// Sort b.
- vector<T> b_sorted(b);
+ std::vector<T> b_sorted(b);
sort(b_sorted.begin(), b_sorted.end());
// Compare.
@@ -1004,7 +1002,7 @@
static void ExpectProblemHasResidualBlocks(
const ProblemImpl& problem,
const ResidualBlockId* expected_residual_blocks) {
- vector<ResidualBlockId> residual_blocks;
+ std::vector<ResidualBlockId> residual_blocks;
problem.GetResidualBlocks(&residual_blocks);
ExpectVectorContainsUnordered(expected_residual_blocks, residual_blocks);
}
@@ -1065,8 +1063,8 @@
ExpectProblemHasResidualBlocks(*problem, expected_residuals);
}
- vector<double*> parameter_blocks;
- vector<ResidualBlockId> residual_blocks;
+ std::vector<double*> parameter_blocks;
+ std::vector<ResidualBlockId> residual_blocks;
// Check GetResidualBlocksForParameterBlock() for all parameter blocks.
struct GetResidualBlocksForParameterBlockTestCase {
@@ -1208,8 +1206,8 @@
const double* expected_gradient,
const double* expected_jacobian) {
double cost;
- vector<double> residuals;
- vector<double> gradient;
+ std::vector<double> residuals;
+ std::vector<double> gradient;
CRSMatrix jacobian;
EXPECT_TRUE(
@@ -1264,8 +1262,8 @@
ProblemImpl problem_;
double parameters_[6];
- vector<double*> parameter_blocks_;
- vector<ResidualBlockId> residual_blocks_;
+ std::vector<double*> parameter_blocks_;
+ std::vector<ResidualBlockId> residual_blocks_;
};
TEST_F(ProblemEvaluateTest, MultipleParameterAndResidualBlocks) {
@@ -1591,7 +1589,7 @@
};
// clang-format on
- vector<int> constant_parameters;
+ std::vector<int> constant_parameters;
constant_parameters.push_back(0);
problem_.SetManifold(parameters_ + 2,
new SubsetManifold(2, constant_parameters));
diff --git a/internal/ceres/program_test.cc b/internal/ceres/program_test.cc
index 300a3a5..115d905 100644
--- a/internal/ceres/program_test.cc
+++ b/internal/ceres/program_test.cc
@@ -46,9 +46,6 @@
namespace ceres {
namespace internal {
-using std::string;
-using std::vector;
-
// A cost function that simply returns its argument.
class UnaryIdentityCostFunction : public SizedCostFunction<1, 1> {
public:
@@ -96,9 +93,9 @@
problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &x, &y);
problem.AddResidualBlock(new TernaryCostFunction(), nullptr, &x, &y, &z);
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -117,9 +114,9 @@
problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &x);
problem.SetParameterBlockConstant(&x);
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -141,9 +138,9 @@
problem.AddParameterBlock(&y, 1);
problem.AddParameterBlock(&z, 1);
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -167,9 +164,9 @@
problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &x, &y);
problem.SetParameterBlockConstant(&x);
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -191,9 +188,9 @@
problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &x, &y);
problem.SetParameterBlockConstant(&x);
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -223,9 +220,9 @@
expected_removed_block->Evaluate(
true, &expected_fixed_cost, nullptr, nullptr, scratch.get());
- vector<double*> removed_parameter_blocks;
+ std::vector<double*> removed_parameter_blocks;
double fixed_cost = 0.0;
- string message;
+ std::string message;
std::unique_ptr<Program> reduced_program(
problem.program().CreateReducedProgram(
&removed_parameter_blocks, &fixed_cost, &message));
@@ -347,7 +344,7 @@
ProblemImpl problem;
double x[20];
- vector<double*> parameter_blocks;
+ std::vector<double*> parameter_blocks;
for (int i = 0; i < 20; ++i) {
problem.AddParameterBlock(x + i, 1);
parameter_blocks.push_back(x + i);
@@ -392,9 +389,9 @@
x[0] = 1.0;
x[1] = std::numeric_limits<double>::quiet_NaN();
problem.AddResidualBlock(new MockCostFunctionBase<1, 2>(), nullptr, x);
- string error;
+ std::string error;
EXPECT_FALSE(problem.program().ParameterBlocksAreFinite(&error));
- EXPECT_NE(error.find("has at least one invalid value"), string::npos)
+ EXPECT_NE(error.find("has at least one invalid value"), std::string::npos)
<< error;
}
@@ -404,9 +401,9 @@
problem.AddResidualBlock(new MockCostFunctionBase<1, 2>(), nullptr, x);
problem.SetParameterLowerBound(x, 0, 2.0);
problem.SetParameterUpperBound(x, 0, 1.0);
- string error;
+ std::string error;
EXPECT_FALSE(problem.program().IsFeasible(&error));
- EXPECT_NE(error.find("infeasible bound"), string::npos) << error;
+ EXPECT_NE(error.find("infeasible bound"), std::string::npos) << error;
}
TEST(Program, InfeasibleConstantParameterBlock) {
@@ -416,9 +413,9 @@
problem.SetParameterLowerBound(x, 0, 1.0);
problem.SetParameterUpperBound(x, 0, 2.0);
problem.SetParameterBlockConstant(x);
- string error;
+ std::string error;
EXPECT_FALSE(problem.program().IsFeasible(&error));
- EXPECT_NE(error.find("infeasible value"), string::npos) << error;
+ EXPECT_NE(error.find("infeasible value"), std::string::npos) << error;
}
} // namespace internal
diff --git a/internal/ceres/reorder_program.cc b/internal/ceres/reorder_program.cc
index 912fe3d..6c5318b 100644
--- a/internal/ceres/reorder_program.cc
+++ b/internal/ceres/reorder_program.cc
@@ -64,11 +64,6 @@
namespace ceres::internal {
-using std::map;
-using std::set;
-using std::string;
-using std::vector;
-
namespace {
// Find the minimum index of any parameter block to the given
@@ -99,7 +94,7 @@
const int* rows = block_jacobian_transpose.rows();
const int* cols = block_jacobian_transpose.cols();
int num_nonzeros = block_jacobian_transpose.num_nonzeros();
- vector<Triplet> triplets;
+ std::vector<Triplet> triplets;
triplets.reserve(num_nonzeros);
for (int i = 0; i < num_nonzeros; ++i) {
triplets.emplace_back(cols[i], rows[i], 1);
@@ -114,7 +109,7 @@
void OrderingForSparseNormalCholeskyUsingSuiteSparse(
const LinearSolverOrderingType linear_solver_ordering_type,
const TripletSparseMatrix& tsm_block_jacobian_transpose,
- const vector<ParameterBlock*>& parameter_blocks,
+ const std::vector<ParameterBlock*>& parameter_blocks,
const ParameterBlockOrdering& parameter_block_ordering,
int* ordering) {
#ifdef CERES_NO_SUITESPARSE
@@ -132,7 +127,7 @@
ss.Ordering(block_jacobian_transpose, OrderingType::AMD, ordering);
} else {
// The user supplied an ordering, so use CAMD.
- vector<int> constraints;
+ std::vector<int> constraints;
constraints.reserve(parameter_blocks.size());
for (auto* parameter_block : parameter_blocks) {
constraints.push_back(parameter_block_ordering.GroupId(
@@ -210,7 +205,7 @@
bool ApplyOrdering(const ProblemImpl::ParameterMap& parameter_map,
const ParameterBlockOrdering& ordering,
Program* program,
- string* error) {
+ std::string* error) {
const int num_parameter_blocks = program->NumParameterBlocks();
if (ordering.NumElements() != num_parameter_blocks) {
*error = StringPrintf(
@@ -222,13 +217,13 @@
return false;
}
- vector<ParameterBlock*>* parameter_blocks =
+ std::vector<ParameterBlock*>* parameter_blocks =
program->mutable_parameter_blocks();
parameter_blocks->clear();
- const map<int, set<double*>>& groups = ordering.group_to_elements();
+ const std::map<int, std::set<double*>>& groups = ordering.group_to_elements();
for (const auto& p : groups) {
- const set<double*>& group = p.second;
+ const std::set<double*>& group = p.second;
for (double* parameter_block_ptr : group) {
auto it = parameter_map.find(parameter_block_ptr);
if (it == parameter_map.end()) {
@@ -248,16 +243,16 @@
bool LexicographicallyOrderResidualBlocks(
const int size_of_first_elimination_group,
Program* program,
- string* error) {
+ std::string* error) {
CHECK_GE(size_of_first_elimination_group, 1)
<< "Congratulations, you found a Ceres bug! Please report this error "
<< "to the developers.";
// 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> min_position_per_residual(residual_blocks->size());
+ std::vector<int> residual_blocks_per_e_block(size_of_first_elimination_group + 1);
+ std::vector<ResidualBlock*>* residual_blocks = program->mutable_residual_blocks();
+ std::vector<int> min_position_per_residual(residual_blocks->size());
for (int i = 0; i < residual_blocks->size(); ++i) {
ResidualBlock* residual_block = (*residual_blocks)[i];
int position =
@@ -270,7 +265,7 @@
// Run a cumulative sum on the histogram, to obtain offsets to the start of
// each histogram bucket (where each bucket is for the residuals for that
// E-block).
- vector<int> offsets(size_of_first_elimination_group + 1);
+ std::vector<int> offsets(size_of_first_elimination_group + 1);
std::partial_sum(residual_blocks_per_e_block.begin(),
residual_blocks_per_e_block.end(),
offsets.begin());
@@ -291,7 +286,7 @@
// from each offset as a residual block is placed in the bucket. When the
// filling is finished, the offset pointers should have shifted down one
// entry (this is verified below).
- vector<ResidualBlock*> reordered_residual_blocks(
+ std::vector<ResidualBlock*> reordered_residual_blocks(
(*residual_blocks).size(), static_cast<ResidualBlock*>(nullptr));
for (int i = 0; i < residual_blocks->size(); ++i) {
int bucket = min_position_per_residual[i];
@@ -332,8 +327,8 @@
const ParameterBlockOrdering& parameter_block_ordering, Program* program) {
#ifndef CERES_NO_SUITESPARSE
SuiteSparse ss;
- vector<int> constraints;
- vector<ParameterBlock*>& parameter_blocks =
+ std::vector<int> constraints;
+ std::vector<ParameterBlock*>& parameter_blocks =
*(program->mutable_parameter_blocks());
for (auto* parameter_block : parameter_blocks) {
@@ -353,12 +348,12 @@
cholmod_sparse* block_jacobian_transpose =
ss.CreateSparseMatrix(tsm_block_jacobian_transpose.get());
- vector<int> ordering(parameter_blocks.size(), 0);
+ std::vector<int> ordering(parameter_blocks.size(), 0);
ss.ConstrainedApproximateMinimumDegreeOrdering(
block_jacobian_transpose, constraints.data(), ordering.data());
ss.Free(block_jacobian_transpose);
- const vector<ParameterBlock*> parameter_blocks_copy(parameter_blocks);
+ const std::vector<ParameterBlock*> parameter_blocks_copy(parameter_blocks);
for (int i = 0; i < program->NumParameterBlocks(); ++i) {
parameter_blocks[i] = parameter_blocks_copy[ordering[i]];
}
@@ -408,8 +403,8 @@
#endif
}
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
- vector<ParameterBlock*> ordering(num_cols);
+ const std::vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ std::vector<ParameterBlock*> ordering(num_cols);
// The ordering of the first size_of_first_elimination_group does
// not matter, so we preserve the existing ordering.
@@ -435,7 +430,7 @@
const ProblemImpl::ParameterMap& parameter_map,
ParameterBlockOrdering* parameter_block_ordering,
Program* program,
- string* error) {
+ std::string* error) {
if (parameter_block_ordering->NumElements() !=
program->NumParameterBlocks()) {
*error = StringPrintf(
@@ -453,7 +448,7 @@
// parameter block ordering as it sees fit. For Schur type solvers,
// this means that the user wishes for Ceres to identify the
// e_blocks, which we do by computing a maximal independent set.
- vector<ParameterBlock*> schur_ordering;
+ std::vector<ParameterBlock*> schur_ordering;
const int size_of_first_elimination_group =
ComputeStableSchurOrdering(*program, &schur_ordering);
@@ -476,7 +471,7 @@
// group.
// Verify that the first elimination group is an independent set.
- const set<double*>& first_elimination_group =
+ const std::set<double*>& first_elimination_group =
parameter_block_ordering->group_to_elements().begin()->second;
if (!program->IsParameterBlockSetIndependent(first_elimination_group)) {
*error = StringPrintf(
@@ -527,7 +522,7 @@
const ParameterBlockOrdering& parameter_block_ordering,
int start_row_block,
Program* program,
- string* error) {
+ std::string* error) {
if (parameter_block_ordering.NumElements() != program->NumParameterBlocks()) {
*error = StringPrintf(
"The program has %d parameter blocks, but the parameter block "
@@ -541,8 +536,8 @@
std::unique_ptr<TripletSparseMatrix> tsm_block_jacobian_transpose(
program->CreateJacobianBlockSparsityTranspose(start_row_block));
- vector<int> ordering(program->NumParameterBlocks(), 0);
- vector<ParameterBlock*>& parameter_blocks =
+ std::vector<int> ordering(program->NumParameterBlocks(), 0);
+ std::vector<ParameterBlock*>& parameter_blocks =
*(program->mutable_parameter_blocks());
if (sparse_linear_algebra_library_type == SUITE_SPARSE) {
@@ -569,7 +564,7 @@
}
// Apply ordering.
- const vector<ParameterBlock*> parameter_blocks_copy(parameter_blocks);
+ const std::vector<ParameterBlock*> parameter_blocks_copy(parameter_blocks);
for (int i = 0; i < program->NumParameterBlocks(); ++i) {
parameter_blocks[i] = parameter_blocks_copy[ordering[i]];
}
diff --git a/internal/ceres/reorder_program_test.cc b/internal/ceres/reorder_program_test.cc
index d6a6577..3510171 100644
--- a/internal/ceres/reorder_program_test.cc
+++ b/internal/ceres/reorder_program_test.cc
@@ -44,8 +44,6 @@
namespace ceres {
namespace internal {
-using std::vector;
-
// Templated base class for the CostFunction signatures.
template <int kNumResiduals, int... Ns>
class MockCostFunctionBase : public SizedCostFunction<kNumResiduals, Ns...> {
@@ -88,10 +86,10 @@
options.linear_solver_type = DENSE_SCHUR;
options.linear_solver_ordering = linear_solver_ordering;
- const vector<ResidualBlock*>& residual_blocks =
+ const std::vector<ResidualBlock*>& residual_blocks =
problem.program().residual_blocks();
- vector<ResidualBlock*> expected_residual_blocks;
+ std::vector<ResidualBlock*> expected_residual_blocks;
// This is a bit fragile, but it serves the purpose. We know the
// bucketing algorithm that the reordering function uses, so we
@@ -156,7 +154,7 @@
EXPECT_TRUE(ApplyOrdering(
problem.parameter_map(), linear_solver_ordering, program, &message));
- const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
EXPECT_EQ(parameter_blocks.size(), 3);
EXPECT_EQ(parameter_blocks[0]->user_state(), &x);
@@ -180,7 +178,7 @@
void ComputeAndValidateOrdering(
const ParameterBlockOrdering& linear_solver_ordering) {
Program* program = problem_.mutable_program();
- vector<ParameterBlock*> unordered_parameter_blocks =
+ std::vector<ParameterBlock*> unordered_parameter_blocks =
program->parameter_blocks();
std::string error;
@@ -190,7 +188,7 @@
0, /* use all rows */
program,
&error));
- const vector<ParameterBlock*>& ordered_parameter_blocks =
+ const std::vector<ParameterBlock*>& ordered_parameter_blocks =
program->parameter_blocks();
EXPECT_EQ(ordered_parameter_blocks.size(),
unordered_parameter_blocks.size());
diff --git a/internal/ceres/residual_block_test.cc b/internal/ceres/residual_block_test.cc
index 8f99b23..0a84248 100644
--- a/internal/ceres/residual_block_test.cc
+++ b/internal/ceres/residual_block_test.cc
@@ -40,8 +40,6 @@
namespace ceres::internal {
-using std::vector;
-
// Trivial cost function that accepts three arguments.
class TernaryCostFunction : public CostFunction {
public:
@@ -87,7 +85,7 @@
double values_z[4];
ParameterBlock z(values_z, 4, -1);
- vector<ParameterBlock*> parameters;
+ std::vector<ParameterBlock*> parameters;
parameters.push_back(&x);
parameters.push_back(&y);
parameters.push_back(&z);
@@ -212,19 +210,19 @@
double values_z[4];
ParameterBlock z(values_z, 4, -1);
- vector<ParameterBlock*> parameters;
+ std::vector<ParameterBlock*> parameters;
parameters.push_back(&x);
parameters.push_back(&y);
parameters.push_back(&z);
// Make x have the first component fixed.
- vector<int> x_fixed;
+ std::vector<int> x_fixed;
x_fixed.push_back(0);
SubsetManifold x_manifold(2, x_fixed);
x.SetManifold(&x_manifold);
// Make z have the last and last component fixed.
- vector<int> z_fixed;
+ std::vector<int> z_fixed;
z_fixed.push_back(2);
SubsetManifold z_manifold(4, z_fixed);
z.SetManifold(&z_manifold);
diff --git a/internal/ceres/residual_block_utils.cc b/internal/ceres/residual_block_utils.cc
index 7dc5d44..74eaf58 100644
--- a/internal/ceres/residual_block_utils.cc
+++ b/internal/ceres/residual_block_utils.cc
@@ -44,8 +44,6 @@
namespace ceres::internal {
-using std::string;
-
void InvalidateEvaluation(const ResidualBlock& block,
double* cost,
double* residuals,
@@ -63,7 +61,7 @@
}
}
-string EvaluationToString(const ResidualBlock& block,
+std::string EvaluationToString(const ResidualBlock& block,
double const* const* parameters,
double* cost,
double* residuals,
@@ -73,7 +71,7 @@
const int num_parameter_blocks = block.NumParameterBlocks();
const int num_residuals = block.NumResiduals();
- string result = "";
+ std::string result = "";
// clang-format off
StringAppendF(&result,
@@ -88,7 +86,7 @@
"to Inf or NaN is also an error. \n\n"; // NOLINT
// clang-format on
- string space = "Residuals: ";
+ std::string space = "Residuals: ";
result += space;
AppendArrayToString(num_residuals, residuals, &result);
StringAppendF(&result, "\n\n");
diff --git a/internal/ceres/rotation_test.cc b/internal/ceres/rotation_test.cc
index 577f8ed..b59c487 100644
--- a/internal/ceres/rotation_test.cc
+++ b/internal/ceres/rotation_test.cc
@@ -50,17 +50,11 @@
namespace ceres {
namespace internal {
-using std::max;
-using std::min;
-using std::numeric_limits;
-using std::string;
-using std::swap;
-
inline constexpr double kPi = constants::pi_v<double>;
const double kHalfSqrt2 = 0.707106781186547524401;
// 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;
@@ -136,12 +130,12 @@
Eigen::Vector3d e(expected[0], expected[1], expected[2]);
const double e_norm = e.norm();
- double delta_norm = numeric_limits<double>::max();
+ double delta_norm = std::numeric_limits<double>::max();
if (e_norm > 0) {
// Deal with the sign ambiguity near PI. Since the sign can flip,
// we take the smaller of the two differences.
if (fabs(e_norm - kPi) < kLooseTolerance) {
- delta_norm = min((a - e).norm(), (a + e).norm()) / e_norm;
+ delta_norm = std::min((a - e).norm(), (a + e).norm()) / e_norm;
} else {
delta_norm = (a - e).norm() / e_norm;
}
@@ -229,7 +223,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};
@@ -290,7 +284,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};
@@ -496,7 +490,7 @@
LOG(INFO) << "Rotation:";
LOG(INFO) << "EXPECTED | ACTUAL";
for (int i = 0; i < 3; ++i) {
- string line;
+ std::string line;
for (int j = 0; j < 3; ++j) {
StringAppendF(&line, "%g ", kMatrix[i][j]);
}
@@ -600,16 +594,16 @@
for (int i = 0; i < 3; ++i) {
EXPECT_NEAR(
- round_trip[i], axis_angle[i], numeric_limits<double>::epsilon());
+ round_trip[i], axis_angle[i], std::numeric_limits<double>::epsilon());
}
}
}
// Transposes a 3x3 matrix.
static void Transpose3x3(double m[9]) {
- swap(m[1], m[3]);
- swap(m[2], m[6]);
- swap(m[5], m[7]);
+ std::swap(m[1], m[3]);
+ std::swap(m[2], m[6]);
+ std::swap(m[5], m[7]);
}
// Convert Euler angles from radians to degrees.
@@ -976,11 +970,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/solver.cc b/internal/ceres/solver.cc
index 12dfc59..5ba477e 100644
--- a/internal/ceres/solver.cc
+++ b/internal/ceres/solver.cc
@@ -61,17 +61,14 @@
using internal::StringAppendF;
using internal::StringPrintf;
-using std::map;
-using std::string;
-using std::vector;
#define OPTION_OP(x, y, OP) \
if (!(options.x OP y)) { \
std::stringstream ss; \
ss << "Invalid configuration. "; \
- ss << string("Solver::Options::" #x " = ") << options.x << ". "; \
+ ss << std::string("Solver::Options::" #x " = ") << options.x << ". "; \
ss << "Violated constraint: "; \
- ss << string("Solver::Options::" #x " " #OP " " #y); \
+ ss << std::string("Solver::Options::" #x " " #OP " " #y); \
*error = ss.str(); \
return false; \
}
@@ -80,11 +77,11 @@
if (!(options.x OP options.y)) { \
std::stringstream ss; \
ss << "Invalid configuration. "; \
- ss << string("Solver::Options::" #x " = ") << options.x << ". "; \
- ss << string("Solver::Options::" #y " = ") << options.y << ". "; \
+ ss << std::string("Solver::Options::" #x " = ") << options.x << ". "; \
+ ss << std::string("Solver::Options::" #y " = ") << options.y << ". "; \
ss << "Violated constraint: "; \
- ss << string("Solver::Options::" #x); \
- ss << string(#OP " Solver::Options::" #y "."); \
+ ss << std::string("Solver::Options::" #x); \
+ ss << std::string(#OP " Solver::Options::" #y "."); \
*error = ss.str(); \
return false; \
}
@@ -96,7 +93,7 @@
#define OPTION_LE_OPTION(x, y) OPTION_OP_OPTION(x, y, <=)
#define OPTION_LT_OPTION(x, y) OPTION_OP_OPTION(x, y, <)
-bool CommonOptionsAreValid(const Solver::Options& options, string* error) {
+bool CommonOptionsAreValid(const Solver::Options& options, std::string* error) {
OPTION_GE(max_num_iterations, 0);
OPTION_GE(max_solver_time_in_seconds, 0.0);
OPTION_GE(function_tolerance, 0.0);
@@ -123,7 +120,7 @@
}
bool OptionsAreValidForDenseSolver(const Solver::Options& options,
- string* error) {
+ std::string* error) {
const char* library_name = DenseLinearAlgebraLibraryTypeToString(
options.dense_linear_algebra_library_type);
const char* solver_name =
@@ -141,7 +138,7 @@
}
bool OptionsAreValidForSparseCholeskyBasedSolver(const Solver::Options& options,
- string* error) {
+ std::string* error) {
const char* library_name = SparseLinearAlgebraLibraryTypeToString(
options.sparse_linear_algebra_library_type);
// Sparse factorization based solvers and some preconditioners require a
@@ -199,12 +196,12 @@
}
bool OptionsAreValidForDenseNormalCholesky(const Solver::Options& options,
- string* error) {
+ std::string* error) {
CHECK_EQ(options.linear_solver_type, DENSE_NORMAL_CHOLESKY);
return OptionsAreValidForDenseSolver(options, error);
}
-bool OptionsAreValidForDenseQr(const Solver::Options& options, string* error) {
+bool OptionsAreValidForDenseQr(const Solver::Options& options, std::string* error) {
CHECK_EQ(options.linear_solver_type, DENSE_QR);
if (!OptionsAreValidForDenseSolver(options, error)) {
@@ -220,13 +217,13 @@
}
bool OptionsAreValidForSparseNormalCholesky(const Solver::Options& options,
- string* error) {
+ std::string* error) {
CHECK_EQ(options.linear_solver_type, SPARSE_NORMAL_CHOLESKY);
return OptionsAreValidForSparseCholeskyBasedSolver(options, error);
}
bool OptionsAreValidForDenseSchur(const Solver::Options& options,
- string* error) {
+ std::string* error) {
CHECK_EQ(options.linear_solver_type, DENSE_SCHUR);
if (options.dynamic_sparsity) {
@@ -242,7 +239,7 @@
}
bool OptionsAreValidForSparseSchur(const Solver::Options& options,
- string* error) {
+ std::string* error) {
CHECK_EQ(options.linear_solver_type, SPARSE_SCHUR);
if (options.dynamic_sparsity) {
*error = "Dynamic sparsity is only supported with SPARSE_NORMAL_CHOLESKY.";
@@ -252,7 +249,7 @@
}
bool OptionsAreValidForIterativeSchur(const Solver::Options& options,
- string* error) {
+ std::string* error) {
CHECK_EQ(options.linear_solver_type, ITERATIVE_SCHUR);
if (options.dynamic_sparsity) {
*error = "Dynamic sparsity is only supported with SPARSE_NORMAL_CHOLESKY.";
@@ -305,7 +302,7 @@
return true;
}
-bool OptionsAreValidForCgnr(const Solver::Options& options, string* error) {
+bool OptionsAreValidForCgnr(const Solver::Options& options, std::string* error) {
CHECK_EQ(options.linear_solver_type, CGNR);
if (options.preconditioner_type != IDENTITY &&
@@ -361,7 +358,7 @@
}
bool OptionsAreValidForLinearSolver(const Solver::Options& options,
- string* error) {
+ std::string* error) {
switch (options.linear_solver_type) {
case DENSE_NORMAL_CHOLESKY:
return OptionsAreValidForDenseNormalCholesky(options, error);
@@ -386,7 +383,7 @@
return false;
}
-bool TrustRegionOptionsAreValid(const Solver::Options& options, string* error) {
+bool TrustRegionOptionsAreValid(const Solver::Options& options, std::string* error) {
OPTION_GT(initial_trust_region_radius, 0.0);
OPTION_GT(min_trust_region_radius, 0.0);
OPTION_GT(max_trust_region_radius, 0.0);
@@ -434,7 +431,7 @@
return true;
}
-bool LineSearchOptionsAreValid(const Solver::Options& options, string* error) {
+bool LineSearchOptionsAreValid(const Solver::Options& options, std::string* error) {
OPTION_GT(max_lbfgs_rank, 0);
OPTION_GT(min_line_search_step_size, 0.0);
OPTION_GT(max_line_search_step_contraction, 0.0);
@@ -454,9 +451,9 @@
options.line_search_direction_type == ceres::LBFGS) &&
options.line_search_type != ceres::WOLFE) {
*error =
- string("Invalid configuration: Solver::Options::line_search_type = ") +
- string(LineSearchTypeToString(options.line_search_type)) +
- string(
+ std::string("Invalid configuration: Solver::Options::line_search_type = ") +
+ std::string(LineSearchTypeToString(options.line_search_type)) +
+ std::string(
". When using (L)BFGS, "
"Solver::Options::line_search_type must be set to WOLFE.");
return false;
@@ -490,7 +487,7 @@
#undef OPTION_LE_OPTION
#undef OPTION_LT_OPTION
-void StringifyOrdering(const vector<int>& ordering, string* report) {
+void StringifyOrdering(const std::vector<int>& ordering, std::string* report) {
if (ordering.empty()) {
internal::StringAppendF(report, "AUTOMATIC");
return;
@@ -590,7 +587,7 @@
// not contain any parameter blocks. Thus, only extract the
// evaluator statistics if one exists.
if (pp.evaluator != nullptr) {
- const map<string, CallStatistics>& evaluator_statistics =
+ const std::map<std::string, CallStatistics>& evaluator_statistics =
pp.evaluator->Statistics();
{
const CallStatistics& call_stats = FindWithDefault(
@@ -612,7 +609,7 @@
// solver from which we can extract run time statistics. In
// particular the line search solver does not use a linear solver.
if (pp.linear_solver != nullptr) {
- const map<string, CallStatistics>& linear_solver_statistics =
+ const std::map<std::string, CallStatistics>& linear_solver_statistics =
pp.linear_solver->Statistics();
const CallStatistics& call_stats = FindWithDefault(
linear_solver_statistics, "LinearSolver::Solve", CallStatistics());
@@ -684,7 +681,7 @@
} // namespace
-bool Solver::Options::IsValid(string* error) const {
+bool Solver::Options::IsValid(std::string* error) const {
if (!CommonOptionsAreValid(*this, error)) {
return false;
}
@@ -833,7 +830,7 @@
solver.Solve(options, problem, summary);
}
-string Solver::Summary::BriefReport() const {
+std::string Solver::Summary::BriefReport() const {
return StringPrintf(
"Ceres Solver Report: "
"Iterations: %d, "
@@ -846,12 +843,12 @@
TerminationTypeToString(termination_type));
}
-string Solver::Summary::FullReport() const {
+std::string Solver::Summary::FullReport() const {
using internal::VersionString;
// NOTE operator+ is not usable for concatenating a string and a string_view.
- string report =
- string{"\nSolver Summary (v "}.append(VersionString()) + ")\n\n";
+ std::string report =
+ std::string{"\nSolver Summary (v "}.append(VersionString()) + ")\n\n";
StringAppendF(&report, "%45s %21s\n", "Original", "Reduced");
StringAppendF(&report,
@@ -967,9 +964,9 @@
num_threads_given,
num_threads_used);
- string given;
+ std::string given;
StringifyOrdering(linear_solver_ordering_given, &given);
- string used;
+ std::string used;
StringifyOrdering(linear_solver_ordering_used, &used);
StringAppendF(&report,
"Linear solver ordering %22s %24s\n",
@@ -990,9 +987,9 @@
}
if (inner_iterations_used) {
- string given;
+ std::string given;
StringifyOrdering(inner_iteration_ordering_given, &given);
- string used;
+ std::string used;
StringifyOrdering(inner_iteration_ordering_used, &used);
StringAppendF(&report,
"Inner iteration ordering %20s %24s\n",
@@ -1003,7 +1000,7 @@
// LINE_SEARCH HEADER
StringAppendF(&report, "\nMinimizer %19s\n", "LINE_SEARCH");
- string line_search_direction_string;
+ std::string line_search_direction_string;
if (line_search_direction_type == LBFGS) {
line_search_direction_string = StringPrintf("LBFGS (%d)", max_lbfgs_rank);
} else if (line_search_direction_type == NONLINEAR_CONJUGATE_GRADIENT) {
@@ -1018,7 +1015,7 @@
"Line search direction %19s\n",
line_search_direction_string.c_str());
- const string line_search_type_string = StringPrintf(
+ const std::string line_search_type_string = StringPrintf(
"%s %s",
LineSearchInterpolationTypeToString(line_search_interpolation_type),
LineSearchTypeToString(line_search_type));
diff --git a/internal/ceres/solver_test.cc b/internal/ceres/solver_test.cc
index 929e293..a8df340 100644
--- a/internal/ceres/solver_test.cc
+++ b/internal/ceres/solver_test.cc
@@ -46,19 +46,17 @@
namespace ceres::internal {
-using std::string;
-
TEST(SolverOptions, DefaultTrustRegionOptionsAreValid) {
Solver::Options options;
options.minimizer_type = TRUST_REGION;
- string error;
+ std::string error;
EXPECT_TRUE(options.IsValid(&error)) << error;
}
TEST(SolverOptions, DefaultLineSearchOptionsAreValid) {
Solver::Options options;
options.minimizer_type = LINE_SEARCH;
- string error;
+ std::string error;
EXPECT_TRUE(options.IsValid(&error)) << error;
}
diff --git a/internal/ceres/stringprintf.cc b/internal/ceres/stringprintf.cc
index 1b6b6ff..1bf4fc2 100644
--- a/internal/ceres/stringprintf.cc
+++ b/internal/ceres/stringprintf.cc
@@ -40,9 +40,7 @@
namespace ceres::internal {
-using std::string;
-
-void StringAppendV(string* dst, const char* format, va_list ap) {
+void StringAppendV(std::string* dst, const char* format, va_list ap) {
// First try with a small fixed size buffer
char space[1024];
@@ -92,16 +90,16 @@
delete[] buf;
}
-string StringPrintf(const char* format, ...) {
+std::string StringPrintf(const char* format, ...) {
va_list ap;
va_start(ap, format);
- string result;
+ std::string result;
StringAppendV(&result, format, ap);
va_end(ap);
return result;
}
-const string& SStringPrintf(string* dst, const char* format, ...) {
+const std::string& SStringPrintf(std::string* dst, const char* format, ...) {
va_list ap;
va_start(ap, format);
dst->clear();
@@ -110,7 +108,7 @@
return *dst;
}
-void StringAppendF(string* dst, const char* format, ...) {
+void StringAppendF(std::string* dst, const char* format, ...) {
va_list ap;
va_start(ap, format);
StringAppendV(dst, format, ap);
diff --git a/internal/ceres/trust_region_preprocessor.cc b/internal/ceres/trust_region_preprocessor.cc
index 67f928e..31ff288 100644
--- a/internal/ceres/trust_region_preprocessor.cc
+++ b/internal/ceres/trust_region_preprocessor.cc
@@ -50,15 +50,13 @@
namespace ceres::internal {
-using std::vector;
-
namespace {
std::shared_ptr<ParameterBlockOrdering> CreateDefaultLinearSolverOrdering(
const Program& program) {
std::shared_ptr<ParameterBlockOrdering> ordering =
std::make_shared<ParameterBlockOrdering>();
- const vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
+ const std::vector<ParameterBlock*>& parameter_blocks = program.parameter_blocks();
for (auto* parameter_block : parameter_blocks) {
ordering->AddElementToGroup(
const_cast<double*>(parameter_block->user_state()), 0);
diff --git a/internal/ceres/types.cc b/internal/ceres/types.cc
index 3de91ed..be61476 100644
--- a/internal/ceres/types.cc
+++ b/internal/ceres/types.cc
@@ -39,14 +39,12 @@
namespace ceres {
-using std::string;
-
// clang-format off
#define CASESTR(x) case x: return #x
#define STRENUM(x) if (value == #x) { *type = x; return true; }
// clang-format on
-static void UpperCase(string* input) {
+static void UpperCase(std::string* input) {
std::transform(input->begin(), input->end(), input->begin(), ::toupper);
}
@@ -64,7 +62,7 @@
}
}
-bool StringToLinearSolverType(string value, LinearSolverType* type) {
+bool StringToLinearSolverType(std::string value, LinearSolverType* type) {
UpperCase(&value);
STRENUM(DENSE_NORMAL_CHOLESKY);
STRENUM(DENSE_QR);
@@ -90,7 +88,7 @@
}
}
-bool StringToPreconditionerType(string value, PreconditionerType* type) {
+bool StringToPreconditionerType(std::string value, PreconditionerType* type) {
UpperCase(&value);
STRENUM(IDENTITY);
STRENUM(JACOBI);
@@ -116,7 +114,7 @@
}
bool StringToSparseLinearAlgebraLibraryType(
- string value, SparseLinearAlgebraLibraryType* type) {
+ std::string value, SparseLinearAlgebraLibraryType* type) {
UpperCase(&value);
STRENUM(SUITE_SPARSE);
STRENUM(EIGEN_SPARSE);
@@ -135,7 +133,7 @@
}
}
-bool StringToLinearSolverOrderingType(string value,
+bool StringToLinearSolverOrderingType(std::string value,
LinearSolverOrderingType* type) {
UpperCase(&value);
STRENUM(AMD);
@@ -155,7 +153,7 @@
}
bool StringToDenseLinearAlgebraLibraryType(
- string value, DenseLinearAlgebraLibraryType* type) {
+ std::string value, DenseLinearAlgebraLibraryType* type) {
UpperCase(&value);
STRENUM(EIGEN);
STRENUM(LAPACK);
@@ -172,7 +170,7 @@
}
}
-bool StringToTrustRegionStrategyType(string value,
+bool StringToTrustRegionStrategyType(std::string value,
TrustRegionStrategyType* type) {
UpperCase(&value);
STRENUM(LEVENBERG_MARQUARDT);
@@ -189,7 +187,7 @@
}
}
-bool StringToDoglegType(string value, DoglegType* type) {
+bool StringToDoglegType(std::string value, DoglegType* type) {
UpperCase(&value);
STRENUM(TRADITIONAL_DOGLEG);
STRENUM(SUBSPACE_DOGLEG);
@@ -205,7 +203,7 @@
}
}
-bool StringToMinimizerType(string value, MinimizerType* type) {
+bool StringToMinimizerType(std::string value, MinimizerType* type) {
UpperCase(&value);
STRENUM(TRUST_REGION);
STRENUM(LINE_SEARCH);
@@ -223,7 +221,7 @@
}
}
-bool StringToLineSearchDirectionType(string value,
+bool StringToLineSearchDirectionType(std::string value,
LineSearchDirectionType* type) {
UpperCase(&value);
STRENUM(STEEPEST_DESCENT);
@@ -242,7 +240,7 @@
}
}
-bool StringToLineSearchType(string value, LineSearchType* type) {
+bool StringToLineSearchType(std::string value, LineSearchType* type) {
UpperCase(&value);
STRENUM(ARMIJO);
STRENUM(WOLFE);
@@ -260,7 +258,7 @@
}
}
-bool StringToLineSearchInterpolationType(string value,
+bool StringToLineSearchInterpolationType(std::string value,
LineSearchInterpolationType* type) {
UpperCase(&value);
STRENUM(BISECTION);
@@ -281,7 +279,7 @@
}
bool StringToNonlinearConjugateGradientType(
- string value, NonlinearConjugateGradientType* type) {
+ std::string value, NonlinearConjugateGradientType* type) {
UpperCase(&value);
STRENUM(FLETCHER_REEVES);
STRENUM(POLAK_RIBIERE);
@@ -298,7 +296,7 @@
}
}
-bool StringToCovarianceAlgorithmType(string value,
+bool StringToCovarianceAlgorithmType(std::string value,
CovarianceAlgorithmType* type) {
UpperCase(&value);
STRENUM(DENSE_SVD);
@@ -316,7 +314,7 @@
}
}
-bool StringToNumericDiffMethodType(string value, NumericDiffMethodType* type) {
+bool StringToNumericDiffMethodType(std::string value, NumericDiffMethodType* type) {
UpperCase(&value);
STRENUM(CENTRAL);
STRENUM(FORWARD);
@@ -333,7 +331,7 @@
}
}
-bool StringToVisibilityClusteringType(string value,
+bool StringToVisibilityClusteringType(std::string value,
VisibilityClusteringType* type) {
UpperCase(&value);
STRENUM(CANONICAL_VIEWS);
diff --git a/internal/ceres/visibility.cc b/internal/ceres/visibility.cc
index 2dcfbe7..92d1e30 100644
--- a/internal/ceres/visibility.cc
+++ b/internal/ceres/visibility.cc
@@ -46,15 +46,9 @@
namespace ceres::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) {
+ std::vector<std::set<int>>* visibility) {
CHECK(visibility != nullptr);
// Clear the visibility vector and resize it to hold a
@@ -63,7 +57,7 @@
visibility->resize(block_structure.cols.size() - num_eliminate_blocks);
for (const auto& row : block_structure.rows) {
- const vector<Cell>& cells = row.cells;
+ const std::vector<Cell>& cells = row.cells;
int block_id = cells[0].block_id;
// If the first block is not an e_block, then skip this row block.
if (block_id >= num_eliminate_blocks) {
@@ -80,7 +74,7 @@
}
std::unique_ptr<WeightedGraph<int>> CreateSchurComplementGraph(
- const vector<set<int>>& visibility) {
+ const std::vector<std::set<int>>& visibility) {
const time_t start_time = time(nullptr);
// Compute the number of e_blocks/point blocks. Since the visibility
// set for each e_block/camera contains the set of e_blocks/points
@@ -88,7 +82,7 @@
int num_points = 0;
for (const auto& visible : visibility) {
if (!visible.empty()) {
- num_points = max(num_points, (*visible.rbegin()) + 1);
+ num_points = std::max(num_points, (*visible.rbegin()) + 1);
}
}
@@ -97,9 +91,9 @@
// cameras. However, to compute the sparsity structure of the Schur
// Complement efficiently, its better to have the point->camera
// mapping.
- vector<set<int>> inverse_visibility(num_points);
+ std::vector<std::set<int>> inverse_visibility(num_points);
for (int i = 0; i < visibility.size(); i++) {
- const set<int>& visibility_set = visibility[i];
+ const std::set<int>& visibility_set = visibility[i];
for (int v : visibility_set) {
inverse_visibility[v].insert(i);
}
@@ -107,7 +101,7 @@
// Map from camera pairs to number of points visible to both cameras
// in the pair.
- std::unordered_map<pair<int, int>, int, pair_hash> camera_pairs;
+ std::unordered_map<std::pair<int, int>, int, pair_hash> camera_pairs;
// Count the number of points visible to each camera/f_block pair.
for (const auto& inverse_visibility_set : inverse_visibility) {
@@ -116,7 +110,7 @@
++camera1) {
auto camera2 = camera1;
for (++camera2; camera2 != inverse_visibility_set.end(); ++camera2) {
- ++(camera_pairs[make_pair(*camera1, *camera2)]);
+ ++(camera_pairs[std::make_pair(*camera1, *camera2)]);
}
}
}
diff --git a/internal/ceres/visibility_test.cc b/internal/ceres/visibility_test.cc
index a107c2f..25d0510 100644
--- a/internal/ceres/visibility_test.cc
+++ b/internal/ceres/visibility_test.cc
@@ -42,9 +42,6 @@
namespace ceres::internal {
-using std::set;
-using std::vector;
-
class VisibilityTest : public ::testing::Test {};
TEST(VisibilityTest, SimpleMatrix) {
@@ -98,7 +95,7 @@
}
bs.cols.resize(num_cols);
- vector<set<int>> visibility;
+ std::vector<std::set<int>> visibility;
ComputeVisibility(bs, num_eliminate_blocks, &visibility);
ASSERT_EQ(visibility.size(), num_cols - num_eliminate_blocks);
for (const auto& visible : visibility) {
@@ -173,7 +170,7 @@
}
bs.cols.resize(num_cols);
- vector<set<int>> visibility;
+ std::vector<std::set<int>> visibility;
ComputeVisibility(bs, num_eliminate_blocks, &visibility);
ASSERT_EQ(visibility.size(), num_cols - num_eliminate_blocks);
for (const auto& visible : visibility) {