/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file GenericMultifrontalSolver-inl.h * @brief * @author Richard Roberts * @created Oct 21, 2010 */ #pragma once #include #include #include #include #include #include using namespace std; namespace gtsam { /* ************************************************************************* */ template GenericMultifrontalSolver::GenericMultifrontalSolver(const FactorGraph& factorGraph) : junctionTree_(factorGraph) {} /* ************************************************************************* */ template typename JUNCTIONTREE::BayesTree::shared_ptr GenericMultifrontalSolver::eliminate() const { typename JUNCTIONTREE::BayesTree::shared_ptr bayesTree(new typename JUNCTIONTREE::BayesTree); bayesTree->insert(junctionTree_.eliminate()); return bayesTree; } /* ************************************************************************* */ template typename FactorGraph::shared_ptr GenericMultifrontalSolver::joint(const std::vector& js) const { // We currently have code written only for computing the if(js.size() != 2) throw domain_error( "*MultifrontalSolver::joint(js) currently can only compute joint marginals\n" "for exactly two variables. You can call marginal to compute the\n" "marginal for one variable. *SequentialSolver::joint(js) can compute the\n" "joint marginal over any number of variables, so use that if necessary.\n"); return eliminate()->joint(js[0], js[1]); } /* ************************************************************************* */ template typename FACTOR::shared_ptr GenericMultifrontalSolver::marginal(Index j) const { return eliminate()->marginal(j); } }