Commit Graph

18 Commits

Author SHA1 Message Date
Alexander Ivanov 53df5ddcfd Removing using std::...
Change-Id: I584402e2a34869183c1d59071a15d97b216c52fb
2023-01-11 16:51:38 +00:00
Sameer Agarwal caf614a6c1 Modernize code using c++17 constructs
Mostly done using

find . \( -name '*.cc' -o -name '*.h' \) -a -type f -exec clang-tidy -p \
cmake-build -checks='-*,google-*,modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type' {} -fix \;

Change-Id: Ifccbcabe7a1d9a32a09d28ac4f3f8466696c1a50
2022-04-22 06:11:18 -07:00
Sergiu Deitsch c8658c8992 Modernize more
Apply clang-tidy Google and modernize fixes without trailing return type
using:

$ clang-tidy -p <build-dir> \
  -checks='-*,google-*,modernize-*,-modernize-use-trailing-return-type' {} -fix

Change-Id: I7450cc58ea9abf928f73a467e87876083217fa26
2022-02-26 22:16:56 +00:00
Sergiu Deitsch f90833f5fa Simplify symbol export
Currently, the logic for exporting symbols is rather complicated: when
tests are enabled internal symbols are exported in addition to the
public symbols. Such logic causes several problems. (1) Test binaries
link against a Ceres build that is different from the final release
since fewer optimizations are applied if more symbols are exported. (2)
Also, some toolchains hide symbols by default breaking the existing
logic eventually causing linker errors.

Since internal symbols are not intended to be used outside of the
project, we can compile them into object files and use exactly the same
binary code both for the final build and the tests without relying on
conditionals.

By default, all symbols are now hidden unless annotated as public.
Internal symbols are explicitly marked as not being exported in case
users chose not to hide symbols by default.

Change-Id: I589dd10be2f6f438508783cf99d141af0120057b
2022-02-14 20:19:08 +01:00
Sameer Agarwal ae65219e04 ClangTidy cleanups
1. NULL -> nullptr
2. foo.reset(new Bar) -> = foo = std::make_unique<Bar>()
3. Missing std library includes & prefixes

Change-Id: I260b261b484554be681ee5a7398126fdb3b3a789
2022-02-09 10:06:49 -08:00
Sameer Agarwal 94712db5c7 Convert calls to CHECK_NOTNULL to CHECK.
CHECK_NOTNULL is being deprecated and removed from the
glog library.

Change-Id: I4a6d1eec6e82a768c7861c8f776bf1f9c0b50c74
2018-08-28 08:14:19 -07:00
Sameer Agarwal 621b79b972 Refactor FunctionSample & LineSearchFunction
1. Move FunctionSample to its own .h/.cc files.
2. Migrate LineSearchFunction::Evaluate to use FunctionSample
   for input and output.

Change-Id: I8bfb97e1900d95a4686c9621dda5b584458b45c0
2017-07-05 07:56:58 -07:00
Sameer Agarwal 5365ad8aa6 A hacky fix for the Eigen::FullPivLU changes.
Changes in Eigen's implementation for FullPivLU significantly
degraded the performance of the line search as reported by Weiguang.

We do not completely understand what is going on, as Eigen's changes
seem sane. So for now, this change explicitly works around the
changes made by Eigen to restore the performance of the line search.

Figuring out the underlying problem and fixing it remains an open
issue.

https://github.com/ceres-solver/ceres-solver/issues/248

Change-Id: I9993d73a09dc990ab567ce6bc447f16eac74abec
2017-02-12 12:04:30 -08:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Sameer Agarwal 05a07ecc77 Remove using std::string from port.h
Change-Id: I7376f5e7eace22ec1fc05a61eaa858594f08682d
2015-01-07 15:10:46 -08:00
Sameer Agarwal bcc865f81c Remove using namespace std;
For historical reasons we had a "using namespace std;" in port.h. This
is generally a bad idea. So removing it and along the way doing a bunch
of cpplint cleanup.

Change-Id: Ia125601a55ae62695e247fb0250df4c6f86c46c6
2015-01-07 14:26:53 -08:00
Sergey Sharybin b811041d78 Code cleanup: fix no previous declaration warnings
Moved some internally used functions into an anonymous namespace.

Change-Id: Ie82df61b0608abac79ccc9f7b14e7f7e04ab733d
2014-01-02 15:20:49 +06:00
Sameer Agarwal 1284a51414 Use explicit formula to solve quadratic polynomials.
polynomial.cc implements a companion matrix base method for solving
polynomials. This is both expensive and numerically sensitive.

This change adds a quadratic equation solver. Instead of using the
usual quadratic formula, it uses the formula suggested by BKP Horn
for improved numerical stability.

Change-Id: I476933ce010d81db992f1c580d2fb23a4457eb3e
2013-11-25 09:49:16 -08:00
Alex Stewart bf4c1b76e4 Decreasing threshold at which L-BFGS Hessian is updated.
- Decreasing threshold at which L-BFGS Hessian is updated from 1e-10
  to 1e-14 results in a very significant improvement in NIST scores
  (43 -> 53 for CUBIC).
- Adding comment in FindPolynomialRoots() explaining why behaviour
  is correct.

Change-Id: If668e087e7a86d29659aa74e8528b192b604c841
2013-11-14 21:34:52 +00:00
Alex Stewart 7124c3474c Fixes for some line search bugs & corner cases.
- Increase precision of numeric values output in error messages to
  allow for easier debugging.
- Ensure termination after Wolfe search bracketing phase if bracket
  width has been shrunk to below tolerance.
- Cleaned up return value for BracketingPhase(), now false iff
  optimisation should stop, true otherwise.
- Fix bug whereby we would mark a step size as satisfying the Wolfe
  conditions when it did not due to numerical issues in the cost
  function.
- Adding explanation of a subtlety in which a zoom could still be
  acceptably invoked with bracket_low.f > bracket_high.f.
- Replacing hard check of a pre-condition of ZoomPhase() with a
  conditional return if not satisfied to address issue whereby a
  bracket could be incorrectly identified due to inconsistent values
  & gradients returned from the cost function.
- Adding missing check for step size validity in line search minimizer.
- Adding ToDebugString() for FunctionSample.

Change-Id: Iad98e635749877f80c079ebad126bf022d82232d
2013-11-14 17:40:10 +00:00
Sameer Agarwal c89ea4b9de Minor corrections based on Jim Roseborough's comments
Change-Id: I4a8c7a454ddf038a3ed2567c101f9aee582044bf
2013-01-09 16:15:09 -08:00
Sameer Agarwal f4d0164607 Add a line search based minimizer.
1. Add a line search based minimization loop.
2. Currently this loop supports steepest descent and three
   kinds of non-linear conjugate gradient algorithms.
3. Update SolverImpl to talk to LineSearchMinimizer.
4. Update IterationCallback to carry information about
   line search.
5. Update LineSearch to take the initial point as input,
   saving on one function evaluation.
6. Updates to the external API.

Change-Id: I901a0e89fc948451ab34c743e70f3dec57c9405e
2012-11-28 16:18:01 -08:00
Sameer Agarwal e7295c246b Add polynomial interpolation and minimization.
1. polynomial_solver* -> polynomial*.
2. Added support for differentiating polynomials.
2. Added support for interpolating polynomials from function
   values and gradients.
3. Added support for minimizing polynomials by solving
   for the roots of their derivatives in an interval.
4. Added support for finding the minimum of a polynomial
   that interpolates function values and gradients in
   an interval.

Change-Id: Id7e6764ad4db09c3edd60f1378c7f50f20dd08dc
2012-11-25 16:53:05 -08:00