Commit Graph

256 Commits

Author SHA1 Message Date
Mike Vitus 0c63bd3efb Add floor and ceil functions to the Jet implementation.
Change-Id: I72ebfb0e9ade2964dbf3a014225ead345d5ae352
2016-04-15 10:47:22 -07:00
Thomas Schneider d61e94da52 Add IsParameterBlockConstant to the ceres::Problem class.
Change-Id: I7d0e828e81324443209c17fa54dd1d37605e5bfe
2016-04-06 23:52:18 +02:00
Keir Mierle efe61b089b Make Jet string output more readable
Change-Id: Iebab111ab136c52f88180688ccb684584ab21dea
2016-03-16 11:27:25 -07:00
Sameer Agarwal 46ad4699f4 A complete refactoring of TrustRegionMinimizer.
1. Break up the monolithic loop in TrustRegionMinimizer::Minimize
   into a number of more easily described and analyzed subfunctions.
2. Break out the logic for evaluating the quality of a Trust Region
   step into its own object - TrustRegionStepEvaluator.

Change-Id: I08580ecac074cfd74c096cb8e4880cbda3d48296
2016-02-04 10:05:12 -08:00
Sameer Agarwal 15587dd1a9 Lint changes from William Rucklidge
Change-Id: If05a774c5e7dd318e6b3ee698e313f0fc58ee922
2016-01-05 11:31:13 -08:00
Wannes Van Loock b0bf9fd2a9 Add covariance matrix for a vector of parameters
Computing the covariance matrix for a number of parameter blocks
previously required adding all parameter blocks to the computation and
subsequently assembling the matrix by concatenating all the blocks.

This patch adds the computation of the covariance matrix for a vector
of parameter blocks. All covariance block pairs are added automatically
and the resulting covariance matrix is assembled in the order the
parameter blocks appear.

Change-Id: I3b70c63f16862adc23a1d7fb7a21dde4e68abe9a
2016-01-04 20:26:40 +00:00
Andrew Hunter d80c112168 Tweak alignment hint implementation for Jets
I169b637a1e2a106956b536c41d6a514a266e7cc0 marked Jets (in C++11) as
aligned to 16 bytes, and enabled Eigen vectorization.  However, to
implement this, we added Eigen includes to port.h.

Turns out this broke some other tricks Ceres uses (redefining Eigen
constants for better performance), so we don't want to do that. Move
most of the implementation to jet.h where it is safe.

Change-Id: I47c6fc4180db1ff674bc660723dd5a2b84254e0d
2015-12-11 14:50:19 -08:00
Andrew Hunter 5667505f35 Align Jet matrices where supported
We currently don't align the infinitesimal part of a Jet to a 16-byte
boundary (and thus force Eigen to avoid using SSE ops)--as a member of a
larger struct, we couldn't guarantee Jets would be allocated on
appropriately-aligned boundaries.  However, C++11 adds better support
for requesting alignment: we can use it to guarantee the members will be
properly aligned, and tell Eigen to vectorize.

There is a significant gotcha here: the standard gives wide latitude to
implementations as to which alignments they choose to support.  If we
ask for 16 and the system only supports 8, we may have misaligned
Jets. So we test (using alignof(std::max_align_t)) that the current
system supports 16-byte aligned values; if not, we fall back to the
current solution.

Two other small notes:
- This is obviously gated on C++11 support, and
  thus we put the logic in port.h and export some useful #defines.

- GCC 4.8.x has a
  bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56019) that has
  max_align_t in the wrong namespace.  This will not be a problem with a
  modern GCC, but add a small workaround since many systems still ship 4.8.

This results (on a x86 workstation) in a 60% speedup in Jacobian
evaluation on bin/simple_bundle_adjuster problem-16-22106-pre.txt.

Change-Id: I169b637a1e2a106956b536c41d6a514a266e7cc0
2015-12-08 01:09:07 +00:00
Sameer Agarwal 992ae55e84 Report the number of line search steps in FullReport.
Accumulate the number of steps of the line search algorithm
and report it as part of Summary::FullReport.

Change-Id: I1de12784009a3e08f2a2c2aff5085d57a3c73828
2015-12-01 14:26:13 -08:00
Sameer Agarwal ba67ed1e01 A variety of small updates
1. Add answers to a number of FAQs.
2. Add a note to the documentation for NumericDiffCostFunction that
   NumericDiffOptions needs to be documented and mentioned.
3. Update the docs for Solver::Options::numeric_derivative_relative_step_size
   to indicate that this setting only applies to the gradient checker.
4. Remove deprecated constructors from NumericDiffCostFunction and
   DynamicNumericDiffCostFunction.

Change-Id: If8fc011b2a5996dbc2c51268aa477550ed014a1c
2015-11-08 10:59:42 -08:00
Alessandro Gentilini 49c86018e0 Add Bessel functions in order to use them in residual code.
See "How can I use the Bessel function in the residual function?" at
https://groups.google.com/d/msg/ceres-solver/Vh1gpqac8v0/NIK1EiWJCAAJ

Change-Id: I3e80d9f9d1cadaf7177076e493ff46ace5233b76
2015-10-22 18:47:02 +00:00
Sameer Agarwal a66d89dcda Get ready for 1.11.0RC1
Update version numbers.
Drop CERES_VERSION_ABI macro.

Change-Id: Ib3eadabb318afe206bb196a5221b195d26cbeaa0
2015-09-08 14:55:28 -07:00
Sameer Agarwal 67622b080c Fix a pointer access bug in Ridders' algorithm.
A pointer to an Eigen matrix was being used as an array.

Change-Id: Ifaea14fa3416eda5953de49afb78dc5a6ea816eb
2015-09-05 21:37:22 +00:00
Sameer Agarwal 2701429f77 Use Eigen::Dynamic instead of ceres::DYNAMIC in numeric_diff.h
Change-Id: Iccb0284a8fb4c2160748dfae24bcd595f1d4cb5c
2015-08-30 21:33:57 -07:00
Tal Ben-Nun 4f049db7c2 Adaptive numeric differentiation using Ridders' method.
This method numerically computes function derivatives in different
scales, extrapolating between intermediate results to conserve function
evaluations. Adaptive differentiation is essential to produce accurate
results for functions with noisy derivatives.

Full changelist:
-Created a new type of NumericDiffMethod (RIDDERS).
-Implemented EvaluateRiddersJacobianColumn in NumericDiff.
-Created unit tests with f(x) = x^2 + [random noise] and
 f(x) = exp(x).

Change-Id: I2d6e924d7ff686650272f29a8c981351e6f72091
2015-08-30 14:06:13 +03:00
Johannes Schönberger b0cbc0f0b0 Reduce memory footprint of SubsetParameterization
Change-Id: If113cb4696d5aef3e50eed01fba7a3d4143b7ec8
2015-08-22 16:15:26 +00:00
Simon Rutishauser 4c3f8987e7 Add missing CERES_EXPORT to ComposedLoss
Change-Id: Id7db388d41bf53e6e5704039040c9d2c6bf4c29c
2015-08-13 11:10:44 +02:00
Sameer Agarwal 560940fa27 A refactor of the cubic interpolation code
1. Push the boundary handling logic into the underlying array
object. This has two very significant impacts:

a. The interpolation code becomes extremely simple to write
and to test.

b. The user has more flexibility in implementing how out of bounds
values are handled. We provide one default implementation.

Change-Id: Ic2f6cf9257ce7110c62e492688e5a6c8be1e7df2
2015-08-06 14:49:55 -07:00
Sameer Agarwal d9790e7789 Add ProductParameterization
Often a parameter block is the Cartesian product of a number of
manifolds. For example, a rigid transformation SE(3) = SO(3) x R^3
In such cases, where you have the local parameterization
of the individual manifolds available,
ProductParameterization can be used to construct a local
parameterization of the cartesian product.

Change-Id: I4b5bcbd2407a38739c7725b129789db5c3d65a20
2015-07-27 13:37:10 -07:00
Alex Stewart c80ce3525d Fix unused parameter compiler warnings in numeric_diff.h
Change-Id: I2b35babba17229387c6d346c46a2c6960db96e47
2015-07-11 18:27:00 +01:00
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
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
Tal Ben-Nun b2dcef36e7 Refactored DynamicNumericDiffCostFunction to use NumericDiff
Change-Id: I2fc4b203e984beaa7af96fb3cbe8ce14e5bca614
2015-05-07 01:48:27 +03: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
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 365084f976 Lint changes from William Rucklidge.
Change-Id: I5a9683333fbab189058076cb2053f8f7afc7096a
2015-04-16 12:35:51 -07: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
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
Mike Vitus cab2267e40 Add Homogeneous vector parameterization.
Change-Id: I42f68a0665a62e2c7dcc7584e5581a05c9b849b0
2015-03-20 22:08:15 +00:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Steve Hsu a1579be80b Add method to return covariance in tangent space
This CL is required to build Tango.

Inspired by this commit in RedwoodInternal repository:
  commit 09dde53c248e04f432b5eccceea5daeedb706aea
  Author: Mike Vitus <mike@hidof.com>
  Date:   Wed Apr 23 11:05:17 2014 -0700

Change-Id: I328b6634969de4ccdd71947945aa67a49ee9073f
2015-03-12 11:40:18 -07:00
Sameer Agarwal 49b815dc84 Add a missing "explicit" to BiCubicInterpolator.
The constructor was missing the explicit keyword.

Change-Id: I283ab15a0d2c4cb90f85926f2aa19fa968086320
2015-03-09 09:35:25 -07:00
Johannes Schönberger d904f36776 Fix MSVC compilation error
MSVC 2013 compiler crashed when not specifying the
template parameter of CubicHermiteSpline explicitly.

Change-Id: I6ab79aea47f55373df5cb7b89e38f8b326ff21c9
2015-03-05 10:11:09 -05:00
Sameer Agarwal afca29c473 Fix a boundary handling but in BiCubicInterpolator.
Thanks to Bernhard Zeisl for reporting this.

Change-Id: I07fb32c187128bc84868b6f0dd4fabb4a85e1302
2015-02-26 21:37:04 -08:00
Sameer Agarwal 7d279fd96d Remove bounds checks from Array1D and Array2D.
This has a measurable impact on interpolation performance.

Also remove an accidentally named enum with an anonymous enum.

Change-Id: Ied6a4b2b06bb27a7f004bd0e01353742e1f84034
2015-02-15 12:42:48 +00:00
Julius Ziegler c2fe657e32 Fix typo in comment section: .a[...] -> .v[...]
Change-Id: I2116645938c4552ed495e371bfdbcaf62a443461
2015-02-12 20:27:30 +00:00
Sameer Agarwal 3125c23228 A complete re-write of the cubic interpolation code.
The key change is that there is a new layer of abstract,
a Array object that the interpolator depends on.

The Array provides a one dimension or two dimensional
array like interface independent of the underlying representation
of the data.

Also included here is support for vector valued functions.

Change-Id: Ica68f03778cf0d84192db00cd55653f8b4124d51
2015-02-06 22:06:11 -08:00
Sameer Agarwal c979a4ce04 Clean up fpclassify.h.
Delete code needed by old versions of the NDK. We do not build
with these versions of the NDK and do not use STLPort anymore.

Change-Id: I61092db0aa3980cfae6ff57f3f318482027e627f
2015-02-05 14:47:33 -08:00
Sameer Agarwal 2bf6fbcd37 Example code for cubic interpolation.
Example code demonstrates how a sampled function can be
minimized. Also, in the process uncovered some deficiencies
in the CubicInterpolator and BicubicInterpolator interfaces and
fixed them.

Change-Id: I18c8f670fbee076bf1e94d1f45c7477fd71640e8
2015-01-28 07:26:06 -08:00
Sameer Agarwal a2a998ce58 Add BiCubic interpolation.
This bi-cubic interpolation implementation is based
on the cubic convolution algorithm of keys, which allows
us to implement a bi-cubic spline like interpolation scheme
using five one dimensional cubic spline operations.

Change-Id: I116aa8036191c3e654af788323fc8298ae8252a6
2015-01-27 21:40:47 -08:00
Sameer Agarwal 1789fc6d66 Add a one dimensional cubic interpolator.
Add a cubic interpolator based on the Catmull-Rom spline,
with support for automatic differentiation.

Change-Id: I02ae4c4ea37805ff1f717b05ea805989b474bd59
2015-01-26 22:24:53 -08:00
Sameer Agarwal 05a07ecc77 Remove using std::string from port.h
Change-Id: I7376f5e7eace22ec1fc05a61eaa858594f08682d
2015-01-07 15:10:46 -08:00
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 60cc520f63 Add explicit no sparse linear algebra library available option.
- Previously we had no defined default value for
  sparse_linear_algebra_library_type in Solver::Options if Ceres
  was compiled with no sparse library available.  Thus in that case,
  the default value (dependent upon the compiler) would indicate that
  one was available.
- Now we have an explicit option that means no sparse library is
  available, which is now the default value in Solver::Options in this
  case.
- Add a warning in CMake when the user disables all sparse libraries.
- Fix typos in trust_region_preprocessor_test:
  (SUITE/CX)_SPARSE -> (SUITE/CX)SPARSE that induced failures when
  no sparse libraries were available.

Change-Id: I869c399a12d42bfc44220cbb25ce6d6dd80236bd
2015-01-01 18:51:45 +00:00
Alex Stewart 9ad59a760a Compute & report timing information for line searches.
- We now compute & report the cumulative time spent performing the
  following tasks as part of a line search:
  - Evaluation of the univariate cost function value & gradient.
  - Minimization of the interpolating polynomial.
  - Total time spent performing line searches.
- This information is now reported for all minimizers, although only in
  the case of a constrained problem for the TR minimizer.
- Remove LineSearch::Function abstraction in place of using
  LineSearchFunction implementation directly, and remove virtual
  functions from LineSearchFunction.
-- LineSearch::Function added an unnecessary level of abstraction since
   the user always had to create a LineSearchFunction anyway to use a
   Ceres Evaluator, and it added an unncessary virtual function call.

Change-Id: Ia4e1921d78f351ae119875aa97a3ea5e8b5d9877
2014-11-26 01:00:17 +00:00
Sameer Agarwal 993622e915 Minor fixes.
1. Remove an unused private member in TukeyLoss.
2. The test for RotationMatrixToAngle had an indexing error.

Change-Id: I7decc9448ae0abef53aa435005f739e9e0931e80
2014-11-14 07:31:31 -08:00