-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,18 +552,27 @@ VectorValues JacobianFactor::hessianDiagonal() const { | |
void JacobianFactor::hessianDiagonalAdd(VectorValues& d) const { | ||
for (size_t pos = 0; pos < size(); ++pos) { | ||
Key j = keys_[pos]; | ||
size_t nj = Ab_(pos).cols(); | ||
Vector dj(nj); | ||
for (size_t k = 0; k < nj; ++k) { | ||
Vector column_k = Ab_(pos).col(k); | ||
if (model_) | ||
model_->whitenInPlace(column_k); | ||
dj(k) = dot(column_k, column_k); | ||
} | ||
auto item = d.find(j); | ||
|
||
if(item != d.end()) { | ||
item->second += dj; | ||
size_t nj = Ab_(pos).cols(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ProfFan
Author
Collaborator
|
||
Vector& dj = item->second; | ||
for (size_t k = 0; k < nj; ++k) { | ||
Vector column_k = Ab_(pos).col(k); | ||
if (model_) | ||
model_->whitenInPlace(column_k); | ||
dj(k) += dot(column_k, column_k); | ||
} | ||
} else { | ||
size_t nj = Ab_(pos).cols(); | ||
Vector dj(nj); | ||
for (size_t k = 0; k < nj; ++k) { | ||
Vector column_k = Ab_(pos).col(k); | ||
if (model_) | ||
model_->whitenInPlace(column_k); | ||
dj(k) = dot(column_k, column_k); | ||
} | ||
|
||
d.emplace(j, dj); | ||
} | ||
} | ||
|
Same comments as other one. Use emplace - and avoid having two copies of almost identical code :-) Sorry for going so deep, but we will be the only ones visiting this code for a while to come.