Repository navigation
Add FactorResidualOffsetAndDim to Linearizer and DenseLinearizer - #479
Open
thiagopari wants to merge 1 commit into
Open
thiagopari wants to merge 1 commit into
thiagopari wants to merge 1 commit into
Conversation
Records, during the first linearization, where each factor's residual lands in the combined residual (and the rows of the combined jacobian), so callers can pull out per-factor residuals or jacobian blocks without recomputing the layout themselves. Fixes symforce-org#320
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
FactorResidualOffsetAndDim(factor_index)toLinearizerandDenseLinearizer, as suggested in #320. It returns the offset and dimension offactors[factor_index]'s residual within the combined residual (equivalently, its rows of the combined jacobian), so callers can uselinearization.residual.segment(offset, dim)instead of replicating the bookkeeping inBuildInitialLinearization().Implementation
factor_residual_offsets_during the first linearization: oneint32_tper factor plus the total residual dimension at the end, so the lookup is O(1).IsInitialized()and that the index is in range, the same contract asStateIndex().Testing
symforce_linearizer_test.cc: interleaves sparse and dense factors with different residual sizes. For every factor it checks the offset and dim, and thatresidual.segment(offset, dim)equals that factor's own residual. It does this on the first linearization and again on a relinearization, and checks that the blocks add up toresidual.size().symforce_dense_linearizer_test.cc: the same checks forDenseLinearizer.I didn't add Python bindings; happy to add them if you'd like.
Fixes #320