mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Modernize CostFunction and FirstOrderFunction constructors
- Add constructors taking std::unique_ptr and ceres::Ownership to AutoDiffCostFunction, NumericDiffCostFunction, and their dynamic and first-order counterparts. - Standardize delegating constructor style to use parentheses. - Standardize ownership check in destructors. - Fix documentation typos and example code in headers. - Add comprehensive tests for Ownership and unique_ptr constructors. Change-Id: I573abd695cdd89905997b573620e8d99d1cacca2
This commit is contained in:
@@ -98,4 +98,16 @@ TEST(NumericDiffFirstOrderFunction, BilinearDifferentiationTestDynamic) {
|
||||
EXPECT_NEAR(gradient[3], parameters[2], kTolerance);
|
||||
}
|
||||
|
||||
TEST(NumericDiffFirstOrderFunction, OwnershipTest) {
|
||||
QuadraticCostFunctor functor(1.0);
|
||||
{
|
||||
NumericDiffFirstOrderFunction<QuadraticCostFunctor, CENTRAL, 4> function(
|
||||
&functor, DO_NOT_TAKE_OWNERSHIP);
|
||||
double parameters[4] = {1.0, 2.0, 3.0, 4.0};
|
||||
double cost;
|
||||
function.Evaluate(parameters, &cost, nullptr);
|
||||
EXPECT_EQ(cost, 13.0);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
Reference in New Issue
Block a user