mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Sized cost function using variadic templates
This PR changes the interface of sized_cost_fucntion, autodiff_cost_function and numeric_diff_costfunction from using ten hardcoded parameter blocks to a variable number of parameter blocks using variadic templates. Trailing parameter blocks of size zero are now considered as error. Change-Id: I37b9a0a420ef0eda6476a46672bbf6bd57e19760
This commit is contained in:
@@ -89,11 +89,11 @@ TEST(ParameterDims, GetUnpackedParameters) {
|
||||
constexpr int N1 = 4;
|
||||
constexpr int N2 = 2;
|
||||
|
||||
using Params = StaticParameterDims<N0, N1, N2>;
|
||||
using ParameterDims = StaticParameterDims<N0, N1, N2>;
|
||||
|
||||
std::array<double, Params::kNumParameters> packed_parameters{};
|
||||
std::array<double, ParameterDims::kNumParameters> packed_parameters{};
|
||||
std::array<double*, 3> unpacked_parameters =
|
||||
Params::GetUnpackedParameters(packed_parameters.data());
|
||||
ParameterDims::GetUnpackedParameters(packed_parameters.data());
|
||||
|
||||
EXPECT_EQ(packed_parameters.data(), unpacked_parameters[0]);
|
||||
EXPECT_EQ(packed_parameters.data() + N0, unpacked_parameters[1]);
|
||||
|
||||
Reference in New Issue
Block a user