diff options
Diffstat (limited to 'extern/ceres/internal/ceres/polynomial.cc')
-rw-r--r-- | extern/ceres/internal/ceres/polynomial.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/extern/ceres/internal/ceres/polynomial.cc b/extern/ceres/internal/ceres/polynomial.cc index 20812f4de81..96267aae97f 100644 --- a/extern/ceres/internal/ceres/polynomial.cc +++ b/extern/ceres/internal/ceres/polynomial.cc @@ -37,7 +37,7 @@ #include "Eigen/Dense" #include "ceres/function_sample.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { @@ -128,12 +128,12 @@ void FindLinearPolynomialRoots(const Vector& polynomial, Vector* real, Vector* imaginary) { CHECK_EQ(polynomial.size(), 2); - if (real != NULL) { + if (real != nullptr) { real->resize(1); (*real)(0) = -polynomial(1) / polynomial(0); } - if (imaginary != NULL) { + if (imaginary != nullptr) { imaginary->setZero(1); } } @@ -147,16 +147,16 @@ void FindQuadraticPolynomialRoots(const Vector& polynomial, const double c = polynomial(2); const double D = b * b - 4 * a * c; const double sqrt_D = sqrt(fabs(D)); - if (real != NULL) { + if (real != nullptr) { real->setZero(2); } - if (imaginary != NULL) { + if (imaginary != nullptr) { imaginary->setZero(2); } // Real roots. if (D >= 0) { - if (real != NULL) { + if (real != nullptr) { // Stable quadratic roots according to BKP Horn. // http://people.csail.mit.edu/bkph/articles/Quadratics.pdf if (b >= 0) { @@ -171,11 +171,11 @@ void FindQuadraticPolynomialRoots(const Vector& polynomial, } // Use the normal quadratic formula for the complex case. - if (real != NULL) { + if (real != nullptr) { (*real)(0) = -b / (2.0 * a); (*real)(1) = -b / (2.0 * a); } - if (imaginary != NULL) { + if (imaginary != nullptr) { (*imaginary)(0) = sqrt_D / (2.0 * a); (*imaginary)(1) = -sqrt_D / (2.0 * a); } @@ -240,14 +240,14 @@ bool FindPolynomialRoots(const Vector& polynomial_in, } // Output roots - if (real != NULL) { + if (real != nullptr) { *real = solver.eigenvalues().real(); } else { - LOG(WARNING) << "NULL pointer passed as real argument to " + LOG(WARNING) << "nullptr pointer passed as real argument to " << "FindPolynomialRoots. Real parts of the roots will not " << "be returned."; } - if (imaginary != NULL) { + if (imaginary != nullptr) { *imaginary = solver.eigenvalues().imag(); } return true; @@ -304,7 +304,7 @@ void MinimizePolynomial(const Vector& polynomial, const Vector derivative = DifferentiatePolynomial(polynomial); Vector roots_real; - if (!FindPolynomialRoots(derivative, &roots_real, NULL)) { + if (!FindPolynomialRoots(derivative, &roots_real, nullptr)) { LOG(WARNING) << "Unable to find the critical points of " << "the interpolating polynomial."; return; @@ -376,8 +376,7 @@ void MinimizeInterpolatingPolynomial(const vector<FunctionSample>& samples, double* optimal_value) { const Vector polynomial = FindInterpolatingPolynomial(samples); MinimizePolynomial(polynomial, x_min, x_max, optimal_x, optimal_value); - for (int i = 0; i < samples.size(); ++i) { - const FunctionSample& sample = samples[i]; + for (const auto& sample : samples) { if ((sample.x < x_min) || (sample.x > x_max)) { continue; } |