Commit Graph

1021 Commits

Author SHA1 Message Date
Niels Ole Salscheider cb467d83fe Install CMake files to lib/cmake/Ceres
This is the right thing to do since the CMake files contain target
specific information - share is only for target-independent files.
Without this patch, the CMake files will collide on distributions
that allow to install for multiple targets in parallel (e. g. on
Exherbo).

Change-Id: Iac17af63b9f9b25d0ca400c77c2b2e0e8a51196f
2016-01-10 20:39:20 +01:00
Niels Ole Salscheider 1f20b72afd Allow users to override the documentation install directory.
This is needed for multiarch layouts where the prefix is /usr/${host}
but where arch-independent files are installed to /usr/share.

Change-Id: Icec01f8ea927594b4edb26997d6384e478415999
2016-01-10 20:39:12 +01:00
Sameer Agarwal 15587dd1a9 Lint changes from William Rucklidge
Change-Id: If05a774c5e7dd318e6b3ee698e313f0fc58ee922
2016-01-05 11:31:13 -08:00
Wannes Van Loock b0bf9fd2a9 Add covariance matrix for a vector of parameters
Computing the covariance matrix for a number of parameter blocks
previously required adding all parameter blocks to the computation and
subsequently assembling the matrix by concatenating all the blocks.

This patch adds the computation of the covariance matrix for a vector
of parameter blocks. All covariance block pairs are added automatically
and the resulting covariance matrix is assembled in the order the
parameter blocks appear.

Change-Id: I3b70c63f16862adc23a1d7fb7a21dde4e68abe9a
2016-01-04 20:26:40 +00:00
Sameer Agarwal 7ec8ba2a64 Saner tolerances & stricter LRE test.
NIST recommends greater than 4 digits rather than greater than
or equal to 4 digits to declare that the solve was successful.

Change-Id: I5c65e6e791508b95b692c23dafd3833d73cd0487
2016-01-03 22:44:48 -08:00
Sameer Agarwal 52c1bc92c6 Fix a malformed sentence in the tutorial.
Thanks to abrock for pointing this out.

Change-Id: I3fe943dc415dc389396e13dbdd5aec09ee9b76cc
2016-01-03 22:42:04 -08:00
Sameer Agarwal 8ecfb2d705 Fix the build.
Change-Id: I95a62a180a1a21fc379fe27b1309d72f19d9ef29
2015-12-17 13:55:02 -08:00
Sameer Agarwal ed32e6a44a Add logging for sparse Cholesky factorization using Eigen
Print information about the fill-in when using Eigen to perform
Simplicial sparse Cholesky factorization.

Change-Id: I09013b7f4ed2f6c55ae8ce8922447e23d63580a8
2015-12-17 20:22:48 +00:00
Sameer Agarwal a1019f6610 Use std::adjacent_find instead of std::unique
When detecting duplicates, it is more efficient to use std::adjacent_find
than it is to use std::unique.

Change-Id: Ib6b4671c10848bb7dd10aa7a1baeffc8c9c825b5
2015-12-17 20:21:42 +00:00
Sameer Agarwal aaa0e3e4c8 Improve logging in CompressedRowJacobianWriter on crash
Change-Id: Ib56955669279724e7f1dffd9a68b7b2b66b24a85
2015-12-17 11:51:50 -08:00
Andrew Hunter d80c112168 Tweak alignment hint implementation for Jets
I169b637a1e2a106956b536c41d6a514a266e7cc0 marked Jets (in C++11) as
aligned to 16 bytes, and enabled Eigen vectorization.  However, to
implement this, we added Eigen includes to port.h.

Turns out this broke some other tricks Ceres uses (redefining Eigen
constants for better performance), so we don't want to do that. Move
most of the implementation to jet.h where it is safe.

Change-Id: I47c6fc4180db1ff674bc660723dd5a2b84254e0d
2015-12-11 14:50:19 -08:00
Andrew Hunter 5667505f35 Align Jet matrices where supported
We currently don't align the infinitesimal part of a Jet to a 16-byte
boundary (and thus force Eigen to avoid using SSE ops)--as a member of a
larger struct, we couldn't guarantee Jets would be allocated on
appropriately-aligned boundaries.  However, C++11 adds better support
for requesting alignment: we can use it to guarantee the members will be
properly aligned, and tell Eigen to vectorize.

There is a significant gotcha here: the standard gives wide latitude to
implementations as to which alignments they choose to support.  If we
ask for 16 and the system only supports 8, we may have misaligned
Jets. So we test (using alignof(std::max_align_t)) that the current
system supports 16-byte aligned values; if not, we fall back to the
current solution.

Two other small notes:
- This is obviously gated on C++11 support, and
  thus we put the logic in port.h and export some useful #defines.

- GCC 4.8.x has a
  bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56019) that has
  max_align_t in the wrong namespace.  This will not be a problem with a
  modern GCC, but add a small workaround since many systems still ship 4.8.

This results (on a x86 workstation) in a 60% speedup in Jacobian
evaluation on bin/simple_bundle_adjuster problem-16-22106-pre.txt.

Change-Id: I169b637a1e2a106956b536c41d6a514a266e7cc0
2015-12-08 01:09:07 +00:00
Sameer Agarwal 6418b33f21 Fix free parameter block handling in covariance computation
Parameter blocks that are not associated with any residual block
lead to structurally zero columns in the Jacobian. The covariance
computation algorithm was only paying attention to structural
sparsity caused by constant parameter blocks but not free parameter
blocks.

This patch fixes this, by iterating over the residual blocks in
the problem and collecting all the parameter blocks in use.

The tests for ComputeCovarianceSparsity are also extended to include
the case where there are constant and free parameter blocks.

Thanks to Wannes Van Loock for reporting this.

Change-Id: Ic298a6e93c53f2f95fb69105397a87200738a2b0
2015-12-04 09:51:57 -08:00
Sameer Agarwal 992ae55e84 Report the number of line search steps in FullReport.
Accumulate the number of steps of the line search algorithm
and report it as part of Summary::FullReport.

Change-Id: I1de12784009a3e08f2a2c2aff5085d57a3c73828
2015-12-01 14:26:13 -08:00
Alex Stewart b5f5100f57 Make CMake read Ceres version directly from include/ceres/version.h.
- Previously we had the Ceres version defined in two places, one in
  include/ceres/version.h, and one in the main CMakeLists.
- Now the main CMakeLists reads the Ceres version directly from
  version.h, as does the make_release script, so that we have a single
  place (version.h) in which the current Ceres version is defined.

Change-Id: Ie80aa7d38f5b576d3ed4d6109dd699f565c91027
2015-12-01 20:50:53 +00:00
Sameer Agarwal f4214e3ecf Lint changes from William Rucklidge.
Change-Id: I34899063edc2fe1f4ed976406448f829a1f210c0
2015-11-19 08:40:08 -08:00
Wannes Van Loock 5a3a23eb39 Fix covariance computation for constant blocks
This commit fixes a bug related to the computation of covariance blocks
in the tangent space for constant parameter blocks, causing out of
bounds memory access.

Change-Id: Iaeee7992405fcaaae6086612798e96f2e10ebc5c
2015-11-13 09:29:05 +01:00
Sameer Agarwal ba67ed1e01 A variety of small updates
1. Add answers to a number of FAQs.
2. Add a note to the documentation for NumericDiffCostFunction that
   NumericDiffOptions needs to be documented and mentioned.
3. Update the docs for Solver::Options::numeric_derivative_relative_step_size
   to indicate that this setting only applies to the gradient checker.
4. Remove deprecated constructors from NumericDiffCostFunction and
   DynamicNumericDiffCostFunction.

Change-Id: If8fc011b2a5996dbc2c51268aa477550ed014a1c
2015-11-08 10:59:42 -08:00
Eduard Feicho 7efc92d413 Add IOS_DEPLOYMENT_TARGET variable to iOS.cmake
- Gives an option to specify a lower deployment target version than the
  current SDK for backward compatibility.

Change-Id: Ieb84ba7f42cdf925510f84b8e0cd01b5e9fc051b
2015-10-27 22:22:55 +00:00
Alessandro Gentilini aef9c9563b Add test for Bessel functions.
Change-Id: Ief5881e8027643d7ef627e60a88fdbad17f3d884
2015-10-22 18:48:13 +00:00
Alessandro Gentilini 49c86018e0 Add Bessel functions in order to use them in residual code.
See "How can I use the Bessel function in the residual function?" at
https://groups.google.com/d/msg/ceres-solver/Vh1gpqac8v0/NIK1EiWJCAAJ

Change-Id: I3e80d9f9d1cadaf7177076e493ff46ace5233b76
2015-10-22 18:47:02 +00:00
Simon Rutishauser dfb201220c Make miniglog threadsafe on non-windows system by using
localtime_r() instead of localtime() for time formatting

Change-Id: Ib8006c685cd8ed4f374893bef56c4061ca2c9747
2015-10-15 09:44:53 +02:00
Alex Stewart 41455566ac Remove link-time optimisation (LTO).
- On GCC 4.9+ although GCC supports LTO, it requires use of the
  non-default gcc-ar & gcc-ranlib.  Whilst we can ensure Ceres is
  compiled with these, doing so with GCC 4.9 causes multiple definition
  linker errors of static ints inside Eigen when compiling the tests
  and examples when they are not also built with LTO.
- On OS X (Xcode 6 & 7) after the latest update to gtest, if LTO
  is used when compiling the tests (& examples), two tests fail
  due to typeinfo::operator== (things are fine if only Ceres itself is
  compiled with LTO).
- This patch disables LTO for all compilers. It should be revisited when
  the performance is more stable across our supported compilers.

Change-Id: I17b52957faefbdeff0aa40846dc9b342db1b02e3
1.11.0 1.11.0rc4
2015-10-05 18:54:11 +01:00
Alex Stewart 89c40005bf Only use LTO when compiling Ceres itself, not tests or examples.
- If Ceres is built as a shared library, and LTO is enabled for Ceres
  and the tests, then type_info::operator==() incorrectly returns false
  in gtests' CheckedDowncastToActualType() in the following tests:
-- levenberg_marquardt_strategy_test.
-- gradient_checking_cost_function_test.
  on at least Xcode 6 & 7 as reported here:
  https://github.com/google/googletest/issues/595.
- This does not appear to be a gtest issue, but is perhaps an LLVM bug
  or an RTTI shared library issue.  Either way, disabling the use of
  LTO when compiling the test application resolves the issue.
- Allow LTO to be enabled for GCC, if it is supported.
- Add CMake function to allow easy appending to target properties s/t
  Ceres library-specific compile flags can be iteratively constructed.

Change-Id: I923e6aae4f7cefa098cf32b2f8fc19389e7918c9
1.11.0rc3
2015-09-28 15:08:39 +01:00
Sameer Agarwal 0794f41cca Documentation updates.
1. Fix a typo in the Trust Region algorithm.
2. Add ARL in the list of users.
3. Update the version history.

Change-Id: Ic286e8ef1a71af07f3890b7592dd3aed9c5f87ce
2015-09-26 14:14:20 -07:00
Alex Stewart 90e32a8dc4 Use old minimum iOS version flags on Xcode < 7.0.
- The newer style, which are more specific and match the SDK names
  are not available on Xcode < 7.0.

Change-Id: I2f07a0365183d2781157cdb05fd49b30ae001ac5
2015-09-21 21:08:25 +01:00
Alex Stewart 26cd5326a1 Add gtest-specific flags when building/using as a shared library.
- Currently these flags are only used to define the relevant DLL export
  prefix for Windows.

Change-Id: I0c05207b512cb4a985390aefc779b91febdabb38
2015-09-21 10:16:01 +01:00
Alex Stewart c4c7947211 Clean up iOS.cmake to use xcrun/xcodebuild & libtool.
- Substantial cleanup of iOS.cmake to use xcrun & xcodebuild to
  determine the SDK & tool paths.
- Use libtool -static to link libraries instead of ar + ranlib, which
  is not compatible with Xcode 7+, this change should be backwards
  compatible to at least Xcode 6.
- Force locations of unordered_map & shared_ptr on iOS to work around
  check_cxx_source_compiles() running in a forked CMake instance without
  access to the variables (IOS_PLATFORM) defined by the user.
- Minor CMake style updates.

Change-Id: I5f83a60607db34d461ebe85f9dce861f53d98277
2015-09-20 20:12:04 +01:00
Sameer Agarwal 155765bbb3 Import the latest version of gtest and gmock.
Change-Id: I4b686c44bba823cab1dae40efa99e31340d2b52a
2015-09-16 19:23:43 +00:00
Alex Stewart 0c4647b8f1 Remove FAQ about increasing inlining threshold for Clang.
- Changing the inlining threshold for Clang as described has a minimal
  effect on user performance.
- The problem that originally prompted the belief that it did was
  due to an erroneous CXX flag configuration (in user code).

Change-Id: I03017241c0f87b8dcefb8c984ec3b192afd97fc2
2015-09-16 20:01:11 +01:00
Sameer Agarwal f4b768b69a Lint changes from William Rucklidge
Change-Id: I0dac2549a8fa2bfd12f745a8d8a0db623b7ec1ac
2015-09-14 13:53:24 -07:00
Sameer Agarwal 5f2f05c726 Refactor system_test
1. Move common test infrastructure into test_util.
2. system_test now only contains powells function.
3. Add bundle_adjustment_test.

Instead of a single function which computes everything,
there is now a test for each solver configuration which
uses the reference solution computed by the fixture.

Change-Id: I16a9a9a83a845a7aaf28762bcecf1a8ff5aee805
2015-09-12 15:41:05 -07:00
Alex Stewart 1936d47e21 Revert increased inline threshold (iff Clang) to exported Ceres target.
- Increasing the inline threshold results in very variable performance
  improvements, and could potentially confuse users if they are trying
  to set the inline threshold themselves.
- As such, we no longer export our inline threshold configuration for
  Clang, but instead document how to change it in the FAQs.

Change-Id: I88e2e0001e4586ba2718535845ed1e4b1a5b72bc
1.11.0rc2
2015-09-08 23:27:42 +01:00
Sameer Agarwal a66d89dcda Get ready for 1.11.0RC1
Update version numbers.
Drop CERES_VERSION_ABI macro.

Change-Id: Ib3eadabb318afe206bb196a5221b195d26cbeaa0
2015-09-08 14:55:28 -07:00
Sameer Agarwal 1ac3dd223c Fix a bug in CompressedRowSparseMatrix::AppendRows
The test for CompressedRowSparseMatrix::AppendRows tries to add
a matrix of size zero, which results in an invalid pointer deferencing
even though that pointer is never written to.

Change-Id: I97dba37082bd5dad242ae1af0447a9178cd92027
2015-09-05 15:56:14 -07:00
Sameer Agarwal 67622b080c Fix a pointer access bug in Ridders' algorithm.
A pointer to an Eigen matrix was being used as an array.

Change-Id: Ifaea14fa3416eda5953de49afb78dc5a6ea816eb
2015-09-05 21:37:22 +00:00
Sameer Agarwal 5742b7d0f1 Improve performance of SPARSE_NORMAL_CHOLESKY + dynamic_sparsity
The outer product computation logic in SparseNormalCholeskySolver
does not work well with dynamic sparsity. The overhead of computing
the sparsity pattern of the normal equations is only amortized if
the sparsity is constant. If the sparsity can change from call to call
SparseNormalCholeskySolver will actually be more expensive.

For Eigen and for CXSparse we now explicitly compute the normal
equations using their respective matrix-matrix product routines and solve.
Change-Id: Ifbd8ed78987cdf71640e66ed69500442526a23d4
2015-09-05 14:31:52 -07:00
Keir Mierle d0b6cf657d Fix incorrect detect structure test
Change-Id: I7062f3639147c40b57947790d3b18331a39a366b
2015-09-04 18:43:41 -07:00
Alex Stewart 0e8264cc47 Add increased inline threshold (iff Clang) to exported Ceres target.
- When compiled with Clang, Ceres and all of the examples are compiled
  with an increased inlining-threshold, as the default value can result
  in poor Eigen performance.
- Previously, client code using Ceres would typically not use an
  increased inlining-threshold (unless the user has specifically added
  it themselves).  However, increasing the inlining threshold can result
  in significant performance improvements in auto-diffed CostFunctions.
- This patch adds the inlining-threshold flags to the interface flags
  for the Ceres CMake target s/t any client code using Ceres (via
  CMake), and compiled with Clang, will now be compiled with the same
  increased inlining threshold as used by Ceres itself.

Change-Id: I31e8f1abfda140d22e85bb48aa57f028a68a415e
2015-09-02 19:37:01 +01:00
Alex Stewart a1b3fce9e0 Add optional export of Ceres build directory to new features list.
Change-Id: I6f1e42b41957ae9cc98fd9dcd1969ef64c4cd96f
2015-08-31 14:14:56 +01:00
Alex Stewart e46777d8df Credit reporters of buildsystem bugs in version history.
Change-Id: I16fe7973534cd556d97215e84268ae0b8ec4e11a
2015-08-31 12:41:54 +01:00
Sameer Agarwal 01548282cb Update the version history.
Change-Id: I29873bed31675e0108f1a44f53f7bc68976b7f98
2015-08-30 22:34:04 -07:00
Sameer Agarwal 2701429f77 Use Eigen::Dynamic instead of ceres::DYNAMIC in numeric_diff.h
Change-Id: Iccb0284a8fb4c2160748dfae24bcd595f1d4cb5c
2015-08-30 21:33:57 -07:00
Tal Ben-Nun 4f049db7c2 Adaptive numeric differentiation using Ridders' method.
This method numerically computes function derivatives in different
scales, extrapolating between intermediate results to conserve function
evaluations. Adaptive differentiation is essential to produce accurate
results for functions with noisy derivatives.

Full changelist:
-Created a new type of NumericDiffMethod (RIDDERS).
-Implemented EvaluateRiddersJacobianColumn in NumericDiff.
-Created unit tests with f(x) = x^2 + [random noise] and
 f(x) = exp(x).

Change-Id: I2d6e924d7ff686650272f29a8c981351e6f72091
2015-08-30 14:06:13 +03:00
Sameer Agarwal 070bba4b43 Lint fixes from William Rucklidge
Change-Id: I719e8852859c970091df842e59c44e02e2c65827
2015-08-25 13:37:33 -07:00
Alex Stewart 887a20ca7f Build position independent code when compiling Ceres statically.
- Previously, when Ceres was built as a static library we did not
  compile position independent code.  This means that the resulting
  static library could not be linked against shared libraries, but
  could be used by executables.
- To enable the use of a static Ceres library by other shared libraries
  as reported in [1], the static library must be generated from
  position independent code (except on Windows, where PIC does not
  apply).

[1] https://github.com/Itseez/opencv_contrib/pull/290#issuecomment-130389471

Change-Id: I99388f1784ece688f91b162d009578c5c97ddaf6
2015-08-25 18:29:08 +00:00
Sameer Agarwal 860bba588b Fix a bug in DetectStructure
The logic for determing static/dynamic f-block size in
DetectStructure was broken in a corner case, where the very first
row block which was used to initialize the f_block_size contained
more than one f blocks of varying sizes. The way the if block
was structured, no iteration was performed on the remaining
f-blocks and the loop failed to detect that the f-block size
was actually changing.

If in the remaining row blocks, there were no row blocks
with varying f-block sizes, the function will erroneously
return a static f-block size.

Thanks to Johannes Schonberger for providing a reproduction for this
rather tricky corner case.

Change-Id: Ib442a041d8b7efd29f9653be6a11a69d0eccd1ec
2015-08-25 11:14:10 -07:00
Johannes Schönberger b0cbc0f0b0 Reduce memory footprint of SubsetParameterization
Change-Id: If113cb4696d5aef3e50eed01fba7a3d4143b7ec8
2015-08-22 16:15:26 +00:00
Sergey Sharybin ad2a997777 Fix for reoder program unit test when built without suitesparse
This commit fixes failure of reorder_program_test when Ceres is built without
any suitesparse.

Change-Id: Ia23ae8dfd20c482cb9cd1301f17edf9a34df3235
2015-08-22 11:18:45 +02:00
Sameer Agarwal 4bf3868bec Fix a bug in the Schur eliminator
The schur eliminator treats rows with e blocks and row with
no e blocks separately. The template specialization logic only
applies to the rows with e blocks.

So, in cases where the rows with e-blocks have a fixed size f-block
but the rows without e-blocks have f-blocks of varying sizes,
DetectStructure will return a static f-block size, but we need to be
careful that we do not blindly use that static f-block size everywhere.

This patch fixes a bug where such care was not being taken, where
it was assumed that the static f-block size could be assumed for all
f-block sizes.

A new test is added, which triggers an exception in debug mode. In
release mode this error does not present itself, due to a peculiarity
of the way Eigen works.

Thanks to Werner Trobin for reporting this bug.

Change-Id: I8ae7aabf8eed8c3f9cf74b6c74d632ba44f82581
2015-08-20 23:34:26 -07:00