Commit Graph

1399 Commits

Author SHA1 Message Date
Sameer Agarwal ac2c4c5666 Add an errant CHECK_NOTNULL
Change-Id: I07851bd103cff8c79dafd4801295d02806b7bd0b
2018-09-09 14:14:13 -07:00
Sameer Agarwal 94712db5c7 Convert calls to CHECK_NOTNULL to CHECK.
CHECK_NOTNULL is being deprecated and removed from the
glog library.

Change-Id: I4a6d1eec6e82a768c7861c8f776bf1f9c0b50c74
2018-08-28 08:14:19 -07:00
Alex Stewart 402a2e4b6d Import Threads::Threads CMake target in CeresConfig.cmake
- Required now that Threads is a public dependency for Ceres and so
  Threads::Threads will appear in the dependency list for the Ceres
  target and so must be defined when Ceres itself is imported.

Change-Id: Ia5f8ea16e8f24cf0158f40e1fc8d3962106459a6
2018-08-23 09:22:22 +01:00
Alex Stewart 1b17405e38 Make CMake threads a public Ceres dependency.
- Required to propagate the threading flags to example targets that
  depend upon Ceres and do not directly specify threads as a dependency
  to support some *nix builds.

Change-Id: I1c229bd0241da55a203c2b1f8fc28ea43c312e69
2018-08-22 15:39:13 +01:00
Sameer Agarwal 4fc5d25f9c Add a missing <cstdint> to block_structure.h
Change-Id: Ic192eb61b87726e5e939a28b00842da4e0f2b30a
2018-08-09 21:47:25 -07:00
Sameer Agarwal e82e128344 Deprecate integral_types.h
This header defined integral types in the pre-C++11 days, and can
be replaced with <cstdint> and the types defined therein.

Also remove a shallow (and incorrect) typedef in include/ceres/types.h

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

Change-Id: I398c652f74d24bbeea459672508bf28f591b100f
2018-08-09 12:17:05 -07:00
Sameer Agarwal 515639e14b Add missing ceres/internal/port.h to two header files.
Without these these files cannot be included on their own.

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

Change-Id: I87ca91d15f5ab2053e43480ecbde74779125c709
2018-08-08 06:58:06 -07:00
Alex Stewart e6f7a75fdc Fix brew installation failing if formula is already installed.
Change-Id: I8b297a7b8ae1cd2e3a34e38f52121f420d5b7651
2018-08-07 12:06:52 +01:00
Dmitriy Korchemkin 2ac62a6d78 Fix docs for Problem::EvaluateOptions and contributing
Fix Problem::EvaluateOptions::residual_blocks description
Fix gerrit interface description in contributing instructions

Change-Id: I3347f35a85700a9f8ae1da3b79a6292a9d4dffe0
2018-08-03 15:16:42 +03:00
Sameer Agarwal 923fddcd0e Fix an uninitialized memory error in EvaluationCallbackTest
prepare_parameter_hash was being used uninitialized.

Change-Id: Ia1a2e2da6845dc536f5463fe12d4ffcd58a95f8c
2018-07-10 14:48:23 -07:00
Sameer Agarwal 32cb9e4a12 Respect bounds when using Solver::Options::check_gradients
When Solver::Options::check_gradients is true, Ceres internally
creates a new ProblemImpl object which wraps each CostFunction
in the user's problem with a GradientCheckingCostFunction.

Doing this also requires creating new ParameterBlock objects,
and when support for upper and lower bounds was added to Ceres,
CreateGradientCheckingProblemImpl should also have been updated
to create a problem with the same parameter bounds. As a result,
if check_gradients is enabled for a bounded problem, it constructs
an unconstrained problem and solves it.

This CL fixes this, by introducing Problem::GetParameterLowerBound,
and Problem::GetParameterUpperBound and using them to create a bounded
problem when checking gradients.

Thanks to @pbeeson for not only reporting this problem, but also
providing a small standalone reproduction which made debugging this
possible.

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

Change-Id: Id18eb858a7009bf4fa452a21b925922d13f3249f
2018-07-09 23:48:45 -07:00
Sameer Agarwal 2dd82fb8a0 Relax the limitation that SchurEliminator::Eliminate requires a rhs.
When using the SchurEliminator to compute a preconditioner, there
is no rhs. This CL removes that limitation and simplifies the
call sites in the two preconditioners.

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

Change-Id: I05b8518fdc9f0d1a6d88ae76d3a7e8e838e7204a
2018-07-10 06:18:01 +00:00
Sameer Agarwal bbe790e0f3 Fix three out of bounds errors in CompressedRowSparseMatrix.
All three errors are of the form where, the vector storing
the columns array for a CompressedRowSparseMatrix is being
accessed out of bounds. But in each case, the access is innocuous
because there are other tests which prevent it from being used.

However, if one compiles with debug mode on, the bounds checking
in the underlying std::vector triggers an error.

More details:

1. FromTripletSparseMatrix tried accessing the col vector of
   a matrix with zero rows, but the following code was a no-op
   because there was nothing to copy.

   Adding an early return which deals with this case fixes this.

2. RightMultiply and SquaredColumnNorm had the following loop

   while (r > cols_[idx] && idx < idx_end) {
        ++idx;
   }

   where cols_ was being accessed out of bounds, before idx < idx_end
   was being checked. Swapping the order of the comparisons fixes this
   error.

@richmattes reported this error.

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

Change-Id: I2dbc90ef24ecaffc6f46f1622339d6053b43db45
2018-07-10 06:17:34 +00:00
Sameer Agarwal 2c1e595b77 Add CONTRIBUTING.md
This was currently being done in README.md, but thats likely not
the best way to do this, CONTRIBUTING.md is shown to users
if they try to create PR on github.

So this CL pulls out the bits that point folks to Gerrit and puts
them in CONTRIBUTING.md

Change-Id: I1d2be0d89cbff72c0655ba341756dd0f54e2ea7f
2018-07-10 06:16:27 +00:00
Sameer Agarwal 3df43b960f Remove Android build using Android.mk.
CMake support in Android is now standard and the CMake file
has fuller richer functionality than the Android.mk file ever did.

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

Change-Id: Ib79bcc19dd47495a81a5d07fafdf06eb8005984e
2018-07-10 06:10:12 +00:00
Sameer Agarwal 483cc4737d Increase the tolerance in sparse_cholesky_test
The current tolerance is too strict and causes failures on
Windows7 x64 with mingw64.

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

Change-Id: Idf6f5e50ac61c36a35d7a576af6c88c6d1609869
2018-07-07 15:24:51 -07:00
Alex Stewart 67338e2600 Add Travis CI support.
- Currently builds for Linux (GCC), Android (r17b), macOS and iOS
  (Xcode 9.4).

Change-Id: I17f9adb90c12bff983c851cdcb20db1f9efce6fb
2018-07-06 21:01:03 +01:00
Alex Stewart fba8ee2d62 Add private dependency include directories to test targets.
Change-Id: Ic8ea67f8b6327700e723346b22f64750864b8d6f
2018-07-05 13:35:42 +01:00
Alex Stewart e86f5a4d46 Recycle numeric factorisation when using Accelerate Sparse.
Change-Id: Id94d77f9437e31c37ae99f48d28800fc9ce841ec
2018-07-05 09:17:16 +01:00
Alex Stewart a6579cb73f Fix missing target_include_directories() for gtest target.
Change-Id: I0c2f0473bcc977bda7bae2f550934d0505ee3e11
2018-07-03 19:24:55 +01:00
Alex Stewart 16f9b34c3b Remove Intel TBB threading support.
- In light of the C++11 threads threading option this is no longer
  necessary for cross-platform threading support and did not offer a
  noticeable performance gain over either the C++11 threads
  implementation or OpenMP.

Change-Id: Icb588d520888c19a1775171795b55bcaffb3d256
2018-07-03 18:05:36 +00:00
Alex Stewart 2166bad133 Replace include_directories() with target_include_directories().
- Now that we require CMake >= 3.x, we can roll the definition of the
  include directories for clients linking against Ceres into the
  exported Ceres CMake target via target_include_directories().
- This removes the requirement for CERES_INCLUDE_DIRS.

Change-Id: Ibe3bbf796339871d66138fc9520053d1766f09a8
2018-07-02 12:15:13 +01:00
Alex Stewart 8f41ca6abc Add Apple's Accelerate framework as a sparse linear algebra library.
- Currently DynamicSparseNormalCholeskySolver is unsupported for
  Accelerate.

Change-Id: I03b5a86bb22fef249c4aecd48947a613e8eff7a5
2018-06-29 09:43:03 +01:00
Alex Stewart 357288008e Add description of option controlling Android debug symbol stripping.
Change-Id: I00b37f38ed5dfca1959eafb410ae85240e1f5c91
2018-06-28 19:20:35 +01:00
Linus Mårtensson 9f3d9aebed Add android CMake support
Change-Id: I78b4794786cc1b03946b6b15aa93e46a4303a39c
2018-06-26 15:59:44 +02:00
Alex Stewart d656d34809 Refactor Ceres threading option configuration.
- Previously we had separate variables for each of the threading
  backends, each of which were made mutually exclusive via
  cmake_dependent_option().  This has unfortunate side-effects when
  trying to disable options if they are not currently enabled, in which
  case they are not defined.
- As all the threading options are mutually exclusive, this replaces
  all threading option variables with a single variable: CERES_THREADS,
  which is constrained to take the value of only the available threading
  backends.

Change-Id: I0822eefbac9a30772907b7732add365b37cc8ca0
2018-06-20 23:20:57 +00:00
Alex Stewart 9671d850e6 Replace (MSVC/GCC/CLANG)_VERSION with CMAKE_CXX_COMPILER_VERSION.
- As raised in issue #377, GCC_VERSION is not always defined, in which
  case we were not enabling compiler optimisations.
- CMAKE_CXX_COMPILER_VERSION is the more modern, uniform method to
  verify the compiler version.
- Also removes legacy Apple-GCC (i.e. Apple's fork of GCC prior to their
  switch to Clang) logic, and Xcode 4.x logic (in June 2018, Xcode 9.x
  is the current version).
- Also removes addition of -march=native on Linux (was not added for
  OS X).  If users wish to append -march=native (which will affect the
  portability of the resulting output) they can do so manually as now
  explained in the docs.
- Fixes check for Clang on OS X.  As per CMP0025 (CMake 3.0+)
  CMAKE_CXX_COMPILER_ID reports AppleClang on OS X, not Clang. Thus
  using: if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") would fail for
  AppleClang.  Instead, MATCHES should be used instead of STREQUAL to
  support both Clang & AppleClang.

Change-Id: I9647030b76f4b85a9ef2deea82d80ed79812ae33
2018-06-20 19:43:12 +01:00
Alex Stewart 799fd50192 Ensure host-built packages are not used when building for iOS.
- Add missing CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = ONLY, mimicking what
  we previously set for INCLUDE/LIBRARY/PROGRAM s/t the standard
  package locations on the host system will not be searched by
  find_package() when cross-compiling for iOS.
- Remove now unnecessary forced disabling of dependency options on iOS
  as they should now never be found (unless they were explicitly built
  for iOS) irrespective of whether the option defaults to ON initially.

Change-Id: I1d2c5da4838d7becb8ebd43f90a88cfc6ded4a1f
2018-06-20 09:43:26 +01:00
Alex Stewart 51dcd40ba5 Do not update CMAKE_REQUIRED_FLAGS to match CMAKE_CXX_FLAGS.
- This was a hangover from the pre-Ceres 2.0 era when we needed to
  ensure that -std=c++11 was passed to check_cxx_source_compiles() in
  FindUnorderedMap/FindSharedPtr if the user had enabled CXX11.
- Unfortunately, the same variable (CMAKE_REQUIRED_FLAGS) is used for
  both check_cxx_source_compiles() and check_c_source_compiles(), and
  thus updating it to include -std=c++11 would thus break any checks
  for C, which are made internally in the version of FindThreads.cmake
  shipped with CMake which could cause build breakage as identified
  in issue #355.

Change-Id: I36be1a21db14e3839eaf955a80bd952ef40fa269
2018-06-17 22:44:15 +00:00
Alex Stewart d7a95968ac Guard parallel_for_nothreads with CERES_NO_THREADS.
- Raised as issue #384.

Change-Id: I72954d93ce3f27b58b719b28b766c7c0e7a6faf6
2018-06-17 20:43:00 +01:00
Alex Stewart 7582834a7e Do not bypass default CMake compiler checks on iOS.
- This should no longer be required on newer (3.5+) CMake versions and
  breaks the detection of supplementary compiler feature information
  such as the population of CMAKE_CXX_COMPILE_FEATURES which is required
  in order to compile Ceres.

Change-Id: Ibceab545925aa1e829320efa03fb74ef149cbb8b
2018-06-17 16:13:56 +01:00
Pau Gargallo fda6214f33 Handle NULL permutation from SuiteSparseQR
SuiteSparseQR sets permutation to NULL when the permutation is the
identity. Thus, instead of checking that permutation is not NULL, we
handle that case when building the inverse_permutation.

Change-Id: Ib0fcdf3462da765ac0d4b7aee47a1dff7b3a6c53
2018-06-14 09:31:11 +02:00
Norbert Wenzel 1e8e9452d0 Remove chunk shuffle in multithreaded SchurEliminator
std::random_shuffle() is deprecated since C++14 and was removed in
C++17. At least MSVC with C++17 fails to compile this code, I assume
other compilers fail as well.

In a Github discussion (#373) Sameer Agarwal states this line can
likely be dropped and asks for a PR/CL.

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

Change-Id: I78e04f36cba398769b8f90916edbdaf33884e7e1
2018-05-22 17:02:02 +02:00
Sameer Agarwal e9397ad352 Enable visibility based preconditioners for CX_SPARSE and EIGEN_SPARSE
CLUSTER_JACOBI and CLUSTER_TRIDIAGONAL preconditioners require a sparse
Cholesky factorization library. Previously this code was hard coded to
use SuiteSparse. Once SparseCholesky abstraction was introduced, it
became possible to use it with Eigen or CXSParse.

Unfortunately the old code path that was enforcing the requirement
of SuiteSparse was not removed.

This change does the following:

1. Remove the SUITE_SPARSE restriction on CLUSTER_TRIDIAGONAL and
   CLUSTER_JACOBI
2. Redo the checking code to be ifdef free and more general.
3. Add bundle adjustment tests to test these configurations.

Thanks to Bjorn Piltz for catching and reporting this bug.

Change-Id: I637791f6f8149694b6aa75f6a4b6417398cb9590
2018-05-09 13:57:12 -07:00
Alex Stewart f9272d3e1b Add /bigobj to nist on MSVC.
- Required by MSVC 2017, raised as issue #368.

Change-Id: Ie1431b4c1fad7a45342a98b1fd20ab7c51d8b899
2018-05-08 09:31:22 +01:00
Alex Stewart d856af0859 Add no-threads ParallelFor implementation.
- When Ceres was configured without any multithreading enabled (actually
  the default) it would fail to build due to undefined symbols for
  ParallelFor() as there was no implementation for that case.
- This adds a trivial single-threaded implementation for that case,
  taken from the C++11 threads implementation.

Change-Id: Ib3cfd620842b09f1acafe95b8b0ba3aee4587581
2018-05-02 13:50:37 +01:00
Sameer Agarwal c6cf24cb1b Update Android.mk
1. Add some missing files.
2. Add support for EIGEN_SPARSE.
3. Enable OpenMP threading by default.

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

Change-Id: I68c6369d0176a2f48c3d036400b5b0675f2e4abb
2018-04-28 17:17:32 +00:00
Sameer Agarwal 7c037647fa Move some jet tests under a eigen 3.3.0 version ifdef
Change-Id: I65c1749d987f9b0925daed277b1373a7e31bf54d
2018-04-27 13:00:55 -07:00
Sameer Agarwal 26a470e863 Resolve two old TODOs in jet.h
1. Use using directive to pull functions from the std:: namespace
   instead of defining a forwarding function.
2. Remove Eigen 2.0 related definitions.

Change-Id: If5f24ef740c17bc4db300fa04f4a2e8f809970d2
2018-04-27 10:57:21 -07:00
Sameer Agarwal cfdc2af28b Remove Solver::Options::num_linear_solver_threads
Also removed Solver::Summary::num_linear_solver_threads_given
and Solver::Summary::num_linear_solver_threads_used.

Change-Id: I559145ae2e7af597ea06ec03d386645a3a892e9f
2018-04-26 21:13:35 -07:00
Keir Mierle cd48f83f8d Bump Ceres version to 2.0.0
Due to the large amount of changes made as part of
the C++11 migration, it makes sense to have a
large version bump.

Change-Id: I2d81828e2d8e23f0829070726e7b3ec31d7f1724
2018-04-24 17:56:25 +00:00
Sameer Agarwal dc8ef467e3 Move max_align_t handling into jet.h
This was currently buried in port.h. Since there is exactly one use
of the max_align_t handling, it is better from a readability
and cleanliness perspective to have this in jet.h.

Change-Id: I2f3dde75df7c333bd95393b9e4fc4cd5160d6afb
2018-04-23 10:03:45 -07:00
Alex Stewart f52e041c49 Fix 'xxx.cc has no symbols' warnings.
- As OPENMP, TBB & CXX11_THREADS are mutually exclusive, and their
  implementations are wholly contained within enclosing #ifdefs if the
  requisite option is not enabled then the source file is 'empty'.
- This triggers 'xxx.cc has no symbol' warnings when compiling
  Ceres statically, as such we now only include these files if they are
  not going to be empty.

Change-Id: I5390251b44c5770bbdd4ccb1bc916dbe3b1814a9
2018-04-22 14:38:54 +01:00
Sameer Agarwal 056140e3a0 Add a typedef to expose the scalar type used in a Jet.
Change-Id: I4232d76619f4f9c48a0c716150b8c5ffc8b74462
2018-04-20 14:05:14 -07:00
Sameer Agarwal 865952821f Fix a use after free bug in the tests.
The way the SystemTest fixture works is that it takes
a "FooProblem" object as a type, which contains a ceres::Problem
and a ceres::Solver::Options object.

The Options object also contains a linear_solver_ordering which
contains double* which refer to memory that is allocated when
a problem object is created.

So it is important that the lifetime of the ceres::Problem object
and the ceres::Solver::Options object be tied together. But we were
violating this by creating a FooProblem object on the stack, grabbing
its Options struct and passing it to the SystemTest fixture, which
would then create another instance of FooProblem, grab its Problem
object and copy the modified options struct into it.

In the case where a user provided ordering was being used,
this ordering would now be referring to memory allocated by the first
FooProblem object, which would cause Ceres's internal ApplyOrdering
function to fail.

The fix is ofcourse to Problem and Options object that are born
together.

Change-Id: I07c377a9d5fcabbb6c7ca8aa3460206ce045ffa9
2018-04-20 11:02:48 -07:00
Sameer Agarwal 4556eb9810 Simplify integration tests.
1. Remove SolverConfig, this was a wrapper
   around Solver::Options. As we experiment
   with more Solver::Options, it became a hurdle.

2. Updated generate_bundle_adjustment_tests.py to use
   Solver::Options directly.
3. Update system_test to use Solver::Options.

NOTE: generate_bundle_adjustment_tests.py changes are a bit
gunky, but I tried to minimize the changes in this CL
as I am going to introduce new test cases and that
is going to significantly change this file.

Change-Id: I34a2f51824b04ef368a5bbe54fbd7b281381909e
2018-04-18 17:37:20 -07:00
Sameer Agarwal d15503219f Simplify OrderedGroups using C++11 syntax
Change-Id: I3e50bb66c43245df979a471622957fd01e73d014
2018-04-18 16:32:16 -07:00
Sameer Agarwal 31f24521cc Deprecate macros.h and fpclassify.h
1. Replace CERES_DISALLOW_* with explicitly deleted constructors.
2. Replace use of CERES_ARRAY_SIZE and stack allocated arrays
   with std::vector.
3. Move CERES_ALIGN_* macros into manual_constructor.h, which is
   the one place they are used and will be deprecated along with that
   file.
4. Introduce isnan,isnormal,isinf and isfinite for Jets.
5. Replace IsNormal,IsFinite,IsNaN and IsInfinite with corresponding
   c++11 function calls.

Change-Id: I04f33a221aae77d247602150988b6d4aa4efeeab
2018-04-18 09:54:42 -07:00
Sameer Agarwal 58c5edae2f Relax an overly strict tolerance in iterative_refiner_test
Change-Id: I01afef985c0d248a50df2cadb97e4be9cd8d7889
2018-04-16 12:54:18 -07:00
Sameer Agarwal 3b2f1f7d28 Add fake FloatCXSparseCholesky and FloatSuiteSparseCholesky
Change-Id: I8d61144d0678b8da92322a18517fa6924d950653
2018-04-12 11:22:49 -07:00