Commit Graph

1177 Commits

Author SHA1 Message Date
Sameer Agarwal 39388bd2ff Address comments from William Rucklidge
Change-Id: I0c4f686b89798435741c55a5ca45cf000af842dc
2017-05-09 17:23:43 -07:00
Sameer Agarwal 0780d22c54 Remove dead code.
Change-Id: Ic6b2bccb44a97604bf966d37d2ae06f568dd999f
2017-05-08 06:47:44 -07:00
Sameer Agarwal 086ff01aca Matrix generation cleanup
1. Convert a CompressedRowSparseMatrix constructor which
takes a TripletSparseMatrix as input into a factory method
which allows the input to be transposed.

2. Move the random matrix creation routine for CompressedRowSparseMatrix
from being a standalone function to a static method.

3. Add a corresponding random matrix generation static method to
TripletSparseMatrix.

4. Add a new constructor to TripletSparseMatrix, which takes as input
the row, col and values arrays.

Change-Id: Iec7b184646818f432a5e6822bea3b2f3128a82aa
2017-05-01 22:53:21 -07:00
Alex Stewart d72e19d985 Use target_compile_features() to specify C++11 requirement if available.
- Use target_compile_features() to specify the C++11 dependency for
  Ceres if the CXX11 option is enabled and the current CMake version
  supports it (>= 3.1).  Otherwise fall back onto our existing
  target_compile_options() solution if available.
- We prefer the use of target_compile_features() if available as it more
  gracefully handles ‘upgrading’ of the C++ standard in client projects
  that depend upon Ceres, e.g. if the client requires C++14.  The
  current solution may fail to produce the expected result in this case
  as raised in
  https://github.com/ceres-solver/ceres-solver/issues/273.

Change-Id: Ib3cff8d4b9fe93fa6d6b376b4dd53923bb1c4ecc
2017-04-30 14:51:03 +00:00
Sameer Agarwal 1d7185f130 Refactor SparseNormalCholeskySolver
Now that there is a single piece of code doing the outer product
computation for all three sparse linear algebra backends, move
this code one level up the call stack and there by make the actual
per-library solver code shorter and simpler.

Also fix a minor omission in the outer product computation code
where row/column blocks were not being copied over to the
outer product matrix.

Change-Id: I22a7967bdc659385b741901afefa7af312e676e5
2017-04-27 01:45:05 -07:00
Sameer Agarwal 0859fe8a57 Integrate InvertPSDMatrix into the SchurEliminator.
SchurEliminator::Init now takes a bool that tells it whether
it can assume that the diagonal blocks it is inverting can
be assumed to be full rank or not.

This information is then passed onto InvertPSDMatrix.

Change-Id: I26037b6233f2aad5584fed245f631c3959928afe
2017-04-25 10:08:45 -07:00
Keir Mierle aaae5c5f62 Update docs: .netrc --> .gitcookies
Change-Id: Ic1d66a25fe74e33667ab71bcf0b346ac3a632257
2017-04-25 01:32:31 +00:00
Sameer Agarwal c9abea1fa0 Add InvertPSDMatrix.
This helper function lets the user compute the inverse or
the pseudo-inverse of a matrix.

Change-Id: Ia257859ad901debce2ea19f47907faf0b7b94759
2017-04-25 01:30:44 +00:00
Ricardo Sanchez-Saez 08d02d7177 Fix implicit precission loss warning on 64-bit archs
Change-Id: Ia9212be3678ea6c92e9aef0e3f5c14447c9d9f88
2017-04-22 16:25:18 -07:00
Alex Stewart 74df65b142 Optionally use exported Eigen CMake configuration if available.
- Updates FindEigen.cmake to default to an installed Eigen CMake
  Configuration if available, otherwise falls back to previous behaviour
  of searching for Eigen components.
- This mimics the behaviour of FindGflags.cmake & FindGlog.cmake.

Change-Id: Ifce948d554a0135ce1a0c443267c0230e516f14b
2017-04-19 16:16:27 +01:00
Sameer Agarwal 85d276c84d Remove future looking comments from types.h
Change-Id: I2c801980778e2575ef8eaa52eafbdb3724f1ae01
2017-04-18 07:46:06 -07:00
Sameer Agarwal 7d1ec64384 Add a missing file.
Change-Id: I4a60a2715d05b6ad158358e150e78226b418cdbd
2017-04-17 15:09:28 -07:00
Sameer Agarwal 14d8297cf9 Refactor Covariance::Options::algorithm_type.
THIS IS AN API BREAKING CHANGE.

Decouple the algorithm from the sparse linear algebra
library being used to perform the computation.

Before this change

Covariance::AlgorithmType had values

DENSE_SVD
EIGEN_SPARSE_QR
SUITE_SPARSE_QR

This has been replaced by two enums now.

Covariance::Options::sparse_linear_algebra_library_type
which can take values EIGEN_SPARSE, SUITE_SPARSE or CX_SPARSE.
The last one is currently not supported.

And Covariance::Options::algorithm_type takes values

DENSE_SVD
SPARSE_QR

This sets the stage for future extensions of the covariance
computation algorithm.

Also as part of this change, the covariance computation chapter
has been made a top level chapter on its own instead of being
buried deep inside the Solving Non-linear Least Squares problem.

Change-Id: Ibfbf60902d8d17694d9ff585047a5a57d329ab22
2017-04-17 09:43:22 -07:00
Sameer Agarwal 5ee2b356b3 Untabify changes from Jim Roseborough
Change-Id: Ic640b34ba785669b415acfbeb2c931bea768f985
2017-04-13 13:17:29 -07:00
Sameer Agarwal d04347af43 Delinting from William Rucklidge.
Change-Id: I1b0243d43d55b6c9cdcda9d4b677ec444928b223
2017-04-13 11:47:01 -07:00
Sameer Agarwal a171ba095c Fix an off by one error in the transpose code.
Change-Id: I0ebcf2e8e29dc48376f60c3fa8d6100b20ec105f
2017-04-13 09:47:49 -07:00
Sameer Agarwal 9a6b4a6491 Fix a bug in the transpose code.
Change-Id: I1ce997329c7d59b831b84bf41d470ce686fea566
2017-04-13 07:27:48 -07:00
Sameer Agarwal 3de61fc9c0 Improve comments for TransposeForCompressedRowSparseStructure.
Also make the code a little more safe in its assumptions around
zeroed out arrays.

Change-Id: I5a3588162da496fae2b31a4bf8adef1a02b85ec6
2017-04-13 07:11:58 -07:00
Sameer Agarwal bb5c3bb001 Fix the build.
Change-Id: I87216d4a349fa7cb297c502a90cb54c02b9b4445
2017-04-13 06:20:13 -07:00
Sameer Agarwal 9a4f554b85 Change a size() == 0 to empty
Change-Id: I79c7021781093ab1cc25e6cc9700e2a83169daac
2017-04-12 14:42:00 -07:00
Sameer Agarwal 1f8fa9d26b Various grammar and lint corrections.
Thanks William Rucklidge as usual :)

Change-Id: I787b3a0302bcfd08dc1be165d39b7295e58ff20f
2017-04-12 13:37:28 -07:00
Sameer Agarwal 0b74859788 Fix how NOT binds in the if statement
Change-Id: Ia6a165abc7c898b031d73179eaf318d8d0c229ec
2017-04-11 12:26:02 -07:00
Sameer Agarwal 64a20e7ce2 Remove dead code from CompressedRowSparseMatrix.
SolveLowerTriangularInPlace
SolveLowerTriangularTransposeInPlace

were unused functions which can be removed.

Change-Id: I0fd29c1efae2a0a74666f6e3541473bebc22ae82
2017-04-11 12:10:40 -07:00
Sameer Agarwal 3d0588b24d Remove dynamic sparsity handling from SparseNormalCholeskySolver
Change-Id: I25d1f9dfe14f9cf526ff7aad1a88ca0e711f6caa
2017-04-11 11:59:52 -07:00
Sameer Agarwal 5c2fd0526a Add DynamicSparseNormalCholeskySolver
This code was currently buried under a bool inside SparseNormalCholeskySolver.
Pulling this out in its own solver makes the code simpler more readable
and more performant in the case of SuiteSparse.

Change-Id: I72379ca9ca162abbb83c12f7ee8ff92bc71e772c
2017-04-11 11:55:43 -07:00
Sameer Agarwal 2755fce8d3 Add a storage type to CompressedRowSparseMatrix
By adding an enum to CompressedRowSparseMatrix, which indicates
whether the matrix is unsymmetric, upper or lower triangular
we are able to improve the readability and fix some minor
bugs in the way some matrix manipulation code was being
called.

Thank to William Rucklidge for this suggestion.

Change-Id: I355c90d11cd5d31f5a25741b0bda4fc4583e9095
2017-04-11 11:47:42 -07:00
Sameer Agarwal 5f41a60458 Refactor CreateRandomCompressedRowSparseMatrix
Move it to compressed_row_sparse_matrix.h/cc for upcoming re-use.
Also clean up the tests for ComputeOuterProduct so that they do
not depend on CXSparse anymore and use Eigen instead. This also
makes the test simpler and shorter.

Change-Id: I06bbeb3b0c6a07fb1f3da354ef0abd17d246be9a
2017-04-11 11:33:37 -07:00
Sameer Agarwal 056d21d948 Fix a bunch of typos in the documentation.
Thanks William Rucklidge.

Change-Id: I3843f90897a61938a2641ef8fb43bcd3ec7796a1
2017-04-10 18:16:57 -07:00
Sameer Agarwal afe1382ff7 Add missing <iterator> include.
Change-Id: Ied1199569d952fcdcaa0171893631d01d40eea7f
2017-04-10 11:55:05 -07:00
Cheng Wang 07dbf31eca Optimize J' * J in sparse_normal_cholesky_solver.
1. Add stype to the outerproduct computation to control the output
matrix in upper or lower triangular matrix. For SuiteSparse,
upper triangular matrix is generated. SuiteSparse can directly use
this matrix format for cholesky without matrix transpose overhead.

2. Change the outerproduct computation to block multiplication.  This
reduces the computation complexity for the sort in preprocessing, also
allows formulation of the block outerproduct computation as dense Eigen
block matrix multiplication.

3. Solve 32 Tango problems on Qualcomm MSM8994 Cortex-A53 (1.55GHz)
   before change: 140 seconds
   after change: 131 seconds

Change-Id: I8054114cef911de6a303310a448821ca296e4744
2017-04-10 09:50:34 -07:00
Alex Stewart 0a50cd8244 Fix typo in docs: max_lbfs_rank -> max_lbfgs_rank.
Change-Id: I49ffec85c2b43fe4f51fd214f461c2ec51360270
2017-04-04 16:56:46 +01:00
Alex Stewart c123864372 Use Ceres_[SOURCE/BINARY]_DIR not CMAKE_XXX_DIR to support nesting.
- Using Ceres_[SOURCE/BINARY]_DIR (which are defined by CMake when
  project(Ceres) is called, in favour of CMAKE_[SOURCE/BINARY]_DIR
  enables Ceres to be nested within (and built by) a larger CMake
  project (which also contains other projects).
- CMAKE_[SOURCE/BINARY]_DIR always refers to the top-level source
  and binary directories (i.e. the first encountered), as a result if
  Ceres is a nested project within a larger project, these would not
  correctly identify the source/binary directories for Ceres (as they
  would refer to the root project in which Ceres is nested).
- Using Ceres_[SOURCE/BINARY]_DIR should ensure that Ceres always uses
  the correct source/binary directories, irrespective of whether Ceres
  is nested or not.

Change-Id: I62226ea3f6552b1d7e2bdac1aef02f1f489ae55e
2017-04-03 14:47:29 +01:00
Sameer Agarwal d02b5d7022 Update Problem::EvaluateOptions documentation.
Thanks to Ricardo Martin for reporting this.

Change-Id: Ic3ce60f8de419f1d2cb19c949054049da79fe91a
2017-03-31 19:03:34 +00:00
Devin Lane f4233598db Add public headers to CMake target for IDEs.
Change-Id: I952c5005689d34bdb7b89820b3aee62f3dcf6fd6
2017-03-29 20:31:19 -06:00
Sameer Agarwal 7146d16dbf Add an article on interfacing with automatic differentiation.
Doing this also necessitated some re-organization of the derivatives
article into chapters and some minor edits.

Change-Id: Ic08e83af138817173caa80a52a9e72707cd57512
2017-03-26 12:47:57 -07:00
Alex Stewart 04291898fd Add default Fedora/Debian locations for CXSparse to search paths.
Change-Id: I7361ae3e821eb1f481b28dc9b94f57cb5eb0093f
2017-03-24 14:01:34 +00:00
Tal Ben-Nun 375a385b2b Revert MSVC compile fix as it is already addressed in CMakeLists.txt
Change-Id: I2ea89c6de7593d77cdf31636686beb05ae6833e9
2017-03-20 14:23:35 +01:00
Sameer Agarwal 85c6b5c308 Add a test for LineSearchMinimizer
Ensures that a quadratic function can be minimizer to zero
and the final cost is reported correctly.

Change-Id: Ib03752b627988dc8038566ed1fa444b7d9d2fd2d
2017-03-19 21:12:53 -07:00
Tal Ben-Nun 66be7c3a0e MSVC compile fix for ellipse approximation
Change-Id: Ib67a2219ee171770f2ab96dcc261a610d515b6a6
2017-03-20 00:50:43 +01:00
Sameer Agarwal 419f330394 Flatten the table of contents.
Remove the "Guide" and expose the modeling and solving non-linear
least squares in the left hand side navigation bar.

Change-Id: Ibbb4f0f580a5981165a0945570fc0f4c4ea559e9
2017-03-19 16:46:26 -07:00
Sameer Agarwal e9eb8a324e Fix when LineSearchMinimizer adds the IterationSummary to Solver::Summary
Previously, even when an iteration was successful, the LineSearchMinimizer
would only add the iteration summary to the Summary object if none
of the convergence tests were passed. This could cause iterations with
significant progress in the last iteration to be mis-reported.

The solution would be correct, but the actual cost would be misreported.

This change changes the order of these operations and ensures that
the iteration summary is added whenever the iteration itself is successful.

Thanks to Daniel Weindl for reporting this.

Change-Id: Iff10eccb49d50ad28127f44e149c17fa466db4ae
2017-03-19 00:38:01 -07:00
Alex Stewart af3b9394ea Fix search path for miniglog headers when Ceres is exported.
- When Ceres is exported (rather than installed), the miniglog headers
  still reside in the internal Ceres source directory, not the public
  headers directory.

Change-Id: Ia54eb7f8bb0cd24c0112a715a739c15247bc9239
2017-03-09 18:19:16 +00:00
Alex Stewart 987d3b6b37 Fix ambiguous reference to WARNING when using miniglog.
- When compiling on Clang on OS X with MINIGLOG enabled, name lookup
  finds two ambiguous definitions of WARNING, one in the global
  namespace and one in the google namespace, both defined in the
  miniglog version of logging.h.

Change-Id: I6f1ad7d2750e1ed20ec1ba4574aab599086431df
2017-03-09 11:56:50 +00:00
Julien Pilet e5dceb3ab0 Fix Jet/Eigen compatibility for Eigen > 3.3
Honour the digits10 NumTraits member introduced in Eigen 3.3.

Change-Id: If20183332beef8335b7758cdb58859a43fc59970
2017-02-28 10:34:26 +01:00
Sameer Agarwal 1ebaff8a10 Two bug fixes.
1. Add schur_templates.cc to Android.mk
2. When detecting the Schur structure of the Jacobian,
   the check for whether linear solver being used is indeed
   of Schur type or not, should use the LinearSolver::Options
   struct created and populated by the preprocessor rather than
   depending on the value in the input Solver::Options. The reason
   is that the preprocessor may change the linear solver type
   depending on the lack of a Schur structure in the problem.

Change-Id: I6f018f6817c05d704409181c7b1e25155528ab84
2017-02-27 15:01:25 -08:00
Sameer Agarwal 784260d0b8 Fix missing ddd Schur specialization generation code
Change-Id: Ic808565844b0564b5fa5f94cbda69e9a18ac49ee
2017-02-27 11:53:22 -08:00
Sameer Agarwal 5f87f35cec Changes from William Rucklidge
Change-Id: Ia5d724edef947870fe13050a71aa1cba878352a8
2017-02-27 11:09:08 -08:00
Taylor Braun-Jones 6120507e03 Add max severity option when MINIGLOG is enabled
Change-Id: I33609464ace6d4d962d81f21f57c42981d2fdfc9
2017-02-24 13:31:54 -05:00
Sameer Agarwal 1cfec3c666 Improvements to Schur template specializations
1. Refactor the python code that generates the template specializations
   to remove code duplication.
2. Improved the logic for template specialization selection where
   Eigen::Dynamic now serves as a wildcard.
3. Added schur_templates.h/cc which allows querying the set of available
   template specializations without instantiating a linear solver.
4. Added Solver::Summary::schur_structre_given and
   Solver::Summary::schur_structure_used and expose them in
   Solver::Summary::FullReport for better performance debugging.
5. Updated the templates with newer dates and some minor comments cleanup
   which lead to the the template specializations to be re-generated.

Change-Id: Iaf3c6f714353597899916c300465da01f151c3de
2017-02-23 14:52:59 -08:00
Sameer Agarwal 5dd76f9f00 Corrections from Bjorn Piltz
Change-Id: I2b56eb29db4b90b22c472d36747ca04e3c06b89f
2017-02-22 11:56:38 -08:00