Skip to content

Commit

Permalink
[SymForce] Rename linearization_sparse_key_helper
Browse files Browse the repository at this point in the history
Renaming `linearization_sparse_key_helper_t` to `linearization_offsets_t`.

I'd like to reuse this type for the dense linearizer, so I thought it
would be better to give it a name that is more suggestive of its
contents and is less specific about who is using it.

I'll be using it for more or less the exact same thing that the sparse
linearizer uses it for. (i.e., for figuring out where the components of
a factor's linearization get mapped to in the combined linearization).

Topic: rename_linearization_sparse_key_helper_t
Relative: fix_initial_residual_order
GitOrigin-RevId: adab6f10c6e3aaad66ca29de371db707a148a989
  • Loading branch information
bradley-solliday-skydio authored and aaron-skydio committed Mar 31, 2023
1 parent 0abeb62 commit 7a34ec0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lcmtypes/symforce.lcm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct linearization_dense_factor_helper_t {
linearization_dense_key_helper_t key_helpers[];
};

struct linearization_sparse_key_helper_t {
struct linearization_offsets_t {
// Offset of this key within the factor's state vector
int32_t factor_offset;
// Offset of this key within the whole problem's state vector
Expand All @@ -108,7 +108,7 @@ struct linearization_sparse_factor_helper_t {
// Offset of this factor's residual slice within the whole problem residual
int32_t combined_residual_offset;
// Data about each key's state offsets
linearization_sparse_key_helper_t key_helpers[];
linearization_offsets_t key_helpers[];

// Mapping from factor jacobian flat storage into problem jacobian flat storage
int32_t jacobian_index_map[];
Expand Down
4 changes: 2 additions & 2 deletions symforce/opt/linearizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void Linearizer<ScalarType>::BuildInitialLinearization(const Values<Scalar>& val

// Add contribution from right-hand-side
for (int key_i = 0; key_i < static_cast<int>(factor_helper.key_helpers.size()); ++key_i) {
const linearization_sparse_key_helper_t& key_helper = factor_helper.key_helpers[key_i];
const linearization_offsets_t& key_helper = factor_helper.key_helpers[key_i];

init_linearization_.rhs.segment(key_helper.combined_offset, key_helper.tangent_dim) +=
linearized_factor.rhs.segment(key_helper.factor_offset, key_helper.tangent_dim);
Expand Down Expand Up @@ -385,7 +385,7 @@ void Linearizer<ScalarType>::UpdateFromLinearizedSparseFactorIntoSparse(

// Add contribution from right-hand-side
for (int key_i = 0; key_i < static_cast<int>(factor_helper.key_helpers.size()); ++key_i) {
const linearization_sparse_key_helper_t& key_helper = factor_helper.key_helpers[key_i];
const linearization_offsets_t& key_helper = factor_helper.key_helpers[key_i];

linearization.rhs.segment(key_helper.combined_offset, key_helper.tangent_dim) +=
linearized_factor.rhs.segment(key_helper.factor_offset, key_helper.tangent_dim);
Expand Down

0 comments on commit 7a34ec0

Please sign in to comment.