Commit Graph

1494 Commits

Author SHA1 Message Date
Darius Rueckert 7d0d69a4df Fix ExpressionRef
- Add missing copy constructor
- Add make functions for input/output expressions
- Add missing ExpressionRef overload for MakeRuntimeConstant
- Add ExpressionRef overloads for common functions (cos,exp,...)
- Make ExpressionRef constructor from double implicit
- Add simple test for using ExpressionRef in Jets.
- Rename expression test macro

Change-Id: I071dc6717e4034a281662021998a91e80636da27
2019-11-18 17:18:15 +01:00
Darius Rueckert 6ba8c57d28 Fix expression_test IsArithmetic
Change-Id: I77b799655321df4d4ffb21d8289c0f2c519786d7
2019-11-15 18:03:11 +01:00
Alex Stewart 2b494cfb36 Update Travis CI to Bionic & Xcode 11.2
- Fix Homebrew Ruby errors by forcing brew update before install.
- Remove use of custom Eigen 3.3.4 on Linux in favour of default Bionic
  3.3.4 package.
- Update Android NDK version to R20b and build for arm64-v8.
- Fix erroneous string -> STRING in iOS toolchain file.

Change-Id: I041c2a08b92b8307c12bd8967159beb6984e3c65
2019-11-14 20:39:30 +00:00
Alex Stewart a3dde68770 Require Xcode >= 11.2 on macOS 10.15 (Catalina)
- As detailed in a previous CL, Xcode 11.0-1 exhibited a -fstack-check
  bug on 10.15 Catalina that broke alignment for at least AVX
  instructions causing segfaults from within Eigen.
- As Xcode 11.2 fixes this issue, and is probably a more reliable fix
  than -fno-stack-check, we now require the user update in this case.

Change-Id: I482748fe5f40f82e7daf4da133cdfabbd95ffc89
2019-11-14 09:44:38 +00:00
Darius Rueckert 6fd4f072d0 Autodiff Codegen Part 2: Conditionals
- Expression types for if/else blocks
- CERES_IF/ELSE macros
- Multiple assignment to the same variable

Change-Id: If529516f243f31823d1ef7b8827bb6f2390e418d
2019-11-13 09:19:36 +01:00
Alex Stewart 52d6477a42 Detect and disable -fstack-check on macOS 10.15 with Xcode 11
- On macOS 10.15 and Xcode 11 -fstack-check is enabled by default. This
  breaks SIMD alignment (and other alignment) as detailed here:
  https://forums.developer.apple.com/thread/121887 resulting in random
  segfaults from within Eigen.
- The underlying problem also exists with earlier OS versions running
  Xcode 11 if -fstack-check is explicitly enabled.
- This CL explicitly disables -fstack-check on affected versions of
  macOS 10.15 and Xcode 11.

Change-Id: I74d964281c360710d5fb722ac59e6930b0fdcc41
2019-11-01 20:11:25 +00:00
Chris Choi 46ca461b7e Fix gradient_check_relative_precision docs typo
In the docs, `Solver::Options::gradient_check_relative_precision` is
documented to have a default precision of 1e08. That is incorrect, it
should be 1e-8.

Change-Id: Ib6b29e356738de4b555c77f7ffd1224d0cae4b6a
2019-10-21 16:19:29 +01:00
Darius Rueckert 4247d420fa Autodiff Codegen Part 1: Expressions
This patch adds the 'Expression' class, which is a fundamental
building block of automatic code generation. The expressions can
be used as scalar types for cost functors as well as Jets.
Dynamic branching is not yet supported.

Change-Id: I8c61bee5c307e0eec20fd39382683ea90f720dff
2019-10-16 07:54:23 +08:00
Sameer Agarwal ba62397d80 Run clang-format on jet.h
Change-Id: Ib865eecaa468330483b40244d62d432b40560712
2019-09-29 12:58:56 -07:00
Sameer Agarwal 667062dcc8 Introduce BlockSparseMatrixData
A number of algorithms like the SchurEliminator do not need
access to the full BlockSparseMatrix interface. They only
need read only access to the values array and the block structure.

This change introduces, BlockSparseDataMatrix a struct that carries
these two bits of information and modifies the Schur type algorithms
to use it.

What this change will allow us to do, in a subsequent CL is to
take the values array of a BlockSparseMatrix and pair it with
a different blocks structure for subset preconditioning.

Change-Id: I1808f12531b586c9ff4d6a70b3d390c7b0d9f441
2019-09-24 06:53:30 -07:00
Sameer Agarwal 17becf4610 Remove a CHECK failure from covariance_impl.cc
The CHECK was to see if SuiteSparseQR returns a non-null QR
factorization. However this can cause problems in production, so its
better to return false and let the user deal with the failure in
factorization.

Change-Id: I4e67f343e30547f4257d0315d507df9864c06dcc
2019-09-11 19:57:36 -07:00
Sameer Agarwal d7f428e5c7 Add a missing cast in rotation.h
Thanks to Lukas Post (@deutschepost) for reporting this.

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

Change-Id: I6d9d0ca5feab3a1f4cf47613537e8cd7ab1ba479
2019-08-07 06:42:28 -07:00
Sameer Agarwal ea4d66e7e5 clang-tidy fixes.
1. Mismatched variable names in local_parameterization.h/cc
2. Add missing final directives in iterative_refiner_test.cc

Change-Id: I954ef00d74c3b5d99f3659cc5c6ee2293fa9ff92
2019-08-06 16:58:21 -07:00
Sameer Agarwal be15b842a7 Integrate the SchurEliminatorForOneFBlock for the case <2,3,6>
Also run clang-format on schur_complement_solver.cc.

A more elaborate integration is not done, because it will cause
binary bloat.

Change-Id: Idf4e9e1794f7401a39f05fb145ec06459209a1e1
2019-08-06 16:34:47 +00:00
Sameer Agarwal 087b28f1b6 Remove use of SetUsage as it creates compilation problems.
Change-Id: Ifd0be489823fb8260e2c599389de943f4a1574d3
2019-08-06 05:09:55 -07:00
Sameer Agarwal 573046d7f7 Protect declarations of lapack functions under CERES_NO_LAPACK
If Ceres is compiled without a LAPACK implementation, there is
no need to declare these function signatures.

Thanks to David Sinuela for reporting this.

Change-Id: I048d1f9d38cef55368d33e74d363cd39f425dbf4
2019-08-05 07:27:10 -07:00
Sameer Agarwal 71d638ef32 Add a specialized schur eliminator.
Add a new specialized Schur Eliminator for the case where there is
exactly one F block and all dimensions are known at compile time.

Benchmark on my macbook shoes ~3x speedup for Eliminate and 4x speedup for BackSubstitute.
Similar speedups are observed on other platforms.

------------------------------------------------------------------------------------------
Benchmark                                                   Time           CPU Iterations
------------------------------------------------------------------------------------------
BM_SchurEliminatorEliminate/10                           4176 ns       4132 ns     153522
BM_SchurEliminatorEliminate/64                          24392 ns      24234 ns      29993
BM_SchurEliminatorEliminate/512                        169632 ns     168709 ns       3872
BM_SchurEliminatorEliminate/4096                      1296407 ns    1292873 ns        519
BM_SchurEliminatorEliminate/10000                     3159652 ns    3149532 ns        216
BM_SchurEliminatorForOneFBlockEliminate/10               1187 ns       1184 ns     603953
BM_SchurEliminatorForOneFBlockEliminate/64               7917 ns       7898 ns      87558
BM_SchurEliminatorForOneFBlockEliminate/512             57629 ns      57485 ns      12035
BM_SchurEliminatorForOneFBlockEliminate/4096           484680 ns     480757 ns       1459
BM_SchurEliminatorForOneFBlockEliminate/10000         1157237 ns    1150735 ns        566
BM_SchurEliminatorBackSubstitute/10                       681 ns        679 ns    1070500
BM_SchurEliminatorBackSubstitute/64                      3899 ns       3887 ns     182883
BM_SchurEliminatorBackSubstitute/512                    33632 ns      33467 ns      22582
BM_SchurEliminatorBackSubstitute/4096                  241117 ns     240257 ns       2884
BM_SchurEliminatorBackSubstitute/10000                 631869 ns     626992 ns       1146
BM_SchurEliminatorForOneFBlockBackSubstitute/10           139 ns        138 ns    5021341
BM_SchurEliminatorForOneFBlockBackSubstitute/64           898 ns        892 ns     780396
BM_SchurEliminatorForOneFBlockBackSubstitute/512         7344 ns       7286 ns      87059
BM_SchurEliminatorForOneFBlockBackSubstitute/4096       57634 ns      57345 ns      11642
BM_SchurEliminatorForOneFBlockBackSubstitute/10000     153129 ns     152320 ns       4949

Change-Id: Iae64e96c91beb44b807df0e0572d202df7cdaed8
2019-08-05 07:15:41 -07:00
Sameer Agarwal 2ffddaccfe Use override & final instead of just using virtual.
This is safer than using virtual and this lead to a minor
bug fixes.

Change-Id: Id69cb1cc569bf6bf245f22f029c7871b6c712568
2019-07-25 16:29:14 -07:00
Sameer Agarwal e4577dd6d9 Use override instead of virtual for subclasses.
Now that we are using c++11, it is safer to use override in subclasses
instead of virtual.

This CL does it for the interface, a follow up CL will do it for
other parts of the code base.

Change-Id: Ice8d0f4355cb700019d7a9c1566fbff0099e97d6
2019-07-25 23:26:24 +00:00
Frank 3e5db5bc27 Fixing documentation typo.
- Matrix had two columns squeezed together

Change-Id: I5f18df15364bd8507db98d43f8a547a9efab0913
2019-07-19 03:03:00 +09:00
Alex Stewart 82d325b731 Avoid memory allocations in Accelerate Sparse[Refactor/Solve]().
- Maintain scratch workspaces for solving/refactoring instead of
  forcing Sparse[Refactor/Solve]() to reallocate space on each call.

Change-Id: Idb9eda9c9c6cc7570cfdf851e59e5bf6b39521ce
2019-07-16 11:10:36 +00:00
Sameer Agarwal f66b513826 Fix some clang-tidy warnings.
Change-Id: Ic71bf0fc561edc22e3051d156fac630fcfea5d92
2019-07-15 13:23:04 -07:00
Alex Stewart 0428e2dd0f Fix missing #include of <memory>
Change-Id: I11a4e232305e3866ed418a65041aa87ce385c071
2019-07-12 18:23:26 +01:00
Sameer Agarwal 487c1aa51f Expose SubsetPreconditioner in the API
https://github.com/ceres-solver/ceres-solver/issues/270

Detailed list of changes:

1. Add SUBSET to the PreconditionerType enum.
2. Add Solver::Options::residual_blocks_for_subset_preconditioner
3. Integrate SubsetPreconditioner into the CGNR solver.
4. Add the reordering logic needed for this to TrustRegionPreprocessor.
5. Expect CreateJacobianBlockTranspose to take the starting row block
   so that we can work with subparts of the Jacobian matrix.
6. Extend the denoising example to use this preconditioner.

As an illustration of its performance, we consider the performance of
denoising -input ../data/ceres_noisy.pgm  --foe_file ../data/5x5.foe

tl;dr

For the same cost,

SPARSE_NORMAL_CHOLESKY -  81s
CGNR + JACOBI          - 718s
CGNR + SUBSET          -  57s

SPARSE_NORMAL_CHOLESKY
======================

Cost:
Initial                          2.317806e+05
Final                            2.232323e+04
Change                           2.094574e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         2.999746

  Residual only evaluation           2.306811 (10)
  Jacobian & residual evaluation     7.421727 (10)
  Linear solver                     65.517273 (10)
Minimizer                           78.731011

Postprocessor                        0.026079
Total                               81.756836

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.573046e-04 <= 1.000000e-03)

CGNR + JACOBI
=============
Cost:
Initial                          2.317806e+05
Final                            2.232344e+04
Change                           2.094572e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         0.648814

  Residual only evaluation           2.297607 (10)
  Jacobian & residual evaluation     7.327886 (10)
  Linear solver                    699.601248 (10)
Minimizer                          712.419493

Postprocessor                        0.024014
Total                              713.092321

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.528538e-04 <= 1.000000e-03)

CGNR + SUBSET (random 20% residuals used for the preconditioner)
===============================================================
Cost:
Initial                          2.317806e+05
Final                            2.232327e+04
Change                           2.094574e+05

Minimizer iterations                       10
Successful steps                           10
Unsuccessful steps                          0

Time (in seconds):
Preprocessor                         1.472743

  Residual only evaluation           2.428315 (10)
  Jacobian & residual evaluation     7.367796 (10)
  Linear solver                     42.585999 (10)
Minimizer                           55.664459

Postprocessor                        0.024098
Total                               57.161301

Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 8.538277e-04 <= 1.000000e-03)

Change-Id: Ifb011408bd53edbb9439b0b7345649a38f999e18
2019-07-12 16:08:36 +02:00
Sameer Agarwal bf709ecac2 Move EvaluationCallback from Solver::Options to Problem::Options.
Adding it to Solver::Options was a mistake, as it prevents it from
being used in covariance estimation. Also updated associated docs.

https://github.com/ceres-solver/ceres-solver/issues/380
https://github.com/ceres-solver/ceres-solver/issues/401
https://github.com/ceres-solver/ceres-solver/issues/484

Change-Id: I63809a47a58e84c04a58bf8e59ace92f45fc2873
2019-07-08 21:24:08 +02:00
Scott K Logan 059bcb7f86 Drop ROS dependency on catkin
As a pure CMake package, ceres-solver doesn't need catkin to be built.
This change makes the package buildable using colcon as well.

Change-Id: I3c21f201f947a0e4e87da2708ab9e799816ba97a
2019-06-26 16:07:52 +00:00
Alex Stewart c4dbc927d6 Default to any other sparse libraries over Accelerate
- Accelerate currently does not support dynamic sparsity, whereas the
  other sparse linear algebra libraries do (outstanding issue to update)
- Previously we preferred Accelerate to all but SuiteSparse if it was
  available, which breaks the dynamic_sparsity_test if SuiteSparse is
  *not* available (even if others are) as Accelerate does not support
  dynamic sparsity.

Change-Id: Ibc2dd2f14f83cffbecca38097d02bb2188aaaa05
2019-06-26 16:53:09 +01:00
Sameer Agarwal db1f5b57a0 Allow some methods in Problem to use const double*.
Some methods in Problem do not modify the parameter block
and those methods now allow the user to call them with const double*.

The methods are

RemoveParameterBlock
SetParameterBlockConstant
IsParameterBlockConstant
GetParameterization
GetParameterLowerBound
GetParameterUpperBound

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

Change-Id: I59dcb77134f59576dd498bd732e29aae9abd28b1
2019-06-05 15:45:02 -07:00
huangqinjin a60c14525f Explicitly delete the copy constructor and copy assignment operator
The implicitly-declared copy constructor and copy assignment operator
of ProductParameterization are not deleted since the corresponding
functions of the member vector are defined, though ill-formed if they
are instantiated.

With dllexport, the compiler must generate all of the member functions
of the class, including those are implicitly-declared, so we need
explicitly delete the ill-formed ones.

Change-Id: Iaa763dfaefdc74a9840f244ba05c6bfd0bd99492
2019-06-05 05:09:30 +00:00
Sameer Agarwal 084042c252 Lint changes from William Rucklidge
Update documentation for
Solver::Options::max_num_line_search_step_size_iterations

Change-Id: I03edc74e67940bed0be7e5ccaffed9e97114a5a5
2019-05-31 09:00:40 -07:00
Sameer Agarwal 93d869020b Use selfAdjoingView<Upper> in InvertPSDMatrix.
This restores some sensitive numerical tests.

Change-Id: I7e6fc0236e810b1c112af75067957740c40c8f36
2019-05-30 20:56:55 -07:00
Sameer Agarwal a0cd0854aa Speed up InvertPSDMatrix
For matrices of size <= 4, Eigen implements an optimized matrix
inverse, which is orders of magnitude faster than computing the
Cholesky factorization and inverting it. This can have a significant
impact on the performance of the SchurEliminator.

This change implements this optimization, adds tests and benchmarks.

Before this change on my MacBook Pro

-----------------------------------------------------------------------------------
Benchmark                                            Time           CPU Iterations
-----------------------------------------------------------------------------------
BenchmarkFixedSizedInvertPSDMatrix<1>                0 ns          0 ns 1000000000
BenchmarkFixedSizedInvertPSDMatrix<2>              102 ns        101 ns    6504851
BenchmarkFixedSizedInvertPSDMatrix<3>     	   164 ns        164 ns    4297669
BenchmarkFixedSizedInvertPSDMatrix<4>              200 ns        200 ns    3933623
BenchmarkFixedSizedInvertPSDMatrix<5>              353 ns        353 ns    1930454
BenchmarkFixedSizedInvertPSDMatrix<6>              428 ns        427 ns    1629074
BenchmarkFixedSizedInvertPSDMatrix<7>              559 ns        558 ns    1211639
BenchmarkFixedSizedInvertPSDMatrix<8>              527 ns        527 ns    1000000
BenchmarkFixedSizedInvertPSDMatrix<9>              873 ns        873 ns     902713
BenchmarkFixedSizedInvertPSDMatrix<10>             892 ns        892 ns     787410
BenchmarkFixedSizedInvertPSDMatrix<11>            1201 ns       1201 ns     564334
BenchmarkFixedSizedInvertPSDMatrix<12>            1081 ns       1080 ns     588359
BenchmarkDynamicallyInvertPSDMatrix/1              322 ns        322 ns    2244892
BenchmarkDynamicallyInvertPSDMatrix/2              362 ns        362 ns    1869693
BenchmarkDynamicallyInvertPSDMatrix/3              455 ns        455 ns    1604092
BenchmarkDynamicallyInvertPSDMatrix/4              443 ns        443 ns    1578062
BenchmarkDynamicallyInvertPSDMatrix/5              648 ns        647 ns     963232
BenchmarkDynamicallyInvertPSDMatrix/6              756 ns        755 ns     899766
BenchmarkDynamicallyInvertPSDMatrix/7              906 ns        905 ns     740506
BenchmarkDynamicallyInvertPSDMatrix/8              885 ns        885 ns     790657
BenchmarkDynamicallyInvertPSDMatrix/9             1219 ns       1219 ns     600503
BenchmarkDynamicallyInvertPSDMatrix/10            1267 ns       1266 ns     534555
BenchmarkDynamicallyInvertPSDMatrix/11            1580 ns       1579 ns     469591
BenchmarkDynamicallyInvertPSDMatrix/12            1366 ns       1365 ns     514513

after this change:

-----------------------------------------------------------------------------------
Benchmark                                            Time           CPU Iterations
-----------------------------------------------------------------------------------
BenchmarkFixedSizedInvertPSDMatrix<1>                0 ns          0 ns 1000000000
BenchmarkFixedSizedInvertPSDMatrix<2>                1 ns          1 ns 1000000000
BenchmarkFixedSizedInvertPSDMatrix<3>                1 ns          1 ns  514399512
BenchmarkFixedSizedInvertPSDMatrix<4>                2 ns          2 ns  320587683
BenchmarkFixedSizedInvertPSDMatrix<5>              372 ns        372 ns    1856986
BenchmarkFixedSizedInvertPSDMatrix<6>              446 ns        446 ns    1552502
BenchmarkFixedSizedInvertPSDMatrix<7>              571 ns        570 ns    1208021
BenchmarkFixedSizedInvertPSDMatrix<8>              586 ns        584 ns    1090988
BenchmarkFixedSizedInvertPSDMatrix<9>             1003 ns       1001 ns     753279
BenchmarkFixedSizedInvertPSDMatrix<10>            1074 ns       1070 ns     689974
BenchmarkFixedSizedInvertPSDMatrix<11>            1361 ns       1351 ns     545388
BenchmarkFixedSizedInvertPSDMatrix<12>            1160 ns       1158 ns     615742
BenchmarkDynamicallyInvertPSDMatrix/1              326 ns        326 ns    2206552
BenchmarkDynamicallyInvertPSDMatrix/2              362 ns        361 ns    1820982
BenchmarkDynamicallyInvertPSDMatrix/3              432 ns        431 ns    1696361
BenchmarkDynamicallyInvertPSDMatrix/4              473 ns        472 ns    1294115
BenchmarkDynamicallyInvertPSDMatrix/5              657 ns        656 ns     917888
BenchmarkDynamicallyInvertPSDMatrix/6              804 ns        802 ns     884050
BenchmarkDynamicallyInvertPSDMatrix/7              936 ns        935 ns     679565
BenchmarkDynamicallyInvertPSDMatrix/8              915 ns        915 ns     695548
BenchmarkDynamicallyInvertPSDMatrix/9             1299 ns       1293 ns     583256
BenchmarkDynamicallyInvertPSDMatrix/10            1300 ns       1296 ns     562959
BenchmarkDynamicallyInvertPSDMatrix/11            1617 ns       1610 ns     480393
BenchmarkDynamicallyInvertPSDMatrix/12            1380 ns       1379 ns     503934

Change-Id: Id0d3bbe6d610ee7a3004bb8e2b657b90307b9805
2019-05-30 18:15:01 -07:00
Sameer Agarwal 7b53262b7f Allow Solver::Options::max_num_line_search_step_size_iterations = 0.
This change only affects the TRUST_REGION minimizer and has no effect
on the LINE_SEARCH minimizer.

This options controls the number of iterations that the line search
algorithm performs. The line search algorithm is as the name implies,
used in the LINE_SEARCH minimizer. It is also used by the TRUST_REGION
minimizer when solving bounds constrained optimization problems.

In some bounds constrained problems, it is enough to project each step
onto the bounds constraints and not perform the line search. This can
have a significant impact on runtime. Setting
Solver::Options::max_num_line_search_step_size_iterations = 0 enables
this functionality.

Changchang Wu (ccwu@google.com) came up with the idea for this
implementation.

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

Change-Id: Ifbe0bc5c48eedb2c1231d43cd98e4be7316c0682
2019-05-30 15:16:41 -07:00
Sameer Agarwal 3e2cdca542 Make LineSearchMinizer work correctly with negative valued functions.
When reasoning about the function_tolerance based convergence,
LineSearchMinimizer assumed that the objective function is
positive. This used to be the case when LineSearchMinimizer was used
for minimizing non-linear least squares problems. However, with
GradientProblemSolver, the objective function can be negative (for
example when maximizing a function).

This change the minimizer to use the absolute value of the change
from one iteration to another.

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

Change-Id: I831e2db96b092374e167c582ab1480b1831d5650
2019-05-13 10:20:50 -07:00
Sameer Agarwal 3ff12a878b Fix a clang-tidy warning in problem_test.cc
Change-Id: Iaf26db5711c13e802123a4de724c0445eec884f9
2019-04-29 11:16:09 -07:00
Sameer Agarwal 57441fe909 Fix two bugs.
1. ProblemEvaluateResidualTest was leaking the loss_function in cases
where it was not being used.
2. Fix a grammo in rotation.h

Change-Id: If94ae1624033c8f6d1934dc2f40fa0dfe4e025c3
2019-04-29 10:59:09 -07:00
Sameer Agarwal 1b852c57e0 Add Problem::EvaluateResidualBlock.
This method gives the user the ability to evaluate a given residual
block.

A couple of minor cleanups.

Problem::problem_impl_ -> Problem::impl_
NULL -> nullptr

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

Change-Id: I6dd94762c475fa264c387b8c93d516f6e06fe832
2019-04-29 09:46:33 -07:00
Sergey Sharybin 54ba6c27b5 Fix missing declaration warnings in Ceres code
This commit includes the following:

- Changes to CMake to make it safer to see which compiler flags are supported,
  so this way we do not need to worry about version checks in CMake.

- Unix platforms (which includes both Linux and Apple as far as i can tell)
  will now enable -Wmissing-declarations warning for the whole Ceres.

- Changes in all sources to solve missing declaration warning. In most cases
  it was either matter of using static qualifier or moving functions to an
  anonymous namespace.

  In one case the function got removed, since it seems to be unused.

  Additionally, in slam examples there was a non-inlined function implementation
  in a header, which is a direct way to cause linking errors if other .cc file
  will include that helper header.

- All third party sources (which is currently only gmock) has this extra
  paranoid warning disabled.

This warning is important in the following cases:

- Detect helper functions which are not needed anymore.
- Avoid unnoticed pollution of namespace.
- Avoid bad level calls.
- Avoid missing updates in header files after changes in implementation file.
- Helps integrating Ceres into software where paranoid warnings are important.

Change-Id: I9b1044aced3910d8c6b2356cfe2bf57f3c8c58db
2019-04-23 12:16:28 +02:00
Johannes Beck fac46d50eb Modernize ProductParameterization.
This CL modernizes ProductParameterization in the following ways:
- It uses std::unique_ptr for memory handling instead of using raw
  pointers and handmade memory management.
- Replaces the constructors with a variadic template.

Change-Id: I5c9fe42ac935b6c26e867dbd3369a4c766623047
2019-04-19 13:36:37 +02:00
Sameer Agarwal 53dc6213fa Add some missing string-to-enum-to-string convertors.
LoggingTypeToString
StringtoLoggingType
DumpFormatTypeToString
StringtoDumpFormatType

Fixes https://github.com/ceres-solver/ceres-solver/issues/470

Change-Id: Ic7eb98dada008c869a686fbdf2c7ff9ab81dad54
2019-04-18 07:58:30 -07:00
Johannes Beck c0aa9a2631 Add checks in rotation.h for inplace operations.
Some rotation functions like UnitQuaternionRotatePoint,
QuaternionRotatePoint, etc. will calculate bad results if the input
point and output point points to the same memory (inplace operation).

This CL adds checks in debug mode to guard against it.

Change-Id: Id0a30e9a0286b340757f0790d417d9f9a3409810
2019-04-16 21:45:36 +02:00
Keir Mierle 0f57fa82db Update Bazel WORKSPACE for newest Bazel
The latest Bazel releases have deprecated Bazel-native
"http_archive()" directive in favor of a Skylark version.
This updates the WORKSPACE to use the new format, as well
as removing the Eigen BUILD in favor of a string in the
WORKSPACE.

Fixes: https://github.com/ceres-solver/ceres-solver/issues/463

Change-Id: I2f7051316dbe0c1f283423c56b7672ab83a30860
2019-04-16 01:04:59 -07:00
ngoclinhng f8e5fba7b9 TripletSparseMatrix: guard against self-assignment
Change-Id: I63159b32d0462fe784019f17242cf4a9f05b2825
2019-04-16 02:51:34 +00:00
Johannes Beck 939253c208 Fix Eigen alignment issues.
For proper alignment on the heap Eigen needs to have a custom
allocator. There are two forms, new and in-place new. To make sure
that memory is aligned using new, one needs to overload new by
adding EIGEN_MAKE_ALIGNED_OPERATOR_NEW to any struct which contains a
fixed size Eigen type either through inheritance or as a direct or
indirect member. For the in-place new one need to use the
Eigen::aligned_allocator (e.g. for std::vector, std::list,
FixedArray, etc.). For more details see:
https://eigen.tuxfamily.org/dox/group__DenseMatrixManipulation__Alignement.html

This CL adds EIGEN_MAKE_ALIGNED_OPERATOR_NEW to all structs, which
contain fixed-size Eigen types and uses the Eigen::aligned_allocator
for containers which stores structs of fixed-size Eigen types.

Change-Id: I06c6c4fc74a6835918d5d1c571b7814a14c029d8
2019-04-15 22:09:24 +02:00
Sameer Agarwal bf67daf79e Add the missing <array> header to fixed_array.h
Change-Id: I1f48bd6eab0c6b189d01c68d4940a586a968581f
2019-04-11 10:35:04 -07:00
Johannes Beck 25e1cdbb6f Switch to FixedArray implementation from abseil.
This PR changes the implementation of the current fixed array to the
abseil one, which has proper allocator support.
Some minor changes are made to make the fixed array implementation
self-contained (no dependent to abseil):
- No address sanitizer support (red zones, etc.)
- Remove of noexecpt specified for copy and move constructor.
- Remove of 'at' function as Ceres does not use exceptions.
- Use std::tuple instead of absl::CompressedTuple as it uses the  abseil
  utility header which includes a whole bunch of other headers.

Change-Id: I43445b42c37f944509b5353a587d0efce74cbccf
2019-04-08 19:44:16 +00:00
Sameer Agarwal d467a627b5 IdentityTransformation -> IdentityParameterization
Change-Id: I77b32a3ec4fd666ce99e2248eb50c851d7bb4b0d
2019-04-02 06:43:31 -07:00
Sameer Agarwal eaec6a9d0c Fix more typos in CostFunctionToFunctor documentation.
Change-Id: I337e67152e4c00b91f7b8f0bb471d5a1896f46dc
2019-03-10 20:57:09 -07:00
Sameer Agarwal 99b5aa4aa5 Fix typos in CostFunctionToFunctor documentation.
Thanks to jss.chandler00@gmail.com for reporting this.

Change-Id: I05cc1f17edec227dc0526b2b63a9fb4a4209772f
2019-03-10 14:02:11 +00:00
Alex Stewart ee7e2cb3c8 Set Homebrew paths via HINTS not CMAKE_PREFIX_PATH
- Adding the Homebrew install prefix to CMAKE_PREFIX_PATH, irrespective
  of whether it is a standard location (e.g. /usr/local) overrides any
  user-specified HINTS locations according to the search order of
  CMake's find_xxx() functions.
- Now we append the relevant include/lib directory to its respective
  HINTS directory variable (to the back to avoid overriding any user
  specified values).  This achieves the same effect, but only after
  searching any user specified values.
- Also adds Homebrew install prefix to find_package() calls for
  dependencies optionally exported with CMake after the possible user
  specified <DEPENDENCY_NAME>_DIR prefix.
- Raised as issue #431

Change-Id: I47030f0f4fd9b96665fac57279be2285d9700b9a
2019-03-07 22:12:44 +00:00