diff --git a/cpp/FactorGraph-inl.h b/cpp/FactorGraph-inl.h index af20cc8e6..ba4e4b752 100644 --- a/cpp/FactorGraph-inl.h +++ b/cpp/FactorGraph-inl.h @@ -331,9 +331,8 @@ map FactorGraph::findMinimumSpanningTree() const { } template -pair, FactorGraph > FactorGraph::split(map tree) const { +void FactorGraph::split(map tree, FactorGraph& Ab1, FactorGraph& Ab2) const { - FactorGraph Ab1, Ab2; BOOST_FOREACH(sharedFactor factor, factors_){ if (factor->keys().size() > 2) throw(invalid_argument("split: only support factors with at most two keys")); @@ -350,8 +349,6 @@ pair, FactorGraph > FactorGraph::split(map, FactorGraph > split(std::map tree) const; + void split(std::map tree, + FactorGraph& Ab1, FactorGraph& Ab2) const; private: /** Associate factor index with the variables connected to the factor */ diff --git a/cpp/GaussianBayesNet.cpp b/cpp/GaussianBayesNet.cpp index d745ae8a7..1799aa553 100644 --- a/cpp/GaussianBayesNet.cpp +++ b/cpp/GaussianBayesNet.cpp @@ -64,6 +64,8 @@ VectorConfig optimize(const GaussianBayesNet& bn) /** solve each node in turn in topological sort order (parents first)*/ BOOST_REVERSE_FOREACH(GaussianConditional::shared_ptr cg, bn) { + cg->print(); + result.print(); Vector x = cg->solve(result); // Solve for that variable result.insert(cg->key(),x); // store result in partial solution } diff --git a/cpp/testGaussianFactorGraph.cpp b/cpp/testGaussianFactorGraph.cpp index 60164ec80..a013c3f8c 100644 --- a/cpp/testGaussianFactorGraph.cpp +++ b/cpp/testGaussianFactorGraph.cpp @@ -769,9 +769,7 @@ TEST( GaussianFactorGraph, split ) tree["x4"] = "x1"; GaussianFactorGraph Ab1, Ab2; - pair, FactorGraph > gg = g.split(tree); - Ab1 = *reinterpret_cast(&(gg.first)); - Ab2 = *reinterpret_cast(&(gg.second)); + g.split(tree, Ab1, Ab2); LONGS_EQUAL(3, Ab1.size()); LONGS_EQUAL(2, Ab2.size()); }