Commit Graph

328 Commits

Author SHA1 Message Date
Julian Kent 368a738e52 AutoDiffCostFunction: optional ownership
Add Ownership semantics to the AutoDiffCostFunction

This allows several benefits, such as pointer ordering always being the
same for numerical repeatability (due to blocks being ordered by
pointer address), memory adjacency for better cache performance, and
reduced allocator pressure / overhead.

This is then made use of in libmv by preallocating the errors and
cost functions into vectors

Change-Id: Ia5b97e7249b55a463264b6e26f7a02291927c9f2
2020-09-03 19:19:53 +02:00
Sameer Agarwal 242c703b50 Minor fixes to the documentation
Change-Id: I65e6f648d963b8aa640078684ce02dcde6acb87d
2020-08-04 21:02:11 -07:00
Sameer Agarwal 79bbf95103 Add changelog for 2.0.0
Change-Id: I8acad62bfe629454ae5032732693e43fe37b97ff
2020-08-04 18:26:02 -07:00
Sameer Agarwal 8c3ecec6db Fix some minor errors in IterationCallback docs
Change-Id: Id3d7f21a523ff8466868cdec542921c566bbbfa9
2020-08-04 14:21:23 -07:00
Alex Stewart 7d3ffcb423 Remove forced CONFIG from find_package(Eigen3)
- Ceres will fail to configure if Eigen3::Eigen target is not found, and
  the minimum required Eigen version specified (3.3) exports Eigen as
  a CMake package and this is reflected in the default Ubuntu 18.04
  packages.
- This permits users to specify their own Eigen3 detection should they
  choose to do so, but they must do so via an imported target.

Change-Id: I5edff117c8001770004f49012ac1ae63b66ec9c1
2020-08-04 21:16:25 +00:00
Alex Stewart aa1abbc578 Replace use of GFLAGS_LIBRARIES with export gflags target
- As our minimum required version of gflags (2.2) exports itself as
  a CMake package and this is the case for the default 18.04 package
  we can use the gflags target directly.
- Replaces forced use of CONFIG in find_package(gflags) with a check
  that the gflags imported target exists to avoid ambiguity with
  libgflags if installed in a default location.  This permits users to
  override the gflags detection should they so choose, provided that
  they do so via an imported target.
- Also removes some previously removed legacy GLAGS_ vars from the
  installation docs.

Change-Id: I015f5a751e5b22f956bbf9df692e63a6825c9f0d
2020-08-04 21:15:51 +00:00
Sameer Agarwal db2af1be87 Add Problem::EvaluateResidualBlockAssumingParametersUnchanged
Simplify the semantics for Problem::EvaluateResidualBlock to
not ignore the presence of EvaluationCallback and add another method
EvaluateResidualBlockAssumingParametersUnchanged to handle the case
where the user has an EvaluationCallback but knows that the parameter
blocks do not change between calls.

Updated the documentation for the methods and EvaluationCallback to
reflect these semantics.

Also added tests for Evaluation related methods calling i
EvaluationCallback when its present.

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

Change-Id: If0a0c95c2f1f92e9183a90df240104a69a71c46d
2020-08-04 13:59:42 -07:00
Sameer Agarwal ab4ed32cda Replace NULL with nullptr in the documentation.
Change-Id: I995f68770e2a4b6027c0a1d3edf5eb5132b081d7
2020-08-03 04:18:05 -07:00
Carl Dehlin e39d9ed1d6 Add a missing term and remove a superfluous word
Change-Id: I25f40f0bf241302b975e6fc14690aa863c0728b0
2020-06-16 09:02:05 +02:00
Carl Dehlin 27cab77b69 Reformulate some sentences
Change-Id: I4841aa8e8522008dd816261d9ad98e5fb8ad1758
2020-06-15 20:01:18 +02:00
Carl Dehlin 8ac6655ce8 Fix documentation formatting issues
Change-Id: Iea3a6e75dc3a7376eda866ab24e535a6df84f8ea
2020-06-15 19:10:12 +02:00
Alex Stewart 7ef83e0759 Update minimum required C++ version for Ceres to C++14
- Removes all workarounds for pre-C++14 versions
- Removes '11' qualifier from C++ threading option and associated
  defines.
- Fix missing inclusion of 'Multithreading' in reported Ceres components
  when C++ threading model is enabled.
- Update Sphinx documentation to specify C++14 as minimum requirement.

Change-Id: I706c8b367b3221e3c4d1a0aaf669a8f9c911e438
2020-05-30 19:15:03 +01:00
Sameer Agarwal 1d75e75681 Improve documentation for LocalParameterization
Change-Id: I63fa81206e67bfac56cc42bf2bb4915a3a11332b
2020-05-27 22:34:48 -07:00
Sameer Agarwal 763398ca4e Update the section on Preconditioners
Re-organize the section, add some more references and details for
existing preconditioners and add documentation for the SUBSET
precondition.

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

Change-Id: I93d0af819c160f5e4ce48b18202f629ddb92ca7b
2020-05-28 05:25:41 +00:00
Sameer Agarwal 70308f7bb9 Simplify documentation generation.
1. The MathJax font configuration is moved into conf.py and removed
from make_docs.py along with better font sizing.
2. Remove the bread crumb replacement as it is not working anymore.
3. Fix a parsing error in nnls_modeling.rst which the new version of
sphinx barfed on.

Change-Id: Ia3c2e732323a8b5cabafe851ac5ca0f0c82da071
2020-05-27 19:24:46 +00:00
Bayes Nie 303b078b50 Fix few typos and alter a NULL to nullptr.
Fix typos in docs/source/features.rst and examples/helloworld.cc. Alter a NULL to nullptr in include/ceres/autodiff_cost_function.h

Change-Id: Ibcf00b6ef665ad6be9af14b3add2dd4f3852e7e6
2020-05-25 17:22:40 +00:00
Alex Stewart b70687fcc8 Add namespace qualified Ceres::ceres CMake target
- This reflects modern CMake style, and also provides a measure of
  protection against missing find_package() imports in downstream
  clients resulting in linker errors when 'ceres' matches the compiled
  library and not the imported target.
- The original 'ceres' target remains, as a local imported interface
  target created by CeresConfig for backwards compatibility.

Change-Id: Ie9ed8de9b7059bc0cae1ae5002bb94d8fe617188
2020-05-25 17:16:27 +00:00
Sameer Agarwal 2281c6ed24 Fixes for comments from William Rucklidge
Change-Id: I64fcc25532cc66dc4cb7e2ea7ccfb220b0cb7e1f
2020-04-02 16:43:42 -07:00
Sameer Agarwal 27183d661e Allow LocalParameterizations to have zero local size.
Local parameterizations with zero tangent/local size will cause the
corresponding parameter block to be treated as constant.

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

Change-Id: I554a2acc420f5dd9d0cc7f97b691877eb057b2c0
2020-04-02 06:49:42 -07:00
Johannes Beck 6bde61d6be Add line local parameterization.
This CL adds a local parameterization for a n-dimensional
line, which is represented as an origin point and a direction.
The line direction is updated in the same way as a
homogeneous vector and the origin point is updated
perpendicular to the line direction.

Change-Id: I733f395e5cc4250abf9778c26fe0a5ae1de6b624
2020-03-23 22:36:39 -07:00
Sameer Agarwal f212c92954 Let Problem::SetParameterization be called more than once.
https://github.com/ceres-solver/ceres-solver/issues/501

Change-Id: Ia94e6e62553e97fa2052db2cbebc5c472e26a406
2019-12-17 19:00:06 +00:00
Sameer Agarwal 19728e72d4 Add documentation for Problem::IsParameterBlockConstant
https://github.com/ceres-solver/ceres-solver/issues/485

Change-Id: I1d3d7e6bb2a33e2202b71c989164dd805fb54b89
2019-12-16 16:59:34 -08:00
Sameer Agarwal edb8322bda Update the minimum required version of Eigen to 3.3.
Change-Id: I6e6bd745311b7d4f1d5b749ec70d314f9e765438
2019-12-13 09:43:10 -08:00
Chris Choi 46ca461b7e Fix gradient_check_relative_precision docs typo
In the docs, `Solver::Options::gradient_check_relative_precision` is
documented to have a default precision of 1e08. That is incorrect, it
should be 1e-8.

Change-Id: Ib6b29e356738de4b555c77f7ffd1224d0cae4b6a
2019-10-21 16:19:29 +01:00
Frank 3e5db5bc27 Fixing documentation typo.
- Matrix had two columns squeezed together

Change-Id: I5f18df15364bd8507db98d43f8a547a9efab0913
2019-07-19 03:03:00 +09:00
Sameer Agarwal 487c1aa51f Expose SubsetPreconditioner in the API
https://github.com/ceres-solver/ceres-solver/issues/270

Detailed list of changes:

1. Add SUBSET to the PreconditionerType enum.
2. Add Solver::Options::residual_blocks_for_subset_preconditioner
3. Integrate SubsetPreconditioner into the CGNR solver.
4. Add the reordering logic needed for this to TrustRegionPreprocessor.
5. Expect CreateJacobianBlockTranspose to take the starting row block
   so that we can work with subparts of the Jacobian matrix.
6. Extend the denoising example to use this preconditioner.

As an illustration of its performance, we consider the performance of
denoising -input ../data/ceres_noisy.pgm  --foe_file ../data/5x5.foe

tl;dr

For the same cost,

SPARSE_NORMAL_CHOLESKY -  81s
CGNR + JACOBI          - 718s
CGNR + SUBSET          -  57s

SPARSE_NORMAL_CHOLESKY
======================

Cost:
Initial                          2.317806e+05
Final                            2.232323e+04
Change                           2.094574e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         2.999746

  Residual only evaluation           2.306811 (10)
  Jacobian & residual evaluation     7.421727 (10)
  Linear solver                     65.517273 (10)
Minimizer                           78.731011

Postprocessor                        0.026079
Total                               81.756836

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.573046e-04 <= 1.000000e-03)

CGNR + JACOBI
=============
Cost:
Initial                          2.317806e+05
Final                            2.232344e+04
Change                           2.094572e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         0.648814

  Residual only evaluation           2.297607 (10)
  Jacobian & residual evaluation     7.327886 (10)
  Linear solver                    699.601248 (10)
Minimizer                          712.419493

Postprocessor                        0.024014
Total                              713.092321

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.528538e-04 <= 1.000000e-03)

CGNR + SUBSET (random 20% residuals used for the preconditioner)
===============================================================
Cost:
Initial                          2.317806e+05
Final                            2.232327e+04
Change                           2.094574e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         1.472743

  Residual only evaluation           2.428315 (10)
  Jacobian & residual evaluation     7.367796 (10)
  Linear solver                     42.585999 (10)
Minimizer                           55.664459

Postprocessor                        0.024098
Total                               57.161301

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.538277e-04 <= 1.000000e-03)

Change-Id: Ifb011408bd53edbb9439b0b7345649a38f999e18
2019-07-12 16:08:36 +02:00
Sameer Agarwal bf709ecac2 Move EvaluationCallback from Solver::Options to Problem::Options.
Adding it to Solver::Options was a mistake, as it prevents it from
being used in covariance estimation. Also updated associated docs.

https://github.com/ceres-solver/ceres-solver/issues/380
https://github.com/ceres-solver/ceres-solver/issues/401
https://github.com/ceres-solver/ceres-solver/issues/484

Change-Id: I63809a47a58e84c04a58bf8e59ace92f45fc2873
2019-07-08 21:24:08 +02:00
Sameer Agarwal db1f5b57a0 Allow some methods in Problem to use const double*.
Some methods in Problem do not modify the parameter block
and those methods now allow the user to call them with const double*.

The methods are

RemoveParameterBlock
SetParameterBlockConstant
IsParameterBlockConstant
GetParameterization
GetParameterLowerBound
GetParameterUpperBound

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

Change-Id: I59dcb77134f59576dd498bd732e29aae9abd28b1
2019-06-05 15:45:02 -07:00
Sameer Agarwal 084042c252 Lint changes from William Rucklidge
Update documentation for
Solver::Options::max_num_line_search_step_size_iterations

Change-Id: I03edc74e67940bed0be7e5ccaffed9e97114a5a5
2019-05-31 09:00:40 -07:00
Sameer Agarwal 1b852c57e0 Add Problem::EvaluateResidualBlock.
This method gives the user the ability to evaluate a given residual
block.

A couple of minor cleanups.

Problem::problem_impl_ -> Problem::impl_
NULL -> nullptr

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

Change-Id: I6dd94762c475fa264c387b8c93d516f6e06fe832
2019-04-29 09:46:33 -07:00
Sameer Agarwal d467a627b5 IdentityTransformation -> IdentityParameterization
Change-Id: I77b32a3ec4fd666ce99e2248eb50c851d7bb4b0d
2019-04-02 06:43:31 -07:00
Sameer Agarwal eaec6a9d0c Fix more typos in CostFunctionToFunctor documentation.
Change-Id: I337e67152e4c00b91f7b8f0bb471d5a1896f46dc
2019-03-10 20:57:09 -07:00
Sameer Agarwal 99b5aa4aa5 Fix typos in CostFunctionToFunctor documentation.
Thanks to jss.chandler00@gmail.com for reporting this.

Change-Id: I05cc1f17edec227dc0526b2b63a9fb4a4209772f
2019-03-10 14:02:11 +00:00
huangqinjin 21d40daa00 Remove UTF-8 chars
Change-Id: I1e98dd7441d2de05e0b3b0937e496103177631f8
2019-03-03 18:53:13 +00:00
Alessandro Gentilini 3793693a0c Fix typo in NIST url.
Change-Id: I27937dc4bf6f0216d54be5c90d9f950b8ced87af
2018-09-25 18:30:42 +00:00
Kuang Fangjun b040970cb8 Remove conversions from a double to a Jet.
There are overloaded operators supporting operations between a double and a Jet, so there
is no need to convert a double to a Jet.

Change-Id: I9cfcefb32c6b1a5ad716496b620d578871f0ff03
2018-09-23 11:56:53 +08:00
Kuang Fangjun 0d3a84fce5 Fix typos in doc and errors in the demo code.
Change-Id: I237402958ed8747ae438643132fcab90113ac27d
2018-09-22 12:01:20 +08:00
Kuang Fangjun b979df56b6 Fix a dead link in doc.
The original link is not available any more.

Change-Id: I0d47f5e05d80973bc29deb377ccec814f555e3ef
2018-09-18 03:18:04 +00:00
Dmitriy Korchemkin 2ac62a6d78 Fix docs for Problem::EvaluateOptions and contributing
Fix Problem::EvaluateOptions::residual_blocks description
Fix gerrit interface description in contributing instructions

Change-Id: I3347f35a85700a9f8ae1da3b79a6292a9d4dffe0
2018-08-03 15:16:42 +03:00
Sameer Agarwal 32cb9e4a12 Respect bounds when using Solver::Options::check_gradients
When Solver::Options::check_gradients is true, Ceres internally
creates a new ProblemImpl object which wraps each CostFunction
in the user's problem with a GradientCheckingCostFunction.

Doing this also requires creating new ParameterBlock objects,
and when support for upper and lower bounds was added to Ceres,
CreateGradientCheckingProblemImpl should also have been updated
to create a problem with the same parameter bounds. As a result,
if check_gradients is enabled for a bounded problem, it constructs
an unconstrained problem and solves it.

This CL fixes this, by introducing Problem::GetParameterLowerBound,
and Problem::GetParameterUpperBound and using them to create a bounded
problem when checking gradients.

Thanks to @pbeeson for not only reporting this problem, but also
providing a small standalone reproduction which made debugging this
possible.

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

Change-Id: Id18eb858a7009bf4fa452a21b925922d13f3249f
2018-07-09 23:48:45 -07:00
Sameer Agarwal 3df43b960f Remove Android build using Android.mk.
CMake support in Android is now standard and the CMake file
has fuller richer functionality than the Android.mk file ever did.

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

Change-Id: Ib79bcc19dd47495a81a5d07fafdf06eb8005984e
2018-07-10 06:10:12 +00:00
Alex Stewart 16f9b34c3b Remove Intel TBB threading support.
- In light of the C++11 threads threading option this is no longer
  necessary for cross-platform threading support and did not offer a
  noticeable performance gain over either the C++11 threads
  implementation or OpenMP.

Change-Id: Icb588d520888c19a1775171795b55bcaffb3d256
2018-07-03 18:05:36 +00:00
Alex Stewart 2166bad133 Replace include_directories() with target_include_directories().
- Now that we require CMake >= 3.x, we can roll the definition of the
  include directories for clients linking against Ceres into the
  exported Ceres CMake target via target_include_directories().
- This removes the requirement for CERES_INCLUDE_DIRS.

Change-Id: Ibe3bbf796339871d66138fc9520053d1766f09a8
2018-07-02 12:15:13 +01:00
Alex Stewart 8f41ca6abc Add Apple's Accelerate framework as a sparse linear algebra library.
- Currently DynamicSparseNormalCholeskySolver is unsupported for
  Accelerate.

Change-Id: I03b5a86bb22fef249c4aecd48947a613e8eff7a5
2018-06-29 09:43:03 +01:00
Linus Mårtensson 9f3d9aebed Add android CMake support
Change-Id: I78b4794786cc1b03946b6b15aa93e46a4303a39c
2018-06-26 15:59:44 +02:00
Alex Stewart d656d34809 Refactor Ceres threading option configuration.
- Previously we had separate variables for each of the threading
  backends, each of which were made mutually exclusive via
  cmake_dependent_option().  This has unfortunate side-effects when
  trying to disable options if they are not currently enabled, in which
  case they are not defined.
- As all the threading options are mutually exclusive, this replaces
  all threading option variables with a single variable: CERES_THREADS,
  which is constrained to take the value of only the available threading
  backends.

Change-Id: I0822eefbac9a30772907b7732add365b37cc8ca0
2018-06-20 23:20:57 +00:00
Alex Stewart 9671d850e6 Replace (MSVC/GCC/CLANG)_VERSION with CMAKE_CXX_COMPILER_VERSION.
- As raised in issue #377, GCC_VERSION is not always defined, in which
  case we were not enabling compiler optimisations.
- CMAKE_CXX_COMPILER_VERSION is the more modern, uniform method to
  verify the compiler version.
- Also removes legacy Apple-GCC (i.e. Apple's fork of GCC prior to their
  switch to Clang) logic, and Xcode 4.x logic (in June 2018, Xcode 9.x
  is the current version).
- Also removes addition of -march=native on Linux (was not added for
  OS X).  If users wish to append -march=native (which will affect the
  portability of the resulting output) they can do so manually as now
  explained in the docs.
- Fixes check for Clang on OS X.  As per CMP0025 (CMake 3.0+)
  CMAKE_CXX_COMPILER_ID reports AppleClang on OS X, not Clang. Thus
  using: if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") would fail for
  AppleClang.  Instead, MATCHES should be used instead of STREQUAL to
  support both Clang & AppleClang.

Change-Id: I9647030b76f4b85a9ef2deea82d80ed79812ae33
2018-06-20 19:43:12 +01:00
Sameer Agarwal cfdc2af28b Remove Solver::Options::num_linear_solver_threads
Also removed Solver::Summary::num_linear_solver_threads_given
and Solver::Summary::num_linear_solver_threads_used.

Change-Id: I559145ae2e7af597ea06ec03d386645a3a892e9f
2018-04-26 21:13:35 -07:00
Keir Mierle 7c4e8a454e Replace scoped_ptr with C++11's unique_ptr
Change-Id: Ib5a504c491e3a79af52a95accf009df473470c6b
2018-04-02 14:47:47 -07:00
Alex Stewart 282b8b5f35 Require >= C++11 & CMake >= 3.5 when building Ceres.
- Removes CXX11 option, and all associate paraphernalia.  Ceres now
  requires a compiler with full >= C++11 support.  In MSVC terms this
  means >= 2013 Release 4.
- This deprecates the use of CERES_STD_UNORDERED_MAP and CERES_USE_CXX11
  as they will now always be defined.  They will be removed from the
  source in a future CL.
- For clients with CMake >= 3.8 we propagate via the exported/installed
  Ceres target the CXX version that was specified when Ceres was built.
  For versions < 3.8 (but >= 3.5) we specify the CXX features currently
  used in the Ceres public API.

Change-Id: I535b545b10156e4426659c270a4a0649e071df0e
2018-03-29 09:32:59 +01:00