Currently, it is not possible to accurately evaluate the derivative of
d/dx log(1 + x) under all circumstances and significant deviations from
the actual derivative d/dx log1p(x) can occur. This changeset introduces
the necessary Jet overload and its inverse, expm1.
Change-Id: Ifcf88f6d684f61ba86bbe49f0d551b703f34ad0d
norm allows to compute the squared magnitude both of complex and real
numbers. While Jet does not support decaying of a std::complex to a
scalar performed by norm, the function is still useful when applied to
scalars alone for computing the square.
Change-Id: I27a3513f53f37fb3960411362e80d170d1ae6f74
libc++ (default on macOS) uses the copysign function for std::complex
multiplication which causes compilation errors such as these if
std::complex is combined with jets:
/Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:607:19: error: no matching function for call to 'copysign'
__a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
^~~~~~~~
foo.hpp:218:39: note: in instantiation of function template specialization 'std::__1::operator*<ceres::Jet<double, 3> >' requested here
std::complex<Scalar> result = lhs * rhs;
copysign is also useful in other situations where the sign is required
allowing it to compute without branching.
Change-Id: I84b2d23374f1bf3bae32833016bb686d97d74054
abs() implementation does not correctly handle the sign of the
infinitesimal part when the value is a NaN. Define the function in terms
of copysign which is the only portable way of manipulating the sign of
a NaN value.
Change-Id: I2f13fb1db62d35ca8b09e6bff1c05a736cb91513
This has been a long requested feature so that users can minimize
functions using numeric differentiation.
As part of this, I have also redone rosenbrock.cc, which now has three
variants.
rosenbrock.cc now uses automatic differentiation.
rosenbrock_numeric_diff.cc uses numeric differentiation.
rosenbrock_analytic_diff.cc uses analytic derivatives.
This is analogus to how the helloworld example code is structured.
The tutorial for GradientProblemSolver has also been updated to reflect
this.
https://github.com/ceres-solver/ceres-solver/issues/691
Change-Id: Ib0fb9e35127fe4c8299d4793bea3558722c70dd7
1. Add function_tolerance based termination, updating the
termination logic to be in line with Ceres.
2. Replace the use of "error" with "residuals" in the code.
Change-Id: I3fd543f3a8226fe7f07eeec358559cba934679b2
Comparison operators are defined for Jet-scalar and scalar-Jet.
Add corresponding overloads for fmax and fmix so users
don't have to convert to Jet only to access these functions,
plus it can potentially save an unnecessary conversion.
Change-Id: I20cc2d5874935e019d4ecb2d6a8c2ae631c8a4d3
This is needed to add a layer of indirection which will allow
us to use gflags in the public version and absl inside Google.
Change-Id: I32f3da23200a01c9b658bbf8aaa66cb8fddc2cc3
M_2_SQRTPI is not part of standard C++, replace it with an
equivalent expression. gcc immediately folds this and thus
generates the same code even at -O0.
Change-Id: I5d38e67a4508c1d43a1a8e5f1639f2243cdb143e
- 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
1. Add a move constructor to NumericDiffCostFunction, DynamicAutoDiffCostfunction
and DynamicNumericDiffCostFunction.
2. Add optional ownership of the underlying functor.
3. Update docs to reflect this as well as the variadic templates that allow an
arbitrary number of parameter blocks.
Change-Id: I57bbb51fb9e75f36ec2a661b603beda270f30a19
Add Ownership semantics to the AutoDiffCostFunction
This allows several benefits, such as pointer ordering always being the
same for numerical repeatability (due to blocks being ordered by
pointer address), memory adjacency for better cache performance, and
reduced allocator pressure / overhead.
This is then made use of in libmv by preallocating the errors and
cost functions into vectors
Change-Id: Ia5b97e7249b55a463264b6e26f7a02291927c9f2
erf is necessary for evaluating Gaussian functions.
erfc was added because it is so similar to erf.
Change-Id: I5e470dbe013cc938fabb87cde3b0ebf26a90fff4
Simplify the semantics for Problem::EvaluateResidualBlock to
not ignore the presence of EvaluationCallback and add another method
EvaluateResidualBlockAssumingParametersUnchanged to handle the case
where the user has an EvaluationCallback but knows that the parameter
blocks do not change between calls.
Updated the documentation for the methods and EvaluationCallback to
reflect these semantics.
Also added tests for Evaluation related methods calling i
EvaluationCallback when its present.
https://github.com/ceres-solver/ceres-solver/issues/483
Change-Id: If0a0c95c2f1f92e9183a90df240104a69a71c46d
DynamicAutoDiffCostFunction::Evaluate when provided with a jacobians
array that was non-empty but all its entries are nullptr, would
compute num_active_parameters = 0, and then skip over all the loops
that evaluated the CostFunctor.
The fix is to check if num_active_parameters == 0, and then treat
it as the case where jacobians array is null.
Thanks to Ky Waegel for reporting and providing a reproduction for this.
Change-Id: Ib86930c2c3f722724d249f662bf88238679bbf98
- 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
Re-organize the section, add some more references and details for
existing preconditioners and add documentation for the SUBSET
precondition.
https://github.com/ceres-solver/ceres-solver/issues/490
Change-Id: I93d0af819c160f5e4ce48b18202f629ddb92ca7b
Fix typos in docs/source/features.rst and examples/helloworld.cc. Alter a NULL to nullptr in include/ceres/autodiff_cost_function.h
Change-Id: Ibcf00b6ef665ad6be9af14b3add2dd4f3852e7e6
- 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
For MSVC, instantiating a dllimport class template will cause error C2491:
definition of dllimport function not allowed.
Change-Id: Icc7f7ea84598df0a5436f48ffc2bab5cfab93921
- This results in the same performance as the original solution of
increasing -inline-threshold, but this approach is more viable to
incorporate in a large code base as its effects are more targeted.
Change-Id: Id798dbca7d3050de0ea847a5ecc69484ac78a2cf
A recent change made this function templated and MSVC 16 has trouble
doing automatic argument deduction, so the type of the template is
simplified and all callsites are explicitly annotated with the type
of the arguments.
Change-Id: I83cd0269e6e82c4a8f4e391f5fc03b92c942f74d
Local parameterizations with zero tangent/local size will cause the
corresponding parameter block to be treated as constant.
https://github.com/ceres-solver/ceres-solver/issues/347
Change-Id: I554a2acc420f5dd9d0cc7f97b691877eb057b2c0
This CL adds a local parameterization for a n-dimensional
line, which is represented as an origin point and a direction.
The line direction is updated in the same way as a
homogeneous vector and the origin point is updated
perpendicular to the line direction.
Change-Id: I733f395e5cc4250abf9778c26fe0a5ae1de6b624
Inlining the Jet initialzation is mandatory for good performance
in autodiff, because all the constants in the dual part can be
propagated into the cost functor.
This patch unrolls the initialization loop with templates and adds
EIGEN_ALWAYS_INLINE to the constructors.
Change-Id: Ic89d645984f3e1df6c63948236da823ba60d9620
The class ArraySelector is now used in autodiff to store the
parameters and residuals. This reduces overhead of FixedArray
for fixed-sized residuals and allows more optimizations due
to inlining and unrolling.
Change-Id: Ibadc5644e64d672f7a555e250fb1f8da262f9d4f