2283 Commits

Author SHA1 Message Date
Laurenz fe351d5ab8 Load cc_library from rules_cc
In Bazel 9+ all rulesets have to be explicitly loaded from external
modules.

See
https://blog.bazel.build/2026/01/20/bazel-9.html#:~:text=In%208.0%2C%20we,flag%20in%2010.0.

Change-Id: Ib55d32ea9e935cc5ed0c304a1eed972b3b12b833
2026-08-19 14:29:25 +02:00
Sergiu Deitsch 0b03102b09 Add CMake feature and dependency summary
Use CMake's standard package discovery output and FeatureSummary instead
of custom status messages, so configuration reports package
availability, versions, and failure reasons consistently. Rename Ceres
feature controls to use the WITH_ prefix to group them consistently and
eliminate inconcistent naming. Remove retrospective cache updates so
package discovery preserves caller-provided values and avoids
unnecessary side effects.

Fixes #876

Change-Id: Ib6e40d56a0ea89b292fe34554777593ffda95f42
2026-08-10 00:51:27 +02:00
Sergiu Deitsch 2017abdf9e Fix bundle adjuster perturbation assertions
Avoid debug-mode assertions from zero width normal distributions when
optional perturbations are disabled.

Change-Id: Ic078482a5f845ba3095ba4389a1bcdadf426944e
2026-08-02 16:17:23 -07:00
Sameer Agarwal 611adf7201 Replace --extended-lambda with --expt-extended-lambda for NVCC (fixes #1188)
Change-Id: I82e95145abad58dae9ae7ddee458a951393b63d8
2026-08-02 16:00:46 -07:00
Sameer Agarwal c40331e599 Expose Hopper (sm_90) support only for CUDA 12.0 and later (fixes #1165)
Change-Id: I1e0fdbabdd866494051ed21b7c456ece82a4d6a3
2026-08-02 16:00:01 -07:00
Sergiu Deitsch 06de7240c4 Restore quaternion group action
Commit 370631f01f rescaled the quaternion
manifold's group action so the tangent vector norm matches the full
rotation angle, addressing issue #941. While both conventions are
mathematically valid, issue #311 already concluded that the half-angle
one should be kept because too much code depends on it. The rescaling
effectively broke that expectation for existing callers.

Restore the pre-370631f01f71db36b580e5a65790b2a8d9559821 scaling, keep
the rest of that commit's cleanup, and update the documentation and
tests to match.

Fixes #1190

Change-Id: I1dd189c51153ed62cc8c871472aacb87673ec351
2026-07-31 21:00:38 +02:00
Sergiu Deitsch 76b431ef04 Default SUITESPARSE to OFF due to GPL licensing
Ceres requires the CHOLMOD supernodal factorization and SPQR components
of SuiteSparse, which are only available under GPL or commercial terms.
Because SuiteSparse was previously autodetected and linked whenever
present, a default build could silently become GPL licensed without the
user choosing that outcome.

Make SuiteSparse support opt-in by defaulting SUITESPARSE to OFF,
document the licensing implications in the installation guide.

Fixes #1026

Change-Id: I1cfb2148b830a72fa18caadcff76f35a50aeb179
2026-07-31 19:19:29 +02:00
Sergiu Deitsch 849f854ff9 Clarify building from Git sources
Explain that release archive directory names in the installation guide
must be replaced with the actual Git checkout directory.

Fixes #1209

Change-Id: I66f2246aacd3b5223dcc3792c2cf4670cd6248c5
2026-07-28 01:03:39 +02:00
Sergiu Deitsch cb02fa2f7b Correct Visual Studio 17 2022 Github workflow runner
Change-Id: I00d55fcd312eab5f8de64e92d9aecee517a5897c
2026-07-27 21:34:08 +02:00
reprojection.calibration bac1127f9e Update GradientChecker docs
* Use GradientChecker::ProbeResults instead of GradientCheckResults
* Add missing parenthesis in if statement

Change-Id: I900608eb806753ec8f42c09d395fa3b93f012e76
2026-06-23 11:46:15 +02:00
Ben Hamilton 8a566fcc15 Add support for cuDSS 0.8
cuDSS 0.8 replaced cudaDataType_t with its own cudssDataType_t enum in
the matrix creation APIs, and cudssMatrixCreateCsr() gained a separate
parameter for the type of the row offsets. Select the appropriate enum
type and pass the additional argument based on CUDSS_VERSION, so that
the code compiles against both cuDSS 0.7 and 0.8. Also report the new
CUDSS_STATUS_IR_FAILED status added in 0.8.

Fixes https://github.com/ceres-solver/ceres-solver/issues/1203
Refs SW-8464

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Change-Id: Ibf36261bd814f0f50e08caa5cf9391810a51540f
2026-06-09 14:18:17 -06:00
Sameer Agarwal 0ba987acaf Fix an initialization order error in cuda_sparse_cholesky.cc
Change-Id: I8d6f4d10f7ec5585f00b8324a21f325f353e88e5
2026-05-01 14:31:18 -07:00
Pez Firoozfam 806af056fe Add support for maximum matrix sizes to TinySolver.
This change restructures the `TinySolver` template and its associated
adapters (`AutoDiff` and `CostFunction`) to make maximum sizing
attributes first-class parameters. This enables the entire `TinySolver`
stack to be used in restricted environments (e.g., small MCUs) without
dynamic memory allocation, even when the number of residuals or
parameters is only known at runtime (`Eigen::Dynamic`).

Specifically:
- Adds `kMaxResiduals` and `kMaxParameters` template parameters to
  `TinySolver`.
- Updated `TinySolverAutoDiffFunction` and
  `TinySolverCostFunctionAdapter` to support optional maximum size
  template parameters for their internal buffers.
- The new API maintains backward compatibility for existing users by
  defaulting to the sizes defined in the `Function`'s enums.
- This structure also supports reducing code bloat by allowing
  `TinySolver` to be instantiated with an abstract base class, using
  dynamic dispatch for cost function evaluation.

New test cases for `TinySolver` and its adapters verify the
zero-allocation behavior and the unified API flexibility.

Change-Id: Ic6f43984d384dbe71472b31c5ebd2b538d61f19d
2026-04-07 23:16:48 -07:00
Sameer Agarwal 41958f3fcc [modernize] Fix StringTo... casing, duplicate declaration, and internal header guard
- Correct casing of StringToLoggingType and StringToDumpFormatType for
  consistency with the rest of the API.
- Fix a bug in include/ceres/types.h where StringToDumpFormatType was
  incorrectly declared with a LoggingType* argument.
- Update the header guard in internal/ceres/problem_impl.h to use the
  CERES_INTERNAL_ prefix instead of CERES_PUBLIC_.

Change-Id: Ia28c01e368e839043251594e0b11ba1c17ee4483
2026-04-05 21:09:08 -07:00
Sameer Agarwal 4a60fb8b52 ClangTidy fixes
Change-Id: I7559a1ec2d236ae71f10a3400aa0c8485cbc2928
2026-04-01 07:48:28 -07:00
Sameer Agarwal 2b9a2d77c3 Modernize include/ceres headers to C++17 and Abseil conventions
- include/ceres/autodiff_manifold.h: Replace manual zero-initialization loops with value-initialization ({}) in PlusJacobian and MinusJacobian.
- include/ceres/dynamic_numeric_diff_cost_function.h: Replace std::vector with absl::FixedArray for temporary evaluation buffers and use std::copy_n instead of memcpy in Evaluate.
- include/ceres/numeric_diff_cost_function.h: Replace memcpy with std::copy_n in Evaluate.

Change-Id: I13b546458185d9fdd22b086094ca1072c57c40ed
2026-03-28 08:23:01 -07:00
Sameer Agarwal ea4de24c2e Modernize ParameterBlock::Plus with std::clamp
Use std::clamp for projecting the updated parameter state onto its
box constraints. This provides a more idiomatic and concise
implementation than separate std::min/std::max loops, especially
when both lower and upper bounds are present.

Change-Id: I1f6248ed8f0313338cf9a1c98d79a023ae281e6c
2026-03-23 11:48:42 -07:00
Sameer Agarwal 87c406d9d0 Modernize InvertPSDMatrix with if constexpr
Use if constexpr for kSize checks in InvertPSDMatrix to allow for
dead-code elimination at compile time. This ensures that for small
fixed-size matrices, only the inverse() path is compiled, and for
larger or dynamic matrices, only the LLT path is compiled when
assume_full_rank is true.

Change-Id: I4def2faadd080a4defccf1c0527015ae004f20ce
2026-03-23 11:42:24 -07:00
Sameer Agarwal 2f946a582a [modernize] Modernize internal autodiff and numeric_diff logic
Refactor the core automatic and numeric differentiation internal helpers
to utilize C++17 features for improved readability and maintainability:

- Added IntegerSequenceTraits to provide a uniform compile-time interface
  for accessing head and tail of std::integer_sequence.
- Eliminated recursive template meta-programming in autodiff.h, replacing
  it with fold expressions and std::index_sequence.
- Simplified core helper functions like Make1stOrderPerturbation into
  unrolled loops.
- Refactored EvaluateJacobianForParameterBlocks from a recursive struct
  to a recursive function template using if constexpr.
- Updated NumericDiffCostFunction and NumericDiffFirstOrderFunction
  to use the modernized internal helper API.

Change-Id: I934034f7434fc05a8855565b2b534d325f920584
2026-03-22 12:06:15 -07:00
Sameer Agarwal 3d1b494dce Modernize CostFunction and FirstOrderFunction constructors
- Add constructors taking std::unique_ptr and ceres::Ownership to
  AutoDiffCostFunction, NumericDiffCostFunction, and their dynamic
  and first-order counterparts.
- Standardize delegating constructor style to use parentheses.
- Standardize ownership check in destructors.
- Fix documentation typos and example code in headers.
- Add comprehensive tests for Ownership and unique_ptr constructors.

Change-Id: I573abd695cdd89905997b573620e8d99d1cacca2
2026-03-22 11:30:14 -07:00
Sameer Agarwal 3abe9326f1 [modernize] Modernize ProductManifold using fold expressions
Modernize ProductManifold using C++17 fold expressions and std::index_sequence
to replace recursive implementations of Plus, Minus, and their Jacobians.
This simplifies the code, removes the need for auxiliary recursive ...Impl
methods, and improves index handling by using std::get<I> instead of
pointer arithmetic.

Change-Id: I28498216d8daae7485c382140613fd85519fa42c
2026-03-22 10:25:18 -07:00
Sameer Agarwal bcbaff6656 [modernize] Modernize AutoDiff and NumericDiff CostFunctions to C++17
Modernize the construction and initialization logic of AutoDiffCostFunction,
NumericDiffCostFunction, AutoDiffFirstOrderFunction,
NumericDiffFirstOrderFunction, DynamicAutoDiffCostFunction,
DynamicNumericDiffCostFunction, and CostFunctionToFunctor by utilizing
C++17 features:

- Simplify constructor delegation using if constexpr, removing the need for
  internal InitTag structures.
- Use std::is_constructible_v for cleaner SFINAE in variadic constructors.
- Add static_assert to catch improper usage of DYNAMIC residuals/parameters
  at compile-time.
- Add Ownership support to AutoDiffFirstOrderFunction,
  DynamicAutoDiffCostFunction, and DynamicNumericDiffCostFunction.
- Simplify CostFunctionToFunctor::operator() using variadic parameter packs.
- Use this->num_residuals() for consistent and clear access to base class
  state.
- Minor code quality improvements and removal of redundant template
  parameters.

Change-Id: Id760a26ba2ceca4fb2939ef7632f2f1d9cc430c9
2026-03-18 17:25:41 -07:00
Sameer Agarwal ae3f2e8683 [modernize] Use std::is_scalar_v in jet_traits.h
Change-Id: Iace518cd4b32b96cf7b7adb64b7695064ae1d04d
2026-03-17 16:48:07 -07:00
Sameer Agarwal a694c64765 [modernize] Unify VariadicEvaluate using C++17 std::apply
Change-Id: Iaf8ced8c2b937cb3c503e677adb96be32d6eace8
2026-03-17 14:03:21 -07:00
Sameer Agarwal b25fe07f16 [modernize] Refactor NumericDiff to use if constexpr recursion
Change-Id: I54ad1cec6924e4f4b5275056df7496c2e226f244
2026-03-17 12:44:16 -07:00
Sameer Agarwal bda3823b75 [modernize] Use if constexpr and std::clamp in TinySolver
Change-Id: I4218bfea314a2438cceb7eaf49a2ec921aaa3e45
2026-03-17 12:42:39 -07:00
Sameer Agarwal 188fe7bf4d [modernize] Use inline constexpr in parameter_dims.h
Change-Id: I493843d5be30c512a69fc517c5622c48faa63088
2026-03-17 12:42:00 -07:00
Sameer Agarwal 532ad49568 [modernize] Use std::clamp and C++17 headers in cubic_interpolation.h
Change-Id: Ief7ff6555aeb3d3be83e999d777160b3c7c1bb9b
2026-03-17 12:39:50 -07:00
Sameer Agarwal 4390b34d5b [modernize] Use if constexpr in EuclideanManifold constructor
Change-Id: I61d4827d7b04feed369c72db3643afda67ea434e
2026-03-17 12:39:05 -07:00
Sameer Agarwal 4bd55bd44c [modernize] Convert kImpossibleValue to inline constexpr in types.h
Change-Id: Ide561296f1bbcc244dd655cf229d08582281b234
2026-03-17 12:31:19 -07:00
Sameer Agarwal ccd1198d72 Make test_util GTest-optional to fix benchmark builds with BUILD_TESTING=OFF
When Ceres is configured with BUILD_TESTING=OFF and BUILD_BENCHMARKS=ON,
benchmarks failed to compile and link due to an unconditional dependency on the
test_util library, which requires Googletest (GTest). This commit addresses the issue
by introducing the CERES_HAS_GTEST macro and making the test utility library
GTest-optional.

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

Change-Id: I615c37eb6f21d36a4b87b2d24632016944eda3bd
2026-03-16 16:19:06 -07:00
Johannes Schönberger 084b3e3b83 Apply deterministic parameter block reordering
Change-Id: I0dc58ce754225310ff1a170cec8a3c71a402df57
2026-02-25 14:19:40 -08:00
Sergiu Deitsch a2bab5af51 Fix ODR violations
Compiling Ceres with Schur specializations and Link Time Optimization
(LTO) results in warnings such as

    /usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:31:8: warning: type ‘struct evaluator’ violates the C++ One Definition Rule [-Wodr]
       31 | struct evaluator<Product<Lhs, Rhs, Options>> : public product_evaluator<Product<Lhs, Rhs, Options>> {
          |        ^

due to the redefinition of EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD which
alters internal Eigen class definitions and consequently results in ODR
violations.

Avoid the ODR violation by renaming the Eigen namespace in translation
units that redefine EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD.

While the issue is diagnosed in LTO builds of Ceres only, the problem
exists in non-LTO builds as well and per standard the compiler is not
even required to diagnose ODR issues. ODR violations constitute
undefined behavior.

Change-Id: Idf7c7a30cc8d3a86b0d62cbd33bef58783a62ee4
2026-02-17 10:14:21 -08:00
Sergiu Deitsch de96ed58f5 Eliminate benchmark deprecation warnings
Resolve the following warnings issue by the latest version of the
benchmark library:

/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/small_blas_gemv_benchmark.cc:71:54: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
   71 | static void MatrixSizeArguments(benchmark::internal::Benchmark* benchmark) {
      |

/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/dense_linear_solver_benchmark.cc:67:46: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
   67 | static void MatrixSizes(benchmark::internal::Benchmark* b) {
      |

/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/invert_psd_matrix_benchmark.cc:80:37: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
   80 |     ->Apply([](benchmark::internal::Benchmark* benchmark) {
      |

Change-Id: Ice6fe57dc5635698809e368fda23a018f4d7df5a
2026-02-01 08:24:16 -08:00
Sergiu Deitsch 18887f1bd7 Drop removed macos-13 runner
Change-Id: I7f37bb2f71324353a45e39d12792edabfb3956b7
2026-02-01 15:58:57 +01:00
brettmichaelgreen 0c70ed3a1a Document DumpLinearLeastSquaresProblem
Add documentation on the output of DumpLinearLeastSquaresProblem.
This is to clarify confusion brought up on #608

Change-Id: I935cacee1e4345a1d0250aaac322ca2f8e794e66
2025-11-08 15:56:10 -05:00
Sameer Agarwal 345357a952 ClangTidy cleanup
Change-Id: I5b619f3966dfb988f09cc412def649f3d2868808
2025-10-30 17:34:39 -07:00
Sameer Agarwal 4a3f008e6a Fix a bug in inner iterations
Normally we expect it to be the case that inner iteration cost
will be less than the trust region cost, but due to round off
error it can be that it is larger, so make the test for inner
iteration being successful to be stricter.

Change-Id: Icbafe9fc6a311940d5368cca78eeac7ccd5fa943
2025-10-26 18:20:45 -07:00
Sergiu Deitsch f9b7b6651b Support Eigen3 5.0.0
Change-Id: I5cf476a6d8c090861f4ea4a254a35d39e36a6d68
2025-09-28 11:53:07 -07:00
Sergiu Deitsch 77d7044d23 Do not rely on a define for disabling warnings
Using a define to determine whether to disable warnings introduces a
dependency on the header inclusion order and thus can prevent the
warnings from being enabled.

Fixes #1173

Change-Id: I21f5bca78a83bfe4642e9b01abd220b9fbba31a4
2025-09-28 11:50:21 -07:00
Sergiu Deitsch d4e3ba3173 Ensure consistent visibility attributes
Change-Id: Ib80d655a3601a716956bbd2b977d295a809307c1
2025-09-28 11:49:17 -07:00
Sergiu Deitsch 6f00e41111 Reuse constants
Change-Id: I306da23d26667e801cfa4fb12306cdd92af09a65
2025-09-28 18:04:54 +02:00
Sergiu Deitsch 93e66f0d94 Fixed discrepancy in QuaternionRotatePoint for different orders
Fixes #1178

Change-Id: I0430ffb384ea53a863ba72f076043f0f772db4e1
2025-08-17 10:52:12 +02:00
Sergiu Deitsch 4997d0e5b4 Drop removed windows-2019 runner
Change-Id: I75b52ce778f6e74832dbfaf9dc35a99e28c9b51a
2025-08-17 10:51:26 +02:00
Sameer Agarwal b92ade3e11 Reorder the fields in ParameterBlock
This CL reorders the fields to group the hot fields together to increase data density. This CL doesn’t change functionality but expects to reduce cache misses and save CPU.

Change-Id: I313493a187ac6ebc607b311c39415c79a94f00c8
2025-08-13 15:02:50 -07:00
Mackay f616f61eab Update CMakeLists.txt to support CUDA 13
Change-Id: I4a0a0b29a45c1108d27b6f85670c926f5dda0f5e
2025-08-06 21:36:12 -04:00
Johannes Bruenger bae3cf781d Fix typo in logged warning
Change-Id: Ibf74392b26cbe01bf7ba898491b4442cbdef8b57
2025-08-04 20:11:55 +02:00
Matt Vitelli c380195d31 Fix threading bug in CovarianceImpl.
This change fixes a bug in ceres::CovarianceImpl where a new thread was always being created even when num_threads=1. After this fix, when num_threads=1, CovarianceImpl should run single-threaded and will not create any additional threads.

Change-Id: I784e359f8afe3e7e6d72930500a10e909bfe9308
2025-07-31 23:00:36 -07:00
Sergiu Deitsch 8c50a34a1c Reuse rotation functionality in (Eigen)QuaternionManifold
Allow to specify the memory layout of quaternion coefficients using a
template parameter which defaults to Ceres coefficients order.

The changes are, for the most part, backwards compatible unless the
floating-point type is explicitly specified, e.g., as
&ceres::QuaternionToAngleAxis<double> to obtain a pointer to the
corresponding function. In such rare use cases, the coefficients order
must be given explicitly first as
ceres::QuaternionToAngleAxis<ceres::CeresQuaternionOrder>. In normal
situations, however, this should not be needed.

Change-Id: I05dd80f0593672dec656cc785cf06fe5268aee74
2025-06-19 18:15:51 +02:00
Sergiu Deitsch 370631f01f Use Euler parameters in QuaternionPlusImpl
Define the relation between the axis-angle representation of a rotation
and the corresponding unit quaternion as

  q(𝐞) = cos(𝜃/2) + sin(𝜃/2)/𝜃·𝐞

where 𝐞 = 𝜃𝛚 is the rotation vector given by the rotation angle 𝜃 and
the unit axis of rotation 𝛚 instead of

  q(𝐞) = cos(𝜃) + sin(𝜃)/𝜃·𝐞 .

This brings the former relation closer to the available functionality
provided by ceres/rotation.h.

Fixes #941

Change-Id: Id40c065f78593887ecc52e67a068737d7eb5bda6
2025-06-13 16:23:24 -07:00