Commit Graph

27 Commits

Author SHA1 Message Date
Sameer Agarwal bcc865f81c Remove using namespace std;
For historical reasons we had a "using namespace std;" in port.h. This
is generally a bad idea. So removing it and along the way doing a bunch
of cpplint cleanup.

Change-Id: Ia125601a55ae62695e247fb0250df4c6f86c46c6
2015-01-07 14:26:53 -08:00
Alex Stewart e81a5dd300 Ignore warnings from within Eigen/SparseQR (3.2.2).
- As reported by Chris Sweeney on the mailing list, Eigen 3.2.2
  trips various warnings in Eigen/SparseQR when compiling with GCC.
- Following Petter Strandmark's suggestion, Eigen headers are now
  treated as system headers, which implicitly suppresses all warnings.

Change-Id: I104e8cb3f00935cefb894089bea827771e0e9fd0
2014-10-28 13:04:46 +00:00
Alex Stewart 6c25185bb1 Fix crash in Covariance if # threads > 1 requested without OpenMP.
- Previously if options.num_threads > 1 was given to Covariance compiled
  without OpenMP, a CHECK() would be triggered in program_evalutor.

Change-Id: Iaade4f5ed5326b0c59a7014c750c41ee026e1124
2014-08-28 16:07:51 +01:00
Alex Stewart b27a2044b3 Fix type of suppressed compiler warning for Eigen 3.2.0.
- Warning type generated is unused-but-set-variable, not unused-variable
  and the corresponding "local variable is initialized but not
  referenced" MSVC warning.

Change-Id: I716fd6a87cc91533bc862b2ef932601c8857818d
2014-07-22 19:38:50 +01:00
Alex Stewart b76615a670 Suppress unused variable warning from Eigen 3.2.0.
- Eigen 3.2.0 emits an unused variable warning from Ordering.h
  #included by Eigen/SparseQR which prevents Ceres compilation due
  to -Werror.
- As Eigen 3.2.0 is still in widespread use, we explicitly disable
  the warning only around the inclusion of Eigen/SparseQR.

Change-Id: I48ce905ef6a22bc1b06f9e5bed328bd315f407f0
2014-07-22 18:18:08 +00:00
Sameer Agarwal 060a850602 Remove SPARSE_CHOLESKY based covariance estimation.
Sparse Cholesky factorization is not rank revealing. Therefore
this algorithm cannot reliably tell when the Jacobian matrix is
rank deficient or so poorly conditioned that the covariance matrix
cannot be estimated.

Making things worse, this algorithm works on the normal equations,
which makes the conditioning problem much worse.

This change, deletes the SPARSE_CHOLESKY algorithm in the covariance
estimation code. Also to make the naming consistent, it renames

SPARSE_QR -> SUITE_SPARSE_QR

so that it parallels EIGEN_SPARSE_QR.

Also, since we now have EIGEN_SPARSE_QR, we can default to using
it when SuiteSparse is not available instead of DENSE_SVD, which
generally speaking should only be used by folks who are dealing
with small rank deficient jacobians.

Change-Id: I8b134c7e8a2e86ca374371f185b19f1c3e74349c
2014-07-20 07:35:35 -07:00
Mike Vitus 0bbb48a941 Adds support for computing the covariance using Eigen's sparse QR module.
For smaller problems Eigen is faster than SuiteSparseQR. This has been
tested with Eigen 3.2.1. Below are detailed timings. Problem 1 is the
smallest and problem 3 is the largest. The timings below are:
mean +- standard deviation.

Problem 1:
Eigen       0.0009218 +- 0.0002755
SuiteSparse 0.001406 +- 0.001610

Problem 2:
Eigen       0.002338 +- 0.001005
SuiteSparse 0.001910 +- 0.0004513

Problem 3:
Eigen       0.005455 +- 0.001759
SuiteSparse 0.002411 +- 0.0004974

Detailed problem descriptions:

Problem 1 size:
                               Original                  Reduced
Parameter blocks                533                       54
Parameters                      368                      104
Effective parameters           1201                       94
Residual blocks                 233                       77
Residual                       1194                      258

Problem 2 size:
                              Original                  Reduced
Parameter blocks                573                       84
Parameters                     1458                      184
Effective parameters           1281                      164
Residual blocks                 263                      107
Residual                       1314                      378

Problem 3 size:
                              Original                  Reduced
Parameter blocks                613                      114
Parameters                     1548                      264
Effective parameters           1361                      234
Residual blocks                 293                      137
Residual                       1434                      498

Change-Id: I884a67e2f728fe2992812148d82ccf5f27864fd7
2014-07-11 14:42:48 -07:00
Sameer Agarwal 3b1ad31a1f Fix build breakage on old versions of SuiteSparse.
Change-Id: I2a061615fc374abef2ed323c298359002a6fc5f1
2013-12-02 15:43:20 -08:00
Sameer Agarwal ed92366592 Lint cleanup from William Rucklidge.
Change-Id: I745810f5496a1b93263b20ff140f8883da61995e
2013-11-28 07:02:03 -08:00
Sameer Agarwal 33e01b9c5e Rename LinearSolverTerminationType enums.
This increases clarity, drops redundant enums and makes things
cleaner all around.

Change-Id: I761f195ddf17ea6bd8e4e55bf5a72863660c4c3b
2013-11-27 10:24:03 -08:00
Sameer Agarwal 89a592f410 LinearSolver::Summary::status -> LinearSolver::Summary::message.
And a bunch of minor lint cleanups as they showed up.

Change-Id: I430a6b05710923c72daf6a5df4dfcd16fbf44b3a
2013-11-26 11:35:49 -08:00
Sameer Agarwal b16e118b96 Better error checking and reporting for linear solvers.
A lot of error checking cruft has accumulated over the years
in the various linear solvers. This change makes the error reporting
more robust and consistent across the various solvers.

Preconditioners are not covered by this change and will be the
subject of a future change.

Change-Id: Ibeb2572a1e67758953dde8d12e3abc6d1df9052d
2013-11-26 10:00:03 -08:00
Sameer Agarwal 66e15b41d8 Lint cleanup from Jim Roseborough.
Change-Id: I6ddbf5c3d66595d27f7967a309768e5f5dd7e1fd
2013-11-22 07:59:23 -08:00
Sameer Agarwal 79bde35f29 SuiteSparse errors do not cause a fatal crash.
1. Move LinearSolverTerminationType to ceres::internal.
2. Add FATAL_ERROR as a new enum to LinearSolverTerminationType.
3. Pipe SuiteSparse errors via a LinearSolverTerminationType so
   to distinguish between fatal and non-fatal errors.
4. Update levenberg marquardt and dogleg strategies to deal
   with FATAL_ERROR.
5. Update trust_region_minimizer to terminate when FATAL_ERROR
   is encountered.
6. Remove SuiteSparse::SolveCholesky as it screws up the error
   handling.
7. Fix all clients calling SuiteSparse to handle the result of
   SuiteSparse::Cholesky correctly.
8. Remove fatal failures in SuiteSparse when symbolic factorization
   fails.
9. Fix all clients of SuiteSparse to deal with null symbolic factors.

This is a temporary fix to deal with some production problems. A more
extensive cleanup and testing regime will be put in place in a
subsequent CL.

Change-Id: I1f60d539799dd95db7ecc340911e261fa4824f92
2013-11-21 22:16:24 -08:00
Sameer Agarwal 29310f066b Fix a free/delete bug in covariance_impl.cc
Change-Id: I5c43abc5c4d349bc98e88edaf0ad46a97fe9e62b
2013-09-23 10:59:45 -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
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
Sameer Agarwal c5bcfc01af Lint fixes from Jim Roseborough.
Change-Id: If93e1972041b36410225a509e3c8c7c818f92124
2013-07-19 15:50:27 -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 5a974716e1 Covariance estimation using SuiteSparseQR.
Change-Id: I70d1686e3288fdde5f9723e832e15ffb857d6d85
2013-07-17 22:56:01 -07: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
Sameer Agarwal d48feb838e Lint cleanup
Change-Id: Ia342b1203aa690e5380aeca20e5adec29a388835
2013-06-04 16:47:50 -07:00
Sameer Agarwal 8f7e8963cb Multithread covariance estimation.
1. Multithread the inversion of J'J.
2. Simplify the dense rank truncation loop.
3. Minor correction to building documentation.

Change-Id: Ide932811c0f28dc6c253809339fb2caa083865b5
2013-06-04 16:19:45 -07:00
Sameer Agarwal 7129cd3157 Pay attention to condition number in covariance estimation.
1. Sparse covariance estimation now uses cholmod_rcond to
detect singular Jacobians.

2. Dense covariance estimation now uses relative magnitude
of singular/eigen values to compute the pseudoinverse.

3. Truncation logic is now unified with Solver::Options::null_space_rank.

Change-Id: I095bd737510c836b4251255926190a7f31d64bce
2013-06-02 23:36:27 -07:00
Sameer Agarwal df0125666a Add profiling to covariance estimation.
Prevent GetCovarianceBlock from being called before
Compute or when Compute failed.

Change-Id: I5c28d27a88081e230d316c5e365d3e21d6e23376
2013-05-21 15:12:21 -07:00
Sameer Agarwal 02706c1906 Sparse covariance estimation.
Add a Covariance object to the API.

Given a Problem object and a set of parameter block pairs the
Covariance object computes a sparse covariance matrix corresponding
to those block pairs and provides random access to them.

Constant parameter blocks and parameter blocks with local parameterizations
are correctly handled.

Sparse and dense implementations are provided. With the dense implementation
rank deficient Jacobians can also be handled.

Parts of the code are threaded using OpenMP if available.

Change-Id: I5b49583b3d79579df3e0f334c22567acb23ed4ad
2013-05-18 23:33:02 -07:00