Changed setBCN to take a reference

release/4.3a0
Frank Dellaert 2009-08-22 22:01:17 +00:00
parent 5780b39816
commit fd11a1e2c7
4 changed files with 9 additions and 9 deletions

View File

@ -57,8 +57,8 @@ public:
/** return begin and end of the nodes. FD: breaks encapsulation? */ /** return begin and end of the nodes. FD: breaks encapsulation? */
typedef std::map<std::string, ConditionalGaussian::shared_ptr>::const_iterator const_iterator; typedef std::map<std::string, ConditionalGaussian::shared_ptr>::const_iterator const_iterator;
const_iterator const begin() {return nodes.begin();} const_iterator const begin() const {return nodes.begin();}
const_iterator const end() {return nodes.end();} const_iterator const end() const {return nodes.end();}
/** optimize */ /** optimize */
boost::shared_ptr<FGConfig> optimize(); boost::shared_ptr<FGConfig> optimize();

View File

@ -18,17 +18,17 @@ using namespace std;
using namespace gtsam; using namespace gtsam;
/* ************************************************************************* */ /* ************************************************************************* */
LinearFactorGraph::LinearFactorGraph(ChordalBayesNet::shared_ptr CBN) LinearFactorGraph::LinearFactorGraph(const ChordalBayesNet& CBN)
{ {
setCBN(CBN); setCBN(CBN);
} }
/* ************************************************************************* */ /* ************************************************************************* */
void LinearFactorGraph::setCBN(ChordalBayesNet::shared_ptr CBN) void LinearFactorGraph::setCBN(const ChordalBayesNet& CBN)
{ {
clear(); clear();
ChordalBayesNet::const_iterator it = CBN->begin(); ChordalBayesNet::const_iterator it = CBN.begin();
for(; it != CBN->end(); it++) { for(; it != CBN.end(); it++) {
LinearFactor::shared_ptr lf(new LinearFactor(it->first, it->second)); LinearFactor::shared_ptr lf(new LinearFactor(it->first, it->second));
push_back(lf); push_back(lf);
} }

View File

@ -32,13 +32,13 @@ namespace gtsam {
/** /**
* Constructor that receives a Chordal Bayes Net and returns a LinearFactorGraph * 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 * given a chordal bayes net, sets the linear factor graph identical to that CBN
* FD: imperative !! * FD: imperative !!
*/ */
void setCBN(ChordalBayesNet::shared_ptr CBN); void setCBN(const ChordalBayesNet& CBN);
/** /**
* This function returns the best ordering for this linear factor * This function returns the best ordering for this linear factor

View File

@ -457,7 +457,7 @@ TEST( LinearFactorGraph, CONSTRUCTOR_ChordalBayesNet )
ord.push_back("x1"); ord.push_back("x1");
ChordalBayesNet::shared_ptr CBN = fg.eliminate(ord); ChordalBayesNet::shared_ptr CBN = fg.eliminate(ord);
LinearFactorGraph fg2(CBN); LinearFactorGraph fg2(*CBN);
ChordalBayesNet::shared_ptr CBN2 = fg2.eliminate(ord); ChordalBayesNet::shared_ptr CBN2 = fg2.eliminate(ord);
CHECK(CBN->equals(*CBN2)); CHECK(CBN->equals(*CBN2));