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? */
typedef std::map<std::string, ConditionalGaussian::shared_ptr>::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<FGConfig> optimize();

View File

@ -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);
}

View File

@ -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

View File

@ -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));