23 Commits

Author SHA1 Message Date
Sameer Agarwal 42475eec77 Use absl::btree_map instead of std::map
Change-Id: Iece280a6cb0f37fa0bc572046b9d7f79ca825ebc
2024-09-17 12:18:31 -07:00
Sameer Agarwal 0a53aa9054 Take abseil as a dependency
1. Add abseil-cpp as a submodule. We are tracking the latest LTS
release, which is lts_2024_01_16.
2. Replace glog/gflags with absl::log and absl::flags.
3. Remove miniglog
4. Also take a whack at making the bazel build work with
   abseil-cpp and gtest.

There are a number of TODOs in this CL that still need to be resolved.

Change-Id: I39355ed7d61375be4ebcbc8596d9cc70acc1c678
2024-07-18 00:24:49 -07:00
Sameer Agarwal 5a30cae583 Preparing for 2.2.0rc1
1. Add a version history
2. Update copyright years across the code base
3. Run format_all.sh
4. Update version strings from 2.1.0 to 2.2.0 in the docs and
   elsewhere.

Change-Id: I46d8d479d54bd6002d532785e67342106e73c9ac
2023-09-21 11:23:38 -07:00
Dmitriy Korchemkin 77ad8bb4e5 Change storage in BlockRandomAccessSparseMatrix
- TripletSparseMatrix in BlockRandomAccessSparseMatrix is replaced with
   BlockSparseMatrix
 - BlockSparseMatrix::ToCompressedRowSparseMatrix is performed in a
   direct sort-less way

Change-Id: Ib951fda1b9394050e2c47a9721172c5e3c674801
2023-04-18 01:34:30 +03:00
Sameer Agarwal ba360ab074 Change the value of BlockRandomAccessSparseMatrix::kMaxRowBlocks
1. Rename it to kRowShift.
2. Make it a static constexpr.
3. Change it to 2^32, which should allow for easier bit arithmetic
   for the compiler than the previously used value of 10000000.
4. Change the name of the two associated private methods from
   IntPairToLong to IntPairToInt64 and LongToIntPair to Int64ToIntPair.

Change-Id: I54d61bcf1121079b222ef518324de5cffc1be064
2023-04-09 14:04:58 -07:00
Sameer Agarwal 19ab2c1793 BlockRandomAccessMatrix Refactor
1. Add threading to all three subclasses of BlockRandomAccessMatrix.
   i.e. BlockRandomAccessDenseMatrix, BlockRandomAccessSparseMatrix
   and BlockRandomAccessDenseMatrix.

   For BlockRandomAccessDenseMatrix and BlockRandomAccessSparseMatrix
   this just means SetZero is parallelized. Which by itself is no
   big deal, but by doing so, the constructor for all three subclasses
   become uniform.

   BlockRandomAccessSparseMatrix::SymmetricRightMultiplyAndAccumulate
   maybe threaded in the future if needed.

   BlockRandomAccessDiagonalMatrix is the biggest beneficiary. SetZero
   Invert and RightMultiplyAndAccumulate are all threaded now.

2. Change the storage in BlockRandomAccessDiagonalMatrix from
   TripletSparseMatrix to CompressedRowSparseMatrix. This has no
   performance implications since we do not really use the capabilities
   of the underlying matrix indexing representation. This is a forward
   looking change when we decide to transfer this matrix to the GPU,
   a CompressedRowSparseMatrix will save on a data conversion.

3. Use std::unique_ptr as needed and eliminate the need for custom
   destructors.

4. Modify CompressedRowSparseMatrix::CreateBlockDiagonalMatrix to
   take a nullptr as the data vector.

Fixes https://github.com/ceres-solver/ceres-solver/issues/936
Fixes https://github.com/ceres-solver/ceres-solver/issues/935

Change-Id: Ia6487f2d924fbe669835bdcc38abf2b451bda4ee
2022-12-23 06:45:28 -08:00
Sameer Agarwal f86a3bdbea Unify Block handling across matrix types
Previously some matrices used Block to keep track of
row/column block sizes and some would just use ints, and
then compute the position of each row and column from it.

By uniformly using Block everywhere, we reduce duplicate
computation and data copies.

I also cleaned up a bunch of c++17 related stuff as I edited
these files.

Change-Id: I4c86b1593fd4c91f9057fbb38314f62f303e0477
2022-09-11 07:31:28 -07:00
Sameer Agarwal 04899645cc LinearOperator::FooMultiply -> LinearOperator::FooMultiplyAndAccumulate
These methods were historically poorly named and every time I read code
I get confused whether they are just multiplying or multiplying and
adding. Clarifying them also gives us the changce to introduce
RightMultiply and LeftMultiply methods in the base class which will
simplify a number call sites in a subsequent CL.

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

Change-Id: Ice4fb483f1acd02527a6dd753ef0c5a66037f4b0
2022-08-10 10:03:03 -07:00
Sameer Agarwal ae65219e04 ClangTidy cleanups
1. NULL -> nullptr
2. foo.reset(new Bar) -> = foo = std::make_unique<Bar>()
3. Missing std library includes & prefixes

Change-Id: I260b261b484554be681ee5a7398126fdb3b3a789
2022-02-09 10:06:49 -08:00
Nikolaus Demmel 7b8f675bfd fix formatting for (non-generated) internal source files
- Change formatting standard to Cpp11. Main difference is not having
  the space between two closing >> for nested templates. We don't
  choose c++14, because older versions of clang-format (version 9
  and earlier) don't know this value yet, and it doesn't make a
  difference in the formatting.
- Apply clang-format to all (non generated) internal source files.
- Manually fix some code sections (clang-format on/off) and c-strings
- Exclude some embedded external files with very different formatting
  (gtest/gmock)
- Add script to format all source files

Change-Id: Ic6cea41575ad6e37c9e136dbce176b0d505dc44d
2020-09-21 02:52:07 +02: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 e82e128344 Deprecate integral_types.h
This header defined integral types in the pre-C++11 days, and can
be replaced with <cstdint> and the types defined therein.

Also remove a shallow (and incorrect) typedef in include/ceres/types.h

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

Change-Id: I398c652f74d24bbeea459672508bf28f591b100f
2018-08-09 12:17:05 -07:00
Sameer Agarwal e49507cbea More C++ification.
"> >" -> ">>"
"> > >" -> ">>>"

Change-Id: Id1ddd9dbf030fe21d57207741b4ca8403068e55b
2018-04-03 10:58:15 -07:00
Keir Mierle 7c4e8a454e Replace scoped_ptr with C++11's unique_ptr
Change-Id: Ib5a504c491e3a79af52a95accf009df473470c6b
2018-04-02 14:47:47 -07:00
Sameer Agarwal a1458f3348 More C++11ification.
1. Replace HashMap and HashSet with std::unordered_map and
   std::unordered_set respectively.
2. Extract the pair hasher into a struct pair_hash.
3. Delete collections_port.h
4. Convert explicit iterator based loops to auto based
   loops where sensible.

Change-Id: Ib88bcd13a7463d18435639d3b771abaa52080efb
2018-03-30 12:03:28 -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 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
Sameer Agarwal c99872d48e Add BlockRandomAccessSparseMatrix::SymmetricRightMultiply.
Change-Id: Ib06a22a209b4c985ba218162dfb6bf46bd93169e
2014-09-24 21:34:53 -07:00
Sameer Agarwal 0beab86dfa Fix glog includes and include sorting order.
Change-Id: I0ec85218e82d1714279d41f7635104d480fb91c3
2012-08-13 15:47:24 -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 58ad13c05d BlockRandomAccessSparseMatrix::IntPairToLong suffers from integer
overflow.

Even though the return value of this function is a long int, the
computation happens with three ints, which causes an overflow before
the upgrade happens.

The fix is to upgrade the constant used int his computation to be a
long int, which causes the computation to be done in longs instead of
ints.

A test has been added to verify that the fix works.

Change-Id: Ibb0aef877125bb37ca28754cb07b8e1627fd1d5a
2012-06-05 18:06:00 -07:00
Sameer Agarwal a2758db84a Exact equality for floating point values seems to be processor/compiler sensitive, this causes correct tests to fails. Replacing EXPECT_EQ with EXPECT_NEAR with a tight tolerance fixes this. 2012-05-10 21:51:39 -07:00
Keir Mierle 8ebb073038 Initial commit of Ceres Solver. 2012-04-30 23:09:08 -07:00