Commit Graph

941 Commits

Author SHA1 Message Date
David Gossow 2a1dfd2b71 Add DynamicCostFunctionToFunctor.
This adds a new wrapper class called DynamicCostFunctionToFunctor
that closes a gap in the current API: the existing
CostFunctionToFunctor can only be used with a SizedCostFunction, where
the number and sizes of all parameter vectors are known at compile-time.
The DynamicCostFunctionToFunctor allows you to wrap a generic
CostFunction into a templated functor which can then be used in a
DynamicAutoDiffCostFunction.

Also updates the existing CostFunctionToFunctor class to internally use
DynamicCostFunctionToFunctor.

Change-Id: I088adc3271c58d2519126c27037c3576965a36d6
2015-06-18 16:01:15 -07:00
Sameer Agarwal 6d1dedad50 Fix an incorrect usage message in bundle_adjuster.cc
Change-Id: I66889ac8e52dd3baaee9e80cb04b7a8575537249
2015-06-10 09:26:31 -04:00
Alex Stewart 51f4b44fcd Gracefully disable docs if Sphinx is not found.
- Also fixes a typo in the search paths in FindSphinx.cmake.

Change-Id: I8da50ffd85358f7e67445b02eabfc9cf57c97935
2015-05-30 15:31:32 +00:00
Alex Stewart 2edcd9ee0c Explicitly use (new) default OS X rpath policy if present.
- CMake 3.0+ prefers the use of @rpath, and CMake 3.2+ produces a
  developer warning if this policy is not set, thus if present we
  explicitly specify the new default behaviour.
- http://www.cmake.org/cmake/help/v3.2/policy/CMP0042.html
- Also remove unnecessary check for presence of cmake_policy(), as it
  exists in all versions of CMake >= 2.8 (our minimum required version).

Change-Id: Iacbf8186bee4bf07d8a53068fd528cd6237c5efb
2015-05-30 15:51:04 +01:00
pmoulon 5a5526e1d8 Typo fix.
Change-Id: I7c59f92f8691beb2a0b999c1f93e31a099bbdb9d
2015-05-27 09:07:33 +02:00
pmoulon e210bbee19 Add support of EIGEN_SPARSE type in IsSparseLinearAlgebraLibraryTypeAvailable function.
Change-Id: I53f1a245509a216f31e1824486a13c4bac548a7f
2015-05-26 17:29:17 +02:00
Simon Rutishauser 1e241b7cc3 Allow the LossFunction contained in a LossFunctionWrapper to be NULL.
This is consistent with how NULL LossFunctions are treated everywhere
else.

Change-Id: Ic91e39ccb13137fcad7f85e78613a29ecde30d67
2015-05-19 17:13:57 +02:00
Sameer Agarwal 9064b4ed27 Improve numeric differentation near zero.
Before this change, the default step size
for a function F(x) at x was

step_size = |x| * relative_step_size

if step_size was exactly zero, then to prevent
division by zero we would fall back to relative_step_size.

This however is not good enough, as values of x say 1e-64
would lead to step sizes ~ 1e-70 and dividing by such numbers
leads to inaccurate results. For even smaller numbers, like
1e-300, which I have observed can occur as the optimization
algorithm makes progress, this leads to NaNs.

The key change in this CL is to change the fallback mechanism
to be

step_size = max(|x| * relative_step_size, min_step_size)

where

min_step_size = sqrt(DBL_EPSILON)

This is the recommended minimum value for the step size
for double precision arithmetic on the interwebs.

This results in a small loss of precision in the transcendental
functions test, but that is unavoidable as we are not taking
sufficiently small steps anymore.

On the whole though this will improve the numerical performance
of the algorithm.

To validate this approach, one of the parameter values for the
EasyFunctorTest has been set to 1e-64, which causes the test
to start failing without the corrected fallback logic.

This change should also address some if not all of

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

Change-Id: I4a9013ef358626c1ba7b8abad60b3904163d63f6
2015-05-13 21:37:15 -07:00
Chris Sweeney 967122def6 Add Theia to users.
Change-Id: Ic112d31e2b8d7ecd28816fdc76e27adb1da27ac5
2015-05-13 12:11:14 -07:00
Tal Ben-Nun b2dcef36e7 Refactored DynamicNumericDiffCostFunction to use NumericDiff
Change-Id: I2fc4b203e984beaa7af96fb3cbe8ce14e5bca614
2015-05-07 01:48:27 +03:00
Alex Stewart 4707eb22e9 Remove use of :caption tag in Sphinx.
Change-Id: I1fb5f2504424506e1bba244bcb8efb25329564d1
2015-05-06 20:56:08 +01:00
Sameer Agarwal 3c52ef2fab More lint changes from William Rucklidge.
Change-Id: I3594ed46e78243034389cad158243e11dd1dc2b0
2015-05-05 11:34:05 -07:00
Sameer Agarwal 5c0954438f Lint changes from William Rucklidge.
Change-Id: I6592b61451ead8f0407bec134fcf4b56ba22ffb9
2015-05-05 11:25:42 -07:00
Petter Strandmark e059a7d39e Add a small test to make sure GradientProblemSolver works correctly.
The test makes sure the Rosenbrock function is correctly minimized from the
canonical starting point using the default settings.

Change-Id: Iea820f976707bde37162981c5db87fac5167ba9e
2015-05-04 16:11:35 +02:00
Petter Strandmark 733a20a9fc Add simple unit tests for GradientProblem.
Change-Id: Id3b25a177aa92032f7f99b0a381c4f97d07d73b2
2015-05-04 09:21:33 +02:00
Russell Smith 77e80aecf7 Additional special cases in the handling of pow(Jet,Jet).
I think this is all of the cases. These cases arise because pow(a,b) is limited
to real valued results, if the argument and result were complex valued then
these cases would disappear.

NOTE: Since there is so much special casing here, it is worth checking to see
if cpow() is implemented in terms of pow(), and what might be the consequences
of using cpow() on the type std::complex<Jet<double, N> >. It is *possible*
that a separate implementation of cpow might be required also.

Also some comment fixes.

Change-Id: Ia1e38df4cdcb548f778304c2854cacba6e1556ff
2015-04-29 12:38:04 +00:00
Sameer Agarwal 2175d025a6 Make the robust curve fitting example robust.
Change-Id: Iffcde8f168b7cd68e56f351c43088d7aef1e5e2f
2015-04-27 06:54:12 -07:00
Johannes Schönberger 239dd59ea5 Homogenize convergence operators in docs and code
Change-Id: Iec7c12e971b331d1847f9aa91349317eb6524856
2015-04-16 16:01:18 -04:00
Sameer Agarwal 365084f976 Lint changes from William Rucklidge.
Change-Id: I5a9683333fbab189058076cb2053f8f7afc7096a
2015-04-16 12:35:51 -07:00
Johannes Schönberger 4eb3b8f34e Add parameter_tolerance convergence to line search minimizer
Change-Id: Id3bd3c7490d679b87259bb0fbf0b2dbc7e831a07
2015-04-16 19:09:12 +00:00
Russell Smith a6f39a939d Fix bug where pow(JetA,JetB) returned wrong result for JetA==0.
Change-Id: Ife7f6f3aca06322fa414ef747008d2b4dc468a57
2015-04-16 18:21:21 +00:00
Johannes Schönberger e00f78edc2 Remove duplicate step norm computation
Change-Id: I58685b81e119360a5b9085bb44efc55131ec9117
2015-04-15 17:03:56 -04:00
Keir Mierle 3527c0e324 Enhance usability when encountering Eigen version mismatches
Change-Id: I78fae5be517e3ee4756ea3ce448c1173c39857d6
2015-04-14 21:57:51 -07:00
pmoulon 0b9147692d Fix typo Matlab->Meshlab.
Change-Id: If64a1e2bd10637eac8ed74a5c43cfa133c7aa575
2015-04-14 14:51:42 +02:00
pmoulon 9536c967a0 Add PLY file logger before and after BA in order to ease visual comparison.
Change-Id: Ib14e8f4b2de686ab6494de270458392f81a0b946
2015-04-14 12:12:21 +00:00
Alex Stewart 08f3861b43 Fix CMake config file docs to include 2.8.x & 3.x styles.
- Include example use of new find_dependency() macro in CMake 3.x to
  find dependencies in <Project>Config.cmake files.
- Also fix typo in NNLS modeling docs.

Change-Id: Ie9862b69c0451ee8775826f2957f5e182d937439
2015-04-11 14:53:52 +01:00
Mark Moll 1c3d85b0ba Python3 fixes
Change-Id: I5ba9d264cce7b9a986b28fb24f27200d5c5f328d
2015-04-10 22:28:06 -05:00
Sameer Agarwal d500caaceb Remove confusing code from DenseJacobianWriter
The code seemed to imply that its possible to call the Write
method with a null pointer which is never the case. There would
be no point to calling Write.

Thanks to Michael Vitus for pointing this out.

Change-Id: Ic9a276856d0a7e65d53a1cc8742d4831c1a52615
2015-04-09 21:05:22 -07:00
Sameer Agarwal e712ce1810 Revert 81219ff.
Eigen upstream was broken a little while ago, and it seemed to be
the case that we needed a fix for using the LLT factorization on
ARM.

This has been fixed and AFAIK there are no stable eigen releases
with this bug in it.

For full gore, see

http://eigen.tuxfamily.org/bz/show_bug.cgi?id=992

In light of the fix, the extra layer of indirection introduced earlier
is not needed and we are reverting to normal programming.

Change-Id: I16929d2145253b38339b573b27b6b8fabd523704
2015-04-07 14:13:25 -07:00
Sameer Agarwal e78a97accb Lint changes from Jim Roseborough.
Change-Id: I4b1e9ac6c1c74e96f51e57e0cbeaa3d3d649f770
2015-04-06 16:23:23 +00:00
Alex Stewart d95f9192dd Add documentation on CMake package installation process.
- A lot of users find the CMake package installation process confusing,
  particularly the use of imported targets when exporting their own
  projects which use Ceres.
- This patch adds a brief description of the overall process and the
  main bear-trap users are ensnared by.

Change-Id: I44c022bbd18a393868bf88ea9ddd807c5e08abc9
2015-04-06 16:22:32 +00:00
Sameer Agarwal e2a716994e Revert a call to SolveUpperTriangularUsingCholesky.
The call to llt in backsubstitute seems to be using one
of the fixed size specializations which is best done with
an inline call to llt/ldlt rather than introducing yet another
variant of the SolverUpperTriangularUsingCholesky and calling it.

Also change the way SolverUpperTriangularUsingCholesky handles
error. It always computes the solution even if it is garbage
and then returns the error code.

This ensures that the previous code that depends on unconditional
computation still works.

Change-Id: Idb1e6efdae9a3775a072e3b87cde02e0bbddb319
2015-04-06 02:16:46 -07:00
Sameer Agarwal 59d7f9842e Use solveInPlace correctly.
When solving a linear system using Eigen's dense Cholesky factorization
if the right hand side of the linear system is the same vector
that will store the solution, call solveInPlace instead of solve.

Change-Id: I3e6d2f21ff420c25217cd87ee5d269fdfabbf19a
2015-04-06 07:41:44 +00:00
Sameer Agarwal 10cbe858f8 Make CERES_EIGEN_VERSION macro independent of CMake.
CERES_EIGEN_VERSION was being defined by the CMakeList.txt file
but it is needed by the android build too. So this change
directly constructs the CERES_EIGEN_VERSION string out of the
raw Eigen version numbers.

Change-Id: I65309805a59076c3082141d9042ab7e0e1b972bc
2015-04-05 23:35:04 -07:00
Sameer Agarwal 81219fff78 Allow using Eigen's LDLT factorization instead of LLT factorization
It seems that Eigen's LLT factorization is broken on ARM.
This patch enables the use of LDLT factorization instead of LLT
factorization. The switch is controlled at compile time using a
preprocessor define - CERES_USE_EIGEN_LDLT.

By default we continue to use LLT factorization though.

To make the switching easier without introducing the Cholesky factorization
based inversion and linear system solve routines have been abstracted into
two new functions.

Android.mk has been updated to enable the LDLT factorization, but
the cmake file has not been updated as I will leave it to Alex's
capable hands to do proper detection of ARM as a target platform.

Change-Id: Iffe3abd2ce894de2a388b454df3da909b482d5e5
2015-04-05 22:50:41 -07:00
Alex Stewart 857c18ace0 Add versions of dependencies used to FullReport().
Change-Id: I0a41e88e0669364d21ef86146f0b572f0f08ece5
2015-04-05 14:25:25 +01:00
Alex Stewart 5b043a9400 Ensure local config.h is used if Ceres is already installed.
- Previously, if Ceres was already installed to the same location as one
  of the depenedencies (e.g. /usr/local) then as the BUILD_DIR/config
  path was necessarily added to the include_directories() list *after*
  the INCLUDE_DIRS for the dependencies, the config.h for the
  *installed* version of Ceres would be used instead of the locally
  configured version, as it would appear first on the path.
- Forcing the location of the locally configured config.h to the front
  of the include_directories() list ensures that it is found first
  (and is thus used) even if an installed version of Ceres also exists
  on the path.

Change-Id: I7b4f97a3ad0120bd11551f9b8eb6bffc66966eb4
2015-04-04 18:20:23 +01:00
Keir Mierle 11d3b9e715 Small messaging and comment updates in CMake
Change-Id: I9d6707bc686b6c74d878d8c36bbe5e95a805c6f7
2015-03-30 19:05:46 -07:00
Alex Stewart 58ee9f7d9b Handle possible presence of library prefixes in MSVC.
- On MSVC, a Ceres dependency such as glog, may be named glog.lib, or
  libglog.lib.  By default, CMake assumes no prefix for libraries on
  MSVC when using find_library(), thus find_library(glog) would fail
  if glog was named libglog.lib.
- This patch caches & updates CMAKE_FIND_LIBRARY_PREFIXES in all of
  Ceres' find_package scripts to include lib & "" (no prefix) on MSVC
  and then returns CMAKE_FIND_LIBRARY_PREFIXES to its original state
  before returning.

Change-Id: Ic82799e3b786cfb7228a51183bc189578b072bbe
2015-03-31 00:47:44 +00:00
Alex Stewart 4a423f9129 Use -O2 not -O3 on MinGW to workaround issue with Eigen.
- MinGW produces code that segfaults when performing matrix
  multiplications in Eigen when compiled with -O3 (see below), as such
  force the use of -O2 which works.
- http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556

Change-Id: I420e965d5033944374a5cc93490546c25e46bce5
2015-03-30 23:13:50 +00:00
Alex Stewart c8eeaf4ad9 Increase tolerance in small_blas test for Cygwin.
- Previous tolerance of 2.0 * std::numeric_limits<double>::epsilon()
  was too tight for Cygwin, worked on all other known platforms.

Change-Id: Ia79ad8961272dbb608d8e8ddd3f6d52e5f0735f4
2015-03-30 19:54:26 +01:00
Jack Feng 9982791969 Fix ios cmake file for cmake 3.0
In cmake 3.0, it is required to use full path for compilers. And it
seems like there's no need to force the compiler. Instead we can just
use set(CMAKE_C_COMPIER clang) so that we don't need to specify full
path of clang and clang++.

Change-Id: I9f6a625068e9d37a4bf5a595bafd82cbc13fdde4
2015-03-25 10:02:11 +00:00
Alex Stewart b611bdea11 Fix missing gflags shlwapi dependency on MinGW.
- Reported by Simeon (s1m3mu3@gmail.com) on Ceres mailing list.

Change-Id: If23491128fb6320d9b643eb3d5db7d9e67ffcf0b
2015-03-24 18:21:07 +00:00
Filippo Basso 26f50e1e72 Add users: OpenPTrack and IAS-Lab@Univ. of Padova
Change-Id: I841aeddb0f0c2b0d905fc0520553f263db7e7959
2015-03-23 11:29:07 +01:00
Alex Stewart 5a21b8b1e9 Add thread dependency & fix namespace detection on Windows for gflags.
- Add missing gflags threading dependency.
- Also add optional gflags Shlwapi dependency on Windows.
- Add check_cxx_source_compiles() with CMAKE_BUILD_TYPE to fix
  namespace test builds on Windows with NMake generators.
- Add namespace regex on gflags.h when check_cxx_source_compiles()
  fails on Windows using Visual Studio generator.

Change-Id: I6570c566e5a29c665d621a54935c16d16bac7117
2015-03-21 17:55:19 +00:00
Sameer Agarwal a6971f6c29 Documentation changes.
1. Add documentation for cubic_interpolation.h
2. Remove the list of publications. It is an incomplete list which is
   a pain to maintain.
3. Add a note about the interaction between manifolds and
   NumericDiffCostFunction.
4. Fix some of the comments in cubic_interpolation.h to better reflect reality.
5. Updated the version history.

Change-Id: I0b4a5a6f3361d3fc85f1b4aec685cd80540934f1
2015-03-21 10:42:29 -07:00
Chris Sweeney 4df3d11397 Bug fix for reversing OrderedGroups.
Reverse() method now handles the case where no groups exist.

Change-Id: Ia1ef08aa3cde01ceb71285b605a2e1f882c3b620
2015-03-21 17:00:40 +00:00
Keir Mierle 3fafa3cd72 Add CERES_ prefix to macros in public headers
Change-Id: Ie4f4311d5a669c03746e8f00426f4d7cbef20ad0
2015-03-21 04:55:20 -07:00
Sameer Agarwal 649f5c22b8 Lint changes from William Rucklidge.
Change-Id: I4c34caa57c48c97df213d6fb44a1a2534a953f0f
2015-03-20 17:05:35 -07:00
Mike Vitus cab2267e40 Add Homogeneous vector parameterization.
Change-Id: I42f68a0665a62e2c7dcc7584e5581a05c9b849b0
2015-03-20 22:08:15 +00:00