mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Modernize include/ceres headers to C++17 and Abseil conventions
- include/ceres/autodiff_manifold.h: Replace manual zero-initialization loops with value-initialization ({}) in PlusJacobian and MinusJacobian.
- include/ceres/dynamic_numeric_diff_cost_function.h: Replace std::vector with absl::FixedArray for temporary evaluation buffers and use std::copy_n instead of memcpy in Evaluate.
- include/ceres/numeric_diff_cost_function.h: Replace memcpy with std::copy_n in Evaluate.
Change-Id: I13b546458185d9fdd22b086094ca1072c57c40ed
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/container/fixed_array.h"
|
||||
#include "absl/log/check.h"
|
||||
#include "ceres/dynamic_cost_function.h"
|
||||
#include "ceres/internal/eigen.h"
|
||||
@@ -142,9 +143,10 @@ class DynamicNumericDiffCostFunction final : public DynamicCostFunction {
|
||||
}
|
||||
|
||||
// Create local space for a copy of the parameters which will get mutated.
|
||||
int parameters_size = accumulate(block_sizes.begin(), block_sizes.end(), 0);
|
||||
std::vector<double> parameters_copy(parameters_size);
|
||||
std::vector<double*> parameters_references_copy(block_sizes.size());
|
||||
int parameters_size =
|
||||
std::accumulate(block_sizes.begin(), block_sizes.end(), 0);
|
||||
absl::FixedArray<double> parameters_copy(parameters_size);
|
||||
absl::FixedArray<double*> parameters_references_copy(block_sizes.size());
|
||||
parameters_references_copy[0] = parameters_copy.data();
|
||||
for (size_t block = 1; block < block_sizes.size(); ++block) {
|
||||
parameters_references_copy[block] =
|
||||
@@ -153,9 +155,9 @@ class DynamicNumericDiffCostFunction final : public DynamicCostFunction {
|
||||
|
||||
// Copy the parameters into the local temp space.
|
||||
for (size_t block = 0; block < block_sizes.size(); ++block) {
|
||||
memcpy(parameters_references_copy[block],
|
||||
parameters[block],
|
||||
block_sizes[block] * sizeof(*parameters[block]));
|
||||
std::copy_n(parameters[block],
|
||||
block_sizes[block],
|
||||
parameters_references_copy[block]);
|
||||
}
|
||||
|
||||
for (size_t block = 0; block < block_sizes.size(); ++block) {
|
||||
|
||||
Reference in New Issue
Block a user