From 4949d6988cc918f67188291c7fc0edc74671c03d Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Sat, 7 Sep 2019 15:48:30 -0400 Subject: [PATCH 1/3] Fix compilation of PartialPriorFactor --- gtsam_unstable/slam/PartialPriorFactor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam_unstable/slam/PartialPriorFactor.h b/gtsam_unstable/slam/PartialPriorFactor.h index fa06d47a3d..c71ee7abd7 100644 --- a/gtsam_unstable/slam/PartialPriorFactor.h +++ b/gtsam_unstable/slam/PartialPriorFactor.h @@ -121,7 +121,7 @@ namespace gtsam { // access const Vector& prior() const { return prior_; } - const std::vector& mask() const { return mask_; } + const std::vector& mask() const { return mask_; } const Matrix& H() const { return H_; } protected: From b61636e2f711971e875df3aca63ce69907bce9c5 Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Sat, 7 Sep 2019 16:10:49 -0400 Subject: [PATCH 2/3] Fix segfault in SubgraphBuilder --- gtsam/linear/SubgraphBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtsam/linear/SubgraphBuilder.cpp b/gtsam/linear/SubgraphBuilder.cpp index 22ad89cd88..34c4c0440d 100644 --- a/gtsam/linear/SubgraphBuilder.cpp +++ b/gtsam/linear/SubgraphBuilder.cpp @@ -127,7 +127,8 @@ static vector UniqueSampler(const vector &weight, /* sampling and cache results */ vector samples = iidSampler(localWeights, n - count); - for (const size_t &index : samples) { + const auto samplesSize = samples.size(); + for (size_t index = 0; index < samplesSize; index++) { if (touched[index] == false) { touched[index] = true; samples.push_back(index); From cb80f27ee8a7af8eada3b9dfb214cee46b99c390 Mon Sep 17 00:00:00 2001 From: Fan Jiang Date: Sat, 7 Sep 2019 17:30:18 -0400 Subject: [PATCH 3/3] Restoring the correct behavior of UniqueSampler --- gtsam/linear/SubgraphBuilder.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gtsam/linear/SubgraphBuilder.cpp b/gtsam/linear/SubgraphBuilder.cpp index 34c4c0440d..a999b3a719 100644 --- a/gtsam/linear/SubgraphBuilder.cpp +++ b/gtsam/linear/SubgraphBuilder.cpp @@ -107,7 +107,7 @@ static vector UniqueSampler(const vector &weight, const size_t m = weight.size(); if (n > m) throw std::invalid_argument("UniqueSampler: invalid input size"); - vector samples; + vector results; size_t count = 0; vector touched(m, false); @@ -127,16 +127,15 @@ static vector UniqueSampler(const vector &weight, /* sampling and cache results */ vector samples = iidSampler(localWeights, n - count); - const auto samplesSize = samples.size(); - for (size_t index = 0; index < samplesSize; index++) { + for (const size_t &index : samples) { if (touched[index] == false) { touched[index] = true; - samples.push_back(index); + results.push_back(index); if (++count >= n) break; } } } - return samples; + return results; } /****************************************************************************/