Commit Graph

1727 Commits

Author SHA1 Message Date
Sameer Agarwal c0cb42e5f9 Add Problem::HasParameterization
This will help the transition from LocalParameterization to Manifolds,
since most uses of Problem::GetParameterization is to just check
whether a parameter block has a local parameterization associated
with it or not.

Change-Id: Ib3539f377eaed853d7542c9844ec1487aa0fb4d6
2022-01-11 21:05:56 -08:00
Sameer Agarwal 7e2f9d9d41 Add EigenQuaternion manifold and tests for it.
Change-Id: I579a45a2921424a07d03b3b4d9cfcbc0ab529f9b
2022-01-11 14:40:21 -08:00
Sameer Agarwal b81a8bbb7a Add the Quaternion manifold and tests.
Change-Id: I0a396a5834168c1526d6f2b8c99a1ad3348ad657
2022-01-07 04:59:02 -08:00
Sameer Agarwal 4a01dcb887 Add more invariants and documentation to manifold_test.cc
Change-Id: I62e040679cc4fd4c5a7486885ebb4ad1a08b7b45
2022-01-06 09:50:30 -08:00
Sameer Agarwal bdd80fcce8 Improve Manifold testing
1. Increase number of trials.
2. Make all the matchers per point.
3. Add matchers for delta = 0.
4. Add a macro which invokes all the matchers, reducing boilerplate

Change-Id: Ia1bf110323c5877a1b92aef34c12c39008256f05
2022-01-05 13:06:30 -08:00
Sameer Agarwal ce1537030b Fixed missing headers in manifold.h
https://github.com/ceres-solver/ceres-solver/issues/739

Change-Id: Ia4079b025c53f75abb7145a4b8f5eacaddf8fc67
2021-12-30 12:16:43 -08:00
Sameer Agarwal 23b204d7e6 LocalParameterization -> Manifold #1
This is the first in a series of changes that will eventually
replace the LocalParameterization interface with the richer
Manifold interface.

1. Add the Manifold interface.
2. Add implementations and test for:
   a. EuclideanManifold (formerly the IdentityParameterization)
   b. SubsetManifold (formerly the SubsetParameterization)
   c. ProductManifold (formerly the ProductParameterization)

The testing has been completely re-done, where instead of adhoc
testing, we now define a number of matchers which explicitly
enforce the invariants demanded by the Manifold interface.

Change-Id: I3f296d0964388d52b027c99dc86b7730d24d55fa
2021-12-29 17:27:28 -08:00
Alex Stewart c2fab6502e Fix docs of supported sparse backends for mixed_precision_solves option
- Also adds documentation of mixed precision solves to Sphinx docs.
- Fix reference to Sphinx theme used (RTD not better).
- Fix NOTE syntax in use_explicit_schur_complement Sphinx docs.

Change-Id: I7bdac0f07eb737f49b05e3fcaa3eebd087355d2d
2021-12-15 20:58:47 +00:00
Alex Stewart 8cb441c49a Fix missing declaration warnings in GCC
- Follow up to commit https://github.com/ceres-solver/ceres-solver/commit/54ba6c27b504f43b59b0d91da0165995c66d9a3d
  which enabled -Wmissing-declarations and fixed all previous
  infractions.

Change-Id: Ia10b49b4c9bc12c0f7bec2b8c0706f38be18f1dc
2021-12-15 18:20:14 +00:00
Sameer Agarwal d2b7f337ce Remove split.cc from the bazel sources.
Change-Id: I15eb78eaccabb3c00610b3d8bfcb22a6156105df
2021-12-14 11:58:58 -08:00
Sameer Agarwal 206061a6ba Use standard c++ types in jet_test.cc
Change-Id: I8fb91bf04626eba1ceda676dc6564b9798d6a4a9
2021-11-30 11:26:18 -08:00
Sergiu Deitsch 1f374a9fe5 Support promotion in comparison between Jet and scalars
Previously, Jet did not allow comparison between its value and a scalar
of another type. Specifically, the comparison was limited to scalars of
the same type effectively disabling standard promotion rules. Instead,
users would be required either to cast values to target Jet arithmetic
type or explicitly construct a Jet instance that can be eventually used
for comparison purposes.

However, such a behavior is not intuitive and causes problems with types
that rely on standard promotion rules (e.g., std::complex in some
implementations).

This changeset extends the comparison operators by enabling logical
comparisons between a Jet and values compatible to the underlying scalar
type (e.g., int). To be as generic as possible, the types allowed to be
passed to comparison operators are constrained using SFINAE. This in
turn allows a recursive expansion of jets and therefore the comparison
of a nested jets with a scalar.

The changes alleviate problems described in #414 and also allow the use
of special functions from Boost.Math, e.g., for computing the reciprocal
using boost::math::pow<-1>(...).

Change-Id: I3625791e6c8c2c0bfbffbbdb09e179a32e57f306
2021-11-29 21:33:28 +01:00
Sergiu Deitsch 06e68dbc5a Avoid midpoint overflow in the differential
Change-Id: I8c75a819db33f4105e62942cddc83b2653318169
2021-11-28 01:04:27 +01:00
Sergiu Deitsch 276d24c73a Fix C++20 compilation
Several std::allocator<> members were deprecated in C++17 and
subsequently removed in C++20. Drop deprecated members altogether since
these are unused anyway.

Change-Id: Ic26471a4b1cb3ccc1fdf3231400c81827b0ff712
2021-11-27 02:05:39 +01:00
Sergiu Deitsch b1391e0625 Support midpoint Jet
Provide autodiff support for C++20 std::midpoint if the standard is
active.

Change-Id: I1308a1e514bef4c74f08f655cbf803fa43503ce5
2021-11-25 21:14:32 +01:00
Sergiu Deitsch 8426526dff Support lerp Jet
Provide autodiff support for C++20 std::lerp if the standard is active.

Change-Id: I04ef6f17c707dd5f8ac426d9127b221e17aa08d6
2021-11-25 21:02:25 +01:00
Sergiu Deitsch 57c2796890 support 3-argument hypot jet
C++17 provides a three argument hypot(x, y, z) which can now be used
for jets if the standard is active.

Change-Id: Ide62e101f780fe738bb2d4f826b10daf94c585b3
2021-11-22 17:26:01 +01:00
Sameer Agarwal 123fba61cf Eigen::MappedSparseMatrix -> Eigen::Map<Eigen::SparseMatrix>
Eigen::MappedSparseMatrix has been deprecated and removed from
Eigen at HEAD.

Thanks to rmlarsen@ for fixing this.

Change-Id: I34f3b0dda2bb91ee8cc65a20e53a3d7de6929221
2021-11-21 10:33:23 -08:00
Sergiu Deitsch 3f950c66d8 reworked copysign tests
Zero sign propagation is not always guaranteed. Replace signbit checks
by checks for -nan and +nan sign.

Change-Id: If2ba367e4116d4e6a008a83cf2bc6a8851b27af7
2021-11-19 11:17:51 +01:00
Sergiu Deitsch 48cb54d1b2 fix fmin and fmax NaN handling
fmin and fmax do not handle NaNs correctly. Also, the comparison
operator for floating-point numbers may raise FE_INVALID if one of the
arguments is NaN. Both functions, however, are not subject to any of the
error conditions specified by the error handling for related
floating-point operators and functions.

Change-Id: Ic6bb65f18568066dba3c739a2df06f5fc3131a80
2021-11-19 03:13:56 +00:00
Sergiu Deitsch 552a4e5170 support log10 jet
Change-Id: I1425f7c8fc891cf941a162b8e5b427b5ab4e71da
2021-11-18 23:11:31 +01:00
Sergiu Deitsch 4e49c54223 reuse expm1 result for differential
We can reuse the expm1 result to compute the differential and eliminate
the extra exp call.

Change-Id: Ibd4f0564ab6da99fc23fbf6462408cfc3408fda1
2021-11-18 19:21:40 +01:00
Alex Stewart 8d3e64dd5e Use modern-style Eigen3 CMake variables
Change-Id: I4c14aa54552b3f718dff90eb397cb030aeb6ecd4
2021-11-16 19:51:06 +00:00
Sergiu Deitsch 2fba61434b support log1p and expm1 jet
Currently, it is not possible to accurately evaluate the derivative of
d/dx log(1 + x) under all circumstances and significant deviations from
the actual derivative d/dx log1p(x) can occur. This changeset introduces
the necessary Jet overload and its inverse, expm1.

Change-Id: Ifcf88f6d684f61ba86bbe49f0d551b703f34ad0d
2021-11-16 00:14:39 +01:00
Sergiu Deitsch a668cabbcf support norm jet
norm allows to compute the squared magnitude both of complex and real
numbers. While Jet does not support decaying of a std::complex to a
scalar performed by norm, the function is still useful when applied to
scalars alone for computing the square.

Change-Id: I27a3513f53f37fb3960411362e80d170d1ae6f74
2021-11-15 22:29:44 +00:00
Sergiu Deitsch a3a4b6d77f support copysign jet
libc++ (default on macOS) uses the copysign function for std::complex
multiplication which causes compilation errors such as these if
std::complex is combined with jets:

/Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:607:19: error: no matching function for call to 'copysign'
            __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
                  ^~~~~~~~
foo.hpp:218:39: note: in instantiation of function template specialization 'std::__1::operator*<ceres::Jet<double, 3> >' requested here
    std::complex<Scalar> result = lhs * rhs;

copysign is also useful in other situations where the sign is required
allowing it to compute without branching.

Change-Id: I84b2d23374f1bf3bae32833016bb686d97d74054
2021-11-15 23:27:33 +01:00
Sergiu Deitsch b75dac1694 fix abs jet test comment
The comment suggests a non-existing (incorrect) test. Update the comment
and extend the test.

Change-Id: I362f0b5a2e81d286b672476bdb4394ed20263eb1
2021-11-15 18:34:34 +00:00
Sergiu Deitsch 034bf566f0 use copysign for abs jet
abs() implementation does not correctly handle the sign of the
infinitesimal part when the value is a NaN. Define the function in terms
of copysign which is the only portable way of manipulating the sign of
a NaN value.

Change-Id: I2f13fb1db62d35ca8b09e6bff1c05a736cb91513
2021-11-14 17:07:14 +01:00
Dmitriy Korchemkin 31008453fe Add example for BiCubicInterpolator
Add example of BiCubicInterpolator usage, for both analytic and
automatic differentiation

Change-Id: I2e52bec5e0721a21a789e714a126ea24b1c0ce8b
2021-10-06 20:26:18 +03:00
Sameer Agarwal 7ef4a12218 Add a section on implicit and inverse function theorems
Change-Id: I0e6c7d2850a33d03aa629579f049ad44a7618621
2021-10-01 12:05:06 -07:00
Sameer Agarwal 686428f5cd Move the further reading section to bibliography
Change-Id: I673e74587486cdf5f91a146605dafa8fc2df6ee6
2021-09-24 05:44:45 -07:00
Sameer Agarwal e47d87fdd6 Add a note about Trigg's correction
Add a pointer about how the theory and practice of Trigg's correction
for loss function differs when the second derivative of the loss
function becomes positive.

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

Change-Id: Ic22ce91cc230f7ed7fa7b70a1cc2050919039828
2021-09-24 05:02:40 -07:00
Sameer Agarwal d2852518d6 Fix the docs for Problem::RemoveResidualBlock & Problem::RemoveParameterBlock
The documentation was out of date about how memory management is
done in Problem.

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

Change-Id: Ie55027796bc372cdcbaaca2bf2c93643c303a8e5
2021-09-23 09:32:11 -07:00
Sameer Agarwal 06e02a1735 Delete unused files split.h/cc
Change-Id: I67a4542389a0c1162875975efd23cdfbe797c6bc
2021-09-18 06:10:26 -07:00
Sameer Agarwal ac7268da52 Fix an 80cols issue in covariance_impl.cc
Change-Id: I2422282919e7100ac852be2176cd754941a8b472
2021-09-15 06:22:29 -07:00
Sameer Agarwal 17dccef91b Add NumericDiffFirstOrderFunction
This has been a long requested feature so that users can minimize
functions using numeric differentiation.

As part of this, I have also redone rosenbrock.cc, which now has three
variants.

rosenbrock.cc now uses automatic differentiation.
rosenbrock_numeric_diff.cc uses numeric differentiation.
rosenbrock_analytic_diff.cc uses analytic derivatives.

This is analogus to how the helloworld example code is structured.

The tutorial for GradientProblemSolver has also been updated to reflect
this.

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

Change-Id: Ib0fb9e35127fe4c8299d4793bea3558722c70dd7
2021-09-15 06:21:02 -07:00
Sameer Agarwal 03d64141ae Fix a incorrect check in reorder_program.cc
Thanks to William Gandler for pointing this out.

Change-Id: I7a4e0eebd2e557f7572df7455d7fa77527c087b6
2021-09-14 17:36:07 -07:00
Sameer Agarwal 8841119134 Two changes to TinySolver
1. Add function_tolerance based termination, updating the
   termination logic to be in line with Ceres.
2. Replace the use of "error" with "residuals" in the code.

Change-Id: I3fd543f3a8226fe7f07eeec358559cba934679b2
2021-09-14 16:33:34 -07:00
Sameer Agarwal 4dff3ea2c4 Fix a number of typos in rotation.h
Thanks to @yiping for reporting these.
https://github.com/ceres-solver/ceres-solver/issues/672

Change-Id: I9c59d2b666430edf33f10aaba0d0ee4cd520e0a4
2021-09-13 17:19:49 -07:00
Sameer Agarwal 98719ced43 Fix a type in interfacing_with_autodiff.html
Thanks to @tangobravo for reporting this.

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

Change-Id: I2b063267c9b501c698ce6cd439a666363ba16fde
2021-09-13 17:15:02 -07:00
Sameer Agarwal 0299ce9442 Update conf.py to be compatible with Sphinx 4.1.2
Change-Id: I905911121fca48ae85f046bef714135cbf641d0a
2021-09-13 17:12:02 -07:00
Sameer Agarwal 2a2b9bd6fa Fix a bug in covariance_impl.cc
A matrix reference was being incorrectly sized. It was using
the block_size number of rows, where as there are only block_local_size
number of rows that are present in the underlying matrix.

This did not affect the correctness of the resulting code, because
right after construction we then access a subblock with block_local_size
rows.

Thanks to William Gandler for reporting this.

Change-Id: I35e1f5a30b79e31b0b9fac79f7e361821d6073df
2021-08-15 16:52:08 -07:00
Sameer Agarwal 27fade7b8c Fix a bug in system_test.cc
Fix an error in the cost functor for Powell's function.
Reported by William Gandler.

Change-Id: I4ffbbca3b3731aa13c3608067baaebd06c1a044a
2021-08-15 16:44:15 -07:00
Sameer Agarwal d4eb83ee58 Fix the Jacobian in trust_region_minimizer_test.cc
The analytical Jacobians for Powell's singular function were
incorrect. Thanks to William Gandler for reporting this.

Change-Id: I780ffe449daa6935a79b904835e13edcf1cdffa2
2021-08-15 16:37:47 -07:00
Sameer Agarwal 5f6071a1cc Fix a bug in local_parameterization_test.cc
Fix an incorrect comparison between in QuaternionParameterizationTestHelper.
Reported by William Gandler.

Change-Id: If4d63a51f6a55013b4e6f0c299462c5af6e80c70
2021-08-15 16:10:12 -07:00
Sameer Agarwal b2e732b1e2 Fix errors in comments from William Gandler.
Change-Id: I1c1f1f7bdc4a1748994c3b43e72270b88f2a2b96
2021-08-15 16:01:40 -07:00
Sameer Agarwal 42f1d67176 Add accessors to GradientProblem
Change-Id: Ic818eec240fe69b09815f1cc54f7f132cca0abb8
2021-08-14 12:28:19 -07:00
Ahmed Taei aefd37b182 Refactor small_blas_gemm_benchmark
This allows benchmarking both dynamic and static problem sizes.

On my X86 2Ghz machine:

CPU Caches:
  L1 Data 32 KiB (x48)
  L1 Instruction 32 KiB (x48)
  L2 Unified 1024 KiB (x48)
  L3 Unified 39424 KiB (x2)

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_MatrixMatrixMultiplyEigen_Static_2x3x4                 10.9 ns         10.9 ns     63960496
BM_MatrixMatrixMultiplyEigen_Static_3x3x3                 11.9 ns         11.9 ns     58093785
BM_MatrixMatrixMultiplyEigen_Static_4x4x4                 24.9 ns         24.9 ns     28540133
BM_MatrixMatrixMultiplyEigen_Static_8x8x8                  258 ns          258 ns      2755921
BM_MatrixMatrixMultiplyEigen_Static_9x9x3                  255 ns          255 ns      2778628
BM_MatrixMatrixMultiplyEigen_Static_9x3x3                 37.7 ns         37.7 ns     18556359
BM_MatrixMatrixMultiplyEigen_Static_3x9x9                  220 ns          220 ns      3195163
BM_MatrixMatrixMultiplyEigen_Dynamic_2x3x4                37.8 ns         37.7 ns     18491162
BM_MatrixMatrixMultiplyEigen_Dynamic_3x3x3                48.8 ns         48.8 ns     13724884
BM_MatrixMatrixMultiplyEigen_Dynamic_4x4x4                74.5 ns         74.5 ns      9313146
BM_MatrixMatrixMultiplyEigen_Dynamic_8x8x8                 271 ns          271 ns      2595807
BM_MatrixMatrixMultiplyEigen_Dynamic_9x9x3                 259 ns          259 ns      2688515
BM_MatrixMatrixMultiplyEigen_Dynamic_9x3x3                 123 ns          123 ns      5792115
BM_MatrixMatrixMultiplyEigen_Dynamic_3x9x9                 236 ns          236 ns      2963896
BM_MatrixMatrixMultiplyNaive_Static_2x3x4                 12.2 ns         12.2 ns     56472772
BM_MatrixMatrixMultiplyNaive_Static_3x3x3                 15.5 ns         15.5 ns     44346456
BM_MatrixMatrixMultiplyNaive_Static_4x4x4                 41.5 ns         41.5 ns     17196984
BM_MatrixMatrixMultiplyNaive_Static_8x8x8                  199 ns          199 ns      3561730
BM_MatrixMatrixMultiplyNaive_Static_9x9x3                  148 ns          148 ns      4764814
BM_MatrixMatrixMultiplyNaive_Static_9x3x3                 38.4 ns         38.4 ns     17259019
BM_MatrixMatrixMultiplyNaive_Static_3x9x9                  115 ns          115 ns      6104752
BM_MatrixMatrixMultiplyNaive_Dynamic_2x3x4                9.66 ns         9.66 ns     74722971
BM_MatrixMatrixMultiplyNaive_Dynamic_3x3x3                13.0 ns         13.0 ns     53435308
BM_MatrixMatrixMultiplyNaive_Dynamic_4x4x4                47.8 ns         47.8 ns     14358184
BM_MatrixMatrixMultiplyNaive_Dynamic_8x8x8                 200 ns          200 ns      3572809
BM_MatrixMatrixMultiplyNaive_Dynamic_9x9x3                 104 ns          104 ns      6793797
BM_MatrixMatrixMultiplyNaive_Dynamic_9x3x3                34.0 ns         34.0 ns     20790695
BM_MatrixMatrixMultiplyNaive_Dynamic_3x9x9                 130 ns          130 ns      5170402
BM_MatrixTransposeMatrixMultiplyEigen_Static_2x3x4        10.3 ns         10.3 ns     69105234
BM_MatrixTransposeMatrixMultiplyEigen_Static_3x3x3        28.9 ns         28.9 ns     24478934
BM_MatrixTransposeMatrixMultiplyEigen_Static_4x4x4        23.7 ns         23.7 ns     29351926
BM_MatrixTransposeMatrixMultiplyEigen_Static_8x8x8         233 ns          233 ns      2929398
BM_MatrixTransposeMatrixMultiplyEigen_Static_9x9x3         211 ns          211 ns      3287409
BM_MatrixTransposeMatrixMultiplyEigen_Static_9x3x3        26.5 ns         26.5 ns     26515136
BM_MatrixTransposeMatrixMultiplyEigen_Static_3x9x9         196 ns          196 ns      3594314
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_2x3x4       9.05 ns         9.05 ns     77621001
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_3x3x3       11.1 ns         11.1 ns     62227812
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_4x4x4       25.5 ns         25.5 ns     27356089
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_8x8x8        248 ns          248 ns      2834983
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_9x9x3        229 ns          229 ns      3082369
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_9x3x3       28.4 ns         28.4 ns     24318629
BM_MatrixTransposeMatrixMultiplyEigen_Dynamic_3x9x9        229 ns          229 ns      3091288
BM_MatrixTransposeMatrixMultiplyNaive_Static_2x3x4        11.0 ns         11.0 ns     63773538
BM_MatrixTransposeMatrixMultiplyNaive_Static_3x3x3        19.1 ns         19.1 ns     37003139
BM_MatrixTransposeMatrixMultiplyNaive_Static_4x4x4        49.1 ns         49.1 ns     14142301
BM_MatrixTransposeMatrixMultiplyNaive_Static_8x8x8         244 ns          244 ns      2874755
BM_MatrixTransposeMatrixMultiplyNaive_Static_9x9x3         140 ns          140 ns      4992156
BM_MatrixTransposeMatrixMultiplyNaive_Static_9x3x3        46.2 ns         46.2 ns     15068317
BM_MatrixTransposeMatrixMultiplyNaive_Static_3x9x9         112 ns          112 ns      6213574
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_2x3x4       9.74 ns         9.74 ns     72155001
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_3x3x3       11.5 ns         11.5 ns     60070577
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_4x4x4       52.5 ns         52.5 ns     13473642
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_8x8x8        224 ns          224 ns      3124264
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_9x9x3       98.0 ns         98.0 ns      7199292
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_9x3x3       34.7 ns         34.6 ns     20203685
BM_MatrixTransposeMatrixMultiplyNaive_Dynamic_3x9x9        105 ns          105 ns      6653151

Change-Id: Iee403b4d27801d1614ecc1f78a1f8c0011514bd7
2021-08-09 21:24:17 -07:00
Alexander Karatarakis dc20db3032 [docs] Fix IterationSummary section. Add missing IterationCallback
Change-Id: I1d10201cd927003fd3d46728d13231d3fbc27f96
2021-08-09 16:29:29 -07:00
Alexander Karatarakis 90ba7d1ef4 [docs] Fix typos
Change-Id: I447bd63b58a7bfc7c1df36dbef5dcba454d28256
2021-08-09 16:29:23 -07:00