Lint cleanup from William Rucklidge. Change-Id: Ifb36de18f95d521242d8853bb54024b09effb937
diff --git a/examples/more_garbow_hillstrom.cc b/examples/more_garbow_hillstrom.cc index 5e4d6e1..4158396 100644 --- a/examples/more_garbow_hillstrom.cc +++ b/examples/more_garbow_hillstrom.cc
@@ -52,7 +52,7 @@ #include <cmath> -#include <iostream> +#include <iostream> // NOLINT #include "ceres/ceres.h" #include "gflags/gflags.h" #include "glog/logging.h" @@ -71,14 +71,14 @@ static const double constrained_optimal_cost; \ static const double unconstrained_optimal_cost; \ static CostFunction* Create() { \ - return new AutoDiffCostFunction<name, \ + return new AutoDiffCostFunction<name, \ // NOLINT num_residuals, \ num_parameters>(new name); \ } \ template <typename T> \ bool operator()(const T* const x, T* residual) const { -#define END_MGH_PROBLEM return true; } }; +#define END_MGH_PROBLEM return true; } }; // NOLINT // Rosenbrock function. BEGIN_MGH_PROBLEM(TestProblem1, 2, 2) @@ -91,7 +91,8 @@ const double TestProblem1::initial_x[] = {-1.2, 1.0}; const double TestProblem1::lower_bounds[] = {-kDoubleMax, -kDoubleMax}; const double TestProblem1::upper_bounds[] = {kDoubleMax, kDoubleMax}; -const double TestProblem1::constrained_optimal_cost = std::numeric_limits<double>::quiet_NaN(); +const double TestProblem1::constrained_optimal_cost = + std::numeric_limits<double>::quiet_NaN(); const double TestProblem1::unconstrained_optimal_cost = 0.0; // Freudenstein and Roth function. @@ -105,7 +106,8 @@ const double TestProblem2::initial_x[] = {0.5, -2.0}; const double TestProblem2::lower_bounds[] = {-kDoubleMax, -kDoubleMax}; const double TestProblem2::upper_bounds[] = {kDoubleMax, kDoubleMax}; -const double TestProblem2::constrained_optimal_cost = std::numeric_limits<double>::quiet_NaN(); +const double TestProblem2::constrained_optimal_cost = + std::numeric_limits<double>::quiet_NaN(); const double TestProblem2::unconstrained_optimal_cost = 0.0; // Powell badly scaled function. @@ -157,14 +159,17 @@ const T x1 = x[0]; const T x2 = x[1]; for (int i = 1; i <= 10; ++i) { - residual[i - 1] = T(2.0) + T(2.0 * i) - exp(T(double(i)) * x1) - exp(T(double(i) * x2)); + residual[i - 1] = T(2.0) + T(2.0 * i) - + exp(T(static_cast<double>(i)) * x1) - + exp(T(static_cast<double>(i) * x2)); } END_MGH_PROBLEM; const double TestProblem6::initial_x[] = {1.0, 1.0}; const double TestProblem6::lower_bounds[] = {-kDoubleMax, -kDoubleMax}; const double TestProblem6::upper_bounds[] = {kDoubleMax, kDoubleMax}; -const double TestProblem6::constrained_optimal_cost = std::numeric_limits<double>::quiet_NaN(); +const double TestProblem6::constrained_optimal_cost = + std::numeric_limits<double>::quiet_NaN(); const double TestProblem6::unconstrained_optimal_cost = 124.362; // Helical valley function. @@ -196,17 +201,20 @@ 0.73, 0.96, 1.34, 2.10, 4.39}; for (int i = 1; i <=15; ++i) { - const T u = T(double(i)); - const T v = T(double(16 - i)); - const T w = T(double(std::min(i, 16 - i))); + const T u = T(static_cast<double>(i)); + const T v = T(static_cast<double>(16 - i)); + const T w = T(static_cast<double>(std::min(i, 16 - i))); residual[i - 1] = T(y[i - 1]) - x1 + u / (v * x2 + w * x3); } END_MGH_PROBLEM; const double TestProblem8::initial_x[] = {1.0, 1.0, 1.0}; -const double TestProblem8::lower_bounds[] = {-kDoubleMax, -kDoubleMax, -kDoubleMax}; -const double TestProblem8::upper_bounds[] = {kDoubleMax, kDoubleMax, kDoubleMax}; -const double TestProblem8::constrained_optimal_cost = std::numeric_limits<double>::quiet_NaN(); +const double TestProblem8::lower_bounds[] = { + -kDoubleMax, -kDoubleMax, -kDoubleMax}; +const double TestProblem8::upper_bounds[] = { + kDoubleMax, kDoubleMax, kDoubleMax}; +const double TestProblem8::constrained_optimal_cost = + std::numeric_limits<double>::quiet_NaN(); const double TestProblem8::unconstrained_optimal_cost = 8.21487e-3; // Gaussian function. @@ -221,12 +229,12 @@ for (int i = 0; i < 15; ++i) { const T t_i = T((8.0 - i - 1.0) / 2.0); const T y_i = T(y[i]); - residual[i] = x1 * exp( -x2 * (t_i - x3) * (t_i - x3) / T(2.0)) - y_i; + residual[i] = x1 * exp(-x2 * (t_i - x3) * (t_i - x3) / T(2.0)) - y_i; } END_MGH_PROBLEM; const double TestProblem9::initial_x[] = {0.4, 1.0, 0.0}; -const double TestProblem9::lower_bounds[] = {0.398, 1.0 ,-0.5}; +const double TestProblem9::lower_bounds[] = {0.398, 1.0, -0.5}; const double TestProblem9::upper_bounds[] = {4.2, 2.0, 0.1}; const double TestProblem9::constrained_optimal_cost = 0.11279300e-7; const double TestProblem9::unconstrained_optimal_cost = 0.112793e-7; @@ -258,7 +266,8 @@ const double kMinLogRelativeError = 5.0; const double log_relative_error = -std::log10( - std::abs(2.0 * summary.final_cost - TestProblem::constrained_optimal_cost) / + std::abs(2.0 * summary.final_cost - + TestProblem::constrained_optimal_cost) / (TestProblem::constrained_optimal_cost > 0.0 ? TestProblem::constrained_optimal_cost : 1.0)); @@ -288,7 +297,8 @@ const double kMinLogRelativeError = 5.0; const double log_relative_error = -std::log10( - std::abs(2.0 * summary.final_cost - TestProblem::unconstrained_optimal_cost) / + std::abs(2.0 * summary.final_cost - + TestProblem::unconstrained_optimal_cost) / (TestProblem::unconstrained_optimal_cost > 0.0 ? TestProblem::unconstrained_optimal_cost : 1.0));
diff --git a/internal/ceres/line_search_minimizer.cc b/internal/ceres/line_search_minimizer.cc index 977fd6c..7623f8d 100644 --- a/internal/ceres/line_search_minimizer.cc +++ b/internal/ceres/line_search_minimizer.cc
@@ -95,7 +95,8 @@ } state->gradient_squared_norm = (x - projected_gradient_step).squaredNorm(); - state->gradient_max_norm = (x - projected_gradient_step).lpNorm<Eigen::Infinity>(); + state->gradient_max_norm = + (x - projected_gradient_step).lpNorm<Eigen::Infinity>(); return true; }
diff --git a/internal/ceres/parameter_block.h b/internal/ceres/parameter_block.h index c3fcce3..a978eb5 100644 --- a/internal/ceres/parameter_block.h +++ b/internal/ceres/parameter_block.h
@@ -352,6 +352,10 @@ // If non-null, contains the residual blocks this parameter block is in. scoped_ptr<ResidualBlockSet> residual_blocks_; + // Upper and lower bounds for the parameter block. These arrays are + // initialized to std::numeric_limits<double>::max() and + // -std::numeric_limits<double>::max() respectively which correspond + // to the parameter block being unconstrained. scoped_array<double> upper_bounds_; scoped_array<double> lower_bounds_;
diff --git a/internal/ceres/solver_impl.cc b/internal/ceres/solver_impl.cc index 937ab78..a0ad1b7 100644 --- a/internal/ceres/solver_impl.cc +++ b/internal/ceres/solver_impl.cc
@@ -364,7 +364,8 @@ for (int j = 0; j < size; ++j) { if (array[j] < lower_bounds[j] || array[j] > upper_bounds[j]) { *message = StringPrintf( - "ParameterBlock: %p with size %d has at least one infeasible value." + "ParameterBlock: %p with size %d has at least one infeasible " + "value." "\nFirst infeasible value is at index: %d." "\nLower bound: %e, value: %e, upper bound: %e" "\nParameter block values: ", @@ -380,7 +381,8 @@ for (int j = 0; j < size; ++j) { if (lower_bounds[j] >= upper_bounds[j]) { *message = StringPrintf( - "ParameterBlock: %p with size %d has at least one infeasible bound." + "ParameterBlock: %p with size %d has at least one infeasible " + "bound." "\nFirst infeasible bound is at index: %d." "\nLower bound: %e, upper bound: %e" "\nParameter block values: ",
diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc index 51eb75f..e2f1234 100644 --- a/internal/ceres/trust_region_minimizer.cc +++ b/internal/ceres/trust_region_minimizer.cc
@@ -175,7 +175,8 @@ if (options.is_constrained) { delta.setZero(); if (!evaluator->Plus(x.data(), delta.data(), x_plus_delta.data())) { - summary->message = "Unable to project initial point onto the feasible set."; + summary->message = + "Unable to project initial point onto the feasible set."; summary->termination_type = FAILURE; LOG_IF(WARNING, is_not_silent) << "Terminating: " << summary->message; return;