Commit Graph

2222 Commits

Author SHA1 Message Date
Sameer Agarwal 5d7baac258 ClangTidy fixes
Change-Id: Iae5a6b0067c726a5c5f6a88acee15a574cb46be6
2025-05-07 08:26:26 -07:00
Sameer Agarwal a3fd8ec461 Add a module statement to MODULE.bazel
Change-Id: I504517b5d582c4ce4a538761c41a6ccae6ec9305
2025-05-07 07:43:41 -07:00
Sergey Sharybin a43073a389 Fix vector operations benchmark compilation
Some of the benchmark functions use the same name as other functions
in the ceres namespace. For example Axpby defines both benchmark but
also an utility function in eigen_vector_ops.h. It seems to confuse
some compilers and leads to a compilation error rooting deeper into
the benchmark header itself: it seems that the compiler can not
deduct which of the instances of such functions to use.

Wrapping the file into an anonymous namespace solves the problem.
Alternative could be to use benchmark namespace to make thins more
explicit, for example ceres::internal::benchmark.

Tested on the following configuration:
- macOS 15.4
- Xcode 16.3
- Apple M3 CPU
- google-benchmark 1.9.2 installed via homebrew

Change-Id: Id127015dd22de99c6c3da88e71f255736e0bed82
2025-04-03 14:23:24 +02:00
Sergiu Deitsch 46b4b3b002 Do not discard caller's CMAKE_MODULE_PATH
Ceres CMake package configuration relies on several own find modules
(e.g., for SuiteSparse and METIS). To allow CMake to discover additional
find modules, the CMAKE_MODULE_PATH variable must be updated to include
the directories containing the corresponding find modules.

Previously, before updating CMAKE_MODULE_PATH, Ceres stored the
variable's initial value and then completely replaced it by the
directory containing Ceres's modules. However, a find_dependency failure
would cause an early return preventing CMAKE_MODULE_PATH to be restored.
Thus, any initial user changes to CMAKE_MODULE_PATH would be lost.

Now, instead of completely replacing the CMAKE_MODULE_PATH value we only
prepend additional directories. An early return no longer has a
destructive effect on CMAKE_MODULE_PATH. In a failure case,
CMAKE_MODULE_PATH still contains caller's initial set of directories and
an additional path prepended by Ceres.

Fixes #1024

Change-Id: I80d92a5dff9f3cff651f950c4f8d04ece008b44b
2025-02-19 15:54:17 -08:00
Sergiu Deitsch af39e3b9ee Use standard CMake package configuration mechanism to report failures
Fixes #1123

Change-Id: Idd327c97391395fb23fc458e8d3dae0e5f3d1ed2
2025-02-19 15:53:42 -08:00
Sergiu Deitsch ded29e4243 Do not custom format TBB version
Recent TBB CMake package configurations do not define the
TBB_INTERFACE_VERSION variable. This causes the reported version to be
incomplete, i.e., the version looks as "(2022.0 / )". Use the CMake
specified package variable to report the identified version instead.

Change-Id: Ic7851c821217e20fd6673de5442808ea3d302f4a
2025-02-19 15:53:01 -08:00
Sergiu Deitsch 7d196b4e6a Emit deprecation warning on unscoped import target usage
CMake will print the following warning:

CMake Warning (dev) at CMakeLists.txt:n (target_link_libraries):
  The library that is being linked to, ceres, is marked as being deprecated
  by the owner.  The message provided by the developer is:

  The unscoped import target `ceres' is deprecated and will be removed in a
  future Ceres Solver release.  Please use the Ceres::ceres import target
  instead.

This warning is for project developers.  Use -Wno-dev to suppress it.

Change-Id: I5abc875b1f61e1f47523375d1579a188047c45d4
2025-02-19 15:52:25 -08:00
Sergiu Deitsch ca4da54950 Use LINK_LIBRARY generator expression only for static absl
Change-Id: I348434be68a7bf112513cacf5791095cba8f95b3
2025-02-19 17:52:31 +01:00
Sergiu Deitsch bcca8fbd4f Use ubuntu-24.04 Github runner in Android Github workflow
The ubuntu-20.04 actions runner image is deprecated will be fully
unsupported by 2025-04-01 (see https://github.com/actions/runner-images/issues/11101).

Change-Id: Ib6e25b5eef020aa5f3f183638725f7702903954a
2025-02-17 17:09:44 -08:00
Sergiu Deitsch cd8c1074b2 Avoid GNU linker LTO warnings in Github workflows
Stop linker emitting warnings such as

  lto-wrapper: warning: using serial compilation of n LTRANS jobs

Change-Id: Ic933ef7b45955eabfa5b06e88cd195077ff9fc86
2025-02-17 17:09:13 -08:00
Sergiu Deitsch 5121022789 Update NDK in Android Github workflow to latest LTS
Change-Id: I278fc0faaac764277d6985f0de23e602f1cde766
2025-02-17 17:08:32 -08:00
Sergiu Deitsch 539dffbec3 Use high-speed linker in Linux Github workflow
Using mold instead of GNU ld reduces the total build time by roughly
5-15 min. (depending on the load).

Change-Id: I66feab4e54c248cf92cc379d0085a93bdfdfef69
2025-02-17 17:08:02 -08:00
Sergiu Deitsch f0720aeb84 Raise minimum required Eigen version to 3.3.4
Ubuntu 22.04 ships with Eigen 3.4.0. The MinGW workaround for -O3
related crashes has been available in Eigen since at least version
3.2.0, see https://gitlab.com/libeigen/eigen/-/commit/cc03c9d68354ea3fed03481de045c185ddc1fc49.

Change-Id: Iebfd6ed1fa55a6b0f5bd57bd920188e7b486d8cb
2025-02-17 17:07:27 -08:00
Sergiu Deitsch 2d2b7b57c7 Ensure DynamicCostFunctionToFunctor to be exported
Fixes #1022

Change-Id: I090790ac4a1f32e6cb318bc32273d63898659dc3
2025-02-17 23:59:36 +01:00
Sergiu Deitsch 1b27b6610c Specify docs requirements
Use `pip install -r docs/requirements.txt` (e.g., in a virtual environment) to install Python dependencies required for building the documentation.

Change-Id: Ied9bd505bd6fc92f8c04f526ebd3ccacec306371
2025-02-17 07:44:47 -08:00
Sergiu Deitsch 8ff216cef6 Add ReadTheDocs support
Mirror versioned documentation at https://ceres-solver.readthedocs.io.

Change-Id: I180e8fc32d05a0fa7dce09f77dbe38c5ca207420
2025-02-17 07:44:20 -08:00
Sergiu Deitsch fc3699d675 Cleanup Sphinx config
Change-Id: Iea63ec709fda82685c5f484d643627213cdc1496
2025-02-17 07:42:57 -08:00
Sergiu Deitsch 533bcfd694 Avoid incorrect member reference warning
Change-Id: I6f1b271c3a7b805dd4e539d0d44e2cbc626ef1f7
2025-02-17 07:41:21 -08:00
Sergiu Deitsch f86747f66d Remove unreferenced footnote
Change-Id: I6988ef4f0c6a98c7cbf44a45c3c11c81ab26466e
2025-02-17 11:20:54 +01:00
Sergiu Deitsch 018bb49e80 Use subsections instead of an enumeration for FAQs
Change-Id: I37c1256417240bf7decec1f756df8a8402f5c586
2025-02-16 15:35:49 -08:00
Sergiu Deitsch 80e466994b Fix FAQs spelling
Change-Id: I53f69875cc8e82e39602f0aae80e30d456c933c1
2025-02-16 15:35:04 -08:00
Sergiu Deitsch 3fb154795d Use console syntax highlighting for application output
Change-Id: I75c5a4bef55416e456528fde5485264c8c7545aa
2025-02-16 15:34:34 -08:00
Sergiu Deitsch d1c79cbd1c Fix docs indent
Change-Id: I4cc8bfb1883439cf91322e6383fb5107e31cc7d4
2025-02-16 15:34:04 -08:00
Sergiu Deitsch 32df9c52c3 Replace macos-12 runner by macos-15
The macos-12 runner is no longer available.

Change-Id: Ib559bf949f423d2bcc350686dbc829b72fe9a9bb
2025-02-16 16:59:40 +01:00
connorlee77 2c90a63af9 Add residuals and jacobian getters to TinySolver.
- Add methods to aceess the cached residuals and jacobian computed in
the optimization process in TinySolver. Usage of such methods will
retrieve the corresponding values associated with the converged
parameter.
- Reorder the Update() call to ensure that the jacobian/residuals
associated with the converged parameter are computed and cached.

Change-Id: If82e19d67d28b057833357f2c9a75b2d0fd139af
2025-02-11 21:07:58 +00:00
Sameer Agarwal c29b5257e2 Fix the Bazel build
Change-Id: I864c1a10e21a4d0e985262c61e7fd270da452d05
2024-09-29 13:44:55 -07:00
Sameer Agarwal 3db40b8013 Use std::string_view in EventLogger
Change-Id: If23504e146826f143220b031a5fbc2be2013d127
2024-09-29 09:43:26 -07:00
Sameer Agarwal 01a06ef7b1 Add an EventLogger to TrustRegionPreprocessor
Change-Id: I808567a6462f9326f385e88fdf2849537595ef7b
2024-09-28 13:19:09 -07:00
Reinhold Gschweicher a0dc19eb52 Fix Abseil usage of installed cmake-config
Fix the generated cmake-config file to look for the used Abseil-cpp
config files providing the needed targets.

When using Abseil from system (or locally installed and set via
`absl_DIR`) the used targets like `absl::log` need to be made available
in downstream projects using `ceres-solver`.

For system packages with no `absl_VERSION` info check for the required
target `absl::absl_vlog_is_on`, just like we do in `CMakeLists.txt`.

Error on installation/export of "no-absl-VERSION" as we can't check
version mismatches.

When using `abseil-cpp` as submodule the abseil-configs are added to the
install target as well. Use these config files to make the needed Abseil
targets available.

In the submodule case extract the `absl_VERSION` variable from its
`CMakeLists.txt` file for us to check against in the generated
cmake-config-file.

Fixes: https://github.com/ceres-solver/ceres-solver/issues/1089

Change-Id: I3e3d079ddf931e7fe1b57783471c32c19e4d31b6
2024-09-25 08:00:24 +02:00
Sameer Agarwal 8c740b83ee ClangTidy fixes
Change-Id: I8d1a0258fc586040bd1cb5cc6131fdad2fe134eb
2024-09-18 21:41:18 -07:00
Sameer Agarwal 42475eec77 Use absl::btree_map instead of std::map
Change-Id: Iece280a6cb0f37fa0bc572046b9d7f79ca825ebc
2024-09-17 12:18:31 -07:00
Sameer Agarwal dcce78b8df Add some time logging to bundle_adjuster.cc
Change-Id: I0deec65ec8d612a133748a242fe50d8e154f2704
2024-09-17 12:17:34 -07:00
Sergiu Deitsch e1385cc7e7 Fix MSVC build
Previously missed instance of preprocessor directives used in a macro
expansion.

Change-Id: I2f1e4ad95036851fa502a9ea01d2a9684a3e0f9d
2024-09-17 00:00:37 +02:00
Sameer Agarwal 39b7cbaa5d Use absl hash containers for graph algorithms
This reduces pre-processor time when finding an
ordering automatically substantially.

Before:

ComputeStableSchurOrdering
                                        Delta   Cumulative
              CreateHessianGraph :    0.50324      0.50324
                     Preordering :    0.00692      0.51017
            StableIndependentSet :    0.26341      0.77358
         ConstantParameterBlocks :    0.00095      0.77453
                           Total :    0.23978      1.01431

After:

ComputeStableSchurOrdering
                                        Delta   Cumulative
              CreateHessianGraph :    0.17183      0.17183
                     Preordering :    0.00226      0.17409
            StableIndependentSet :    0.12510      0.29919
         ConstantParameterBlocks :    0.00073      0.29991
                           Total :    0.01638      0.31629

Change-Id: I50bbac69f8b3f19240a61a218913cebf34da0db5
2024-09-16 21:51:54 +00:00
Sergiu Deitsch 00b33b6523 Fix MSVC build
Using preprocessor directives in a macro expansion is a (non-standard)
language extension that is not supported by MSVC.

Change-Id: I6e158b108a9c13cd277afb96cab2017ac192e3a2
2024-09-16 23:16:07 +02:00
Sameer Agarwal 0a7845fef4 Unbreak the build due to a silly typo
Change-Id: Ib05cb3ceeb974b1099bc7b090f77e109ddcd7166
2024-09-15 21:24:47 -07:00
Sameer Agarwal 88f2cb32cd ClangTidy fixes
Change-Id: I1f4d6975fd1b9629d1db0d529d9ee92d79c11e84
2024-09-15 20:12:27 -07:00
Sameer Agarwal c59882eca0 ClangTidy fixes
Change-Id: I421b29e218c045c5d8bef42c840fa366d7c011fc
2024-09-15 22:29:56 +00:00
Sameer Agarwal 793efde013 Fix Abseil version checking
Previously the find_package call was followed by a manual version
check because we were using a Major.Minor version. Just checking
for Major version works.

Change-Id: If83f8d1c6001d0ac3d53d9b24946b9168eb4932b
2024-09-15 15:13:13 -07:00
Sameer Agarwal 07651df0ad Partially update the installation docs
1. Update dependencies
2. Mention submodules

Change-Id: I2f238c92a3a1eeee3277e3ec6f973fc2d50fe008
2024-09-15 15:00:25 -07:00
Sameer Agarwal 8f1b6123ad GradientProblem & related classes use std::unique_ptr
Previously these classes in analogy with ceres::Problem's interface
had interfaces to allow bare pointers as well as unique_ptrs. This
CL changes the API to always use unique_ptr, this is less error prone
and makes the default ownership semantics clearer.

Change-Id: I7577a90761f341c7e009c248c820f0fec2e6f32d
2024-09-15 21:57:23 +00:00
Reinhold Gschweicher 487ce37fa7 Allow system/local Abseil master
Add special handling when `absl_VERSION` is empty. This is
the case when the `master` branch of `abseil-cpp` was installed using
`CMake`. In that case check for VLOG availability through the CMake
target `absl::absl_vlog_is_on`.

Fixes: https://github.com/ceres-solver/ceres-solver/issues/1098
Change-Id: I3367aeb65caceb11558d8d6265dafe3ecc9a4875
2024-09-11 08:06:36 +02:00
Sameer Agarwal 6aa7df9650 Reduce the minimum required version of Abseil
1. The required version of Abseil is now 20240116.0 instead of 20240116.2.
   This was an oversight. Thanks to @NeroBurner for pointing this out.
   Both CMake and Bazel builds are updated.

2. Unbreak the Bazel build which had become stale.

Change-Id: I274bbad2f94f7710387f9693de9c66b035758970
2024-09-09 08:48:58 -07:00
Ian Muldoon ea4400cd57 Update reference from Project Tango to ARCore
Change-Id: Idcba8afc980561bfc9444c375f573e388a53e85f
2024-09-05 10:23:05 -07:00
Sameer Agarwal ecae3de151 Fix a declaration order problem in sparse_cholesky_test.cc
Change-Id: Ie74069e8716145c244955bf907e2bae79f48972f
2024-08-26 16:57:17 +00:00
Sameer Agarwal 8964e52b01 ClangTidy fixes
Change-Id: Id7358fcdccae69b46b479d55ed6aee80efd3431e
2024-08-26 09:18:17 -07:00
Sameer Agarwal 80fce72bfd Add mixed precision solves for SUITE_SPARSE
Starting with SuiteSparse version 7.4.0 CHOLMOD has support for single
precision matrices. This allows us to have single precision and mixed
precision solves when using the SUITE_SPARSE backend.

This CL also fixes sparse_cholesky_test which was completely broken for
single precision testing.

Sample performance on my Mac.
/usr/bin/time -l ./bin/bundle_adjuster --input=../../Downloads/problem-3068-310854-pre.txt
<SNIP>

Cost:
Initial                          9.099334e+07
Final                            4.161838e+06
Change                           8.683150e+07

Minimizer iterations                        6
Successful steps                            4
Unsuccessful steps                          2

Time (in seconds):
Preprocessor                         2.528222

  Residual only evaluation           0.142804 (5)
  Jacobian & residual evaluation     0.424014 (4)
  Linear solver                     54.083396 (5)
Minimizer                           54.895752

Postprocessor                        0.024564
Total                               57.448539

Termination:                   NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 5.)

       59.04 real       341.24 user         5.49 sys
          5776375808  maximum resident set size
<SNIP>
        616329634071  instructions retired
        929475980510  cycles elapsed
          5375034560  peak memory footprint

/usr/bin/time -l ./bin/bundle_adjuster --input=../../Downloads/problem-3068-310854-pre.txt  -mixed_precision_solves
<SNIP>

Cost:
Initial                          9.099334e+07
Final                            4.148930e+06
Change                           8.684441e+07

Minimizer iterations                        6
Successful steps                            4
Unsuccessful steps                          2

Time (in seconds):
Preprocessor                         2.580217

  Residual only evaluation           0.144098 (5)
  Jacobian & residual evaluation     0.396723 (4)
  Linear solver                     23.636074 (5)
Minimizer                           24.427163

Postprocessor                        0.023790
Total                               27.031170

Termination:                   NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 5.)

       28.58 real       128.53 user         2.37 sys
          4818386944  maximum resident set size
<SNIP>
        395186936091  instructions retired
        368802808856  cycles elapsed
          4327029824  peak memory footprint

Change-Id: I1f137b0dd12da8da7f9ced338dd8f20f4bbdf99d
2024-08-24 21:12:54 -07:00
Sameer Agarwal 8f85014dcf Change the version from 2.2.0 to 2.3.0
The dependencies and the API have changed enough that
it is worth incrementing the version number.

Change-Id: I4e2911a91988d97f47320c56072ad1546e20030b
2024-08-24 09:29:51 -07:00
Sameer Agarwal 9186dcc49c Add the ability to use system installed versions of abseil and googletest
If the user has checked out the submodules in third_party, they will be
used, otherwise we will try and find the system installed versions of
these dependencies and use them if they are modern enough.

Change-Id: I52164bc48a6ea804b85cdda05fee9cb94632f6c0
2024-08-14 21:16:57 -07:00
Sameer Agarwal 6726cd5073 Fix absl::log_flags linking on Linux
Generator expressions were introduced in CMake version 3.24. Without
them including absl::log_flags as an internal dependency causes
linking problems on some platforms. So for platforms with an older
CMake version we make absl::log_flags a public dependency.

Change-Id: I686f41e76b0ac17a03f1cd1d614372a7f130dfd9
2024-08-12 07:06:34 -07:00