Commit Graph

19 Commits

Author SHA1 Message Date
Sameer Agarwal caf614a6c1 Modernize code using c++17 constructs
Mostly done using

find . \( -name '*.cc' -o -name '*.h' \) -a -type f -exec clang-tidy -p \
cmake-build -checks='-*,google-*,modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type' {} -fix \;

Change-Id: Ifccbcabe7a1d9a32a09d28ac4f3f8466696c1a50
2022-04-22 06:11:18 -07:00
Nikolaus Demmel 9d762d74f0 fix formatting for public header files
- ensure all public headers files adhere to clang-format
- preserve one-per-line for enums by adding trailing comma
- preserve include order for en/disable_warning.h

Change-Id: I78dbd0527a294ab2ec5f074fb426e48b20c393e6
2020-09-07 23:14:51 +02:00
Alex Stewart 7ef83e0759 Update minimum required C++ version for Ceres to C++14
- Removes all workarounds for pre-C++14 versions
- Removes '11' qualifier from C++ threading option and associated
  defines.
- Fix missing inclusion of 'Multithreading' in reported Ceres components
  when C++ threading model is enabled.
- Update Sphinx documentation to specify C++14 as minimum requirement.

Change-Id: I706c8b367b3221e3c4d1a0aaf669a8f9c911e438
2020-05-30 19:15:03 +01:00
Alex Stewart 99efa54bdb Replace type aliases deprecated/removed in C++17/C++20 from FixedArray
- Raised as issue #551
- Also adds C++20 to the set of ALLOWED_CXX_STANDARDS, although this
  will require a version of CMake >= 3.12.

Change-Id: I0f13c72e93a35391fd2d18590b4243a329a2322c
2020-05-24 19:18:38 +01:00
Johannes Beck f26f954105 Fix windows MSVC build.
This CL improves the build experience with MSVC:
- It adds the build flag '/bigobj' otherwise the build of
  the unit test fails.
- It adds the flag '/wd4267' to suppress signed / unsigned int
  conversions (size_t to int).
- It removes the use of std::aligned_storage from FixedArray.
  This has been done from the Abseil Team and is in the
  absl::FixedArray. Those changes has been ported to ceres.
  This fixes the alignemnt for older MSVC versions due to a
  bug in the implementation of std::aligned_storage, and
  prevents the use of the macro '_ENABLE_EXTENDED_ALIGNED_STORAGE'
  for newer MSVC versions, which is problematic as it could affect
  user code.
- Fix of the fixed array unit test. Due to the use of std::tuple
  instead of absl::tuple in ceres::internal::FixedArray, the
  unit test needs to reflect that change as well.
- Replaces 'add_definitions' with 'add_compile_options' for
  compiler flags as suggested by the cmake documentation.

Change-Id: I63f08cd6c0a8db8c9931289b909b4deafd75b039
2020-01-07 17:25:54 +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
Kuang Fangjun 72d8e1cdb1 Fix typos.
Change-Id: I61296f42354eab797c55c1435ca46b3475b767e9
2018-09-20 22:52:39 +08:00
Sameer Agarwal 31f24521cc Deprecate macros.h and fpclassify.h
1. Replace CERES_DISALLOW_* with explicitly deleted constructors.
2. Replace use of CERES_ARRAY_SIZE and stack allocated arrays
   with std::vector.
3. Move CERES_ALIGN_* macros into manual_constructor.h, which is
   the one place they are used and will be deprecated along with that
   file.
4. Introduce isnan,isnormal,isinf and isfinite for Jets.
5. Replace IsNormal,IsFinite,IsNaN and IsInfinite with corresponding
   c++11 function calls.

Change-Id: I04f33a221aae77d247602150988b6d4aa4efeeab
2018-04-18 09:54:42 -07: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
Sameer Agarwal af04d7f187 Remove DCHECK_GE checks from fixed_array.h
This triggers -Wtype-limits warnings on comparisons
which are always true, since the test being done is
n >= 0, where n is of type size_t, which is always
true.

This causes problems when compiling Ceres on linux
with miniglog.

Change-Id: Ia1d1d1483e03469c71fde029b62ca6d84e9b27e0
2013-11-05 13:47:30 -08:00
Sameer Agarwal a1eaa262ea Update glog path
Change-Id: I47a69cb267c71a9f8f3350c4f645e8cf83e44cc9
2013-05-09 10:09:38 -07:00
Ricardo Martin 0b5b788187 Tiny changes to prevent a signed/unsigned compile warning.
Change-Id: Id80bad85009df7be039324609528c944b3195c60
2012-09-06 11:07:52 -07:00
Sameer Agarwal 45ccb51701 Drop alignment requirements for Jets.
Change-Id: I7cd1e8f73c6d3e0b9369e567149205075bfbcd82
2012-07-16 21:13:38 -07:00
Keir Mierle efe7ac60a0 Port Ceres to Windows
This is a preliminary, but full, port of Ceres to Windows.
Currently all tests compile and run, with only system_test
failing to work correctly due to a path issue.

Change-Id: I4152c1588bf51ffd7f4d9401ef9759f5d28c299c
2012-06-24 23:22:04 -07:00
Sameer Agarwal 0005dcf1e2 FixedArray internal struct was not respecting Eigen alignment.
Added EIGEN_MAKE_ALIGNED_OPERATOR_NEW to the struct so that
the Jet members are aligned. This fixes an eigen assert in
autodiff_test reported by multiple Ceres users.

Thanks Koichi Akabe & Stephan Kassemeyer

Change-Id: Id3574e926deffa57d205dddaa9d08389b5dc33a8
2012-06-23 13:51:33 -07:00
Sameer Agarwal eb893404fa Fix alignment issues with Jets.
1. Test that reproduces the failure on macos.
2. Move the alignment macros from manual_constructor.h
   to macros.h and rename them to prevent conflicts.
3. The inline array used by FixedArray is now aligned.
4. Jet has been modified to be eigen friendly.

Change-Id: I4563847a767a92156dabab1ab420f0cdddb8ba77
2012-06-18 11:08:20 -07:00
Keir Mierle 8ebb073038 Initial commit of Ceres Solver. 2012-04-30 23:09:08 -07:00