From fd11a1e2c76b40f7b4195578029c9680c91e5b01 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sat, 22 Aug 2009 22:01:17 +0000 Subject: [PATCH] Changed setBCN to take a reference --- cpp/ChordalBayesNet.h | 4 ++-- cpp/LinearFactorGraph.cpp | 8 ++++---- cpp/LinearFactorGraph.h | 4 ++-- cpp/testLinearFactorGraph.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/ChordalBayesNet.h b/cpp/ChordalBayesNet.h index 481fe43e6..881c7a31e 100644 --- a/cpp/ChordalBayesNet.h +++ b/cpp/ChordalBayesNet.h @@ -57,8 +57,8 @@ public: /** return begin and end of the nodes. FD: breaks encapsulation? */ typedef std::map::const_iterator const_iterator; - const_iterator const begin() {return nodes.begin();} - const_iterator const end() {return nodes.end();} + const_iterator const begin() const {return nodes.begin();} + const_iterator const end() const {return nodes.end();} /** optimize */ boost::shared_ptr optimize(); diff --git a/cpp/LinearFactorGraph.cpp b/cpp/LinearFactorGraph.cpp index ea70ac53b..cc8eb2b87 100644 --- a/cpp/LinearFactorGraph.cpp +++ b/cpp/LinearFactorGraph.cpp @@ -18,17 +18,17 @@ using namespace std; using namespace gtsam; /* ************************************************************************* */ -LinearFactorGraph::LinearFactorGraph(ChordalBayesNet::shared_ptr CBN) +LinearFactorGraph::LinearFactorGraph(const ChordalBayesNet& CBN) { setCBN(CBN); } /* ************************************************************************* */ -void LinearFactorGraph::setCBN(ChordalBayesNet::shared_ptr CBN) +void LinearFactorGraph::setCBN(const ChordalBayesNet& CBN) { clear(); - ChordalBayesNet::const_iterator it = CBN->begin(); - for(; it != CBN->end(); it++) { + ChordalBayesNet::const_iterator it = CBN.begin(); + for(; it != CBN.end(); it++) { LinearFactor::shared_ptr lf(new LinearFactor(it->first, it->second)); push_back(lf); } diff --git a/cpp/LinearFactorGraph.h b/cpp/LinearFactorGraph.h index a20889e94..04e3cd8bb 100644 --- a/cpp/LinearFactorGraph.h +++ b/cpp/LinearFactorGraph.h @@ -32,13 +32,13 @@ namespace gtsam { /** * Constructor that receives a Chordal Bayes Net and returns a LinearFactorGraph */ - LinearFactorGraph(ChordalBayesNet::shared_ptr CBN); + LinearFactorGraph(const ChordalBayesNet& CBN); /** * given a chordal bayes net, sets the linear factor graph identical to that CBN * FD: imperative !! */ - void setCBN(ChordalBayesNet::shared_ptr CBN); + void setCBN(const ChordalBayesNet& CBN); /** * This function returns the best ordering for this linear factor diff --git a/cpp/testLinearFactorGraph.cpp b/cpp/testLinearFactorGraph.cpp index b25e2d701..6adf192ce 100644 --- a/cpp/testLinearFactorGraph.cpp +++ b/cpp/testLinearFactorGraph.cpp @@ -457,7 +457,7 @@ TEST( LinearFactorGraph, CONSTRUCTOR_ChordalBayesNet ) ord.push_back("x1"); ChordalBayesNet::shared_ptr CBN = fg.eliminate(ord); - LinearFactorGraph fg2(CBN); + LinearFactorGraph fg2(*CBN); ChordalBayesNet::shared_ptr CBN2 = fg2.eliminate(ord); CHECK(CBN->equals(*CBN2));