(#378) Allow zero dimension factors, as it was in gtsam 3.x

release/4.3a0
Cyril Roussillon 2018-10-09 17:30:41 +02:00
parent f33eef1f86
commit b84f7ed22d
2 changed files with 3 additions and 6 deletions

View File

@ -70,9 +70,6 @@ Scatter::Scatter(const GaussianFactorGraph& gfg,
iterator first = begin();
if (ordering) first += ordering->size();
if (first != end()) std::sort(first, end());
// Filter out keys with zero dimensions (if ordering had more keys)
erase(std::remove_if(begin(), end(), SlotEntry::Zero), end());
}
/* ************************************************************************* */

View File

@ -113,9 +113,9 @@ struct LevenbergMarquardtState : public NonlinearOptimizerState {
// Small cache of A|b|model indexed by dimension. Can save many mallocs.
mutable std::vector<CachedModel> noiseModelCache;
CachedModel* getCachedModel(size_t dim) const {
if (dim > noiseModelCache.size())
noiseModelCache.resize(dim);
CachedModel* item = &noiseModelCache[dim - 1];
if (dim >= noiseModelCache.size())
noiseModelCache.resize(dim+1);
CachedModel* item = &noiseModelCache[dim];
if (!item->model)
*item = CachedModel(dim, 1.0 / std::sqrt(lambda));
return item;