From 582d67eea46d857ade63cb60496c33173ccaeef1 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 9 Feb 2025 11:41:47 -0500 Subject: [PATCH] undo C++ changes and add additional reInitialize method --- examples/Hybrid_City10000.cpp | 2 +- gtsam/hybrid/HybridSmoother.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/Hybrid_City10000.cpp b/examples/Hybrid_City10000.cpp index f42496cef..76771ad36 100644 --- a/examples/Hybrid_City10000.cpp +++ b/examples/Hybrid_City10000.cpp @@ -127,7 +127,7 @@ class Experiment { auto bayesNet = linearized->eliminateSequential(); HybridValues delta = bayesNet->optimize(); initial_ = initial_.retract(delta.continuous()); - smoother_.reInitialize(*bayesNet); + smoother_.reInitialize(std::move(*bayesNet)); clock_t afterUpdate = clock(); std::cout << "Took " << (afterUpdate - beforeUpdate) / CLOCKS_PER_SEC << " seconds." << std::endl; diff --git a/gtsam/hybrid/HybridSmoother.h b/gtsam/hybrid/HybridSmoother.h index 017b1fb4e..f8eaec26c 100644 --- a/gtsam/hybrid/HybridSmoother.h +++ b/gtsam/hybrid/HybridSmoother.h @@ -49,8 +49,16 @@ class GTSAM_EXPORT HybridSmoother { /** * Re-initialize the smoother from a new hybrid Bayes Net. */ + void reInitialize(HybridBayesNet&& hybridBayesNet) { + hybridBayesNet_ = std::move(hybridBayesNet); + } + + /** + * Re-initialize the smoother from + * a new hybrid Bayes Net (non rvalue version). + */ void reInitialize(HybridBayesNet& hybridBayesNet) { - hybridBayesNet_ = hybridBayesNet; + this->reInitialize(std::move(hybridBayesNet)); } /**