mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Add support for removing parameter and residual blocks.
This adds support for removing parameter and residual blocks. There are two modes of operation: in the first, removals of paremeter blocks are expensive, since each remove requires scanning all residual blocks to find ones that depend on the removed parameter. In the other, extra memory is sacrificed to maintain a list of the residuals a parameter block depends on, removing the need to scan. In both cases, removing residual blocks is fast. As a caveat, any removals destroys the ordering of the parameters, so the residuals or jacobian returned from Solver::Solve() is meaningless. There is some debate on the best way to handle this; the details remain for a future change. This also adds some overhead, even in the case that fast removals are not requested: - 1 int32 to each residual, to track its position in the program. - 1 pointer to each parameter, to store the dependent residuals. Change-Id: I71dcac8656679329a15ee7fc12c0df07030c12af
This commit is contained in:
@@ -45,13 +45,14 @@ namespace internal {
|
||||
// with one residual succeeds with true or dies.
|
||||
void CheckEvaluation(const CostFunction& cost_function, bool is_good) {
|
||||
double x = 1.0;
|
||||
ParameterBlock parameter_block(&x, 1);
|
||||
ParameterBlock parameter_block(&x, 1, -1);
|
||||
vector<ParameterBlock*> parameter_blocks;
|
||||
parameter_blocks.push_back(¶meter_block);
|
||||
|
||||
ResidualBlock residual_block(&cost_function,
|
||||
NULL,
|
||||
parameter_blocks);
|
||||
parameter_blocks,
|
||||
-1);
|
||||
|
||||
scoped_array<double> scratch(
|
||||
new double[residual_block.NumScratchDoublesForEvaluate()]);
|
||||
|
||||
Reference in New Issue
Block a user