Commit Graph

18 Commits

Author SHA1 Message Date
Sameer Agarwal 03caeed1c6 ceres/stringprintf -> absl::strings
Replace ceres::String* with their more modern and performant
absl strings library equivalent and delete our string
manipulation library.

Change-Id: Iecbdba9864e0abf329778f81fdc0708f78f7594f
2024-08-08 07:05:23 -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
Sameer Agarwal d340f81bd0 Clang Tidy fixes
Change-Id: I51429acbf2a7b81605a2fd03a6b7c10317984674
2023-04-10 16:43:30 -07:00
Alexander Ivanov f4eb768e0b Using int64 in file.cc. Fixing compilation error in array_utils.cc
Change-Id: Ie38e257df59bf1884ef431d5d25b3c5ac0dde7a1
2023-01-17 18:59:36 +00:00
Alexander Ivanov 74a0f0d246 Using int64_t for sizes and indexes in array utils
Change-Id: I61177d868850c4538adbd77e413238d9cb2d9248
2023-01-17 15:27:56 +00:00
Alexander Ivanov 53df5ddcfd Removing using std::...
Change-Id: I584402e2a34869183c1d59071a15d97b216c52fb
2023-01-11 16:51:38 +00:00
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
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 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
Sameer Agarwal 2dd907744d Ensure that partial evaluation of residuals triggers an error
ResidualBlock evaluation has logic to ensure that CostFunction
should always fill out the residual and jacobian arrays completely
by using a special value to pre-populate these arrays.

This works for CostFunctions with analytical Jacobians but not for
AutoDiffCostFunction and NumericDiffCostFunction Jacobians.

There is no way to fix this for NumericDiffCostFunctions without
introducing significant performance penalties but the residual
evaluation fails, which should be enough to catch such errors.

For AutoDiffCostFunction the way the Jets are default initialized
was sidestepping this check. So now, the Jet that is used to
capture the output residuals is now initialized with
kImpossibleValue, which will ensure that if the user forgets
to fill all output fields, it triggers an evaluation error.

This change required that ceres::internal::kImpossibleValue be moved
out of array_utils.h/cc to types.h.

Change-Id: I35bb0946cf0785a5d43c7b5459a2272848fb2a9b
2017-01-16 10:00:36 -08: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 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
Sameer Agarwal 041f27516a Move CompactifyArray to array_utils.
1. Rename it to MapValuesToContiguousRange.
2. Improve implementation to just use a vector.

Change-Id: I2a5e73e3a6fb81694c6f452a00d60df16c0149e6
2014-05-29 14:52:17 -07:00
Sameer Agarwal 5e8321c39a Validate ParameterBlocks before solve.
Ensure that all parameter blocks have finite values
before the minimizer is called.

Change-Id: I15fd9c487247989626f799496bb8f5ea8728d6f0
2014-02-05 11:12:16 -08:00
Keir Mierle 58ede2772e Add a portable floating point classification API
Ceres has traditionally battled with portability issues
when trying to classify floating point values as one
type or another. For example, in C99 'isnan' is a
macro. Since it is a macro, it is impossible to
override the name in other namespaces.

Instead of trying to use preprocessor hacks to work
around the issue, define our own set of camel-case
names for use internally and by Ceres clients. For
example do this:

  template<typename T>
  void MyFunction(T x, T y) {
    if (ceres::IsNaN(x)) {
      ...
    }
  }

instead of using "isnan" or "std::isnan". Note that
while GCC and Apple GCC both import 'isnan' into
the std namespace, it is not standard until C++11
which Ceres will not require for some years.

Change-Id: Ibcc96a8bb4ba63aa67cbbc58658b2e5671cd5824
2012-06-24 17:42:53 -07:00
Sameer Agarwal 1fdc520f7b Refactor the array validation routines into their own file, as they are used by
more than just the residual block evaluation routines now.
Check the step computed by the linear solver for finiteness, and terminate early
if it is not. This will prevent bugs where the solver continues to run after
encountering an nan.
2012-05-12 07:29:10 -07:00