Commit Graph

477 Commits

Author SHA1 Message Date
Sameer Agarwal d61b68aaac Lint cleanups from William Rucklidge
Change-Id: Ia4756ef97e65837d55838ee0b30806a234565bfd
2013-08-16 17:02:56 -07:00
Sameer Agarwal b22d063075 Reduce memory usage in covariance estimation.
When using the SPARSE_QR algorithm, now a Q-less
factorization is used. This results in significantly
less memory usage.

The inversion of the semi-normal equations is now
threaded using openmp. Indeed if one has SuiteSparse
compiled with TBB, then both the factorization
and the inversion are completely threaded.

Change-Id: Ia07591e48e7958d427ef91ff9e67662f6e982c21
2013-08-16 10:48:54 -07:00
Sergey Sharybin f258e4624f Move most of suitesparse/cxsparse ifdef code to their headers
Main purpose of this is to make implementation files free from
endless ifdef blocks every time this libraries are needed to be
included. This would hopefully prevent compilation errors in
the future caused by missing ifdef around header include.

This also includes some stubs added to suitesparse/cxsparse
headers to make code even more free from ifdefs.

Change-Id: Ic8554e7df31d8c4751583fe004b99e71b3c9087b
2013-08-15 17:54:55 +00:00
Sameer Agarwal dc60d9c451 Fix broken android build.
Change-Id: I6f27e3ef9bd678f7393c9f573491064978e9c368
2013-08-15 10:13:45 -07:00
Sameer Agarwal 367b65e17a Multiple dense linear algebra backends.
1. When a LAPACK implementation is present, then
DENSE_QR, DENSE_NORMAL_CHOLESKY and DENSE_SCHUR
can use it for doing dense linear algebra operations.

2. The user can switch dense linear algebra libraries
by setting Solver::Options::dense_linear_algebra_library_type.

3. Solver::Options::sparse_linear_algebra_library is now
Solver::Options::sparse_linear_algebra_library_type to be consistent
with all the other enums in Solver::Options.

4. Updated documentation as well as Solver::Summary::FullReport
to reflect these changes.

Change-Id: I5ab930bc15e90906b648bc399b551e6bd5d6498f
2013-08-13 14:57:03 -07:00
Sameer Agarwal 080d1d04bd Use more performant, less conservative Eigen solvers.
colPivHouseholderQR -> householderQR
ldlt -> llt.

The resulting performance differences are significant enough
to justify switching.

LAPACK's dgels routine used for solving linear least squares
problems does not use pivoting either.

Similarly, we are not actually using the fact that the matrix
being factorized can be indefinite when using LDLT factorization, so
its not clear that the performance hit is worth it.

These two changes result in Eigen being able to use blocking
algorithms, which for Cholesky factorization, brings the performance
closer to hardware optimized LAPACK. Similarly for dense QR
factorization, on intel there is a 2x speedup.

Change-Id: I4459ee0fc8eb87d58e2b299dfaa9e656d539dc5e
2013-08-13 21:27:55 +00:00
Sergey Sharybin fb465a03b8 Fix compilation error caused by missing suitesparse headers
Covariance implementation file used to unconditionally include
SuiteSparseQR.hpp which caused compilation error in cases you
don't have SuiteSuite installed to the system

Moved the include to #ifdef block.

Change-Id: I3a52c0f81711b2b70ae625fe80b758ecb0817cc6
2013-08-05 22:35:14 -07:00
Steven Lovegrove 2460bf0733 Check GCC Version before adding -fast compiler option on OSX.
-fast compiler option is only supported using Apple's GCC packaged with XCode.
Other GCC versions will fail when this flag is enabled. This commit checks the
GCC version on OSX and only enables this flag when < 4.3. Apple's GCC is
currently 4.2.1 and a user is unlikely to install a non-apple version this old
on OSX.

Change-Id: Ifca9149625c065cd16559d7e30c218a322cf79aa
2013-07-21 13:13:11 -04:00
Sameer Agarwal c5bcfc01af Lint fixes from Jim Roseborough.
Change-Id: If93e1972041b36410225a509e3c8c7c818f92124
2013-07-19 15:50:27 -07:00
Sameer Agarwal 16924168ce Update version from 1.6.0 -> 1.7.0rc1.
Change-Id: I420a8907142bffad0e3aa6c7196541ca2309c099
2013-07-18 13:35:01 -07:00
Sameer Agarwal 588228bdad Add the ability to turn shared library compilation on and off
Change-Id: Ib9eacfbc894bb2b66aafff3b930c63e2ad8a555e
2013-07-18 11:29:19 -07:00
Sameer Agarwal 6d93450cb5 Fix build breakage on old versions of SuiteSparse.
SuiteSparse_long is only defined in recent versions of SuiteSparse
as the index variable type for large matrices. In older versions
UF_long was used. Ubuntu still ships with an older version of
SuiteSparse, so an ifdef is needed to fix the build.

This patch has been tested on mac and on linux with older and
newer versions of SuiteSparse.

Change-Id: I4ada86d7973784a79bde4afec13ce3ca4e8dc225
2013-07-18 11:08:07 -07:00
Sameer Agarwal 42be9cafe6 Update documentation for Covariance
Change-Id: Ia4a7347ef8267b7107698d85fcbfc986111958dc
2013-07-18 08:02:08 -07:00
Sameer Agarwal 5a974716e1 Covariance estimation using SuiteSparseQR.
Change-Id: I70d1686e3288fdde5f9723e832e15ffb857d6d85
2013-07-17 22:56:01 -07:00
Sameer Agarwal 719889b8b7 Minor fixes
1. Typo in c_api.h
2. The stream operator for FunctionSample is now in the ceres::internal namespace.

Change-Id: Id927a7a49c47d8903505535749ecca78cd2e83b3
2013-07-17 11:31:08 -07:00
Alex Stewart 12cc164f79 Minor fix to reject a line search config with negative L-BFGS rank.
Change-Id: Iad4c678efe574ef6696c34bd2a0ce61a504c7344
2013-07-17 12:08:33 +01:00
Alex Stewart 9aa0e3cf72 Adding Wolfe line search algorithm and full BFGS search direction options.
Change-Id: I9d3fb117805bdfa5bc33613368f45ae8f10e0d79
2013-07-17 08:14:20 +00:00
Sameer Agarwal 51c772c843 householderQR -> colPivHouseholderQR.
Change-Id: Ida623e853711f665e7a9d3b140a93e861591f96d
2013-07-16 16:42:52 -07:00
Sameer Agarwal c2c6411d16 DENSE_QR solver now uses non pivoting QR decomposition.
Change-Id: I9099221448ccf71d0de20b9f652405009a6c24c5
2013-07-16 16:51:41 +00:00
Sameer Agarwal 3c2ad4018c Speed up Automatic differentiation by 7%.
1. Templatize Make1stOrderPerturbation.
2. Convert a hard CHECK into DCHECK.

Change-Id: I02cd67f2b87bc5722f1a090057d55f23e98d2c3b
2013-07-15 08:09:38 -07:00
Sameer Agarwal 0a07fbf873 Use ATLAS as the example BLAS in building.rst
OpenBLAS has subtle issues releated to threading. It
conflicts with the use of threads in the other parts of
the application.

Careful users can still use it by disabling threads via
an environment variable, but by default we want to use
a BLAS/LAPACK that does not suffer from these problems.

Change-Id: I8c1c0ed0b526453564c5f9ea69b646fac32fe027
2013-07-10 17:02:18 -07:00
Sameer Agarwal aee5597acf Minor fix to curve_fitting.c
Change-Id: Ib3669a5c4c73178b088dc1e80141f844f807b179
2013-07-09 23:31:25 -07:00
Sameer Agarwal bd82f82c3a More CMake file cleanup.
Reduce the verbosity of the Cmake file. All the "Checking for"
messages have been removed since we log both success and failures.

Further, UFConfig is only searched for if SuiteSparse_config cannot
be found.

Change-Id: I601a6ffc808e566ff78ce232c86519ef413f0b33
2013-07-09 23:19:09 -07:00
Sameer Agarwal 9f4552b647 Stop CMake from trying to detect OpenMP when using Clang.
Change-Id: Ie14c6466475b401ba35dbf13adc2e8701999c969
2013-07-09 00:10:08 -07:00
Keir Mierle 6e8bd501b2 Extend the C API to support loss functions
This extends the C API to support loss functions. Both
user-supplied cost functions as well as the stock Ceres cost
functions (Cauchy, Huber, etc) are supported. In addition, this
adds a simple unit test for the C API.

Supporting loss functions required changing the signature of the
ceres_add_residual_block() function to also take a thunk for the
loss function.

Change-Id: Iefa58cf709adbb8f24588e5eb6aed9aef46b6d73
2013-07-09 06:28:55 +00:00
Sameer Agarwal 1ab7fde626 Update gmock and gtest to the latest svn versions.
This fixes a variety of mac/clang/c++11 issues.

Change-Id: I52e76d733cd53c9bb2fda125e51a6b58a90e41b3
2013-07-08 22:41:41 -07:00
Sameer Agarwal eeedd2e191 Rationalize some of the variable names in Solver::Options.
lm_max_diagonal -> max_lm_diagonal
lm_min_diagonal -> min_lm_diagonal
linear_solver_max_num_iterations -> max_linear_solver_iterations
linear_solver_min_num_iterations -> min_linear_solver_iterations

This follows the pattern for the other parameters in Solver::Options
where, the max/min is the first word followed by the name of the
parameter.

Change-Id: I0893610fceb6b7983fdb458a65522ba7079596a7
2013-07-07 23:04:31 -07:00
Sameer Agarwal 7a8f797924 Lint fixes
Change-Id: Ic453597488ef92723a81a224e7443e8f454b25da
2013-07-03 09:03:55 -07:00
Sameer Agarwal 67ccb7379e Fix broken build.
Change-Id: Ieb122bb96d5776f962fff6d6e9345dfc855bfed7
2013-07-03 06:28:34 -07:00
Sameer Agarwal 4f010b2db0 Improve Summary::FullReport when line search is used.
Disable reporting of preconditioner when direct factorization
is being used.

Change-Id: Id264d2292c5cab608724a6a8fab5d588db950468
2013-07-01 08:01:01 -07:00
Sameer Agarwal 09244015e3 Expose line search parameters in Solver::Options.
Change-Id: Ifc52980976e7bac73c8164d80518a5a19db1b79d
2013-06-30 22:51:21 -07:00
Sameer Agarwal 1c70ae9aa6 Fix Solver::Summary when line search is used.
Also enable line search in bundle_adjuster.

Change-Id: Ic4343a4334b9f5a6fdeab38d4e3e1f6932bbc601
2013-06-30 12:50:43 -07:00
Alex Stewart 70b06c89c7 Fix update of L-BFGS history buffers after they become full.
Previously there was an assignment dimension mismatch in the
history update; thus, over time, the history would contain
(only) replicated copies of the (max_num_corrections_ -1)-th
update and the most recent update.

Change-Id: I26203acf689686d41a5029c675ebbe001fe05d90
2013-06-30 18:49:56 +01:00
Sameer Agarwal a427c877f9 Lint cleanup.
Change-Id: Ie489f1ff182d99251ed8c0728cc6ea8e1c262ce0
2013-06-24 18:04:28 -07:00
Sameer Agarwal 6a7c1037d9 Remove dead code that depends on protobuf support.
Change-Id: I9dc948f25f492af6d8de7987a32ba7afc20b81da
2013-06-24 17:21:02 -07:00
Sameer Agarwal 79d9353036 Remove Protocol Buffers support.
Change-Id: I451c543c82cdfb566736aab94d836abcfb5c689d
2013-06-24 14:28:40 -07:00
Sameer Agarwal 5d00bf40f5 Fix the broken build.
1. When protocol buffers support is enabled CompressedRowSparseMatrix
   has a missing virtual method.
2. When SuiteSparse is missing, covariance_test tries to run the
   large scale covariance computation test.

Thanks to Alex Stewart for reporting #1.

Change-Id: I4238c966036362175e31749595ea8bb6f12a696c
2013-06-24 13:24:35 -07:00
Sameer Agarwal c367b12eeb Incomplete LQ Factorization.
Drop support for protocol buffers.
Add CompressedRowSparseMatrix::CreateBlockDiagonalMatrix.
Add CompressedRowSparseMatrix::SolveLowerTriangularInPlace.
Add CompressedRowSparseMatrix::SolveLowerTriangularTranposeInPlace.
Add CompressedRowSparseMatrix::Transpose.

Change-Id: I2328afca9fac632685eac72ebb00998bd3510187
2013-06-23 21:45:57 +00:00
Sergey Sharybin 72cc457a43 Fix configuration error on systems without SuiteSparse installed
Issue was caused by the way how SUITESPARSE_FOUND was set and
used in IF conditions later. Basically, SUITESPARSE_FOUND was
setting to a value which needed to be expanded using ${} to get
it's actual value.

Made it so SUITESPARSE_FOUND is setting to either TRUE or FALSE
from an IF condition which does check for whether all the
dependencies are met.

Also removed expanding some of the variables in IF conditions,
they're not needed actually.

Change-Id: Iad01a3a49fb500375e344e5352a56a0c89be3b5a
2013-06-23 21:12:20 +00:00
Arnaud Gelas 044786669d Enforce the read call returns correct value
fix compilation error on Ubuntu 12.0

In file included from /usr/include/fcntl.h:252:0,
                 from /home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc:91:
/home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc: In member function ‘T {anonymous}::EndianAwareFileReader::Read() const [with T = unsigned char]’:
/home/ajg23/src/ceres-solver/examples/libmv_bundle_adjuster.cc:300:5: error: ignoring return value of ‘ssize_t read(int, void*, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]

Change-Id: Ib23ca19778761bbfe0d77bcf32a2181ce6db1a12
2013-06-21 16:05:15 +02:00
Sergey Sharybin 8b26cc7d35 Fix compilation error on systems without SuiteSparse installed
Issue was caused by declaring class PerThreadContext with some
members of choldmod-specific types. This class in only used from
an #ifndef CERES_NO_SUITESPARSE block and solved compilation error
by simply wrapping PerThreadContext with the same #ifndef block.

Change-Id: Icdc329073fcbd4a328e41ea8c0af0962e9c34ba8
2013-06-19 21:04:02 +06:00
Richard Stebbing 6dd18563a1 Fix DynamicAutoDiffCostFunction
Changed DynamicAutoDiffCostFunction to handle multiple derivative
sections as opposed to just a single contiguous block.

In the previous implementation it was assumed that non-constant
parameters occur in a single contiguous block so that constant
parameters could NOT lie between non-constant parameters. Previously,
start_derivative_section was first set as soon as the first
non-constant parameter block (marked by jacobians[i] != NULL) was
encountered. After this, entries in input_jets[parameter_cursor].v were
accessed with `parameter_cursor - start_derivative_section`. For
contiguous non-constant parameter blocks this is fine, but if constant
parameter blocks fall between then this indexing is incorrect because
`parameter_cursor - start_derivative_section` can go out of bounds.

For a concrete example, take a cost function with three parameter
blocks, each of size 1 and with the center block fixed. Assume that
Stride=1 so that two passes are required. On the first pass
start_derivative_section=0, and the first variable block is handled
correctly. At the end of the first pass end_derivative_section=1, so
for the second pass start_derivative_section=1. Now comes the problem.
When parameter_cursor=1, parameter_cursor >= start_derivative_section
so jacobian[1] is checked to be NULL. Since it is NULL (second
parameter block is constant) then nothing is done and
active_parameter_count is NOT incremented. Next, when
parameter_cursor=2, parameter_cursor >= start_derivative_section and
jacobian[2] is checked. Since it is not NULL then
input_jets[parameter_cursor].v[parameter_cursor -
start_derivative_section] is set to 1.0, BUT parameter_cursor -
start_derivative_section = 2 - 1 = 1 which is out of bounds
(input_jets[parameter_cursor].v is only of size Stride=1).

The proposed solution records the start of each contiguous block of
non-constant parameters and indexing into
input_jets[parameter_cursor].v is independent of parameter_cursor.

Change-Id: I388ab6a0bafa35d317491135ec6fe980453ff888
2013-06-19 02:24:31 +01:00
Johannes Schönberger 1b89595b4c Fix Problem::RemoveParameterBlock documentation
Ordering of Problem::RemoveParameterBlock and Problem::RemoveResidualBlock
changed, as RemoveResidualBlock is being referred in RemoveParameterBlock
with "above".

Change-Id: I07f8e7b7e20ba239a72c15ed9e79576f5def090a
2013-06-16 14:35:06 +02:00
Sameer Agarwal a7eb1d5fab Lint cleanup
Change-Id: I77e84d21e62a0316cab211aafa243d0e11bd8858
2013-06-14 10:25:33 -07:00
Sameer Agarwal 6445bb1a46 Fix a logging bug in parameter_block.h
Not entirely sure how and why this was compiling up till now.

Thanks to Carlos Hernandez for reporting this.

Change-Id: Ieadbb8cb0a3769afe9dcef927ff0287342e44f1f
2013-06-14 10:21:48 -07:00
Sameer Agarwal 2f1454faf2 Add a templated TypedPreconditioner class.
This sets the stage of preconditioners that can utilize
different kinds of matrix layouts, just like the LinearSolver
class hierarchy.

Change-Id: I3579cf344bcd2eeeecb1ae621cab02a3c9a0f920
2013-06-13 23:49:19 -07:00
Sameer Agarwal 85b7e9d3c1 Fix an uninitialized variable warning when building with GCC.
Change-Id: I6f24553a9c4dfb59e05778f19406aefa058b6342
2013-06-13 23:01:01 -07:00
Sameer Agarwal c4a329155c Enable support for dumping trust region minimizer problems.
This support was broken due to the TrustRegionMinimizer refactoring.
It is now enabled again, with the responsibilty for dumping the
problem shifted to the individual TrustRegionStrategy.

There is however one wrinkle, which is perhaps an indication of
poor design to start with. The LinearLeastSquaresProblemProto
carries in it num_eliminate_blocks, something which does not
exist anymore. More importantly, the TrustRegionStrategy does not
have access to this quantity anymore.

Dealing with this will be the subject of a future change.

Change-Id: I358adf6a2e386f4940b617bf950d6c7e87d2635d
2013-06-13 22:00:48 -07:00
Sameer Agarwal 5f433c8a22 Fix a reallocation bug in CreateJacobianBlockSparsityTranspose.
CreateJacobianBlockSparsityTranspose starts with a conservative
estimate of the size of the block sparsity pattern of the Jacobian.
When the Jacobian has more non-zeros than that, the TripletSparseMatrix
being used to store the sparsity has a Reallocate method which
allows one to resize the matrix and IF num_nonzeros is set, then the
existing values in the array are also copied into the newly allocated
memory.

Unfortunately the pattern we follow in ceres code is to call
set_num_nonzeros after one is done populating the sparsity pattern
of a matrix. This does not mix well with Reallocate and results
in the matrix having uninitialized memory.

This patch fixes this problem and adds a test that verifies the fix.

Thanks to Yuliy Schwartzburg for reporting this bug and providing
code to reproduce it.

Change-Id: I58583714ffaebd880d85af16e3685b2d6ee053e8
2013-06-13 06:57:58 -07:00
Sameer Agarwal 1f17f56c4e Add Covariance documentation to html docs.
Change-Id: I11ddc9f7069964596760c6ea4d85c44312c0a67a
2013-06-09 23:23:38 -07:00